<style type="text/css">
	.tr-active {
		background-color: #cfe9ff;
	}
</style>
<?php
	if ($data->num_rows() == 0) {
?>
<div class="alert alert-danger">Data tidak valid</div>
<?php
	}
	else {
?>
<?php 
	$role_name = $this->session->userdata('role_name');

	$the_title = 'HALAMAN KASIR';
	if ($page_type == 'driver') {
		$the_title = 'HALAMAN DRIVER';
	}
	else if ($page_type == 'production') {
		$the_title = 'HALAMAN PRODUKSI';
	}

	echo "<h3 align='center'>".$the_title."</h3>";
?>
<hr>
<input type="hidden" id="hd_type" value="<?php echo $page_type;?>">
<input type="hidden" id="hd_iddstb" value="<?php echo az_encode_url($data->row()->iddstb_clean);?>">
<div class="row">
	<div class="col-md-6">
		<table>
			<tr>
				<td>
					<img style="display:inline-block" src="https://quickchart.io/qr?size=150&text=<?php echo $data->row()->dstb_code;?>">
				</td>
				<td>
					<div style="font-size:30px;font-weight:bold;">DSTB BERSIH <?php echo $data->row()->outlet_name;?></div>
					<table cellspacing="0">
						<tr>
							<td style="font-size:20px;font-weight:bold;">Tgl</td>
							<td align="center" width="10px">:</td>
							<td style="font-size:20px;font-weight:bold;"><?php echo Date('d-m-Y', strtotime($data->row()->dstb_date));?></td>
						</tr>
						<tr>
							<td>No</td>
							<td align="center">:</td>
							<td><?php echo $data->row()->dstb_number;?></td>
						</tr>
						<tr>
							<td colspan="3"><?php echo $data->row()->dstb_code;?></td>
						</tr>
						<!-- <tr>
							<td>Kasir</td>
							<td align="center">:</td>
							<td><?php //echo $data->row()->cashier_name;?></td>
						</tr> -->
						<tr>
							<td>Driver</td>
							<td align="center">:</td>
							<td><?php echo $data->row()->driver_name;?></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<table width="100%">
						<tr>
							<td align="center">Total Bill: <?php echo $data->row()->total_bill;?></td>
							<td align="center">Total Pcs: <?php echo $data->row()->total_pcs_dstb;?></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2">
					<div>
						<?php
							$lbl_status = '';
							if (strlen($data->row()->tgl_diantar) > 0) {
								$lbl_status .= "<label class='label label-info'>Diantar: ".Date('H:i', strtotime($data->row()->tgl_diantar))."</label>";
							}
							if (strlen($data->row()->tgl_end_process) > 0) {
								$lbl_status .= "&nbsp;<label class='label label-success'>End Process: ".Date('H:i', strtotime($data->row()->tgl_end_process))."</label>";	
							}

							echo $lbl_status;
						?>
					</div>
				</td>
			</tr>
		</table>
	</div>
	<div class="col-md-6">
		Catatan DSTB: <?php echo $data->row()->dstb_note;?>
	</div>
</div>
<hr>

<form id="form_dstb" class="form-horizontal">
	<table class="table table-bordered table-condensed" id="table_dstb_list">
		<tr>
			<?php
				if ($page_type == 'cashier') {
			?>
			<!-- <th width="10px">#</th> -->
			<?php
				}
			?>			
			<th width="10px">No</th>
			<th>No Bill</th>
			<th>Nama</th>
			<th>Status</th>
			<th>Jumlah PCS</th>
			<th>Tgl Masuk</th>
			<th>Tgl Selesai</th>
			<th>Detail</th>
			<th>Catatan Bill</th>
			<?php
				if ($page_type == 'cashier') {
			?>
			<th>Posisi Stok</th>
			<?php
				}
			?>
		</tr>
		<?php 
			foreach ($data->result() as $key => $value) {
				$tr_class = '';
				if ($page_type == 'driver') {
					if ($value->dstb_status == 'SELESAI') {
						$value->dstb_status = 'DIANTAR';
					}
					if (in_array($value->dstb_status, array('DIANTAR'))) {
						$tr_class = 'tr-active';
					}
				}
				else if ($page_type == 'cashier') {
					if ($value->dstb_status == 'SELESAI') {
						$value->dstb_status = 'END PROCESS';
					}
					if ($value->dstb_status == 'END PROCESS') {
						$tr_class = 'tr-active';
					}
				}

		?>
		<tr class="<?php echo $tr_class;?>">
			<?php
				if ($page_type == 'cashier') {
			?>
			<!-- <td><button class="btn btn-danger btn-xs btn-remove-dstb" data-id="<?php //echo az_encode_url($value->iddstb_clean_detail);?>" type="button"><i class="fa fa-remove"></i></button></td> -->
			<?php
				}

			?>
			<td align="center"><?php echo ($key + 1);?></td>
			<td><?php echo $value->code;?></td>
			<td><?php echo $value->customer_name;?></td>
			<td><?php echo $value->dstb_status;?></td>
			<td><?php echo $value->total_pcs;?></td>
			<td><?php echo Date('d-m-Y', strtotime($value->date));?></td>
			<td><?php echo Date('d-m-Y', strtotime($value->duedate));?></td>
			<td align="center" width="10px"><button class="btn btn-info btn-xs btn-detail-bill" type="button" data-code="<?php echo $value->code;?>" data-id="<?php echo $value->idtransaction_group;?>"><i class="fa fa-list"></i> Detail Baju</button></td>
			<td><?php echo $value->note;?></td>
			<td align="center"><button class="btn btn-xs btn-primary btn-stock-position" type="button" data-id="<?php echo $value->idtransaction_group;?>"><i class='fa fa-cube'></i> Posisi Stok</button></td>
		</tr>
		<?php
			}
		?>
	</table>
</form>


<?php 
	if (in_array($page_type, array('driver', 'cashier'))) {
?>
<button class="btn btn-info" type="button" data-id="<?php echo $page_type;?>" id="btn_scan"><i class="fa fa-qrcode"></i> Scan QR Code Bill</button>
<div class="box-manual-scan">
	<div class="input-group">
		<input type="text" class="form-control" name="inp_code" id="inp_code" placeholder="Masukkan Kode Bill">
		<span class="input-group-addon btn-go-data" data-id="<?php echo $page_type;?>" ><i class="fa fa-refresh"></i></span>
	</div>
</div>
<?php
	}
?>

<hr>
<a href="<?php echo app_url();?>dstb_clean"><button class="btn btn-default" type="button"><i class="fa fa-arrow-left"></i> Kembali</button></a>&nbsp;
<a href="<?php echo app_url();?>dstb_clean/print_detail/?id=<?php echo az_encode_url($data->row()->iddstb_clean).'&type='.$page_type;?>" target="_blank"><button class="btn btn-info" type="button"><i class="fa fa-print"></i> Cetak</button></a>&nbsp;
<?php 
	if ($page_type == 'driver') {
?>
<button class="btn btn-warning" type="button" id="btn_verif_driver"><i class="fa fa-check"></i> Verifikasi Driver</button>
<?php
	}
	else if ($page_type == 'cashier') {
?>
<button class="btn btn-success" type="button" id="btn_verif_cashier"><i class="fa fa-check"></i> Verifikasi Penerimaan</button>
<?php	
	}
?>
<?php
	}
?>
