<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("Y-m-d");
$har = date('D');

$day = $date->getDayEer();
$mun = $day[$har];
$mun = $date->getPenguranganTanggal($tgl, 0, $mun, 0);
$maj = $date->getPenjumlahanTanggal($mun, 0, 6, 0);

$pros = true;
if($har == 'Fri'){
	$pros = true;
}
?>
<p class="_titleJudul"><a href=""><u>Effort 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">Name</td>
			<td class="_spasi">:</td>
			<td class="_isi"><input type="text" size="10" id="nm_sub" name="nm_sub" class="_formIns" readonly style="width: 150px" value="<?php echo $this->login['nm_user'] ?>"></td>
		</tr>
		<tr>
			<td class="_label">Company</td>
			<td class="_spasi">:</td>
			<td class="_isi"><input type="text" size="10" id="kd_cabang" name="kd_cabang" class="_formIns" readonly style="width: 150px" value="<?php echo $this->login['kd_cabang'] ?>"></td>
		</tr>
		<tr>
			<td class="_label">Departemen</td>
			<td class="_spasi">:</td>
			<td class="_isi"><input type="text" size="10" id="model" name="model" class="_formIns" style="width: 150px"></td>
		</tr>
		<tr>
			<td class="_label"><u>Periode</u></td>
			<td class="_spasi"></td>
			<td class="_isi">
				
			</td>
		</tr>
		<tr>
			<td class="_label">Mulai</td>
			<td class="_spasi">:</td>
			<td class="_isi">
				<input type="date" size="10" id="shift" name="shift" class="_formIns" readonly style="width: 100px" value="<?php echo date("Y-m-d", strtotime($mun)) ?>">
			</td>
		</tr>
		<tr>
			<td class="_label">S/d</td>
			<td class="_spasi">:</td>
			<td class="_isi">
				<input type="date" size="10" id="st" name="st" class="_formIns" readonly style="width: 100px" value="<?php echo date("Y-m-d", strtotime($maj)) ?>">
			</td>
		</tr>
		<tr>
			<td colspan="3">&nbsp;</td>
		</tr>
			<tr>
				<td colspan="3">Weekly Activity :</td>
			</tr>
		<tr>
			<td colspan="3">&nbsp;</td>
		</tr>
		
		<?php
		
		foreach($kode->ham_eer() as $k => $r){
		?>
			<tr>
				<td colspan="3" class="_tanya"><?php echo $r['name'] ?></td>
			</tr>
			<?php 
			$nomS = 1;
			foreach($r['attr'] as $r2){ 
				$idNama = 'ket'.$r2;
			?>
				<tr>
					<td colspan="3">
						<?php echo $nomS++ ?>. 
					</td>
				</tr>
				<tr>
					<td colspan="3">
						<textarea id="<?php echo $idNama ?>" name="<?php echo $idNama ?>" cols="40" rows="4" class="_formIns"></textarea>
					</td>
				</tr>
			<?php } ?>
			<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 
	foreach($this->data->data as $i => $data){ 
	?>
		<div class="_divInsDetApk">
			<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">Name</td>
					<td class="_spasiTab">:</td>
					<td class="_isiTab" colspan="2"><?php echo $data->nm_sub ?></td>
				</tr>
				<tr>
					<td class="_labelTab">Company</td>
					<td class="_spasiTab">:</td>
					<td class="_isiTab" colspan="2"><?php echo $data->kd_cabang ?></td>
				</tr>
				<tr>
					<td class="_labelTab">Departemen</td>
					<td class="_spasiTab">:</td>
					<td class="_isiTab" colspan="2"><?php echo $data->model ?></td>
				</tr>
				<tr>
					<td colspan="3">&nbsp;</td>
				</tr>
				<?php
				foreach($kode->ham_eer() as $k => $r){
				?>
					<tr>
						<td colspan="3"><u><?php echo $r['name'] ?></u></td>
					</tr>
					
					<?php 
					$nomS = 1;
					foreach($r['attr'] as $r2){ 
						$idNama = 'ket'.$r2;
					?>
						<tr>
							<td colspan="3">
								<?php echo $nomS++ ?>. <?php echo $data->$idNama ?>
							</td>
						</tr>
					<?php } ?>
				<tr>
					<td colspan="3">&nbsp;</td>
				</tr>
				<?php
				}
				?>
				<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>
		</div>
	<?php } ?>
</div>

<?php
$notNull = array();
$notNull[] = 'tgl';
$notNull[] = 'st';
$notNull[] = 'shift';
$notNull[] = 'model';
$notNull[] = 'ket1';
$notNull[] = 'ket4';
$notNull[] = 'ket7';
?>

<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>