<?php
 
include("DMMYSQLG.php");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/JavaScript">
	function pp(varr){
		//alert (varr);
		var linea1=varr.name;
		var linea=new String(linea1);
		var lista = linea.substr(3); 
		var can = parseInt(lista);
		//document.frm1.t2.value = lista;
		if(varr.checked == true){
			nm = "ba" + can;
			document.getElementById(nm).checked = 1;
			nm1 = "bc" + can;
			document.getElementById(nm1).checked = 1;
			nm2 = "be" + can;
			document.getElementById(nm2).checked = 1;
			nm3 = "bi" + can;
			document.getElementById(nm3).checked = 1;
			nm4 = "bm" + can;
			document.getElementById(nm4).checked = 1;
		}else{
			nm = "ba" + can;
			document.getElementById(nm).checked = 0;
			nm1 = "bc" + can;
			document.getElementById(nm1).checked = 0;
			nm2 = "be" + can;
			document.getElementById(nm2).checked = 0;
			nm3 = "bi" + can;
			document.getElementById(nm3).checked = 0;
			nm4 = "bm" + can;
			document.getElementById(nm4).checked = 0;
		}
	} 
	
	  function toggle(id){
	ul = "ul_" + id;
	img = "img_" + id;
	ulElement = document.getElementById(ul);
	imgElement = document.getElementById(img);
	if (ulElement){
		if (ulElement.className == 'closed'){
			ulElement.className = "open";
			imgElement.src = "img/CERRAR.jpg";
			}else{
			ulElement.className = "closed";
			imgElement.src = "img/ABRIR.jpg";
			}
		}
	}
	
	  ///fin 
	  ///-----------<
	  
</script>

<body>
<form id="frm1" name="frm1" method="post" action="DX10000_PR.php">
<div align="center">
  	<table>	
		<tr>
	  		<th>SEL.</th>
		  	<th>DESCRICPION.</th>
		  	<th>AGREGAR.</th>	
		  	<th>CONSULTAR.</th>
		  	<th>ELIMINAR.</th>
		  	<th>IMPRIMIR.</th>
		  	<th>MODIFICAR.</th>
		</tr>
	</table>
<?php

$ddd[]= "AL";
$fff[]= "ALMACEN"; 
$ddd[]= "CO";
$fff[]= "COSTOS"; 
$ddd[]= "valeryus";
$fff[]= "FRONT OFFICE"; 
$ddd[]= "DH";
$fff[]= "COMPRAS"; 
$ddd[]= "DN";
$fff[]= "NOMINA"; 
$ddd[]= "DV";
$fff[]= "CUENTAS X COBRAR"; 
$ddd[]= "DI";
$fff[]= "INVENTARIOS"; 
$ddd[]= "DW";
$fff[]= "CUENTAS X PAGAR"; 
$ddd[]= "DA";
$fff[]= "ACTIVOS FIJOS"; 
$ddd[]= "UTI";
$fff[]= "UTILERIAS"; 
$ddd[]= "AN";
$fff[]= "AUTOS NUEVOS"; 
$ddd[]= "AU";
$fff[]= "AUTOS USADOS"; 
$ddd[]= "AR";
$fff[]= "REFACCIONES"; 
$ddd[]= "AS";
$fff[]= "SERVICIO"; 
$ddd[]= "AB";
$fff[]= "BODY SHOP"; 
$ddd[]= "AM";
$fff[]= "MERCADOTECNIA"; 
$ddd[]= "DR";
$fff[]= "ARRENDAMINTO"; 
$ddd[]= "PV";
$fff[]= "PUNTO DE VENTA"; 

$ddd[]= "BQ";
$fff[]= "BOUTIQUE"; 
$ddd[]= "NM";
$fff[]= "SERVI BAR"; 

