<?php
 
session_start();
include("DMMYSQLG.php");

?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>

<body>
<?php
 
$ayuda = 'DX1000A_AG.php';
include("DYAYUDA.php");
?>

<form name="frm1"  id="frm1"method="post" action="">
  <table width="847"  align="center">
    <tr>
      <th colspan="11" class=\"titulo\"><div align="center">AGREGAR OPERADORES  </div></th>
    </tr>
    <tr>
      <td colspan="2">Usuario</td>
      <td colspan="5"><input name="t1" type="text" id="t1" tabindex="1"
	  <?php
 
	  if(isset($_POST['t1'])){
	  	echo 'value ="' . $_POST['t1'] . '"';
	  }
	  ?>
	  ></td>
      <td colspan="2">Contrase&ntilde;a:</td>
      <td colspan="2"><input name="t2" type="password" id="t2" tabindex="2"
	  <?php
 
	  if(isset($_POST['t2'])){
	  	echo 'value ="' . $_POST['t2'] . '"';
	  }
	  ?>
	  ></td>
    </tr>
    <tr>
      <td colspan="2" nowrap>Nombre:</td>
      <td colspan="2" nowrap><input name="t3" type="text" id="t3" tabindex="3"
	  <?php
 
	  if(isset($_POST['t3'])){
	  	echo 'value ="' . $_POST['t3'] . '"';
	  }
	  ?>
	  ></td>
      <td width="96" nowrap>Apellido Paterno:</td>
      <td colspan="3" nowrap><input name="t4" type="text" id="t4" tabindex="4"
	  <?php
 
	  if(isset($_POST['t4'])){
	  	echo 'value ="' . $_POST['t4'] . '"';
	  }
	  ?>
	  ></td>
      <td width="88" nowrap>Apellido Materno:</td>
      <td colspan="2" nowrap><input name="t5" type="text" id="t5" tabindex="5"
	  <?php
 
	  if(isset($_POST['t5'])){
	  	echo 'value ="' . $_POST['t5'] . '"';
	  }
	  ?>
	  ></td>
    </tr>
    <tr>
      <td colspan="11"><div align="center">Departamento:
	      <select name="departamento" id="departamento">
            <?php

	  $sq_catdep=mysqli_query($con ,"select * from $_SESSION['base'].dncatdep order by des_depto");
	  	 while($dt_catdep=mysqli_fetch_array($sq_catdep)){
		 	if($_POST["departamento"]==$dt_catdep["no_depto"])
		 		printf('<option value="%s" selected>%s</option>',$dt_catdep['no_depto'],$dt_catdep['des_depto']);
			else
				printf('<option value="%s">%s</option>',$dt_catdep['no_depto'],$dt_catdep['des_depto']);
		 }
		?>
              </select>
	  </div></td>
    </tr>
    <tr>
      <td colspan="2">Selecciona Empresa: </td>
      <td colspan="5"><select name="t6" id="t6" tabindex="6"  onChange="sel_emp_sn()" onclick="sel_emp_sn()">
        <?php
 
		if(isset($_POST['t6']) and $_POST['t6']==1){
			echo '<option value="1" selected>SI</option>';
		}else{
			echo '<option value="1">SI</option>';
		}
	   	if(isset($_POST['t6']) and $_POST['t6']==0){
			echo '<option value="0" selected>NO</option>';
		}else{
			echo '<option value="0">NO</option>';
		} 
	  ?>
      </select></td>
      <td colspan="2">Acceso Restringido: </td>
      <td colspan="2"><select name="t9" id="t9" tabindex="9">
        <?php
 
	  	if($_POST['t9']==1){
			echo '<option value="1" selected>SI</option>';
		}else{
			echo '<option value="1">SI</option>';
		}
		if($_POST['t9']==0){
			echo '<option value="0" selected>NO</option>';
		}else{
			echo '<option value="0">NO</option>';
		}
		
	  ?>
      </select></td>
    </tr>
    <tr>
      <td colspan="2">Empresa:</td>
      <td colspan="9"><select name="t7" id="t7" tabindex="7" onChange="javascript: document.getElementById('frm1').submit()" 
<?php
 
if($_POST['t6']==1 or !isset($_POST['t7'])){
	echo 'disabled="disabled"';
} 
 ?>	  
	  >
	  <option></option>
        <?php
 
if(isset($_POST['t7'])){
	$em = $_POST['t7'];
}
@$sql2=mysqli_query($con ,"select * from dxempres");
	while (@$reg2 = mysqli_fetch_array($sql2))
	{
		if($reg2['cla_emp'] == $em){
			echo '<option value="'.$reg2['cla_emp'].'" selected>'.$reg2['nom_emp'].'</option>';
		}else{
			echo '<option value="'.$reg2['cla_emp'].'">'.$reg2['nom_emp'].'</option>';
		}
	}
