<style>
#_rasioForm{
	height: <?php echo $height ?>px;
	-webkit-border-radius: 0px; 
	-moz-border-radius: 0px; 
	-khtml-border-radius: 0px; 
	border-radius: 0px 0px 6px 6px;
	background-color: #e0ebf3;
	border-left: 2px double #99bcd7;
	border-right: 2px double #99bcd7;
	border-bottom: 2px double #99bcd7;
	padding: 20px;
	font-size: 13px;
}
</style>
<div id="_rasioForm">
	<form method="post" action="">
	<table id="grid">
		<thead>
			<tr>
				<th width="430">Modul</th>
				<?php
				foreach($this->data->acl as $key => $row):
				?>
					<th width="50"><?php echo $key ?></th>
				<?php endforeach; ?>
			</tr>
		</thead>
		<tbody>
		<?php 
		$menu = new Menu;
		foreach($this->data->menu as $nama => $row ): 
			$key = $row['url'];
		?>
			<tr>
				<td><?php echo $nama; ?></td>
				<?php
				foreach($this->data->acl as $key2 => $row2):
					if(strtoupper($key2) == 'ALL'){
						$class = '';
					}else{
						$class = 'cekAkses';
					}
					
					$modul = $key.'/'.$key2;
					$check = '';

					if(!empty($this->data->dataAcl[$modul])){
						$check = 'checked';
					}

				?>
					<td>
						<input type="checkbox" name="<?php echo $modul ?>"
						class="<?php echo "$key2 $key $class cek-$key"; ?> cekALl"
						id="<?php echo $key ?>" <?php echo $check ?>
						value="1"
						>
					</td>
				<?php endforeach; ?>
			</tr>
		<?php 
		endforeach; 
		?>
		</tbody>
	</table>
	<input style="margin-top: 10px" type="submit" id="simpan" name="simpan" class="submit" value="Simpan">
	</form>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$('#grid').flexigrid({
		width: 1000,
		height: 300,
		title: 'Hak Akses  ( <?php echo $this->data->data->kodegrup.' - '.$this->data->data->namagrup ?> )',
		buttons :[
					{name : '<input type="checkbox" name="centangAll" style="margin: 3px 5px 0px 0px" id="cekAll"> Centang Semua', bclass : 'gridCheckbox' },
				],
	});
	$('.All').click(function(){
		id = this.id;
		ex = id.split(';');
		
		if($(this).attr('checked') == 'checked'){
			$('.'+ex[1]).attr('checked', true);
		}else{
			$('.'+ex[1]).removeAttr('checked');
		}
		
	})
	
	$('.cekAkses').click(function(){
		id = this.id;
		ex = id.split(';');
		$('.cek-'+ex[1]+'-All').removeAttr('checked');
	})
	
	$('#cekAll').click(function(){
		centangAll = $('#cekAll').attr('checked');
		if(centangAll === 'checked'){
			$('.cekALl').attr('checked', true);
		}else{
			$('.cekALl').removeAttr('checked');
		}
	})
})
</script>