<?= form_open('user_role/manage_permissions'); ?>
<table class="table table-hover">
	<thead>
		<tr>
			<th>Permission Name</th>
			<th>Permission Label</th>
			<?php foreach($user_roles as $role): ?>
			<th><?= $role->role_name ?></th>
			<?php endforeach; ?>
		</tr>
	</thead>
	<tbody>
	<?php foreach($role_permissions as $permission): ?>
		<tr>
			<td><?php while($permission->page_level>0){ echo '<span class="glyphicon glyphicon-minus"></span>&nbsp;'; $permission->page_level--; } ?>
			<?= $permission->page_title; ?></td>
			<td><?= $permission->page_label; ?></td>
			<?php foreach($user_roles as $role): 
			$name = 'perm['.$permission->page_ID.']['.$role->role_ID.']';
			$checked = ( in_array($role->role_ID, explode(',',$permission->allowed_roles) ) )?TRUE:FALSE;
			?>
			<td>
				<input type="checkbox" name="<?= $name; ?>" value="<?= $role->role_ID; ?>" <?php echo set_checkbox($name,$role->role_ID,$checked); ?> />
			</td>
			<?php endforeach;  ?>
		</tr>
	<?php endforeach; ?>
	</tbody>
</table>
<nav class="navbar navbar-default navbar-fixed-bottom" style="min-height: 40px">
  <div class="container">
  	<?php echo form_submit(array('value'=>'&nbsp;&nbsp; Save &nbsp;&nbsp;','class'=>'btn-success','style'=>'margin-top: 4px;')); ?>
  </div>
</nav>
<?= form_close(); ?>