?>
      </select></td>
    </tr>
    <tr>
      <tH colspan="11">OPCIONES</tH>
    </tr>
    <tr>
      <td class="thcons"><input name="c1" type="checkbox" id="c1" tabindex="10" value="1"></td>
      <td class="thcons">Administracion</td>
      <td colspan="9" class="thcons">&nbsp;</td>
    </tr>
    <tr>
      <td width="20"><input name="ad1" type="checkbox" id="ad1" tabindex="10" value="1"></td>
      <td width="115">Bancos</td>
      <td width="20"><input name="ad2" type="checkbox" id="ad2" tabindex="10" value="1"></td>
      <td colspan="3">Contabilidad</td>
      <td width="20"><input name="ad3" type="checkbox" id="ad3" tabindex="10" value="1"></td>
      <td colspan="2">Ventas</td>
      <td width="20"><input name="ad4" type="checkbox" id="ad4" tabindex="10" value="1"></td>
      <td width="136">Compras</td>
    </tr>
    <tr>
      <td><input name="ad5" type="checkbox" id="ad5" tabindex="10" value="1"></td>
      <td>Nomina</td>
      <td><input name="ad6" type="checkbox" id="ad6" tabindex="10" value="1"></td>
      <td colspan="3">Cuentas X Cobrar </td>
      <td><input name="ad7" type="checkbox" id="ad7" tabindex="10" value="1"></td>
      <td colspan="2">Inventarios</td>
      <td><input name="ad8" type="checkbox" id="ad8" tabindex="10" value="1"></td>
      <td>Cuentas X Pagar </td>
    </tr>
    <tr>
      <td><input name="ad9" type="checkbox" id="ad9" tabindex="10" value="1"></td>
      <td>Activo Fijo </td>
      <td><input name="ad10" type="checkbox" id="ad10" tabindex="10" value="1"></td>
      <td colspan="3">Utilerias</td>
      <td>&nbsp;</td>
      <td colspan="2">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="thcons"><input name="c3" type="checkbox" id="c3" tabindex="10" value="1"></td>
      <td class="thcons">Automotriz</td>
      <td colspan="9" class="thcons">&nbsp;</td>
    </tr>
    <tr>
      <td><input name="ad11" type="checkbox" id="ad11" tabindex="10" value="1"></td>
      <td>Autos Nuevos </td>
      <td><input name="ad12" type="checkbox" id="ad12" tabindex="10" value="1"></td>
      <td colspan="3">Autos Usados </td>
      <td><input name="ad13" type="checkbox" id="ad13" tabindex="10" value="1"></td>
      <td colspan="2">Refacciones</td>
      <td><input name="ad14" type="checkbox" id="ad14" tabindex="10" value="1"></td>
      <td>Servicio</td>
    </tr>
    <tr>
      <td><input name="ad15" type="checkbox" id="ad15" tabindex="10" value="1"></td>
      <td>Body Shop</td>
      <td colspan="4">&nbsp;</td>
      <td>&nbsp;</td>
      <td colspan="2">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="thcons"><input name="ad16" type="checkbox" id="ad16" tabindex="10" value="1" onClick="sel_em2(ad16.checked)"></td>
      <td class="thcons">Mercadotecnia</td>
      <td colspan="9" class="thcons">&nbsp;</td>
    </tr>
    <tr>
      <td><input name="r1" type="radio" value="1" onClick="sel_em3(r1.checked)" ></td>
      <td colspan="5">Vendedor: <span class="thcons">
        <select name="select2" tabindex="22" disabled="disabled">
          <option></option>
<?php
 
if(isset($_POST['t7'])){
		@$sql24=mysqli_query($con ,"select * from dxempres where cla_emp = '".$_POST['t7']."'");
		@$rr = mysqli_fetch_array($sql24);
		$dbuser = "root";
		$dbpass = "castillejos";
		$dbhost = "localhost";
		$con2 = mysqli_connect($dbhost,$dbuser,$dbpass);
		if (!$con2){
			die('Error N:' . mysqli_errno($con$con2) . ": " . mysqli_error($con2));
		}
		@$corazon = mysqli_select_db($rr['dbname1'], $con2);
}else{
	include("DMMYSQLG.php");
}
@$sql2=mysqli_query($con ,"select * from amcatven");
while (@$reg3 = mysqli_fetch_array($sql2))
{
	echo '<option value="'.$reg3['cod_ven'].'">'.$reg3['nom_ven']. ' ' .$reg3['apa_ven']. ' ' .$reg3['ama_ven'].'</option>';
}
include("DMMYSQLG.php");
?>
        </select>
      </span></td>
      <td><input name="r2" type="radio" value="2" onClick="sel_em4(r2.checked)" disabled="disabled"></td>
      <td colspan="4">Telemarketing:<span class="thcons">
        <select name="select3" tabindex="22" disabled="disabled">
          <option></option>
          <?php
 
