<?php
/**
 * File			: antrian_list.php
 * Description  : View untuk halaman antrian
 * Created By	: Hendi
 * Created Date : 16 Mar 2021
 * Last Update  : 16 Mar 2021
**/
# sts add keterangannya jadi tambah
$sts = $inputs['sts'] ?? 'add';
$stsket = ($sts == 'add' ? 'Tambah' : ucwords($sts));
?>
<div class="container-fluid">
	<div class="row">
		<div class="col-md-3">
			<div class="card">
				<div class="card-header card-header-info">
					<h4 class="card-title">Input Antrian</h4>
					<p id="from-antrian-category" class="card-category"><?= esc($stsket) ?> antrian</p>
				</div>
				<div class="card-body">
					<?php 
						# jika menggunakan form_open(), maka csrf token otomatis sudah dibuat.
						# esc() berfungsi menjaga serangan xss (cross site scripting)
					?>
					<?= form_open('antrian/save', ['id' => 'form-antrian']) ?>
						<input type="hidden" id="sts" name="sts" value="<?= esc($inputs['sts'] ?? 'add') ?>" />
						<input type="hidden" id="antrian-id" name="antrian_id" value="<?= esc($inputs['antrian_id'] ?? '') ?>" />
						<div class="row">
							<div class="col-md-6">
								<label>NO ANTRIAN</label>
								<div class="form-group">
									<input type="number" id="no-antrian" name="no_antrian" class="form-control" value="<?= esc($inputs['no_antrian'] ?? '') ?>" min="1" required />
									<small></small>
								</div>
							</div>
							<div class="col-md-12">
								<label>MENU</label>
								<div class="form-group">
									<select id="menu-id" name="menu_id" class="selectpicker" data-style="select-with-transition" title="-PILIH-" data-live-search="true" required>
										<option value="" <?= ($sts == 'add' ? 'selected' : '') ?>>-PILIH-</option>
										<?php
											foreach ($menu_data as $v)
											{
												echo '<option value="'.$v['menu_id'].'"'.(isset($inputs['menu_id']) && $inputs['menu_id'] == $v['menu_id'] ? ' selected' : '').'>'.strtoupper($v['menu_name']).'</option>';
											}
										?>
									</select>
									<small></small>
								</div>
							</div>
							<div class="col-md-6">
								<label>QTY</label>
								<div class="form-group">
									<input type="number" id="qty" name="qty" class="form-control" value="<?= esc($inputs['qty'] ?? '') ?>" min="1" required />
									<small></small>
								</div>
							</div>
						</div>
						<button id="simpan" type="button" class="btn btn-info pull-right">Simpan</button>
						<div class="clearfix"></div>
					<?= form_close() ?>
				</div>
			</div>
		</div>
		<div class="col-md-9">
			<div class="card">
				<div class="card-header card-header-info">
					<h4 class="card-title">List Antrian</h4>
					<p class="card-category"><?= date('d') . ' ' . date('M') . ' ' . date('Y') ?></p>
				</div>
				<div id="list-antrian" class="card-body">
					<div class="toolbar">
						<button id="btn-add" rel="tooltip" title class="btn btn-info btn-fab" data-original-title="Input Baru"><i class="material-icons">border_color</i><div class="ripple-container"></div></button>
					</div>
					<div class="material-datatables">
						<table id="dt-<?= $mod ?>" class="table table-striped table-no-bordered table-hover dataTable dtr-inline" cellspacing="0" width="100%" role="grid">
							<thead>
								<tr role="row">
									<th>NO</th>
									<th>JAM</th>
									<th>MENU</th>
									<th>QTY</th>
									<th>NO ANTRIAN</th> 
									<th>KETERANGAN</th>
								</tr>
							</thead>
							<tbody></tbody>
							<tfoot></tfoot>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	//_mod dideklarasikan di myscrypt.js
	_mod = '<?= $mod ?>';
</script>