{% include 'header.twig' %}
<style>
    element.style {
}
p, label, a, button, span, div {
    color: #d99d21;
    font-family: "Montserrat", -apple-system, BlinappacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
</style>
  <div class="marginforfixed userbody">
      <!-- Main variables *content* -->
      <div class="container-fluid">
  <div class="row">
    <div class="col-lg-12">
      <div class="ordertopfeats">
        <div class="search">
          <form action="/orders" method="get" id="history-search">
            <i class="fas fa-search searchico"></i>
            <input type="text" name="search" class="form-control" value="" placeholder="Search by ID or Name">
          </form>
        </div>
        <ul class="nav nav-pills ordpills ">
          <li class="active"><a href="/orders"><i class="fas fa-list"></i> All</a></li>

          <li ><a class="alert-info" href="/orders/pending"><i class="far fa-pause-circle"></i> Pending</a></li>

          <li ><a class="alert-inprogress" href="/orders/inprogress"><i class="fad fa-spinner-third"></i> In progress</a></li>

          <li ><a class="alert-success" href="/orders/completed"><i class="far fa-check-circle"></i> Completed</a></li>

          <li ><a class="alert-warning" href="/orders/partial"><i class="far fa-battery-half"></i> Partial</a></li>

          <li ><a class="alert-processing" href="/orders/processing"><i class="far fa-chart-line"></i> Processing</a></li>

          <li ><a class="alert-danger" href="/orders/canceled"><i class="fas fa-ban"></i> Canceled</a></li>
        </ul>
      </div>
      <div class="switch-group">
        <button id="copy-orders-btn" class="btn btn-primary mb-3 threeddarkblue selectord" style=" padding: 6px; margin: 10px 0; min-width: 130px;">Copy</button>
      </div>
      <div class="table-responsive">
        <table class="table newtable ">
          <thead>
           <tr>
                                            <th scope="col">ID</th>
                                            <th scope="col">Date</th>
                                            <th scope="col">Link</th>
                                            <th scope="col">Charge</th>
                                            <th scope="col">Start count</th>
                                            <th scope="col">Quantity</th>
                                            <th scope="col">Service</th>
                                            <th scope="col">Remains</th>
                                            <th scope="col">Status</th>
                                                             <th></th>                        
                                        </tr>
                                    </thead>
                                    <tbody>
                                          
                                           {% for order in orders %}
              <tr>
<td>
<span class="order_id" id="order-{{ order['id'] }}">{{ order['id'] }}</span>
{% if order['order_where'] == "api"  %}<a class="btn btn-actions">Api</a>{% endif %} </td>




                <td>
                <div class="order_date">
                                                {{ order['date'] }}
                                            </div>
                </td>
                
                
                <td>
                <div class="order_link_wrap">
                                                <a href="{{ order['link'] }}" target="_blank" class="order_link">
                                                    <span> <i class="far fa-link"></i> {{ order['link'] }}</span>
                                                </a>
                                            </div></td>
            
            
                 <td>{{order["charge"]}}</td>
                <td class="nowrap">{{ order['start_count'] }}</td>
                <td>{{ order['quantity'] }}</td>
                <td>{{ order['service'] }}</td> 
                <td>{{ order['remains'] }}</td>
                
                
                
                <td>{% if order['status'] == lang['orders.status.completed'] %}
								<div class="ordStatus align-items-center" style="background: #28a745; color:#fff; border-radius: 15px; padding: 6px 15px; font-size: 14px; text-align: center;">
								   <i class="ri-checkbox-line"></i>
								   <span>{{order['status']}}</span>
								</div>
								{% endif %}
								
              {% if order['status'] == lang['orders.status.inprogress'] %}
								<div class="ordStatus align-items-center" style="background: #ff870b; color:#fff; border-radius: 15px; padding: 6px 15px; font-size: 14px; text-align: center;">
								   <i class="ri-loader-2-line"></i>
								   <span>{{order['status']}}</span>
								</div>
								{% endif %}
                
                {% if order['status'] == lang['orders.status.pending'] %}
								<div class="ordStatus align-items-center" style="background: #ffcc29; color:#fff; border-radius: 15px; padding: 6px 15px; font-size: 14px; text-align: center;">
								   <i class="ri-file-damage-line"></i>
								   <span>{{order['status']}}</span>
								</div>
								{% endif %}
								
								{% if order['status'] == lang['orders.status.partial'] %}
								<div class="ordStatus align-items-center" style="background: #11698e; color:#fff; border-radius: 15px; padding: 6px 15px; font-size: 14px; text-align: center;">
								   <i class="ri-star-half-line"></i>
								   <span>{{order['status']}}</span>
								</div>
								{% endif %}
								
									{% if order['status'] == lang['orders.status.processing'] %}
								<div class="ordStatus align-items-center" style="background: #61c0bf; color:#fff; border-radius: 15px; padding: 6px 15px; font-size: 14px; text-align: center;">
								   <i class="ri-remote-control-line"></i>
								   <span>{{order['status']}}</span>
								</div>
								{% endif %}
								
								
									{% if order['status'] == lang['orders.status.canceled'] %}
								<div class="ordStatus align-items-center" style="background: #ec4646; color:#fff; border-radius: 15px; padding: 6px 15px; font-size: 14px; text-align: center;">
								   <i class="ri-qr-scan-line"></i>
								   <span>{{order['status']}}</span>
								</div>
								{% endif %}
								
								</td>
                
                
     
             <td>
{% if order["refillButton"] == "2" %}
{% if order['status'] == "Completed"  %}
{% if order['show_refill'] == "true"  %}
<a class="btn btn-actions order_id" href="orders/refill/{{order['id']}}" class="btn btn-sm refill-button order_id">Refill</a>
<br><br>
{% endif %}
{% endif %}
{% endif %}
{% if order["refillButton"] == "3" %}
{% if order['status'] == "Completed"  %}
{% if order['show_refill'] == "true"  %}
  <button class="btn btn-actions order_id" data-tippy-content="Refill will be available in {{order['refillTimeLeft']}}" class="btn btn-sm refill-button order_id">Refill</button>
{% endif %}
{% endif %}
{% endif %}
{% if order["refillButton"] == "4" %}
{% if order['status'] == "Completed"  %}
{% if order['show_refill'] == "true"  %}
<button class="btn btn-actions order_id badges_inprogress" type="button" class="btn btn-sm refill-button order_id badges_inprogress" disabled="true">{{"Refilling"}}</button>
{% endif %}
{% endif %}
{% endif %}
{% if order['cancelButton']   == true %}
                   <a  class="btn btn-actions order_id order_status_badges badges_canceled" href="orders/cancel/{{order['id']}}" class="btn btn-actions order_id order_status_badges badges_canceled">cancel</a>
               {% endif %}

                 </td>    
                 
                 
                 
                 
              </tr>
            {% endfor %}

          </tbody>
        </table>
      </div>

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

          {% if pagination["current"] != 1 %}
            <li>
              <a class="btn btn-actions" href="orders/{{ 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 class="btn btn-actions" 
 href="orders/{{ status }}/{{ page }}{% if search %}?search={{ search }}{% endif %}">{{ page }}</a></li>
            {%endif%}
          {% endfor %}

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

        </ul>
      {% endif %}
      
      </tbody>
                      </tbody>
        </table>
      </div>

      
    </div>
  </div>
</div>

 {% include 'footer.twig' %}