{% include 'header.twig' %}

<!-- Add CSS for Animations -->
<style>
    /* Pulse Animation for "Completed" and "Pending" */
    @keyframes pulse {
        0% {
            transform: scale(1);
        }
        50% {
            transform: scale(1.2);
        }
        100% {
            transform: scale(1);
        }
    }

    /* Rotate Animation for "In Progress", "Processing" */
    @keyframes rotate {
        0% {
            transform: rotate(0deg);
        }
        100% {
            transform: rotate(360deg);
        }
    }

    /* Shake Animation for "Canceled" */
    @keyframes shake {
        0% {
            transform: translateX(0);
        }
        25% {
            transform: translateX(-5px);
        }
        50% {
            transform: translateX(5px);
        }
        75% {
            transform: translateX(-5px);
        }
        100% {
            transform: translateX(0);
        }
    }

    /* Apply animation to specific icons */
    .ordStatus i {
        display: inline-block;
        transition: all 0.3s ease;
    }
</style>
<!-- Remix Icon CDN -->
<link href="https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css" rel="stylesheet">

   <div class="wrapper-content">
    <div class="wrapper-content__header">
          </div>
    <div class="wrapper-content__body">
      <!-- Main variables *content* -->
<div id="block_62"><div class="block-bg"></div><div class="container-fluid"><div class="orders-history ">
    <div class="row">
        <div class="col">
            <div class="orders-history__margin-tab">
                <div class="component_status_tabs">
                    <div class="">
                        <ul class="nav nav-pills tab">
                            <li class="nav-item">
		<a {% if 'all' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders">All</a>
		</li>
        <li class="nav-item"><a {% if 'pending' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/pending">{{ lang['orders.status.pending'] }}</a></li>
        <li class="nav-item"><a {% if 'inprogress' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/inprogress">{{ lang['orders.status.inprogress'] }}</a></li>
        <li class="nav-item"><a {% if 'completed' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/completed">{{ lang['orders.status.completed'] }}</a></li>
        <li class="nav-item"><a {% if 'partial' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/partial">{{ lang['orders.status.partial'] }}</a></li>
        <li class="nav-item"><a {% if 'processing' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/processing">{{ lang['orders.status.processing'] }}</a></li>
        <li class="nav-item"><a {% if 'canceled' == status %}  class="nav-link active" {% endif %} class="nav-link" href="orders/canceled">{{ lang['orders.status.canceled'] }}</a></li>
       
      						</ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <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="/orders" 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>{{ lang['orders.id'] }}</th>
              <th>{{ lang['orders.date'] }}</th>
              <th>{{ lang['orders.link'] }}</th>
              <th>{{ lang['orders.charge'] }}</th>
              <th class="nowrap">{{ lang['orders.start.count'] }}</th>
              <th>{{ lang['orders.quantity'] }}</th>
              <th>{{ lang['orders.service'] }}</th>
              <th>Status</th>
              <th>Remains</th>
              <th>&nbsp;</th> 
            </tr>
          </thead>
          <tbody>

            {% for order in orders %}
              <tr>
<td data-label="ID">
<span id="order-{{ order['id'] }}">{{ order['id'] }}</span>
                                        <a>
                                            <span
                                                data-clip="true"
                                                title="Order Id copied"
                                                data-clipboard-action="copy"
                                                data-clipboard-target="#order-{{ order['id'] }}"
                                                class="fas fa-clone"></span>
                                        </a>

                                        
{% if order['order_where'] == "api"  %}<a class="btn btn-actions">Api</a>{% endif %} </td>
                <td data-label="Date">{{ order['date'] }}</td>
                <td data-label="Link" class="table-link"> <a target="_blank" href="{{ order['link'] }}">{{ order['link'] }}</a></td>
                <td data-label="Charge">{{order["charge"]}}</td>
                <td data-label="Start count" class="nowrap">{{ order['start_count'] }}</td>
                <td data-label="Quantity">{{ order['quantity'] }}</td>
                <td data-label="Service" class="table-service">{{ order["service_id"] }} — {{ order['service'] }}</td>
                

<td data-label="Status" nowrap>
    {% if order['status'] == lang['orders.status.completed'] %}
        <div class="ordStatus align-items-center" style="background: #28a745; color:#fff; border-radius: 15px; padding: 5px 15px; font-size: 12px; text-align: center;">
            <i class="fas fa-badge-check" style="color: white; animation: pulse 1.5s infinite;"></i> <!-- Animated Icon for Completed -->
            <span style="color: white;">{{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: 5px 15px; font-size: 12px; text-align: center;">
            <i class="ri-refresh-line" style="color: white; animation: rotate 2s infinite linear;"></i> <!-- Animated Icon for In Progress -->
            <span style="color: white;">{{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: 5px 15px; font-size: 12px; text-align: center;">
            <i class="fad fa-hourglass-half" style="color: white; animation: pulse 1.5s infinite;"></i> <!-- Animated Icon for Pending -->
            <span style="color: white;">{{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: 5px 15px; font-size: 12px; text-align: center;">
            <!-- Updated Icon for Partial -->
            <i class="ri-pie-chart-line" style="color: white; animation: pulse 2s infinite;"></i> <!-- Animated Icon for Partial -->
            <span style="color: white;">{{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: 5px 15px; font-size: 12px; text-align: center;">
            <i class="ri-cpu-line" style="color: white; animation: rotate 2s infinite linear;"></i> <!-- Animated Icon for Processing -->
            <span style="color: white;">{{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: 5px 15px; font-size: 12px; text-align: center;">
            <i class="ri-error-warning-line" style="color: white; animation: shake 1s infinite;"></i> <!-- Animated Icon for Canceled -->
            <span style="color: white;">{{order['status']}}</span>
        </div>
    {% endif %}
</td>




                <td>{{ order['remains'] }}</td>
<td>
{% if order["refillButton"] == "2" %}
{% if order['status'] == "Completed"  %}

{% if order['show_refill'] == "true"  %}
<a href="orders/refill/{{order['id']}}" class="btn btn-sm refill-button">Refill</a>
<br><br>
{% endif %}
{% endif %}
{% endif %}
{% if order["refillButton"] == "3" %}

{% if order['status'] == "Completed"  %}

{% if order['show_refill'] == "true"  %}
  <button data-tippy-content="Refill will be available in {{order['refillTimeLeft']}}" class="btn btn-sm refill-button">Refill</button>
{% endif %}
{% endif %}
{% endif %}
{% if order["refillButton"] == "4" %}



{% if order['status'] == "Completed"  %}

{% if order['show_refill'] == "true"  %}
<button type="button" class="btn btn-sm refill-button" disabled="true">{{"Refilling"}}</button>
{% endif %}
{% endif %}
{% endif %}

{% if order['cancelButton']   == true %}
         


                   <a href="orders/cancel/{{order['id']}}" class="btn btn-actions bg-danger">cancel</a>
               {% endif %}

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

          </tbody>
        </table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</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></div></div>
   </div</div></div>
   </div></div></div>
   </div>
 <div class="divider-top"></div>
        <div class="divider-bottom"></div>
        <div class="container-fluid">
 {% if contentText2 %}
 <div class="card mb-4">	
{{ contentText2 }}
</div>
{% endif %}
</div>

{% include 'footer.twig' %}

                

                       