{% include 'header.twig' %}
<style>
    @media (min-width: 768px)
.nav-tabs.nav-justified>li>a {
    /* border-bottom: 1px solid #ddd; */
    border-radius: 4px 4px 0 0;
}
.bg-refill {
    border-radius: 5px;
    background: #0d5bd9;
    color:white;
}
</style>
<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-history ">
        <div class="bg"></div>
        <div class="divider-top"></div>
        <div class="divider-bottom"></div>
        <div class="container-fluid">
            <div class="row">
                <div class="col">
                    <div class="orders-history__margin-tab">
                        <div class="component_status_tabs">
                            <div class="">
      <ul class="nav nav-pills orderNav">
	  
        <li class="mr-2" >
		<a {% if 'all' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders"> <i class="fas fa-filter mr-1"></i> {{ lang['orders.status.all'] }}</a>
		</li>
        <li class="mr-2"><a {% if 'pending' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/pending"><i class="fas fa-file-import mr-1"></i> {{ lang['orders.status.pending'] }}</a></li>
        
        <li class="mr-2"><a {% if 'inprogress' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/inprogress"><i class="fas fa-spinner mr-1"></i>{{ lang['orders.status.inprogress'] }}</a></li>
        <li class="mr-2"><a {% if 'completed' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/completed"><i class="far fa-check-circle mr-1"></i>{{ lang['orders.status.completed'] }}</a></li>
        <li class="mr-2"><a {% if 'partial' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/partial"><i class="fas fa-hourglass-start mr-1"></i>{{ lang['orders.status.partial'] }}</a></li>
        <li class="mr-2"><a {% if 'processing' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/processing"><i class="fas fa-sort-numeric-down mr-1"></i>{{ lang['orders.status.processing'] }}</a></li>
        <li class="mr-2"><a {% if 'canceled' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/canceled"><i class="fas fa-ban mr-1"></i>{{ lang['orders.status.canceled'] }}</a></li>
       
                              <li class="pull-right search mr-2">
                                    <form action="/orders" method="get" id="history-search">
                                    <div class="dfb-search">
                                       <input type="text" name="search" value="{{ search }}" placeholder="Search  orders" class="dfb-input">
                                       <button type="submit" class="dfb-submit">
                                       <i class="fas fa-search"></i>
                                       </button>
                                    </div>
                                 </form>
                                </li>
      </ul><br>
	       <div class="row">
                <div class="col-12">
                    <div class="orders-history__margin-search component_card">
                        <div class="card">
                            <div class="component_form_group component_button_search">
                                <div class="">
                                    <form action="" method="get" id="history-search">
                                        <div class="input-group">
                                            <input type="text" name="search" class="form-control" value="{{ search }}" placeholder="Search orders">
                                            <div class="input-group-append">
                                                <button class="btn btn-big-secondary" type="submit">
                                                    <span class="fas fa-search"></span>
                                                </button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                             </div>
                        </div>
                    </div>
                </div>
            </div>
     <div class="row">
                <div class="col">
                    <div class="orders-history__margin-table">
                        <div class="table-bg component_table ">
                            <div class="table-wr table-responsive">
        <table class="table ">
          <thead>
            <tr>
              <th class="column100 column1" data-column="column1">ID</th>
                              <th class="column100 column2" data-column="column2">Date</th>
                              <th class="column100 column3" data-column="column3">Link</th>
                              <th class="column100 column4" data-column="column4">Charge</th>
                              <th class="column100 column5" data-column="column5">Start count</th>
                              <th class="column100 column6" data-column="column6">Quantity
                              </th>
                              <th class="column100 column7" data-column="column7">Service</th>
                              <th class="column100 column8" data-column="column8">Status</th>
                              <th class="column100 column9" data-column="column9">Remains</th>
                              <th class="column100 column9" data-column="column9">Refill</th> 
            </tr>
          </thead>
          <tbody>

            {% for order in orders %}
                           <tr>
                              <td>{{ order['id'] }}</td>
                              <td>{{ order['date'] }}</td>
                              <td class="width-40">{{ order['link'] }}</td>
                              <td>{{ order['charge'] }}</td>
                              <td class="nowrap">{{ order['start_count'] }}</td>
                              <td>{{ order['quantity'] }}</td>
                              <td>{{ order['service'] }}</td>
                              <td><span class="bg-{{ order['status']|lower }}">{{ order['status'] }}</td>
                              </span>
                              <td>{{ order['remains'] }}</td>
                              
          {% if order['status'] == "Completed"    %}
              
               {% if order['refill'] == 1   %}
<td>
   <form action="" method="post" id="history-search">
      <input type="hidden" name="order_id" value="{{ order['id'] }}" /> 
      <div style="display:inline-block;"  class="tooltip-wrapper" data-toggle={% if order['show_refill'] == 0 %} 
      tooltip
      {% endif %} data-placement="top" title=""  data-original-title="Next Refill will be available after 24 Hours"
      >
      <input style="pointer-events:{% if order['show_refill'] == 0 %} none; {% endif %}"  {% if order['show_refill'] == 0 %}  disabled  {% endif %}    id="refill-button"  class=" btn btn-actions bg-refill" style="display:inline;background: #0d5bd9; color: white;" type="submit" value="Refill" name="refill">
      </div>
   </form>
</td>
               {% endif %}
               {% endif %}                              
                           </tr>
                           {% endfor %}
                        </tbody>
                     </table>
                  </div>

      {% if pagination["count"] > 1 %}
        <ul class="pagination">

          {% if pagination["current"] != 1 %}
            <li>
              <a href="orders/{{ status }}/{{ pagination["previous"] }}{% if search %}?search={{ search }}{% endif %}" aria-label="Previous">
                <span aria-hidden="true">&laquo;</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="orders/{{ status }}/{{ page }}{% if search %}?search={{ search }}{% endif %}">{{ page }}</a></li>
            {%endif%}
          {% endfor %}

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

        </ul>
      {% endif %}

    </div>
  </div>
</div></div></div></div>
</div></div></div></div></div></div>
</div></div>
{% include 'footer.twig' %}