<?php require admin_view('static/header') ?>
<div class="container-fluid">
	<div class="row">
		<div class="col-lg-12">
			<a href="<?=admin_url('drips')?>" class="btn btn-default">Tüm Süreli Siparişler</a>
			<a href="<?=admin_url('drips/1')?>" class="btn btn-default">İşlemde</a>
			<a href="<?=admin_url('drips/0')?>" class="btn btn-default">Tamamlandı</a>
			<a href="<?=admin_url('drips/2')?>" class="btn btn-default">İptal Edildi</a>
			<div class="panel panel-default" style="margin-top:20px;">
				<table id="table" class="table order-table table-grey" style="margin-bottom:0;">
					<thead>
						<tr>
							<th>#</th>
							<th>Kullanıcı</th>
							<th style="width:30%">Servis</th>
							<th style="width:10%">Bağlantı</th>
							<th>Son İşlem Zamanı</th>
							<th>Miktar</th>
							<th>Yapılan</th>
							<th>Gecikme</th>
							<th>Durum</th>
						</tr>
					</thead>
					<tbody>
						<?php foreach($drips as $drip): ?>
							<tr>
								<td><?=$drip["drip_id"];?></td>
								<td><?=($drip["user_username"] != null) ? $drip["user_username"] : "Silinmiş";?></td>
								<td><span class="label-id"><?=($drip["service_id"] != null) ? $drip["service_id"] : "0";?></span><?=($drip["service_name"] != null) ? $drip["service_name"] : "Silinmiş";?></td>
								<td><?=date("d.m.y H:i:s", $drip["drip_last_action"]);?></td>
								<td><?=$drip["drip_link"];?></td>
								<td><?=$drip["drip_quantity"]/$drip["drip_runs"];?></td>
								<td><?=$drip["drip_completed"];?>/<?=$drip["drip_runs"];?></td>
								<td><?=$drip["drip_interval"];?></td>
								<td>
									<select id="status_<?=$drip["drip_id"];?>" class="form-control form-control-sm" onchange="update_drip_status('<?=$drip["drip_id"];?>')">
										<option value="0"<?=$drip["drip_status"] == 0 ? " selected" : null;?>>Tamamlandı</option>
										<option value="1"<?=$drip["drip_status"] == 1 ? " selected" : null;?>>İşlemde</option>
										<option value="2"<?=$drip["drip_status"] == 2 ? " selected" : null;?>>İptal Edildi</option>
									</select>
								</td>
							</tr>
						<?php endforeach; ?>
					</tbody>
				</table>
			</div>
		</div>
	</div>		
</div>
<?php require admin_view('static/footer') ?>