<?php
session_start();
if (!isset($_SESSION["user_id"]) || $_SESSION["user_id"]==null):
    print "<script>alert(\"Acceso Invalido!\");
    window.location='login.php';</script>";
endif;
if ($_SESSION["user_at"] < 4):
    print "<script>alert(\"Sin Acceso a Transaccion!\");
    window.location='vt000.php';</script>";
endif;
include_once ("lib/fpdf/funci.php");
$conex = conectar();
date_default_timezone_set('America/La_Paz');
$xusua = $_SESSION["user_id"];
$xiden = $_GET['id'];
$grupo = $_SESSION["xgrupo"];
$maxsg = mysql_query("select * from insgp where insgpsubg = '$xiden'
                      and    insgpgrup = '$grupo'");
$mysgp = mysql_fetch_array($maxsg);
$cosgp = $mysgp[1];
$subgp = $mysgp[2];
?>
<html>
<head>
   <meta charset="utf-8">
   <link href="bootstrap/css/bootstrap.css" rel="stylesheet" />
   <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
   <script src="//code.jquery.com/jquery-1.9.1.js"></script>
   <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
   <link rel="stylesheet" href="/resources/demos/style.css">
   <script>
   $(function() {
      $("#fenac").datepicker({
         dateFormat: 'dd-mm-yy'});
      $("#fereg").datepicker({
         dateFormat: 'dd-mm-yy'});
      $("#febaj").datepicker({
         dateFormat: 'dd-mm-yy'});
   });
   </script>
   <script>
   function validanum(e) {
      tecla = (document.all) ? e.keyCode : e.which;
      //Tecla de retroceso para borrar, siempre la permite
      if (tecla==8){
         return true;
      }
      // Patron de entrada, en este caso solo acepta numeros
      patron =/[0-9.]/;
      tecla_final = String.fromCharCode(tecla);
      return patron.test(tecla_final);
   }
   </script>
   <script>
   function validalet(e) {
      tecla = (document.all) ? e.keyCode : e.which;
      //Tecla de retroceso para borrar, siempre la permite
      if (tecla==8){
         return true;
      }
      // Patron de entrada, en este caso solo acepta letras
      patron =/[A-Za-z/ ]/;
      tecla_final = String.fromCharCode(tecla);
      return patron.test(tecla_final);
   }
   </script>
<style type="text/css">   
   .redondo{
      border-radius: 5px;
      border: 1px solid #39c;
   }

   select{
      border-radius: 5px;
      border: 1px solid #39c;
   }
</style>
</head>
<body>
   <center><h1>Modificar Sub Grupo</h1></center>
<form method="post" autocomplete="off">
   <center><table bgcolor= "#E0FFFF" border="1" width="34%" cellpadding="1" cellspacing="1" class="redondo">
   <tr height="50">
      <td>&nbsp;&nbsp;&nbsp;
      <FONT FACE="times new roman"><strong>Codigo</strong></FONT>
      &nbsp;
      <input name="cosgp" type="text" class="redondo" style="text-align:center; font-family: Arial; font-size: 10pt" value="<?php echo $cosgp;?>" id="fereg" size="10" maxlength="10" disabled=true>
      &nbsp;&nbsp;&nbsp;&nbsp;
      <FONT FACE="times new roman"><strong>Sub Grupo</strong></FONT>
      &nbsp;
      <input name="subgp" autofocus type="text" class="redondo" style="text-align:left; font-family: Arial; font-size: 10pt" value="<?php echo $subgp;?>" size="21" maxlength="20" onkeypress="return validalet(event)">
      </td>
   </tr>
   <tr height="50">
      <td>
      &emsp;&emsp;&emsp;
      <button type="submit" name="enviar" class="btn btn-success">Grabar el Formulario</button>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <a href="vt251.php" class="btn btn-danger">Salir del Formulario</a></center>
      </td>
   </tr>
</center></table>
</form>
</body>
</html>
<?php
if (isset($_POST["enviar"])):
    if ($_POST["subgp"] == ""):
        print '<script language="JavaScript">';
        print 'alert("Llenar los Campos Requeridos");';
	print '</script>';
    else:
	$subgp = trim(strip_tags($_POST["subgp"]));
        mysql_query("lock tables insgp write");
        $insql = "update insgp set insgpdesc = '$subgp'
                  where  insgpgrup = '$grupo'
                  and    insgpsubg = '$xiden'";
        mysql_query($insql);
        mysql_query("unlock tables");
        print "<script>alert(\"La Informacion de Grabo!\");
        window.location='vt251.php';</script>";
    endif;
endif;
?>