if(isset($_POST['t7'])){
		@$sql24=mysqli_query($con ,"select * from dxempres where cla_emp = '".$_POST['t7']."'");
		@$rr = mysqli_fetch_array($sql24);
		$dbuser = "root";
		$dbpass = "castillejos";
		$dbhost = "localhost";
		$con2 = mysqli_connect($dbhost,$dbuser,$dbpass);
		if (!$con2){
			die('Error N:' . mysqli_errno($con$con2) . ": " . mysqli_error($con2));
		}
		@$corazon = mysqli_select_db($rr['dbname1'], $con2);
}else{
	include("DMMYSQLG.php");
}
@$sql2=mysqli_query($con ,"select * from amcattel");
while (@$reg3 = mysqli_fetch_array($sql2))
{
	echo '<option value="'.$reg3['cod_tel'].'">'.$reg3['nom_ope']. ' ' .$reg3['apa_tel']. ' ' .$reg3['ama_tel'].'</option>';
}
include("DMMYSQLG.php");
?>
        </select>
      </span></td>
    </tr>
    <tr>
      <td class="thcons"><input name="ad20" type="checkbox" id="ad20" tabindex="10" value="1"  onClick="sel_em(ad20.checked)"></td>
      <td class="thcons">Ordenes</td>
      <td colspan="9" class="thcons">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2">Acceso: 
        <select name="select4" disabled="disabled">
          <option value="0">General</option>
          <option value="1">Area</option>
          <option value="2">Personal</option>
        </select>      </td>
      <td colspan="5">
        Area
        <select name="select5" tabindex="22" disabled="disabled">
          <option></option>
          <?php
 
if(isset($_POST['t7'])){
		@$sql24=mysqli_query($con ,"select * from dxempres where cla_emp = '".$_POST['t7']."'");
		@$rr = mysqli_fetch_array($sql24);
		$dbuser = "root";
		$dbpass = "castillejos";
		$dbhost = "localhost";
		$con2 = mysqli_connect($dbhost,$dbuser,$dbpass);
		if (!$con2){
			die('Error N:' . mysqli_errno($con$con2) . ": " . mysqli_error($con2));
		}
		@$corazon = mysqli_select_db($rr['dbname1'], $con2);
}else{
	include("DMMYSQLG.php");
}
@$sql2=mysqli_query($con ,"select * from ddareas");
while (@$reg3 = mysqli_fetch_array($sql2))
{
	echo '<option value="'.$reg3['area'].'">'.$reg3['descrip'].'</option>';
}
include("DMMYSQLG.php");
?>
        </select>
      </span></td>
      <td colspan="4">Empresa:
        <select name="select" tabindex="22" disabled="disabled">
        <option></option>
        <?php
 
include("DMMYSQLG.php");
@$sql2=mysqli_query($con ,"select * from dxbascps");
while (@$reg3 = mysqli_fetch_array($sql2))
{
	echo '<option value="'.$reg3['codigo'].'">'.$reg3['nombre'].'</option>';
}
?>
      </select></td>
    </tr>
    <tr>
      <td class="thcons"><input name="ad17" type="checkbox" id="ad17" tabindex="10" value="1"></td>
      <td class="thcons">Arrendamiento</td>
      <td class="thcons"><input name="ad18" type="checkbox" id="ad18" tabindex="10" value="1"></td>
      <td colspan="3" class="thcons">Hospitalizacion</td>
      <td class="thcons"><input name="ad22" type="checkbox" id="ad22" tabindex="10" value="1"></td>
      <td colspan="2" class="thcons">Operacion de Produccion </td>
      <td class="thcons"><input name="ad19" type="checkbox" id="ad19" tabindex="10" value="1"></td>
      <td class="thcons">Laboratorio</td>
    </tr>
    <tr>
      <td class="thcons"><input name="ad21" type="checkbox" id="ad21" tabindex="10" value="1"></td>
      <td class="thcons">Hoteleria</td>
      <td colspan="9" class="thcons">&nbsp;</td>
    </tr>
    <tr>
      <td style="#0099FF"></td>
      <td style="#0099FF"></td>
      <td width="20" style="#0099FF"></td>
      <td width="137" style="#0099FF"></td>
      <td style="#0099FF"></td>
      <td width="22" style="#0099FF"></td>
      <td style="#0099FF"></td>
      <td width="103" style="#0099FF"></td>
      <td style="#0099FF"></td>
      <td style="#0099FF"></td>
      <td style="#0099FF"></td>
    </tr>
    <tr>
      <td colspan="11" style="#FFFFFF"><div align="center">
          &nbsp;
          <input type="button" name="Submit2" value="Guardar" accesskey="G" onClick="openpage('DX10000_AC.php','_self')"/>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input type="button" name="Submit2" value="Regresar" onClick="openpage('DX10000_PR.php','_self')"/>
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>
