{% include 'header.twig' %}<div class="inner-page">
 <section class="service-search-panel">
    <div class="container">
      <div class="search-panel">
        <form action="" method="get">
              <div class="form-group">
                <div class="input-group">
                <input type="text" name="search" class="form-control" value="" placeholder="Subscription Number">
                
              <span class="input-group-btn">
                <button type="submit" class="btn btn-green"><i class="fa fa-search" aria-hidden="true"> </i> Search</button>
              </span>
            </div>
          </div>
        </form>
      </div>

    </div>
  </section>
  
<section>
    <div class="container-fluid">
      <div class="card my-orders-panel">
        <div class="card-body">
          <div class="tabs-wrapper">
            <ul class="nav nav-justified nav-tabs dragscroll horizontal ">
                
              <li  {% if 'all' == status %}  class="nav-item active" {% endif %}  class="nav-item "><a class="nav-link" href="/subscriptions"><i class="fa fa-list-ul"></i> All Orders</a></li>
              
              <li {% if 'active' == status %}  class=" nav-item active" {% endif %} class="nav-item "><a class="nav-link" href="/subscriptions/active"><i class="fa fa-clock"></i> 
Active</a></li>
              
              <li {% if 'paused' == status %}  class="nav-item active" {% endif %}  class="nav-item "><a class="nav-link" href="/subscriptions/paused"><i class="	fa fa-pause-circle"></i> Stopped</a></li>
              
              <li  {% if 'completed' == status %}  class="nav-item active" {% endif %} class="nav-item "><a class="nav-link" href="/subscriptions/completed"><i class="fa fa-check"></i> Completed</a></li>
              
              <li {% if 'expired' == status %}  class="nav-item active" {% endif %} class="nav-item "><a class="nav-link" href="/subscriptions/expired"><i class="	fa fa-calendar-check-o"></i> Expired</a></li>
           
              <li  {% if 'canceled' == status %}  class="nav-item active" {% endif %} class="nav-item "><a class="nav-link" href="/subscriptions/canceled"><i class="fa fa-times-circle"></i> It is cancelled</a></li>
            </ul>
          </div>
          <div class="tab-content">
            <table class="table table-striped ">
              <thead>
            <tr>
            <th>#</th>
            <th>User name</th>
            <th>Quantity</th>
            <th>Number of posts</th>
            <th>Delay (minutes)</th>
            <th>Service Name</th>
            <th>Order status</th>
            <th>Creation Date</th>
            <th>date of update</th>
            <th>End Date</th>
            <th></th>
            </tr>
          </thead>
          <tbody>

            {% for order in orders %}
              <tr>
                <td>{{ order['id'] }}</td>
                <td class="link">{{ order['link'] }}</td>
                <td class="nowrap">{% if order['quantity_min'] == order['quantity_max'] %}{{ order['quantity_max']}}{% else %}{{ order['quantity_min'] }}-{{ order['quantity_max'] }}{% endif %}</td>
                <td class="nowrap">
                  {% if order['current_count'] %}
                    <a href="subscriptions?subscription={{ order['id'] }}">{{ order['current_count'] }}</a>
                  {% else %}
                    {{ order['current_count'] }}
  								{% endif %}
                  / {{ order['posts'] }}</td>
                <td>{{ order['delay'] }}</td>
                <td>{{ order['service'] }}</td>
                <td>{{ order['status_name'] }}</td>
                <td><span class="nowrap">{{ order['date_created'] }}</span></td>
                <td><span class="nowrap">{{ order['date_updated'] }}</span></td>
                <td><span class="nowrap">{{ order['date_expiry'] }}</span></td>
                <td>
                  {% if order['status'] == "active" %}
                    <a href="subscriptions/pause/{{order['id']}}" class="btn btn-primary btn-xs">Stop</a>
                  {% endif %}
                  {% if order['status'] == "paused" %}
                    <a href="subscriptions/resume/{{order['id']}}" class="btn btn-primary btn-xs">Go on</a>
                    <a href="subscriptions/stop/{{order['id']}}" class="btn btn-default btn-xs">Cancel</a>
                  {% endif %}
                </td>
              </tr>
            {% endfor %}

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

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

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

          {% if pagination['current'] < pagination['count'] %}
            <li>
              <a href="subscriptions/{{ 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>

{% include 'footer.twig' %}
