<?php
@session_start();
  $vg_login=$_SESSION["usuario"];
   $vg_empresa=$_SESSION["empresa"];
  if($vg_login<>""){}
 else
  {echo "<script>";
   echo "window.location='../index.php';";
   echo "</script>";
  }	

include "../valida_permisos.php";
$vg_programa = F_programa();
include "../seguridad.php";
$sql_entrada= mysqli_query($conseg,"select login,nombre,perfil,programa,cedula,pais from permiso     
						where login='".$vg_login."'  and programa=".$vg_programa."");
while($datos= mysqli_fetch_row($sql_entrada))
		{ $vg_nombre=$datos[1];
		  $vg_perfil=$datos[2];				
		} 
//permisos a formularios
$modulo="Parametros_clave_clientes";
$permisos=validar_permiso($vg_login,$modulo,$vg_perfil,$vg_programa);
include "../permisos.php";
$valpermiso=F_permiso($permisos);

if($valpermiso[0]==1){}
else
{echo "<script>";
echo "window.location='../erroracceso.php?formulario=Parametros_clave_clientes';";
echo "</script>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PARAMETROS</title>
<LINK href="../general.css" type=text/css rel=stylesheet>

  <script src="../js/jquery.min.js"></script>
  <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <script src="../bootstrap/js/bootstrap.min.js"></script>
  <link rel="icon" type="image/png" href="../sige.ico"/>
  
      <!-- DataTables -->
  <link rel="stylesheet" href="../plugins1/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="../plugins1/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="../plugins1/datatables-buttons/css/buttons.bootstrap4.min.css">
 
</head>
<body>
<?php
include "../conexion.php";
$empresa="";
$rs_empresa=mysqli_query($conexion,"SELECT id,nombre FROM empresa
										 union select 0,'' 
										from empresa order by nombre asc");
										

if(isset($_REQUEST['oculto']))
  { 
	$empresa=$_REQUEST['empresa'];						
  }
?>	

<form name="frmalumnos" method="post" action="" >
    <input name="nuevo" type="submit"  id="nuevo"  value="Actualizar"     class="btn btn-primary" />
    <table width="99%" border="0" cellpadding="0" cellspacing="0" bordercolor="#999999" >
      <tr>
        <td width="4%" height="-10"><span class="texto">Empresa</span></td>
        <td width="40%"><select name="empresa" id="empresa" class="form-control"  style="width: 100%" onchange="submit();">
          <?php while ($rowba=mysqli_fetch_array($rs_empresa))
									{
									 if ($empresa==$rowba['id'])
										{echo "<option value=".$rowba['id']." selected>".substr($rowba['nombre'],0,40)."</option>";}
									 else
										{echo "<option value=".$rowba['id'].">".substr($rowba['nombre'],0,40)."</option>";}		
									}
							 ?>
        </select></td>
        <td width="15%">&nbsp;</td>
        <td width="41%">&nbsp;</td>
      </tr>
    </table>
      <input type="hidden" name="oculto" />
<?php

if($empresa>0){$sqlempresa="and empresa='".$empresa."'";} else {$sqlempresa="";}
$c=0;
	echo "<center> <table width='95%' border='1' cellspacing='0' cellpadding='0'  bordercolor='#000000'  id='example1' class='table table-bordered table-striped' style='font-size:12px'>";
	echo "<thead><tr >";
	echo "<th class='btn-primary' align='center'>Empresa</th>";
	echo "<th class='btn-primary' align='center'>Entidad</th>";
	echo "<th class='btn-primary' align='center'>Usuario</th>";
	echo "<th class='btn-primary' align='center'>Cedula RP</th>";	
	echo "<th class='btn-primary' align='center'>Clave Ingreso RP</th>";	
	echo "<th class='btn-primary' align='center'>Clave Firma RP</th>";	
	echo "<th class='btn-primary' align='center'>Cedula RF</th>";	
	echo "<th class='btn-primary' align='center'>Clave Ingreso RF</th>";	
	echo "<th class='btn-primary' align='center'>Clave Firma RF</th>";	
	echo "<th class='btn-primary' align='center'>Observacion</th>";	
	echo "</tr></thead><tbody>";	
	
	 $sql_datosrs=mysqli_query($conexion,"SELECT entidad,usuario,cedularp,claveingresorl,clavefirmarl,cedularf,claveingresorf,clavefirmarf,id,observacion,empresa
  									   from empresa_entidad_clave where id>0 $sqlempresa
  									   order by empresa asc");
  while($datos= mysqli_fetch_row($sql_datosrs))
    { 
		 $entidad=$datos[0];
		 $usuario=$datos[1];
		 $cedularp=$datos[2];
		 $claveingresorl=$datos[3];
		 $clavefirmarl=$datos[4];
		 $cedularf=$datos[5];
		 $claveingresorf=$datos[6];
		 $clavefirmarf=$datos[7];
		 $id=$datos[8];
		 $observacion=$datos[9];
		 $empresa=$datos[10];
		   
		   $sql_datosee=mysqli_query($conexion,"SELECT 	nombre   from empresa_entidad where id='".$entidad."'");
		  while($datosee= mysqli_fetch_row($sql_datosee))	{ $nentidad=$datosee[0];}
			 

		   $sql_datosee=mysqli_query($conexion,"SELECT 	nombre   from empresa where id='".$empresa."'");
		  while($datosee= mysqli_fetch_row($sql_datosee))	{ $nempresa=$datosee[0];}


		   echo " <tr>";
			 echo "<td>".$nempresa."</td>";
			 echo "<td>".$nentidad."</td>";
			 echo "<td>".$usuario."</td>";

			 echo "<td>".$cedularp."</td>";
			 echo "<td>".$claveingresorl."</td>";
			 echo "<td>".$clavefirmarl."</td>";
			 echo "<td>".$cedularf."</td>";
			 echo "<td>".$claveingresorf."</td>";
			 echo "<td>".$clavefirmarf."</td>";
			 echo "<td>".$observacion."</td>";
		  echo "</tr>";
				$c=$c+1;
				
	 }
 echo "</tbody></table></center>"; 
	

?>


<!-- jQuery -->
<script src="../plugins1/jquery/jquery.min.js"></script>
<script src="../plugins1/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="../plugins1/datatables/jquery.dataTables.min.js"></script>
<script src="../plugins1/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../plugins1/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../plugins1/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../plugins1/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../plugins1/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../plugins1/jszip/jszip.min.js"></script>
<script src="../plugins1/pdfmake/pdfmake.min.js"></script>
<script src="../plugins1/pdfmake/vfs_fonts.js"></script>
<script src="../plugins1/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../plugins1/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../plugins1/datatables-buttons/js/buttons.colVis.min.js"></script>

<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": ["excel", "colvis"]
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
  });
  
  
</script>
 
</form>
</body>
</html>    
