Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 25.96 KB | None | 0 0
  1. <?php
  2.  
  3.          require ('validarnum.php');
  4.  
  5. $fecha2=date("Y-m-d");     
  6.  
  7. if (isset($_GET['nuevo'])) {
  8.  
  9.                         if (isset($_POST['lugarguardar'])) {
  10.                            
  11.  
  12.  
  13.  
  14.  
  15.  
  16. $nombre=strtoupper($_POST["nombre"]);
  17. $apellido=strtoupper($_POST["apellido"]);
  18. $correo=strtoupper($_POST["correo"]);
  19. $ci=strtoupper($_POST["ci"]);
  20. $direccion=strtoupper($_POST["direccion"]);
  21. $telefono=strtoupper($_POST["telefono"]);
  22. $fechai=$fecha2;
  23.                        
  24.  
  25.  
  26.  
  27.  
  28. $sql="select * from `usuarios` where cedula='$ci'";
  29.  
  30. $cs=$bd->consulta($sql);
  31.  
  32. if($bd->numeroFilas($cs)!=0){
  33.  
  34. /*
  35. $cs=mysql_query($sql,$cn);
  36. while($resul=mysql_fetch_array($cs)){
  37.     $var6=$resul[0];
  38. }
  39. //CONSULTAR SI EL CAMPO YA EXISTE
  40. */
  41.  
  42.       echo '<div class="alert alert-danger alert-dismissable">
  43.                                        <i class="fa fa-check"></i>
  44.                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
  45.                                        <b>Alerta no se registro este usuario </b> Ya Existe... ';
  46.  
  47.  
  48.  
  49.                                echo '   </div>';
  50. }else{
  51.  
  52. $sql = "INSERT INTO `usuarios` (`cedula`, `nombre`, `apellido`, `correo`, `fechai`, `telefono`, `direccion`) VALUES ('$ci', '$nombre', '$apellido', '$correo', '$fechai', '$telefono', '$direccion')";
  53.  
  54.                            
  55.                           $cs=$bd->consulta($sql);  
  56.                          // $cs=mysql_query($sql,$cn);
  57.  
  58.                            
  59.  
  60.  
  61.            
  62.  
  63.                             //echo "Datos Guardados Correctamente";
  64.                             echo '<div class="alert alert-success alert-dismissable">
  65.                                        <i class="fa fa-check"></i>
  66.                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
  67.                                        <b>Bien!</b> Datos Guardados Correctamente... ';
  68.  
  69.  
  70.  
  71. echo "
  72. Nombre: $nombre
  73.  
  74. ";
  75.                                echo '   </div>';
  76.                            
  77.                            
  78.                         }
  79.  
  80.  
  81.  
  82. }
  83. ?>
  84.   <div class="col-md-10">
  85.                             <!-- general form elements -->
  86.                             <div class="box box-primary">
  87.                                 <div class="box-header">
  88.                                     <h3 class="box-title">Clientes</h3>
  89.                                 </div>
  90.                                
  91.                            
  92.                                 <!-- form start -->
  93.                                 <form role="form"  name="fe" action="?mod=registro&nuevo=nuevo" method="post">
  94.                                     <div class="box-body">
  95.                                         <div class="form-group">
  96.                                            
  97.                                            
  98.                                            
  99.                                            
  100.                                             <label for="exampleInputFile">Nombre</label>
  101.                                             <input  onkeypress="return caracteres(event)" onblur="this.value=this.value.toUpperCase();" type="text" required type="tex" name="nombre" class="form-control" value="<?php echo $var2 ?>" id="exampleInputEmail1" placeholder="Intoducir el Nombre">
  102.                                             <label for="exampleInputFile">Apellido</label>
  103.                                             <input  onkeypress="return caracteres(event)" onblur="this.value=this.value.toUpperCase();" required type="tex" name="apellido" class="form-control" value="<?php echo $var3 ?>" id="exampleInputEmail1" placeholder="Apellido">
  104.                                             <label for="exampleInputFile">cedula</label>
  105.                                             <input onkeydown="return enteros(this, event)" required type="text" name="ci" class="form-control" value="<?php echo $var1 ?>" id="exampleInputEmail1" placeholder="Cedula">
  106.                                              <label for="exampleInputFile">telefono</label>
  107.                                             <input onkeydown="return enteros(this, event)" required type="text" name="telefono" class="form-control" value="<?php echo $var1 ?>" id="exampleInputEmail1" placeholder="telefono">
  108.  
  109.                                              <label for="exampleInputFile">Direccion</label>
  110.                                             <input  required type="tex" name="direccion" class="form-control" value="<?php echo $var3 ?>" id="exampleInputEmail1" placeholder="direccion">
  111.                                             <label for="exampleInputFile">correo</label>
  112.  
  113.                                             <input  required type="email" name="correo" class="form-control" value="<?php echo $var4 ?>"  placeholder="Correo">
  114.                                            
  115.                                            
  116.                                            
  117.  
  118.                                         </div>
  119.                                        
  120.                                      
  121.                                        
  122.                                     </div><!-- /.box-body -->
  123.  
  124.                                     <div class="box-footer">
  125.                                         <button type="submit" class="btn btn-primary btn-lg" name="lugarguardar" id="lugarguardar" value="Guardar">Agregar</button>
  126.                                        
  127.                                    
  128.                                     </div>
  129.                                 </form>
  130.                             </div><!-- /.box -->
  131. <?php
  132. }
  133.  
  134.    
  135.    
  136.    if (isset($_GET['lista'])) {
  137.  
  138.     $x1=$_GET['codigo'];
  139.  
  140.                         if (isset($_POST['lista'])) {
  141.                            
  142.  
  143.  
  144.  
  145.        
  146.  
  147. }
  148. ?>
  149.  
  150.                            
  151.                     <div class="row">
  152.                         <div class="col-xs-8">
  153.                            
  154.                             <div class="box">
  155.                                 <div class="box-header">
  156.                                     <h3 class="box-title">Lista Clientes:</h3>                                    
  157.                                 </div><!-- /.box-header -->
  158.                                 <div class="box-body table-responsive">
  159.                                     <table id="example1" class="table table-bordered table-striped">
  160.                                         <thead>
  161.                                             <tr>
  162.                                                 <th>Cedula</th>
  163.                                                 <th>Nombre</th>
  164.                                                 <th>Apellido</th>
  165.                                                 <th>correo</th>
  166.                                                 <th>Acción</th>
  167.                                             </tr>
  168.                                         </thead>
  169.                                         <tbody>
  170.                                         <?php
  171.                                             if($tipo2==1){
  172.                                        
  173.                                         $consulta="SELECT cedula, nombre, apellido, correo,id_usuarios FROM usuarios ORDER BY cedula ASC ";
  174.                                         $bd->consulta($consulta);
  175.                                         while ($fila=$bd->mostrar_registros()) {
  176.                                             switch ($fila['status']) {
  177.                                                 case 1:
  178.                                                     $btn_st = "danger";
  179.                                                     $txtFuncion = "Desactivar";
  180.                                                     break;
  181.                                                
  182.                                                 case 0:
  183.                                                     $btn_st = "primary";
  184.                                                     $txtFuncion = "Activar";
  185.                                                     break;
  186.                                             }
  187.                                              //echo '<li data-icon="delete"><a href="?mod=lugares?edit='.$fila['id_tipo'].'"><img src="images/lugares/'.$fila['imagen'].'" height="350" >'.$fila['nombre'].'</a><a href="?mod=lugares?borrar='.$fila['id_tipo'].'" data-position-to="window" >Borrar</a></li>';
  188.                                              echo "<tr>
  189.                                                        <td>
  190.                                                          
  191.                                                              $fila[cedula]
  192.                                                            
  193.                                                        </td>
  194.                                                        <td> $fila[nombre]                                                        </td>
  195.                                                        <td>
  196.                                                            $fila[apellido]
  197.                                                        </td>
  198.                                                         <td>
  199.                                                            $fila[correo]
  200.                                                        </td>
  201.                                                         <td><center>
  202.                                                            <a  href=?mod=registro&editar&codigo=".$fila["id_usuarios"]."><img src='./img/consul.png' width='25' alt='Edicion' title=' CONSULTAR ".$fila["nombre"]."'></a>";
  203.      
  204.                                 echo "
  205.      
  206.      <a  href=?mod=registro&editar&codigo=".$fila["id_usuarios"]."><img src='./img/editar.png' width='25' alt='Edicion' title='EDITAR LOS DATOS DE ".$fila["nombre"]."'></a>
  207.      <a   href=?mod=registro&eliminar&codigo=".$fila["id_usuarios"]."><img src='./img/elimina.png'  width='25' alt='Edicion' title='ELIMINAR A   ".$fila["nombre"]."'></a>
  208.      ";}
  209.       echo "
  210.      
  211.    
  212.      
  213.     </center>
  214.                                                        </td>
  215.                                                    </tr>";
  216.                                        
  217.                                         }
  218.                                        
  219.                                        
  220.                                         else {
  221.                                        
  222.                                            $consulta="SELECT cedula, nombre, apellido, correo,id_usuarios FROM usuarios ORDER BY cedula ASC ";
  223.                                         $bd->consulta($consulta);
  224.                                         while ($fila=$bd->mostrar_registros()) {
  225.                                             switch ($fila['status']) {
  226.                                                 case 1:
  227.                                                     $btn_st = "danger";
  228.                                                     $txtFuncion = "Desactivar";
  229.                                                     break;
  230.                                                
  231.                                                 case 0:
  232.                                                     $btn_st = "primary";
  233.                                                     $txtFuncion = "Activar";
  234.                                                     break;
  235.                                             }
  236.                                              //echo '<li data-icon="delete"><a href="?mod=lugares?edit='.$fila['id_tipo'].'"><img src="images/lugares/'.$fila['imagen'].'" height="350" >'.$fila['nombre'].'</a><a href="?mod=lugares?borrar='.$fila['id_tipo'].'" data-position-to="window" >Borrar</a></li>';
  237.                                              echo "<tr>
  238.                                                        <td>
  239.                                                          
  240.                                                              $fila[cedula]
  241.                                                            
  242.                                                        </td>
  243.                                                        <td> $fila[nombre]                                                        </td>
  244.                                                        <td>
  245.                                                            $fila[apellido]
  246.                                                        </td>
  247.                                                         <td>
  248.                                                            $fila[correo]
  249.                                                        </td>
  250.                                                         <td>
  251.                                                            <a  href=prestacion2.php?codigo=".$fila["cedula"]."><img src='./img/consul.png' width='25' alt='Edicion' title=' CONSULTAR ".$fila["nombre"]."'></a>";
  252.      
  253.                              
  254.       echo "
  255.      
  256.      <a target='_blank'  href=./pdf/.php?codigo=".$fila["cedula"]."><img src='./img/impresora.png'  width='25' alt='Edicion' title='Imprimir reporte de prestaciones de  ".$fila["nombre"]."'></a>
  257.      
  258.    
  259.                                                        </td>
  260.                                                    </tr>";
  261.                                         }
  262.                                        
  263.                                         } ?>                                            
  264.                                         </tbody>
  265.                                         <tfoot>
  266.                                             <tr>
  267.                                               <th>Cedula</th>
  268.                                                 <th>Nombre</th>
  269.                                                 <th>Apellido</th>
  270.                                                 <th>correo</th>
  271.                                                 <th>Acción</th>
  272.                                             </tr>
  273.                                         </tfoot>
  274.                                     </table>
  275.                                 </div><!-- /.box-body -->
  276.                             </div><!-- /.box -->
  277.                         </div>
  278.                    
  279.              
  280.  
  281.                          
  282.                             <?php
  283.  if($tipo2==1){
  284.                                 echo '
  285.  <div class="col-md-3">
  286.  <div class="box">
  287.                                <div class="box-header">
  288.                                <div class="box-header">
  289.                                    <h3> <center>Agregar Clientes <a href="#" class="alert-link">Nuevos</a></center></h3>                                    
  290.                                </div>
  291.                        <center>        
  292.                            <form  name="fe" action="?mod=registro&nuevo" method="post" id="ContactForm">
  293.    
  294.  
  295.  
  296. <input title="AGREGAR UN NUEVO EMPLEADO" name="btn1"  class="btn btn-primary"type="submit" value="Agregar Nuevo">
  297.  
  298.    
  299.  </form>
  300.  </center>
  301.                                </div>
  302.                            </div>
  303.                            </div>  '; } ?>
  304.                         </br>      
  305.                                
  306.   <div class="col-md-3">
  307.   <div class="box">
  308.                                 <div class="box-header">
  309.                                 <center>
  310.                                 <div class="box-header">
  311.                                    <h3> <center>Imprimir Lista De Clientes</a></center></h3>                                    
  312.                                 </div>
  313.                                
  314.                                
  315.                                  <a target='_blank'  href=./pdf/listaclientes.php><img src='./img/impresora.png'  width='50' alt='Edicion' title='Imprimir lista de Registro De empleados'></a>
  316.                                 </center>
  317.                                 </div>
  318.                                 </div>
  319.                                 </div>
  320.  
  321. <?php
  322. }
  323.  
  324.      
  325.  
  326.      if (isset($_GET['editar'])) {
  327.  
  328. //codigo que viene de la lista
  329. $x1=$_GET['codigo'];
  330.                         if (isset($_POST['editar'])) {
  331.                            
  332.  
  333.  
  334.  
  335.  
  336.  
  337. $nombre=strtoupper($_POST["nombre"]);
  338. $apellido=strtoupper($_POST["apellido"]);
  339. $correo=strtoupper($_POST["correo"]);
  340. $ci=strtoupper($_POST["ci"]);
  341. $telefono=strtoupper($_POST["telefono"]);
  342. $direccion=strtoupper($_POST["direccion"]);
  343.  
  344.                        
  345. if( $nombre=="" )
  346.                 {
  347.                
  348.                     echo "
  349.   <script> alert('campos vacios')</script>
  350.   ";
  351.                     echo "<br>";
  352.                    
  353.                 }
  354.         else
  355.            {
  356. $sql=" UPDATE usuarios SET
  357. nombre='$nombre' ,
  358. apellido='$apellido' ,
  359. cedula='$ci' ,
  360. telefono='$telefono' ,
  361. direccion='$direccion' ,
  362. correo='$correo'
  363. where id_usuarios='$x1'";
  364.  
  365.  
  366. $bd->consulta($sql);
  367.                          
  368.  
  369.    
  370.                             //echo "Datos Guardados Correctamente";
  371.                             echo '<div class="alert alert-success alert-dismissable">
  372.                                        <i class="fa fa-check"></i>
  373.                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
  374.                                        <b>Bien!</b> Datos Editados Correctamente... ';
  375.  
  376.  
  377.  
  378. echo "
  379. Nombre: '$nombre',
  380. apellido='$apellido' ,
  381. cedula='$ci' ,
  382. correo='$correo',
  383. telefono='$telefono',
  384. direccion='$direccion',
  385. id_usuarios='$x1'
  386. ";
  387.                                echo '   </div>';
  388.                            
  389.                            
  390.                        
  391.  
  392.  
  393.  
  394. }
  395.    
  396. }
  397.  
  398.  
  399.                                        
  400.      $consulta="SELECT cedula, nombre, apellido, correo,telefono,direccion FROM usuarios where id_usuarios='$x1'";
  401.      $bd->consulta($consulta);
  402.      while ($fila=$bd->mostrar_registros()) {
  403.  
  404.  
  405.  
  406. ?>
  407.   <div class="col-md-10">
  408.                             <!-- general form elements -->
  409.                             <div class="box box-primary">
  410.                                 <div class="box-header">
  411.                                     <h3 class="box-title">Editar Empleados</h3>
  412.                                 </div>
  413.                                
  414.                            
  415.         <?php  echo '  <form role="form"  name="fe" action="?mod=registro&editar=editar&codigo='.$x1.'" method="post">';
  416.         ?>
  417.                                     <div class="box-body">
  418.                                         <div class="form-group">
  419.                                            
  420.                                            
  421.                                            
  422.                                            
  423.                                             <label for="exampleInputFile">Nombre</label>
  424.                                             <input  onkeypress="return caracteres(event)" onblur="this.value=this.value.toUpperCase();" type="text" required type="tex" name="nombre" class="form-control" value="<?php echo  $fila[nombre] ?>" id="exampleInputEmail1" placeholder="Intoducir el Nombre">
  425.                                             <label for="exampleInputFile">Apellido</label>
  426.                                             <input  onkeypress="return caracteres(event)" onblur="this.value=this.value.toUpperCase();" required type="tex" name="apellido" class="form-control" value="<?php echo  $fila[apellido] ?>" id="exampleInputEmail1" placeholder="Apellido">
  427.                                             <label for="exampleInputFile">cedula</label>
  428.                                             <input onkeydown="return enteros(this, event)" required type="text" name="ci" class="form-control" value="<?php echo $fila[cedula] ?>" id="exampleInputEmail1" placeholder="Cedula">
  429.     <label for="exampleInputFile">telefono</label>
  430.                                             <input onkeydown="return enteros(this, event)" required type="text" name="telefono" class="form-control" value="<?php echo $fila[telefono] ?>" id="exampleInputEmail1" placeholder="telefono">
  431.  
  432.                                              <label for="exampleInputFile">Direccion</label>
  433.                                             <input  required type="tex" name="direccion" class="form-control" value="<?php echo $fila[direccion] ?>" id="exampleInputEmail1" placeholder="direccion">
  434.  
  435.                                             <label for="exampleInputFile">correo</label>
  436.                                             <input  required type="email" name="correo" class="form-control" value="<?php echo $fila[correo] ?>"  placeholder="Correo">
  437.                                            
  438.                                            
  439.                                            
  440.  
  441.                                         </div>
  442.                                        
  443.                                      
  444.                                        
  445.                                     </div><!-- /.box-body -->
  446.  
  447.                                     <div class="box-footer">
  448.                                         <button type="submit" class="btn btn-primary btn-lg" name="editar" id="editar" value="Editar">Editar</button>
  449.                                        
  450.                                    
  451.                                     </div>
  452.                                 </form>
  453.                             </div><!-- /.box -->
  454. <?php
  455.  
  456.  
  457. }
  458. }
  459.  
  460.  //eliminar
  461.  
  462.      if (isset($_GET['eliminar'])) {
  463.  
  464. //codigo que viene de la lista
  465. $x1=$_GET['codigo'];
  466.                         if (isset($_POST['eliminar'])) {
  467.                            
  468.  
  469.  
  470. $nombre=strtoupper($_POST["nombre"]);
  471. $apellido=strtoupper($_POST["apellido"]);
  472. $correo=strtoupper($_POST["correo"]);
  473. $ci=strtoupper($_POST["ci"]);
  474.  
  475.                        
  476. if( $nombre=="" )
  477.                 {
  478.                
  479.                     echo "
  480.   <script> alert('campos vacios')</script>
  481.   ";
  482.                     echo "<br>";
  483.                    
  484.                 }
  485.         else
  486.            {
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494. $sql="delete from usuarios where id_usuarios='$x1' ";
  495.  
  496.  
  497. $bd->consulta($sql);
  498.                          
  499.  
  500.    
  501.                             //echo "Datos Guardados Correctamente";
  502.                             echo '<div class="alert alert-success alert-dismissable">
  503.                                        <i class="fa fa-check"></i>
  504.                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
  505.                                        <b>Bien!</b> Se Elimino Correctamente... ';
  506.  
  507.  
  508.  
  509. echo "
  510. Nombre: '$nombre',
  511. apellido='$apellido' ,
  512. cedula='$ci' ,
  513. correo='$correo',
  514. id_usuarios='$x1'
  515. ";
  516.                                echo '   </div>';
  517.                            
  518.                            
  519.                        
  520.  
  521.  
  522.  
  523. }
  524.    
  525. }
  526.  
  527.  
  528.                                        
  529.      $consulta="SELECT cedula, nombre, apellido, correo FROM usuarios where id_usuarios='$x1'";
  530.      $bd->consulta($consulta);
  531.      while ($fila=$bd->mostrar_registros()) {
  532.  
  533.  
  534.  
  535. ?>
  536.   <div class="col-md-10">
  537.                             <!-- general form elements -->
  538.                             <div class="box box-primary">
  539.                                 <div class="box-header">
  540.                                     <h3 class="box-title">Eliminar Empleados</h3>
  541.                                 </div>
  542.                                
  543.                            
  544.         <?php  echo '  <form role="form"  name="fe" action="?mod=registro&eliminar=eliminar&codigo='.$x1.'" method="post">';
  545.         ?>
  546.                                     <div class="box-body">
  547.                                         <div class="form-group">
  548.                                            
  549.                                            
  550.                                            
  551.                                            
  552.                                             <label for="exampleInputFile">Nombre</label>
  553.                                             <input  onkeypress="return caracteres(event)" onblur="this.value=this.value.toUpperCase();" type="text" required type="tex" name="nombre" class="form-control" value="<?php echo  $fila[nombre] ?>" id="exampleInputEmail1" placeholder="Intoducir el Nombre">
  554.                                             <label for="exampleInputFile">Apellido</label>
  555.                                             <input  onkeypress="return caracteres(event)" onblur="this.value=this.value.toUpperCase();" required type="tex" name="apellido" class="form-control" value="<?php echo  $fila[apellido] ?>" id="exampleInputEmail1" placeholder="Apellido">
  556.                                             <label for="exampleInputFile">cedula</label>
  557.                                             <input onkeydown="return enteros(this, event)" required type="text" name="ci" class="form-control" value="<?php echo $fila[cedula] ?>" id="exampleInputEmail1" placeholder="Cedula">
  558.                                             <label for="exampleInputFile">correo</label>
  559.                                             <input  required type="email" name="correo" class="form-control" value="<?php echo $fila[correo] ?>"  placeholder="Correo">
  560.                                            
  561.                                            
  562.                                            
  563.  
  564.                                         </div>
  565.                                        
  566.                                      
  567.                                        
  568.                                     </div><!-- /.box-body -->
  569.  
  570.                                     <div class="box-footer">
  571.                                         <input type=submit  class="btn btn-primary btn-lg" name="eliminar" id="eliminar" value="ELIMINAR">
  572.                                        
  573.                                    
  574.  
  575.  
  576.                                     </div>
  577.                                 </form>
  578.                             </div><!-- /.box -->
  579. <?php
  580.  
  581.  
  582. }
  583.  
  584.  
  585.  
  586.  
  587. }
  588. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement