<style>
._titleJudul{
	font-size: 20px;
}
._tanya{
	padding-left: 15px;
}
._tanya2{
	padding-left: 50px;
}
._tanya3{
	text-align: center;
}
</style>
<?php 
$date = new Date;
$kode = new Kode;
$tgl = $date->getPenguranganTanggal(date("Y-m-d"), 0, 1, 0);

$jam = date("H:i");
// $jam = '13:00';
$pros = true;
if($jam > '15:00'){
	$pros = false;
}
?>
<p class="_titleJudul"><a href=""><u>Pandemic Report</u></a></p>

<div id="_divIconPil" style="height: 300px; overflow: auto; margin-top: 20px">
	<form method="POST" action="" id="_simpan">
	<table class="_form" style="margin-top: 20px">
		<tr>
			<td class="_label" style="width: 100px">Transaksi#</td>
			<td class="_spasi">:</td>
			<td class="_isi"><input type="text" size="10" id="nojnl" name="nojnl" class="_formIns" readonly style="width: 150px"></td>
		</tr>
		<tr>
			<td class="_label">Tanggal</td>
			<td class="_spasi">:</td>
			<td class="_isi"><input type="date" size="10" id="tgl" name="tgl" class="_formIns" readonly style="width: 100px" value="<?php echo date("Y-m-d", strtotime($tgl)) ?>"></td>
		</tr>
		<tr>
			<td class="_label">Status Kerja</td>
			<td class="_spasi">:</td>
			<td class="_isi">
				<select id="st" name="st">
					<option value="">--Pilih Salah Satu--
					<?php foreach($kode->ham_st() as $k => $r){ ?>
						<option value="<?php echo $k ?>"><?php echo $r ?>
					<?php } ?>
				</select>
			</td>
		</tr>
		<tr>
			<td class="_label">Laporan</td>
			<td class="_spasi">:</td>
			<td class="_isi">
				<select id="shift" name="shift">
				<option value="">--Pilih Salah Satu--
				<?php foreach($kode->ham_shift2() as $k => $r){ ?>
					<option value="<?php echo $k ?>"><?php echo $r ?>
				<?php } ?>
				</select>
			</td>
		</tr>
		<tr>
			<td class="_label">Lokasi</td>
			<td class="_spasi">:</td>
			<td class="_isi"><input type="text" size="4" id="lokasi" name="lokasi" style="width: 150px"></td>
		</tr>
		<tr>
			<td colspan="3">&nbsp;</td>
		</tr>
		<tr>
			<td colspan="3"><u>Kondisi & Kegiatan</u></td>
		</tr>
		<tr>
			<td colspan="3">&nbsp;</td>
		</tr>
		
		<?php
		
		$funT = array();
		$funT[1] = 'ham_kon';
		$funT[2] = 'ham_yt';
		$funT[3] = 'ham_yt';
		$funT[4] = 'ham_yt';
		$funT[5] = 'ham_yt';
		$funT[6] = 'ham_yt';
		$funT[7] = 'ham_yt';
		$funT[8] = 'ham_yt';
		foreach($kode->ham_tanya2() as $k => $r){
			$func = $funT[$k];
			$idNama = 'tanya'.$k;
			$idKet = 'ket'.$k;
		?>
			<tr>
				<td colspan="3" class="_tanya"><?php echo $r ?></td>
			</tr>
			<tr>
				<td colspan="3" class="_tanya2">
					<select id="<?php echo $idNama ?>" name="<?php echo $idNama ?>">
					<option value="">--Pilih Salah Satu--
					<?php foreach($kode->$func() as $k => $r){ ?>
						<option value="<?php echo $k ?>"><?php echo $r ?>
					<?php } ?>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="3">
					<textarea id="<?php echo $idKet ?>" name="<?php echo $idKet ?>" cols="40" rows="6" class="_formIns"></textarea>
				</td>
			</tr>
			<tr>
				<td colspan="3">&nbsp;</td>
			</tr>
		<?php } ?>
		
		<tr>
			<td colspan="3">&nbsp;</td>
		</tr>

		<?php if($pros == true){ ?>
			<tr>
				<td class="_label"></td>
				<td class="_spasi"></td>
				<td class="_isi">
					<input type="submit" id="_proses" value="Simpan">
				</td>
			</tr>
			<tr>
				<td colspan="3">&nbsp;</td>
			</tr>
		<?php } ?>
	</table>
	</form>
	
	<hr style="border: dubled; margin-bottom: 20px; margin-top: -10px;">
	
	<?php 
	$shift = $kode->ham_shift2();
	foreach($shift as $i => $r){ 
		$data = 'shift'.$i;
		$data = $this->data->$data;
	?>
		<div class="_divInsDetApk">
			<?php if(empty($data->nojnl)){ ?>
				<div class="_labelHed" style="color: red; text-align: center">Aktivitas Laporan <?php echo $r ?> Belum di Input</div>
			<?php }else{ 
				$st = $kode->ham_st();
			?>
				<div class="_labelHed"><u>#Transaksi : <?php echo $data->nojnl ?></u></div>
				<table style="width: 100%">
					<tr>
						<td class="_labelTab">Tanggal</td>
						<td class="_spasiTab">:</td>
						<td class="_isiTab" colspan="2"><?php echo date("d M Y", strtotime($data->tgl)) ?></td>
					</tr>
					<tr>
						<td class="_labelTab">Shift</td>
						<td class="_spasiTab">:</td>
						<td class="_isiTab" colspan="2"><?php echo $r ?></td>
					</tr>
					<tr>
						<td class="_labelTab">Status Kerja</td>
						<td class="_spasiTab">:</td>
						<td class="_isiTab" colspan="2"><?php echo $st[$data->st] ?></td>
					</tr>
					<tr>
						<td class="_labelTab">Lokasi</td>
						<td class="_spasiTab">:</td>
						<td class="_isiTab" colspan="2"><?php echo $data->lokasi ?></td>
					</tr>
					<tr>
						<td colspan="3">&nbsp;</td>
					</tr>
					<tr>
						<td colspan="4"><u>Kondisi & Kegiatan</u></td>
					</tr>
					<tr>
						<td colspan="3">&nbsp;</td>
					</tr>
					<?php 
					foreach($kode->ham_tanya2() as $k => $r){
						$idNama = 'tanya'.$k;
						$idKet = 'ket'.$k;
					?>
					<tr>
						<td colspan="4" class="_tanya3"><?php echo $r ?> <b><?php echo $data->$idNama ?></b></td>
					</tr>
					<tr>
						<td colspan="4" class="_tanya" style="text-align: center"><i><?php echo $data->$idKet ?></i></td>
					</tr>
					<tr>
						<td colspan="3">&nbsp;</td>
					</tr>
					<?php } ?>
					<tr>
						<td colspan="4">
							&nbsp;
						</td>
					</tr>
					<tr>
						<td class="_labelTab">Waktu Input</td>
						<td class="_spasiTab">:</td>
						<td class="_isiTab" colspan="2"><?php echo date("d/m/Y H:i", strtotime($data->chtime)) ?></td>
					</tr>
					<tr>
						<td class="_labelTab">Input Oleh </td>
						<td class="_spasiTab">:</td>
						<td class="_isiTab" colspan="2"><?php echo $data->chusr ?></td>
					</tr>
					<tr>
						<td colspan="4">
							&nbsp;
						</td>
					</tr>
					<?php if($pros == 'apank'){ ?>
						<!--
						<tr>
							<td colspan="2">
								<img src="<?php echo $this->baseAssets ?>images/close.png" class="_del _delApk" nojnl="<?php echo $data->nojnl ?>">
							</td>
							<td colspan="2" align="right">
								<img src="<?php echo $this->baseAssets ?>images/edit.png" class="_edit" nojnl="<?php echo $data->nojnl ?>">
							</td>
						</tr>
						-->
					<?php } ?>
				</table>
			<?php } ?>
		</div>
	<?php } ?>