$ddd[]= "RC";
$fff[]= "COMEDORES"; 
$ddd[]= "DD";
$fff[]= "ORDENES"; 
$ddd[]= "DK";
$fff[]= "HOTELERIA"; 
$ddd[]= "DP";
$fff[]= "OPERACION DE PRODUCCION"; 
$num_tip = count ($ddd);
echo '<ul class="open">';
echo '<li class="celda3" id="menu" name="menu"><center>GENERALES</center></li>';
echo '<li id="menux" name="menux"><center>&nbsp;</center></li>';
$sq = mysqli_query($con ,"select * from dxopemaex where oper = '".$_POST['bot']."'");
$re = mysqli_fetch_array($sq);
for($i = 0 ; $i < $num_tip ; $i++){
	
	$j = $i + 1;
	//echo 'Entrada:'.$j. '  Valor: ' .$ddd[$i].'<br>';
	if(isset($_POST['bot'])){
		$sql = mysqli_query($con ,"select * from dxacceope where modulo like '$ddd[$i]%' and usuario = '".$re['nombre']."' order by n_reg");
		echo '<input name="tusu" type="hidden" value="'.$re['nombre'].'"/>';
	}else{
		$sql = mysqli_query($con ,"select * from dxacceope where modulo like '$ddd[$i]%' and usuario = '".$_POST['t1']."' order by n_reg");
		echo '<input name="tusu" type="hidden" value="'.$_POST['t1'].'"/>';
	}
	$nnu_re = mysqli_num_rows($sql);
	//echo 'v:'.$nnu_re.'<br>';
	if($nnu_re >= 1){
		//titulo 
		 echo '<li id="menu'.$j .'" name="menu'.$j .'">';
		 ?>
		 <a onClick="toggle('menu<?php
 echo $j ?>');" class="a2"><img src="img/ABRIR.jpg" alt="" id="img_menu<?php
 echo $j ?>" border="0"/><?php
 echo $fff[$i] ?></a>
		 <?php

        echo '<ol id="ul_menu'.$j .'" class="closed"><li id="menu1_'.$j .'"><table >';
		
		echo '<tr>
	  		<th>SEL.</th>
		  	<th>DESCRICPION.</th>
		  	<th>AGREGAR.</th>	
		  	<th>CONSULTAR.</th>
		  	<th>ELIMINAR.</th>
		  	<th>IMPRIMIR.</th>
		  	<th>MODIFICAR.</th>
		</tr>';
		echo '<tr>
		  	<th colspan="2">&nbsp;</th>
		  	<th><input id="o3'.$i.'" name="o3'.$i.'" type="checkbox" value="" onClick="ppe(this)"></th>	
		  	<th><input id="o4'.$i.'" name="o4'.$i.'" type="checkbox" value="" onClick="ppe(this)"></th>
		  	<th><input id="o5'.$i.'" name="o5'.$i.'" type="checkbox" value="" onClick="ppe(this)"></th>
		  	<th><input id="o6'.$i.'" name="o6'.$i.'" type="checkbox" value="" onClick="ppe(this)"></th>
		  	<th><input id="o7'.$i.'" name="o7'.$i.'" type="checkbox" value="" onClick="ppe(this)"></th>
		</tr>';
		$in = 0;
		while($reg = mysqli_fetch_array($sql)){
			if ($in == 0){
				$inicio = $reg['n_reg'];
				$in = 1;
			}
			//echo $reg['modulo'].'<br>';
			//color-------------------->
			 $nr = $nr + 1;
			$v1 = $nr / 2;
			$v2 = (int) ($nr / 2);
			if($v1 == $v2){
				$col ="#3399FF";
			}else{
				$col ="#66CCFF";
			}
			echo '<tr>';
			if ($reg['status']==1){
				$che = "checked";
			}else{
				$che = "";
			}
			echo '<td style="'.$col.'"> <div align="center"><input id="bot'.$reg['n_reg'].'" name="bot'.$reg['n_reg'].'" type="checkbox" value="1" '.$che.' onClick="pp(bot'.$reg['n_reg'].')"></div></td>';
			
			//buscar modulo y mostrar nombre
			@$sql1=mysqli_query($con ,"select * from dxaccgen where modulo = '".$reg['modulo']."' order by n_reg");
			$row = mysqli_fetch_array($sql1);
			echo '<td style="'.$col.'"><div align="center">' . $row["descrip"] . '</div></td>';
			if($reg["tipo"]==1){
				echo '<td style="'.$col.'"> <div align="center">&nbsp;</div></td>';
				echo '<td style="'.$col.'"> <div align="center">&nbsp;</div></td>';
				echo '<td style="'.$col.'"> <div align="center">&nbsp;</div></td>';
				echo '<td style="'.$col.'"> <div align="center">&nbsp;</div></td>';
				echo '<td style="'.$col.'"> <div align="center">&nbsp;</div></td>';
			}else{
				$p = strstr($reg["acciones"],"A"); 
				if ($p){
					$che1 = "checked";
				}else{
					$che1 = "";
				}
				$p = strstr($reg["acciones"],"C"); 
				if ($p){
					$che2 = "checked";
				}else{
					$che2 = "";
				}
				$p = strstr($reg["acciones"],"E"); 
				if ($p){
					$che3 = "checked";
				}else{
					$che3 = "";
				}
				$p = strstr($reg["acciones"],"I"); 
				if ($p){
					$che4 = "checked";
				}else{
					$che4 = "";
				}
				$p = strstr($reg["acciones"],"M"); 
				if ($p){
					$che5 = "checked";
				}else{
					$che5 = "";
				}
				echo '<td style="'.$col.'"> <div align="center"><input id="ba'.$reg['n_reg'].'" name="ba'.$reg['n_reg'].'" type="checkbox" value="1" '.$che1.'></div></td>';
				echo '<td style="'.$col.'"> <div align="center"><input id="bc'.$reg['n_reg'].'" name="bc'.$reg['n_reg'].'" type="checkbox" value="1" '.$che2.'></div></td>';
				echo '<td style="'.$col.'"> <div align="center"><input id="be'.$reg['n_reg'].'" name="be'.$reg['n_reg'].'" type="checkbox" value="1" '.$che3.'></div></td>';
				echo '<td style="'.$col.'"> <div align="center"><input id="bi'.$reg['n_reg'].'" name="bi'.$reg['n_reg'].'" type="checkbox" value="1" '.$che4.'></div></td>';
				echo '<td style="'.$col.'"> <div align="center"><input id="bm'.$reg['n_reg'].'" name="bm'.$reg['n_reg'].'" type="checkbox" value="1" '.$che5.'></div></td>';
				$fim = $reg['n_reg'];
			}	
			echo '</tr>'; 	
		}
		echo '<input id="limite'.$i.'" name="limite'.$i.'" value = "'.$inicio.'-'.$fim.'" type="hidden">';
		echo '</table></li></ol></li>';
	}
}
echo '</ul>';
?>
<table>
<tr>
<th colspan="7">
<input type="button" name="Submit" value="Actualizar" onClick="openpage('DX10000_AC3.php','_self')">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="Submit" name="Submit2" value="Regresar"></th>
</tr>
</table>
</div>
</form>
</body>
</html>