{% include 'header.twig' %}

         <div class="app-content">
            <!-- page-content -->
            <div class="container-fluid">
               <section class="services-list mt-4">
                  <div class="d-card">
                     <div class="d-card-body p0">
                        <div class="orders-btn py-3">
                           <ul class="nav nav-pills orderNav">
                              <li class="mr-2">
                                 <a {% if 'all' == status %} class="active"{% endif %} href="dripfeeds"><i class="fas fa-filter mr-1"></i>{{ lang['dripfeed.status.all'] }}</a>
                              </li>
                              <li class="mr-2">
                                 <a {% if 'active' == status %} class="active"{% endif %} href="dripfeeds/active"><i class="fas fa-spinner mr-1"></i>{{ lang['dripfeed.status.active'] }}</a>
                              </li>
                              <li class="mr-2">
                                 <a {% if 'completed' == status %} class="active"{% endif %} href="dripfeeds/completed"><i class="far fa-check-circle mr-1"></i>{{ lang['dripfeed.status.completed'] }}</a>
                              </li>
                              <li class="mr-2">
                                 <a {% if 'canceled' == status %} class="active"{% endif %} href="dripfeeds/canceled"><i class="fas fa-ban mr-1"></i>{{ lang['dripfeed.status.canceled'] }}</a>
                              </li>
                              <li class="pull-right search mr-2">
                                 <form action="" method="get">
                                    <div class="dfb-search">
                                       <input type="text" name="search" value="{{ search }}" placeholder="Siparişleri ara" class="dfb-input">
                                       <button type="submit" class="dfb-submit">
                                       <i class="fas fa-search"></i>
                                       </button>
                                    </div>
                                 </form>
                              </li>
                           </ul>
                        </div>
                        <div class="dash-list mt-4">
                           <div class="accordion" id="orderDetail">
						    {% for dripFeed in orders %}
                              <div class="card">
                                 <div class="card-header" id="ordHead{{ dripFeed['id'] }}">
                                    <a href="#" class="btn-header-link" data-toggle="collapse" data-target="#dfeed{{ dripFeed['id'] }}"
                                       aria-expanded="true" aria-controls="dfeed{{ dripFeed['id'] }}">
                                       <div class="row align-items-center">
                                          <div class="col-lg-2 col-12 ordNumber">
                                             <strong>Order number</strong>: <span id="ordersid{{ dripFeed['id'] }}"><code>{{ dripFeed['id'] }}</code> <em id="paparaCopy" href="javascript:void(0);" onclick="copywalletid('#ordersid{{ dripFeed['id'] }}')"><small><span  data-toggle="tooltip" data-placement="top" title="" data-original-title="Copy" class="far fa-copy"></span></small></em> </span>
                                          </div>
                                          <div class="col-lg-7 col-12">
                                             <h4>{{ dripFeed['link'] }}</h4>
                                             <small>{{ dripFeed['date'] }}</small>
                                          </div>
                                          <div class="col-lg-3 col-12">
											{% if dripFeed['status'] == 'Tamamlanmış' %}
                                             <div class="ordStatus align-items-center" style="color: #28a745">
                                                <i class="fas fa-check-circle"></i>
                                                <span>Order completed</span>
                                             </div>
											{% endif %}
											{% if dripFeed['status'] == 'Aktif' %}
                                             <div class="ordStatus align-items-center" style="color: #ff870b">
                                                <i class="fas fa-spinner"></i>
                                                <span>Order active</span>
                                             </div>
											{% endif %}
											{% if dripFeed['status'] == 'İptal' %}
                                             <div class="ordStatus align-items-center" style="color: #ec4646">
                                                <i class="fas fa-times-circle"></i>
                                                <span>Cancelled</span>
                                             </div>
											{% endif %}
                                          </div>
                                       </div>
                                    </a>
                                 </div>
                                 <div id="dfeed{{ dripFeed['id'] }}" class="collapse" aria-labelledby="ordHead{{ dripFeed['id'] }}" data-parent="#orderDetail">
                                    <div class="card-body">
                                       <ul>
                                          <li><strong>Service:</strong>{{ dripFeed['service'] }}</li>
                                          <li><strong>Link:</strong> 
                                             <a href="{{ dripFeed['link'] }}" target="_blank">{{ dripFeed['link'] }}</a>
                                          </li>
                                          <li><strong>Total Fee:</strong> {{ dripFeed['total_charges'] }}</li>
                                          <li><strong>Quantity:</strong> {{ dripFeed['quantity'] }}</li>
                                          <li><strong>Again:</strong> 
												{% if dripFeed['delivery'] %}
													<a href="orders?dripfeed={{ dripFeed['id'] }}"> {{ dripFeed['delivery'] }} </a> / {{ dripFeed['runs'] }}
												{% else %}
													{{ dripFeed['delivery'] }} / {{ dripFeed['runs'] }}
												{% endif %}
										  </li>
                                          <li><strong>Interval:</strong> {{ dripFeed['interval'] }}</li>
                                          <li><strong>Total quantity:</strong> {{ dripFeed['total_quantity'] }}</li>
                                       </ul>
                                    </div>
                                 </div>
                              </div>
							  {% endfor %}

                           </div>
                        </div>
                        <!-- dash-list -->
                     </div>
                  </div>
      {% if pagination["count"] > 1 %}
        <ul class="pagination">

          {% if pagination["current"] != 1 %}
            <li>
              <a href="dripfeeds/{{ status }}/{{ pagination["previous"] }}{% if search %}?search={{ search }}{% endif %}" aria-label="Previous">
                <span aria-hidden="true">«</span>
              </a>
            </li>
          {% endif %}

          {% set r, l = 3, 3 %}

          {% if pagination['current'] == 1 %}
            {% set r = 7 %}
          {% endif %}

          {% if pagination['current'] == 2 %}
            {% set r = 5 %}
          {% endif %}

          {% if pagination['current'] >= pagination['count'] %}
            {% set l = 5 %}
          {% endif %}

          {% for page in 1..pagination["count"] %}
            {% if page >= (pagination['current']-l) and page <= (pagination['current']+r) %}
              <li{% if page == pagination['current'] %} class="active" {%endif%}><a href="dripfeeds/{{ status }}/{{ page }}{% if search %}?search={{ search }}{% endif %}">{{ page }}</a></li>
            {%endif%}
          {% endfor %}

          {% if pagination['current'] < pagination['count'] %}
            <li>
              <a href="dripfeeds/{{ status }}/{{ pagination['next'] }}{% if search %}?search={{ search }}{% endif %}" aria-label="Next">
                <span aria-hidden="true">»</span>
              </a>
            </li>
          {% endif %}

        </ul>
      {% endif %}
               </section>
            </div>
            <!-- container end -->
         </div>
         <!-- app-content -->

      </div>

{% include 'footer.twig' %}
