{% include 'header.twig' %}
<main class="app-main">
	<div class="page-content">
		<div class="container-fluid">

			<div class="row mt-4 pt-2">
				<div class="col-12">
					<form action="" method="get" id="history-search">
					<div class="fg fg-dark">
						<div class="fg-icon" style="background-color: transparent;"><i class="far fa-search"></i></div>
						<input type="text" name="search" class="fg-control" value="{{ search }}" placeholder="{{ lang['smmspot.orders.search.text'] }}">
					</form>
					</div>

					<ul class="order-navs mt-3">
						<li {% if 'all' == status %} class="active"{% endif %}>
							<a href="subscriptions">
								<i class="far fa-filter"></i>
								<div class="onav-text">{{ lang['subscriptions.status.all'] }}</div>
							</a>
						</li>
						<li {% if 'active' == status %} class="active"{% endif %}>
							<a href="subscriptions/active">
								<i class="far fa-tasks"></i>
								<div class="onav-text">{{ lang['subscriptions.status.active'] }}</div>
							</a>
						</li>
						<li {% if 'paused' == status %} class="active"{% endif %}>
							<a href="subscriptions/paused">
								<i class="fas fa-spinner"></i>
								<div class="onav-text">{{ lang['subscriptions.status.paused'] }}</div>
							</a>
						</li>
						<li {% if 'completed' == status %} class="active"{% endif %}>
							<a href="subscriptions/completed">
								<i class="far fa-check-circle"></i>
								<div class="onav-text">{{ lang['subscriptions.status.completed'] }}</div>
							</a>
						</li>
						<li {% if 'expired' == status %} class="active"{% endif %}>
							<a href="subscriptions/expired">
								<i class="far fa-project-diagram"></i>
								<div class="onav-text">{{ lang['subscriptions.status.expired'] }}</div>
							</a>
						</li>
						<li {% if 'canceled' == status %} class="active"{% endif %}>
							<a href="subscriptions/canceled">
								<i class="far fa-times-circle"></i>
								<div class="onav-text">{{ lang['subscriptions.status.canceled'] }}</div>
							</a>
						</li>
					</ul>
				</div>
			</div>

			<div class="order-list">

				{% for order in orders %}
				<div id="order-items" class="card card-order mt-5">
					<div class="card-body">
						<div class="row">
							<div class="col-lg-auto col-md-auto col-12 co-part">
								<div class="coh-icon">
								{{ order['id'] }}
								</div>
							</div>
							<div class="col-lg col mb-lg-0 mb-3 co-part">
								<h4 class="co-text">{{ order['service'] }}</h4>
							</div>
							<div class="col-lg-auto pe-lg-0 co-part mb-lg-0 mb-4">
								<div class="order-input">
									<button class="btn btn-transparent btn-sm"
										onclick="copyToClipboard('{{ order['link'] }}')">
										<i class="far fa-copy"></i>
									</button>
									<a class="oi-control" href="{{ order['link'] }}"
										target="_blank">{{ order['link'] }}</a>
								</div>
							</div>
							<div class="col-lg-auto col-12 co-part co-right">
								<div>
									{% if order['status_name'] == lang['subscriptions.status.completed'] %}
										<div class="order-status d-block os-completed">{{ order['status_name'] }}</div>
									{% endif %}
									{% if order['status_name'] == lang['subscriptions.status.active'] %}
										<div class="order-status d-block os-processing">{{ order['status_name'] }}</div>
									{% endif %}
									{% if order['status_name'] == lang['subscriptions.status.paused'] %}
										<div class="order-status d-block os-pending">{{ order['status_name'] }}</div>
									{% endif %}
									{% if order['status_name'] == lang['subscriptions.status.expired'] %}
										<div class="order-status d-block os-iprogress">{{ order['status_name'] }}</div>
									{% endif %}
									{% if order['status_name'] == lang['subscriptions.status.canceled'] %}
										<div class="order-status d-block os-cancel">{{ order['status_name'] }}</div>
									{% endif %}
								</div>
								<div class="co-right-right">
									<button class="btn btn-dark orderToggle"><i
											class="fas fa-chevron-down"></i></button>
								</div>
							</div>
						</div>
						<div class="co-hidden" style="display: none;">
							<div class="row">
								<div class="col-xl-3 col-lg-6 col-md-12 mb-4">
									<div class="chid-item">
										<div class="d-flex align-items-center">
											<div class="coh-icon">
												<i class="far fa-chart-line"></i>
											</div>
											<div class="coh-details ps-2">
												<h3 class="coh-m-title">{% if order['quantity_min'] == order['quantity_max'] %}{{ order['quantity_max']}}{% else %}{{ order['quantity_min'] }}-{{ order['quantity_max'] }}{% endif %}</h3>
												<div class="coh-count">{{ lang['subscriptions.quantity'] }}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-3 col-lg-6 col-md-12 mb-4">
									<div class="chid-item">
										<div class="d-flex align-items-center">
											<div class="coh-icon">
												<i class="far fa-chart-line"></i>
											</div>
											<div class="coh-details ps-2">
												<h3 class="coh-m-title">{% if order['current_count'] %}
                  <a href="orders?subscription={{ order['id'] }}">{{ order['current_count'] }}</a>
                {% else %}
                  {{ order['current_count'] }}
								{% endif %}
                / {% if order['quantity'] == 0 %}∞{% else %}{{ order['quantity'] }}{% endif %}</h3>
												<div class="coh-count">{{ lang['subscriptions.posts'] }}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-3 col-lg-6 col-md-12 mb-4">
									<div class="chid-item">
										<div class="d-flex align-items-center">
											<div class="coh-icon">
												<i class="far fa-chart-line"></i>
											</div>
											<div class="coh-details ps-2">
												<h3 class="coh-m-title">{{ order['delay'] }}</h3>
												<div class="coh-count">{{ lang['subscriptions.delay'] }}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-3 col-lg-6 col-md-12 mb-4">
									<div class="chid-item">
										<div class="d-flex align-items-center">
											<div class="coh-icon">
												<i class="far fa-chart-line"></i>
											</div>
											<div class="coh-details ps-2">
												<h3 class="coh-m-title">{{ order['date_created'] }}</h3>
												<div class="coh-count">{{ lang['subscriptions.created'] }}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-3 col-lg-6 col-md-12 mb-4">
									<div class="chid-item">
										<div class="d-flex align-items-center">
											<div class="coh-icon">
												<i class="far fa-chart-line"></i>
											</div>
											<div class="coh-details ps-2">
												<h3 class="coh-m-title">{{ order['date_updated'] }}</h3>
												<div class="coh-count">{{ lang['subscriptions.updated'] }}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-3 col-lg-6 col-md-12 mb-4">
									<div class="chid-item">
										<div class="d-flex align-items-center">
											<div class="coh-icon">
												<i class="far fa-chart-line"></i>
											</div>
											<div class="coh-details ps-2">
												<h3 class="coh-m-title">{% if order['date_expiry'] == "" %}Devam Ediyor{% else %}{{ order['date_expiry'] }}{% endif %}</h3>
												<div class="coh-count">{{ lang['subscriptions.expiry'] }}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-auto col-md-12 col-12 mb-4">
									<button class="btn btn-primary ahbtn btn-block bs-3" onclick="window.location.href='/tickets'">
										<i class="fas fa-headset"></i>
										<span class="ms-3 d-inline-block d-xl-none">{{ lang['smmspot.subscriptions.create.ticket.text'] }}</span>
									</button>
								</div>
							</div>
							<div class="row mt-3">
								<div class="col-lg-4">
								{% if order['status'] == "paused" %}
									  <a href="subscriptions/stop/{{order['id']}}" class="btn btn-primary btn-block">{{ lang['subscriptions.button.cancel'] }}</a>
									{% endif %}
								</div>
								<div class="col-lg-4">
								{% if order['status'] == "paused" %}
									  <a href="subscriptions/resume/{{order['id']}}" class="btn btn-dark btn-block">{{ lang['subscriptions.button.unpause'] }}</a>
									{% endif %}
								</div>
								<div class="col-lg-4">
								{% if order['status'] == "active" %}
									  <a href="subscriptions/pause/{{order['id']}}" class="btn btn-dark btn-block">{{ lang['subscriptions.button.pause'] }}</a>
									{% endif %}
								</div>
							</div>							
						</div>
					</div>
				</div><!-- card-order -->
				
						<div class="modal fade" id="report{{ order['id'] }}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
								   <div class="modal-dialog modal-dialog-centered">
									  <div class="modal-content">
										 <!-- Modal Header -->
										 <div class="modal-header">
											<h4 class="modal-title">{{ lang['smmspot.subscriptions.create.ticket.text2'] }}</h4>
											<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
										 </div>
										 <!-- Modal body -->
										 <div class="modal-body">
											<div class="payout">
											  
												 <form  id="gonderilenform{{ order['id'] }}">
													<div id="sonuc"></div>
												  <div class="form-group mb-3">
													<label for="subject" class="control-label">{{ lang['smmspot.subscriptions.ticket.subject.title'] }}</label>
													<select class="form-control" id="subject" name="TicketForm[subject]">
														  <option value="Siparişimi iptal etmek istiyorum #{{ order['id'] }}">{{ lang['smmspot.subscriptions.ticket.subject.1'] }} </option>
														  <option value="Gönderilen miktar düştü #{{ order['id'] }}">{{ lang['smmspot.subscriptions.ticket.subject.2'] }} </option>
														  <option value="Siparişim beklemede kaldı #{{ order['id'] }}">{{ lang['smmspot.subscriptions.ticket.subject.3'] }}</option>
														  <option value="Siparişim neden iptal edildi? #{{ order['id'] }}">{{ lang['smmspot.subscriptions.ticket.subject.4'] }}</option>
														  <option value="Diğer #{{ order['id'] }}">{{ lang['smmspot.subscriptions.ticket.subject.5'] }}</option>  
													</select>
												  </div>
												  <div class="form-group">
													<label for="message" class="control-label">{{ lang['smmspot.subscriptions.ticket.message.text'] }}</label>
													<textarea class="form-control" rows="7" id="message" name="TicketForm[message]" required></textarea>
												  </div>
												  <button id="buton{{ order['id'] }}" class="btn btn-primary btn-block mt-3">{{ lang['smmspot.subscriptions.ticket.send.text'] }}</button>
												</form>
											  
											</div>
										  
										 </div>
									  </div>
								   </div>
								</div>  
				{% endfor %}


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

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

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

									</ul>
									{% endif %}

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