<script type="text/javascript">
function some_function(element, group)
	{
		$.post("/admin/change_user_group_elements/"+element+"/"+group);
	}
			      	
$(document).ready(function() {
 });
</script>   

<h1><?= ucfirst($this->site['prawa']);?></h1>
<table class="news_data_table">
	<tr class="admin_table_header">
		<td>Sekcja</td>
		<?php
			foreach($groups as $group){
				echo '<td>'.$group['name'].'</td>';
			}
		?>
	</tr>
<?php
	foreach($rights as $right){
		echo '<tr class="data_row"><td><b>'.$right['name'].'</b></td>';
		foreach($groups as $group){
			echo '<td>'.form_open('', array('name' => 'dataform'));
			$js = 'onClick="some_function('.$right['idelements'].','.$group['iduser_groups'].')"';
			$checked = false;
			foreach($user_group_elements as $user_group_element){
				if($user_group_element['idelements'] == $right['idelements'] && $user_group_element['iduser_groups'] == $group['iduser_groups']){
					$checked = $user_group_element['active'];
					break;
				}
			}
			echo form_checkbox('check', 'accept', $checked, $js);
			echo form_close().'</td>';
			}
			echo '<td>'.form_open('admin/change_element_priority/'.$right['idelements']).form_input(array('name'=>'priority', 'size'=>'3', 'value'=>$right['showorder'])).form_submit('submit', ucfirst($this->site['ustaw'].' '.$this->site['kolejnosc'])).form_close().'</td>';	
		echo '</tr>';		
	}	
?>
</table>