</div>

<?php
$notNull = array();
$notNull[] = 'tgl';
$notNull[] = 'st';
$notNull[] = 'shift';
$notNull[] = 'lokasi';
$notNull[] = 'tanya1';
$notNull[] = 'tanya2';
$notNull[] = 'tanya3';
$notNull[] = 'tanya4';
$notNull[] = 'tanya5';
$notNull[] = 'tanya6';
$notNull[] = 'tanya7';
$notNull[] = 'tanya8';
$notNull[] = 'ket1';
$notNull[] = 'ket2';
$notNull[] = 'ket3';
$notNull[] = 'ket4';
$notNull[] = 'ket5';
$notNull[] = 'ket6';
$notNull[] = 'ket7';
$notNull[] = 'ket8';
?>

<script type="text/javascript">
$(document).ready(function(){
	_height = screen.height;
	_height = parseInt(_height) - 350;
	$('#_divIconPil').css("height", _height+'px');
	
	_prosesSimpan = false;
	$('#_simpan').submit(function(e){
		e.preventDefault();
		
		_nul = false;
		<?php foreach($notNull as $r){ ?>
			_style = $('#<?php echo $r ?>').attr('style');
			if(_style === undefined){
				_style = '';
			}
			_style = str_ireplace(';background-color: #f59fb0', '', _style);
				
			_cek = $('#<?php echo $r ?>').val();
			_cek = _cek.trim();
			$('#<?php echo $r ?>').removeAttr('style');
			if(_cek === ''){
				_style+= ';background-color: #f59fb0';
				_nul = true;
			}
			$('#<?php echo $r ?>').attr('style', _style);
		<?php } ?>
		
		if(_nul === true){
			return;
		}
		
		if(_prosesSimpan != false){
			_prosesSimpan.abort();
		}
		_prosesSimpan = $.ajax({
		type: 'POST',
			url: $('#defaultBaseUrl').val()+$('#defaultController').val()+'/eks/',
			data: $(this).serialize(),
			success: function(data) {
				$('#errorDisplay').html(data);
			}
		})
	})
	
	_upLoad = false;
	$('._edit').live('click', (function(){
		if(_upLoad != false){
			_upLoad.abort();
		}
		_nojnl = $(this).attr('nojnl');
		_upLoad = $.ajax({
		type: 'POST',
			url: $('#defaultBaseUrl').val()+$('#defaultController').val()+'/apk_up/&nojnl='+_nojnl,
			data: $(this).serialize(),
			success: function(data) {
				$('#errorDisplay').html(data);
				setDec();
			}
		})
	}));
	
	$('._delApk').live("click", (function(){
		alertApk("_delApk", $(this).attr('nojnl'), "Yakin menghapus "+$(this).attr('nojnl')+"?");
	}))
	_delPros = false;
	$('#_apkOke').live("click", (function(){
		_mode = $(this).attr("mode");
		_kode = $(this).attr("kode");
		if(_mode === '_delApk'){
			if(_delPros != false){
				_delPros.abort();
			}
			_delPros = $.ajax({
			type: 'POST',
				url: $('#defaultBaseUrl').val()+$('#defaultController').val()+'/del/&nojnl='+_kode,
				data: $(this).serialize(),
				success: function(data) {
					$('#errorDisplay').html(data);
				}
			})
		}
		$('#apankForm').html('');
	}))
	
})
</script>