{% include 'header.twig' %}

<!-- Main variables *content* -->

          <div class="appContent">
        <div class="hiddenTitle">
    <div id="appTt">Orders</div>
    <div id="appTx">We're the best!</div>
</div>

<section class="orders-nav-wrapper">
    <div class="container-fluid">
      <div class="row">
        <div class="col-lg-9 col-md-12">
            <ul class="orders-nav">
                <li>
                <a {% if 'all' == status %}  class="orders-nav-link active" {% endif %} class="orders-nav-link" href="/orders">
                        <div class="icon">
                            <i class="ri-list-check-2"></i>
                        </div>
                        <span class="text">
                            All
                        </span>
                    </a>
                </li>

                <li>
                    <a {% if 'pending' == status %}  class="orders-nav-link active" {% endif %} class="orders-nav-link " href="/orders/pending">
                        <div class="icon">
                            <i class="ri-loader-2-line"></i>
                        </div>
                        <span class="text">
                            Pending
                        </span>
                </a>
                </li>

                <li>
                    <a {% if 'inprogress' == status %}  class="orders-nav-link active" {% endif %} class="orders-nav-link " href="/orders/inprogress">
                        <div class="icon">
                        <i class="ri-loader-2-line"></i>
                        </div>
                        <span class="text">
                            In progress
                        </span>
                    </a>
                </li>

                <li>
                    <a {% if 'completed' == status %}  class="orders-nav-link active" {% endif %} class="orders-nav-link " href="/orders/completed">
                        <div class="icon">
                        <i class="ri-checkbox-circle-line"></i>
                        </div>
                        <span class="text">
                            Completed
                        </span>
                    </a>
                </li>

                <li>
                    <a {% if 'partial' == status %}  class="orders-nav-link active" {% endif %} class="orders-nav-link " href="/orders/partial">
                        <div class="icon">
                        <i class="ri-pie-chart-line"></i>
                        </div>
                        <span class="text">
                            Partial
                        </span>
                    </a>
                </li>

                <li>
                    <a {% if 'processing' == status %}  class="orders-nav-link active" {% endif %} class="orders-nav-link " href="/orders/processing">
                        <div class="icon">
                        <i class="ri-truck-line"></i>
                        </div>
                        <span class="text">
                            Processing
                        </span>
                    </a>
                </li>

                <li>
                    <a {% if 'canceled' == status %}  class="orders-nav-link active" {% endif %} class="orders-nav-link " href="/orders/canceled"> 
                        <div class="icon">
                        <i class="ri-close-circle-line"></i>
                        </div>
                        <span class="text">
                            Canceled
                        </span>
                    </a>
                </li>

            </ul>
            
        </div>
        <div class="col-lg-3 col-md-12">
          <div class="orders-nav-link op-search-box">
            <div class="icon">
              <i class="ri-search-line"></i>
            </div>
            <form action="/orders" method="get" id="history-search">
              <input type="text" name="search" class="form-control" value="" placeholder="Search">
            </form>
          </div>
        </div>
      </div><!-- ./row -->
    </div>
  </section>				
  

      
            <div class="card card-border my-3">
  <div class="table-responsive table-responsive__search ">
									<table class="table">
                                    <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">Status</th>
                                            <th scope="col">Remains</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        
                                        {% for order in orders %}
              <tr>
<td>
<span class="order_id" id="order-{{ order['id'] }}">{{ order['id'] }}</span>

                                <!-- Refill Status -->

                                     {% if order['refillButton'] %}
							 <div class="col-lg-6 col-12">
							 {% elseif order['cancelButton'] %}
							 <div class="col-lg-6 col-12">
							 {% else %}
							 <div class="col-lg-8 col-12">
							 {% endif %}
                                    
                                    <!-- Refill Status -->
                                    
                                        
{% 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>{% if order['status'] == lang['orders.status.completed'] %}
								<div class="ordStatus align-items-center" style="background: #28a745; color:#000; border-radius: 15px; padding: 5px 15px; font-size: 12px; text-align: center;">
								   <i class="ri-checkbox-line"></i>
								   <span style="color:#000">{{order['status']}}</span>
								</div>
								{% endif %}
								
              {% if order['status'] == lang['orders.status.inprogress'] %}
								<div class="ordStatus align-items-center" style="background: #ff870b; color:#000; border-radius: 15px; padding: 5px 15px; font-size: 12px; text-align: center;">
								   <i class="ri-loader-2-line"></i>
								   <span style="color:#000">{{order['status']}}</span>
								</div>
								{% endif %}
                
                {% if order['status'] == lang['orders.status.pending'] %}
								<div class="ordStatus align-items-center" style="background: #ffcc29; color:#000; border-radius: 15px; padding: 5px 15px; font-size: 12px; text-align: center;">
								   <i class="ri-file-damage-line"></i>
								   <span style="color:#000">{{order['status']}}</span>
								</div>
								{% endif %}
								
								{% if order['status'] == lang['orders.status.partial'] %}
								<div class="ordStatus align-items-center" style="background: #11698e; color:#000; border-radius: 15px; padding: 5px 15px; font-size: 12px; text-align: center;">
								   <i class="ri-star-half-line"></i>
								   <span style="color:#000">{{order['status']}}</span>
								</div>
								{% endif %}
								
									{% if order['status'] == lang['orders.status.processing'] %}
								<div class="ordStatus align-items-center" style="background: #61c0bf; color:#000; border-radius: 15px; padding: 5px 15px; font-size: 12px; text-align: center;">
								   <i class="ri-remote-control-line"></i>
								   <span style="color:#000">{{order['status']}}</span>
								</div>
								{% endif %}
								
								
									{% if order['status'] == lang['orders.status.canceled'] %}
								<div class="ordStatus align-items-center" style="background: #ec4646; color:#000; border-radius: 15px; padding: 5px 15px; font-size: 12px; text-align: center;">
								   <i class="ri-qr-scan-line"></i>
								   <span style="color:#000">{{order['status']}}</span>
								</div>
								{% endif %}</td>
                <td>{{ order['remains'] }}</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 %}

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

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


{% include 'footer.twig' %}