<?php require view('theme/header'); ?>
<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="{{ page['url'] }}" 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" placeholder="Siparişlerde Ara">
					</form>
					</div>
				</div>
			</div>

			<div class="order-list">


                
				<?php 
				if ($orders != NULL) {
				foreach($drips as $drip) { ?>
				<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">
									<?=$drip[drip_id]?>
								</div>
							</div>
							<div class="col-lg col mb-lg-0 mb-3 co-part">
								<h4 class="co-text"><?=$name?></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('<?=$drip[drip_link]?>')">
										<i class="far fa-copy"></i>
									</button>
									<a class="oi-control" href="<?=$drip[drip_link]?>"
										target="_blank"><?=$drip[drip_link]?></a>
								</div>
							</div>
							<div class="col-lg-auto col-12 co-part co-right">
								<div>
								    <div class="order-status d-block os-<?php if($drip["drip_status"] == 1) {echo "processing";}elseif($drip["drip_status"] == 2){echo "cancel";}else{echo "completed";} ?>">
								        <?php if($drip["drip_status"] == 1) {echo "{DRIP_STATUS_PROCESSING}";}elseif($drip["drip_status"] == 2){echo "{DRIP_STATUS_CANCELED}";}else{echo "{DRIP_STATUS_COMPLETED}";} ?>
								        </div>
								
								</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-2 col-lg-6 col-md-12 mb-4 mb-xl-0">
									<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"><?=$drip[drip_amount]?> {CURRENCY_SYMBOL}</h3>
												<div class="coh-count">{DRIPS_AMOUNT}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-auto col-lg-6 col-md-12 mb-4 mb-xl-0">
									<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"><?=$drip[drip_quantity]?></h3>
												<div class="coh-count">{DRIPS_QUANTITY}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-auto col-lg-6 col-md-12 mb-4 mb-xl-0">
									<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"><?=$drip[drip_completed]."/".$drip[drip_runs]?></h3>
												<div class="coh-count">{DRIPS_COMPLETED}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-auto col-lg-6 col-md-12 mb-4 mb-xl-0">
									<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"><?=$drip[drip_interval]?></h3>
												<div class="coh-count">{DRIPS_INTERVAL}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-auto col-lg-6 col-md-12 mb-4 mb-xl-0">
									<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"><?=date("d.m.y H:i:s", $drip["drip_last_action"])?></h3>
												<div class="coh-count">{DRIPS_LAST_ACTION}</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xl-auto col-md-12 col-12 col-4">
									<button class="btn btn-primary ahbtn btn-block bs-3" data-bs-toggle="modal"
										data-bs-target="#report<?=$drip[drip_id]?>">
										<i class="fas fa-headset"></i>
										<span class="ms-3 d-inline-block d-xl-none">Create Ticket</span>
									</button>
								</div>
							</div>						
						</div>
					</div>
				</div><!-- card-order -->
				
						<div class="modal fade" id="report<?=$drip[drip_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">Ticket Oluştur</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="create_ticket" onsubmit="return false;">
													<div id="sonuc"></div>
												  <div class="form-group mb-3">
													<label for="subject" class="control-label">Konu</label>
													<select class="form-control" id="title" name="title">
														  <option value="Siparişimi iptal etmek istiyorum #<?=$drip[drip_id]?>">Siparişimi iptal etmek istiyorum</option>
														  <option value="Gönderilen miktar düştü #<?=$drip[drip_id]?>">Gönderilen miktar düştü</option>
														  <option value="Siparişim beklemede kaldı #<?=$drip[drip_id]?>">Siparişim beklemede kaldı</option>
														  <option value="Siparişim neden iptal edildi? #<?=$drip[drip_id]?>">Siparişim neden iptal edildi?</option>
														  <option value="Diğer #<?=$drip[drip_id]?>">Diğer</option>  
													</select>
												  </div>
												  <div class="form-group">
													<label for="message" class="control-label">Mesaj</label>
													<textarea class="form-control" rows="7" id="message" name="message" required></textarea>
												  </div>
												  <input type="hidden" name="_csrf" value="{{ csrftoken }}">
												  <button id="buton<?=$drip[drip_id]?>" class="btn btn-primary btn-block mt-3">Gönder</button>
												</form>
											  
											</div>
										  
										 </div>
									  </div>
								   </div>
								</div>  
							<?php }}else {?>
				<div class="card mt-3">
				<div class="card-body">
					<div class="noorders text-center">
							<img src="<?= theme("assets/images/smiley.svg"); ?>" class="img-fluid smiley my-5" />
							<p>Merhaba <strong>{USER_USERNAME}</strong>, daha önce hiç sipariş vermedin.</p>
							<p>Bakiye Ekleyip <a href="/">Yeni Sipariş</a> Sayfasından Dilediğin Hizmeti Verebilirsin...</p>
						<div class="d-flex justify-content-center mt-5">
							 <a href="/addfunds"><button class="btn btn-primary btn-lg mb-4 mx-1">Bakiye Yükle</button></a>
							 <a href="/"><button class="btn btn-dark btn-lg mb-4 mx-1">Sipariş Ver</button></a>
						</div>
					</div>
				</div>
			</div>
				<?php } ?>


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

<?php require view('theme/footer'); ?>
