domingo, 5 de mayo de 2013

Codigos ejemplo jqgrid php y postgresql en español.

Codigos ejemplo jqgrid php y postgresql en español.

En estos enlaces encontraras:

1) Codigo fuente:  Sistemas Ejemplo de Contabilidad, Requisiciones e Inventario.

2) Xampp 1.71

3)Postgresql 8.4.7



Codigo Fuente sistema ejemplo Contabilidad

Codigo Fuente Sistema de Requisiciones.

xampp-win32-1.7.1-installer

Postgresql 8.4.7

Codigo Fuente Sistema de Inventario.

recuerda:

1) Debes instalar el postgresql 8.4.7 o superior

2) Instalar el Xampp version 1.71 preferiblemente

3) Modificar el php ini, debes desmarcar la linea

;extension=php_pgsql.dll 

asi:

extension=php_pgsql.dll

para que los sistemas puedan comunicarse con la base de datos.

4)Revisa dentro de la carpeta funciones el archivo "Conectar.php "  y asegurate  que el puerto PORT sea el mismo con el que se configuro la instalacion de postgresql de lo contrario no se conectara el sistema con la base de datos.

$conn->PConnect('host=127.0.0.1 port=5432 dbname=Bd_Nomina user=postgres password=123') or die ('Fallo conexion al Servidor');




Importante: en el sistema de contabilidad el tipo de asiento de cierre no esta operativo no lo uses para cargar registros. Saludos.



Importante:

Por favor comparte el codigo y los conocimientos, el conocimiento debe ser libre es lo unico que pido. Gracias.

Lic. David Rafael Blanco Leon. Caracas Venezuela.


viernes, 5 de abril de 2013

Jqgrid Codigo que permite recorrer todas las filas del grid y sumar el contenido de las celdas con cifras numéricas dependiendo si son positivas o negativas.



Jqgrid Codigo que permite recorrer todas las filas del grid y sumar el contenido de las celdas con cifras numéricas dependiendo si son positivas o negativas.

 



<?php
extract($_POST);
extract($_GET);
if (!isset($_SESSION["mapa"])){
    include('msj_inicio_session.php');
}else{       
    if ($_SESSION["mapa"] == -1 || $_SESSION["mapa"] == 2 || $_SESSION["mapa"] == 3){       
    //Includes Necesarios
        include('funciones/Conectar.php');//Conexion a la Base de datos
        include('funciones/Funciones_Contabilidad.php');//Conexion a la Base de datos
?>
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" href="css/estilo.css">
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
function formafecha(fecha)
 {
 Anio =fecha.substr(0,4);
 mes=fecha.substr(5,2);
 dia=fecha.substr(8,2);
 fecha=dia+"/"+mes+"/"+Anio;
 return (fecha);
 }



$(function(){
 var Identifica_accion =<?php echo $_GET['rp'];?>;
       // $.jgrid.formatter.integer.thousandsSeparator = ',';
        $.jgrid.formatter.number.thousandsSeparator = '.';
         $.jgrid.formatter.number.decimalSeparator = ',';
         $.jgrid.formatter.number.decimalPlaces = 2;
      //  $.jgrid.formatter.currency.thousandsSeparator = ',';

$.getJSON('Funciones_Contabilidad.php',{Id_Proceso:2},function(solicitud){$('#Debe_Original').val(solicitud.Total_Monto);});// cierra getJSON
$.getJSON('Funciones_Contabilidad.php',{Id_Proceso:1},function(solicitud){$('#Haber_Original').val(solicitud.Total_Monto);});// cierra getJSON

   
   
     if(Identifica_accion!=0)
 {


 $.getJSON('Busca_Data.php',{Num_Comprobante:Identifica_accion},function(solicitud){   
       
             //var plantilla=(solicitud.Plantilla_Id);
            //$('select[id="Tipo_solicitud_Id"] option:selected').val(solicitud.Tipo_solicitud_Id);
            $('#Id_Comprobante').val(solicitud.Id_Registro);
            $('#Num_Comprobante').val(solicitud.Numero_Comprobante);
            $('#fecha_Cambio').val(formafecha(solicitud.Fecha_Comprobante));
            $('#Comentario').val(solicitud.Descripcion);
            $('#Tipo_Asiento').val(solicitud.Tipo_Comprobante);
            $('#Estatus_Asiento').val(solicitud.Estatus_Actualizado);
           
           

   
        });// cierra getJSON
       

 }// cierra el if identifica_accion


$("#enlace").click(function() {
     location.href = this.href; // ir al link
});   
   
// ESTA RUTINA PERMITE RECORRER EL GRID Y SUMAR EL CONTENIDO DE LAS CELDAS DEPENDIENDO SI SON CIFRAS POSITIVAS O NEGATIVAS
function Totaliza () {
 var total_haber=0,total_debe=0;
 var rows= jQuery("#grps").jqGrid('getRowData');
                for(var i=0;i<rows.length;i++){
                      var row=rows[i];
                      if(Number(row['Monto'])>0)
                        {
                         total_haber +=Number(row['Monto']);
                        }else{
                         total_debe +=Number(row['Monto']);
                        }
                     
                  }
                 
                  total_haber=Number(total_haber)+Number($('#Haber_Original').val());
                  total_debe=Number(total_debe)+Number($('#Debe_Original').val());
                $('#Haber').val(total_haber);
                $('#Debe').val(total_debe);
                 
      return true;
};


    var ccosto = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Centro_Costo.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();
   
   
    var dasocia = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Doc_Asociado.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();   


    var dtipo = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Doc_Tipo.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();   
       
$("#grps").jqGrid({
url:'Carga_Datos.php?filtro='+<?php echo $_GET['rp'];?>,
datatype: 'json',
mtype: 'GET',
  colNames: ['Id_Registro','Codigo_Cuenta','Centro_Costo', 'Doc_Asoc','Tipo', 'Descripcion', 'Monto'],
          colModel: [
      { name: 'Id_Registro', index: 'Id_Registro', width: 100, align: 'left',editable: false},
     { name: 'Codigo_Cuenta', index: 'Codigo_Cuenta', width: 100, align: 'left',editable: true,editrules:{required:true},edittype:"select",editoptions:{dataUrl:'Plan_Cuentas.php'} ,sortable: true, resizable: false},
      { name: 'Centro_Costo', index: 'Centro_Costo', width: 100, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: ccosto},sortable: true, resizable: false},
      { name: 'Doc_Asoc', index: 'Doc_Asoc', width: 100, align: 'left',editable: true,editrules:{required:true},edittype:'text'},
      { name: 'Tipo', index: 'Tipo', width: 100, align: 'left',editable: true,editrules:{required:true},edittype:"select",formatter:'select',editoptions: { value: dasocia},sortable: true, resizable: false},
      { name: 'Descripcion', index: 'Descripcion', width: 200, align: 'left',editable: true,editrules:{required:true},edittype:'text'},
      { name: 'Monto', index: 'Monto', width: 200, align: 'left',editable: true,editrules:{number:true},formatter: 'number',edittype:'text'},
      ],
   
   

    rownumbers:true,
    pager: '#pgrps',
    rowNum:15,
    rowList:[10,25,50,100],
    autowidth: true,
  //  sortname: 'Id_Registro',
  //  sortorder: 'desc',
    viewrecords: true,
    width: "98%",
    height: "100%",
    editurl: "inlineEdit.php",
    caption: 'Carga Asientos Contables',
    footerrow: true,
    cellEdit: true,
    cellurl:"otro.php",
   


afterSaveCell: function (rowid, cellname, value) {
                    if (cellname === 'Monto') {
                        var sum = jQuery("#grps").jqGrid('getCol', 'Monto', false, 'sum');
                    

                     var total_registros =jQuery("#grps").jqGrid('getGridParam', 'records');// lee el numero total de filas a recorrer
                     jQuery("#grps").setGridParam({ rowNum: total_registros }).trigger('reloadGrid');// cambia el numero de filas  que tiene el grid al numero de total_registros 
   

                        var z=Totaliza();
                        jQuery("#grps").jqGrid('footerData','set', {Id_Registro: 'Total:', Monto: sum});
                       }
                },
               
ondblClickRow: function(rowid,iRow,iCol,e){
                   var myCellData = $('#grps').jqGrid('getCell', rowid, 'Codigo_Cuenta');
                   $.post('Funciones.php',{Codigo:myCellData},Busca_Texto);
                    function Busca_Texto(datos)
                    {
                    $("#Cuenta").val(datos);
                    }
                },


afterInsertRow:function(rowid,rowdata,rowelem) {
             var sum =  jQuery("#grps").jqGrid('getCol', 'Monto', false, 'sum');



                     var total_registros =jQuery("#grps").jqGrid('getGridParam', 'records');// lee el numero total de filas a recorrer
                     jQuery("#grps").setGridParam({ rowNum: total_registros }).trigger('reloadGrid');// cambia el numero de filas  que tiene el grid al numero de total_registros 
          

  var z=Totaliza();
             jQuery("#grps").jqGrid('footerData','set', {Id_Registro: 'Total:', Monto: sum});
           
  
        },
 
gridComplete: function(){
             var sum = jQuery("#grps").jqGrid('getCol', 'Monto', false, 'sum');
             jQuery("#grps").jqGrid('footerData','set', {Id_Registro: 'Total:', Monto: sum});
        },

  });




jQuery("#grps").jqGrid('navGrid','#pgrps',{}, //options
{height:280,width:600,reloadAfterSubmit:false,closeAfterEdit:true},// edit
{height:280,width:600,reloadAfterSubmit:false,closeAfterAdd:true}, // add options
{reloadAfterSubmit:false}, // del options
{multipleSearch:true,closeAfterSearch: true, closeOnEscape: true}
);






jQuery("#grps").jqGrid('navButtonAdd','#pgrps',{
       caption:"Cuenta",
       title:"Cuenta",
       onClickButton : function () {
          var prueba=0;
          var id = jQuery("#grps").jqGrid('getGridParam','selrow');
          if (id)
          {
             var ret = jQuery("#grps").jqGrid('getRowData',id);
             var prueba=ret.Codigo_Cuenta;
            }
       
               $.getJSON('Funciones.php',{Codigo:prueba},Busca_Texto);
               function Busca_Texto(datos)
               {
                 alert(datos);
                 $("#Cuenta1").html(datos);
                }
       
       
       } ,
      
});   


$("#bedata").click(function()
        {
                             // CODIGO MUY IMPORTANTE SIN EL CUAL NO SE GRABARAN TODAS LAS FILAS DEL GRID
                     var total_registros =jQuery("#grps").jqGrid('getGridParam', 'records');// lee el numero total de filas a recorrer
                     jQuery("#grps").setGridParam({ rowNum: total_registros }).trigger('reloadGrid');// cambia el numero de filas  que tiene el grid al numero de total_registros


                if(!confirm(" Esta seguro  de Grabar los asientos?"))  {return false;}
                else {
               
                     var Identifica_Usuario=$('#Id_Usuario').val();
                     var busca_error =0;
                     var mensaje ="";
                     var fecha_Cambio = $('#fecha_Cambio').val();
                     var Num_Comprobante =$('#Num_Comprobante').val();
                     var Comentario =$('#Comentario').val();
                     var cantidad = $("#grps tbody").find("tr").length;
                     var Tipo_Asiento =$('#Tipo_Asiento option:selected').val();
                     var Estatus_Asiento =$('#Estatus_Asiento option:selected').val();
                   
                     if ($("#Estatus_Asiento option:selected").text()=="Seleccione"){busca_error=1;mensaje="Estatus_Asiento";}
                     if ($("#Tipo_Asiento option:selected").text()=="Seleccione"){busca_error=1;mensaje="Tipo_Asiento";}
                     if (cantidad==1){busca_error=2;mensaje="No Puede Grabar Registros en blanco";}
                     if (fecha_Cambio==""){busca_error=1;mensaje="Fecha";}
                     if (Num_Comprobante==""){busca_error=1;mensaje="Numero de Comprobante";}
                     if (Comentario==""){busca_error=1;mensaje="Comentario";}

                   
               
               
                        var z=0;
                     var texto ="";
                     var columns = new Array ();
                     var lista = jQuery("#grps").getDataIDs();
                     for(i=0;i<lista.length;i++)
                        {
                            rowData=jQuery("#grps").getRowData(lista[i]);
                            columns[z]=rowData.Codigo_Cuenta+';'+rowData.Centro_Costo+';'+rowData.Doc_Asoc+';'+rowData.Tipo+';'+rowData.Descripcion+';'+rowData.Monto;
                            z++;
                       }// cierra el for
       
 if(busca_error==0)
{     
          
    var jObject={};
    for(i in columns)
    {
        jObject[i] = columns[i];
    }
   
           
                      $.post("pruebaz.php",{jObject:  jObject,fecha_Cambio:fecha_Cambio,Num_Comprobante:Num_Comprobante,Comentario:Comentario,Tipo_Asiento:Tipo_Asiento,Identifica_Usuario:Identifica_Usuario,Estatus_Asiento:Estatus_Asiento,Identifica_accion:Identifica_accion},function(result){alert(result);$("#enlace").click();});
                         // return false;
                       

}else{

if (busca_error==1){alert('Ingrese un Valor para el Campo '+mensaje);}
if (busca_error==2){alert(mensaje);}
}
                      
                           
                        
                     }   // cierra el confirm       
        });  // cierra la funcion clic
});
</script>



<table width="900" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td><a href="index.php?m=1&amp;p=0" id='enlace' name='enlace'>Volver al listado</a></td>
  </tr>
</table>
<br />

<form action="?m=82" method="post" enctype="application/x-www-form-urlencoded" name="rp" id="rp" onSubmit="return ValidaRP1(this)">
  <table width="900" border="0" align="center" cellpadding="3" cellspacing="0" class="srcTabla">
    <tr>
      <th scope="col" style="text-align:center" >Carga de Asientos </th>
    </tr>
    <tr>
      <td align="center" valign="middle" nowrap="nowrap" bgcolor="#ECECEC">
        <table width="100%" border="1" cellspacing="0" cellpadding="6" class="srcTabla">
            <tr>

              <th scope="col" width="140">Id Comprobante  </th>
              <th scope="col" width="140">Tipo de Asiento  </th>
              <th scope="col" width="85">Numero</th>
              <th scope="col" width="125">Fecha</th>
              <th width="492" scope="col">Comentario</th>
              <th width="492" scope="col">Estatus</th>
            </tr>
             <tr>
           
   
               <td valign="middle" nowrap="nowrap"><input type="text" name="Id_Comprobante" Id="Id_Comprobante" readonly="True" /></td>
       
              <td height="50" valign="middle" nowrap="nowrap"><div id="Combo_Asiento" style=" float:left">
                <select name="Tipo_Asiento" id="Tipo_Asiento">
            <option value="Seleccione"      title="Seleccione">Seleccione</option>
            <option value="ad"      title="ad">ad</option>
            <option value="b"       title="b">b</option>
            <option value="cierre"  title="cierre">cierre</option>
            <option value="n"  title="n">n</option>
            <option value="p"  title="p">p</option>
               </select>
                </div>
              </td>
             
              <td valign="middle" nowrap="nowrap"><input type="text" name="Num_Comprobante" Id="Num_Comprobante" /></td>
             
                <td valign="middle" nowrap="nowrap"><input name="fecha_Cambio" type="text" id="fecha_Cambio" size="12" maxlength="10" value="" onkeyup = "this.value=formateafecha(this.value);"/>
      <img src="images/calendar.png" alt="Elija una fecha" name="cal_x_fecha_reg" width="16" height="16" align="bottom" id="cal_x_fecha_reg" style="cursor:pointer;cursor:hand;" onMouseOver="crearcalendar();" />                    </td>
           
             <td valign="middle" nowrap="nowrap"><input name="Comentario" type="text" Id="Comentario" size="70" /></td>
             <td valign="middle" nowrap="nowrap"><div id="Combo_Estatus_Asiento" style=" float:left">
                <select name="Estatus_Asiento" id="Estatus_Asiento">
            <option value="Seleccione"      title="Seleccione">Seleccione</option>
            <option value="S"      title="Actualizado">Actualizado</option>
            <option value="N"       title="No Actualizado">No Actualizado</option>
               </select>
                </div>
              </td>
            </tr>
           
           
      </table></td>
    </tr>
   
   
    <tr>
   
      <td height="63" bgcolor="#ECECEC"><table width="100%" border="1" cellspacing="0" cellpadding="5">
      
      
      </table>
        <table width="1111" border="1" cellspacing="0" cellpadding="0">
          <tr>
            <td width="471" height="30">DEBE:
            <input type="text" name="Debe"   Id="Debe"  readonly="True" value="0"/>
       
            <input type="hidden" name="Debe_Original" Id="Debe_Original" value="" /></td>
           
            <td width="634">HABER:
              <input type="text" name="Haber" Id="Haber" readonly="True" value="0"/>
             
              <input type="hidden" name="Haber_Original" Id="Haber_Original" value=""/></td>
             
          </tr>
        </table>
      </td>
    </tr>
   
   
   
   
   
   
   
   
  </table>
  <br />
 
  <br />
 

  <table id="grps"></table>
  <div id="pgrps"></div>

   <p>&nbsp;</p>
   <p>
     <label id="Cuenta1">     </label>

  </p>
<div id="boton" align="center">
<input type="BUTTON" id="bedata" value="Grabar Comprobante y Asientos Cargados" />
</div>
</form>
<br/><br/><br/>


<?php

    }//Cierra if de Nivel de Acceso
        else{
            include ('msj_nivel_acceso.php');
        }
}//Cierra Nivel de Seguridad
?>

<p>
    <input type="hidden" name="Id_Usuario"  Id="Id_Usuario" value="<?php echo $_SESSION["nombres"].' '.$_SESSION["apellidos"]?>"/>
  </p>

martes, 26 de febrero de 2013

Postgresql y Jqgrid Recargar Jqgrid con parametros

Buenas tardes hoy voy a colocar un ejemplo de como recargar el jqgrid con parametros.



<?php if (!isset($_SESSION["mapa"])){?>
<link rel="stylesheet" type="text/css" href="css/estilo.css">
<br/>
    <table width="400" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td align="center" background="images/blue.png"><strong class="Titulos">Debe Entrar con un usuario valido</strong></td>
  </tr>
  <tr>
    <td align="center"><a href="index.php" class="menu">Entrar</a></td>
  </tr>
</table>
<?php } else{ ?>

<!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=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>

<link rel="stylesheet" type="text/css" href="scripts/calendar/calendar-blue.css"/>
<link rel="stylesheet" type="text/css" href="css/estilo.css">
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="text/js/jquery-ui-1.10.1.custom.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script language="javascript" src="scripts/sisminalve.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="scripts/validar.js"></script>
<script type="text/javascript" src="text/js/jquery.ui.datepicker-es.js"></script>

<?php
extract($_POST);
extract($_GET);
        include('funciones/Conectar.php');//Conexion a la Base de datos
        include('funciones/FuncionesListBox.php');
        include('funciones/globales.php');
        include('funciones/librerias.php');
       
?>
 <script>
$(function() {
$( "#fechaR" ).datepicker();
$( "#fecha_Cambio" ).datepicker();
$( "#Fecha_Desde" ).datepicker();
$( "#Fecha_Hasta" ).datepicker();
});
</script>
<script type="text/javascript">
$(function(){
 var identificador_rubro=$('#Renglon_Oculto').val();
 var Identifica_accion =<?php echo $_GET['rp'];?>;
 var selICol; //iCol of selected cell
 var selIRow; //iRow of selected cell

 // ESTE CODIGO HACE LA LLAMADA PARA LA RECARGA  DEL JQGRID  EL CODIGO DE SUBE_PLANTILLA.PHP LA MOSTRARE AL FINAL DE LA PAGINA
 $('#Combo_Plantilla').bind('change',function(){
              var plantilla=$('#Plantilla_Id option:selected').val();
              $("#grps").jqGrid('setGridParam',{url:'Sube_Plantilla.php?Plantilla='+plantilla,datatype:'json',mtype: 'GET'}).trigger('reloadGrid');

   
             
            });   





 if(Identifica_accion!=0)
 {


 $.getJSON('Busca_Data.php',{Num_Reque:Identifica_accion},function(solicitud){   
       
           
            //$('select[id="Tipo_solicitud_Id"] option:selected').val(solicitud.Tipo_solicitud_Id);
           
            $('#Tipo_solicitud_Id').val(solicitud.Tipo_solicitud_Id);
            $('#Status_decision_Id').val(solicitud.Status_Decision_Id);
            $('#Plantilla_Id').val(solicitud.Plantilla_Id);
            $('#Unidad_requerente_Id').val(solicitud.Unidad_requerente_Id);
            //$('#Unidad_requerente_Id_a option:selected').val(solicitud.Unidad_requerente_Id_a);
            $('#fechaR').val(solicitud.Solicitud_maestro_fecha);
            $('#fecha_Cambio').val(solicitud.Solicitud_maestro_status_fecha);
            $('#Num_Reque').val(solicitud.Solicitud_Numero);
            $('#Fecha_Desde').val(solicitud.Fecha_Desde);
            $('#Fecha_Hasta').val(solicitud.Fecha_Hasta);
            $('#Matricula').val(solicitud.Matricula);
        });
       
   


 }// cierra el if identifica_accion

$("#enlace").click(function() {
     location.href = this.href; // ir al link
});


$("#Num_Reque").blur(function(){
  if($(this).val() == '') {
    $(this).after('<div class="error">Numero de Requisicion Requerido.</div>');
    hasError = true;
  }else{
      $.post("Valida_Reque.php",{Num_r:$(this).val()},function(result){if (result!=0){alert(result);$("#enlace").click();}});
  }
 
 
});


var drubro = (function () {
            var list = null;
           
            $.ajax({
                async: false,
                global: false,
                url: 'Rubro.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();

   
$("#grps").jqGrid({
url:'Carga_Datos.php?filtro='+<?php echo $_GET['rp'];?>,
datatype: 'json',
mtype: 'GET',
  colNames: ['Cantidad','Unidad_medida_Des','Rubro_des','Costo'],
          colModel: [
     { name: 'Cantidad', index: 'Cantidad', width: 80, align: 'left',editable: true,editrules:{required:true,number:true},formatter: 'number',edittype:'text',editoptions:{dataEvents: [
  
    {
        type: 'keypress',
        fn: function(e) {
            var key = e.charCode || e.keyCode; // to support all browsers
             if (key == 13){setTimeout("jQuery('#grps').editCell(" + selIRow + " + 1, " + selICol + ", true);", 100);}
             if((key < 48 || key > 57) &&   key !== 46 && key !== 44 && key !== 8 &&  key !== 37 && key !== 39){ return false;}
        }// cierra la funcion e
    }// cierra el control del keypress
   
]   
     }// cierra editoptions
     }, // cierra la linea de sistema
   
   
{ name: 'Unidad_medida_Des', index: 'Unidad_medida_Des', width: 80, align: 'left',editable: false,editrules:{required:true},formatter:'text',edittype:"text"},

 { name: 'Rubro_des', index: 'Rubro_des', width: 80, align: 'left',editable: false,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: drubro},sortable: true},  

   
 { name: 'Costo', index: 'Costo', width: 80, align: 'left',editable: true,editrules:{required:true,number:true},formatter: 'number',edittype:'text',editoptions:{dataEvents: [
  
    {
        type: 'keypress',
        fn: function(e) {
            var key = e.charCode || e.keyCode; // to support all browsers
             if (key == 13){setTimeout("jQuery('#grps').editCell(" + selIRow + " + 1, " + selICol + ", true);", 100);}
             if((key < 48 || key > 57) &&   key !== 46 && key !== 44 && key !== 8 &&  key !== 37 && key !== 39){ return false;}
        }// cierra la funcion e
    }// cierra el control del keypress
   
]   
     }// cierra editoptions
     }, // cierra la linea de sistema   
   
      ],
   
    rownumbers:true,
    pager: '#pgrps',
    rowNum:15,
    rowList:[10,25,50,100],
    autowidth: true,
    viewrecords: true,
    width: "98%",
    height: "100%",
    editurl: "someurl.php",
    caption: 'Carga de Requisiciones',
    footerrow: true,
    cellEdit: true,
    cellurl:"otro.php",//Esta es una pagina vacia php
   




beforeEditCell : function(rowid, cellname, value, iRow, iCol)
{
    selICol = iCol;
    selIRow = iRow;
},


afterSaveCell: function (rowid, cellname, value,iRow, iCol) {
                    if (cellname === 'Cantidad') {
                        var sum = jQuery("#grps").jqGrid('getCol', 'Cantidad', false, 'sum');
                        jQuery("#grps").jqGrid('footerData','set', {Unidad_medida_Des: 'Total:', Cantidad: sum});
                    }

                    if (cellname === 'Costo') {
                        var sum1 = jQuery("#grps").jqGrid('getCol', 'Costo', false, 'sum');
                        jQuery("#grps").jqGrid('footerData','set', {Unidad_medida_Des: 'Total:', Costo: sum1});
                    }


                },
       

afterInsertRow:function() {
             var sum = jQuery("#grps").jqGrid('getCol', 'Cantidad', false, 'sum');
             var sum1 = jQuery("#grps").jqGrid('getCol', 'Costo', false, 'sum');
               jQuery("#grps").jqGrid('footerData','set', {Unidad_medida_Des: 'Total:', Cantidad: sum});
             jQuery("#grps").jqGrid('footerData','set', {Unidad_medida_Des: 'Total:', Costo: sum1});
        },
 
gridComplete: function(){
             var sum = jQuery("#grps").jqGrid('getCol', 'Cantidad', false, 'sum');
             var sum1 = jQuery("#grps").jqGrid('getCol', 'Costo', false, 'sum');
             jQuery("#grps").jqGrid('footerData','set', {Unidad_medida_Des: 'Total:', Cantidad: sum});
             jQuery("#grps").jqGrid('footerData','set', {Unidad_medida_Des: 'Total:', Costo: sum1});
        },

  });



$("#bedata").click(function()
        {
       
       
        //jQuery("#grps").jqGrid('excelExport',{tag:"pdf","url":"querygrid.php"});
             
                if(!confirm(" Esta seguro  de Grabar los asientos?"))  {return false;}
                else {
                   
                     var busca_error =0;
                     var mensaje ="";
                     var plantilla=$('#Plantilla_Id option:selected').val();
                     var Tipo_Requisicion = $('#Tipo_solicitud_Id option:selected').val();
                     var status = $('#Status_decision_Id option:selected').val();
                     var Fecha = $('#fechaR').val();
                     var Num_r =$('#Num_Reque').val();
                     var Unidad =$('#Unidad_requerente_Id option:selected').val();
                     var Fecha_Solicitud = $('#fecha_Cambio').val();
                     var Fecha_Desde = $('#Fecha_Desde').val();
                     var Fecha_Hasta = $('#Fecha_Hasta').val();
                     var Matricula =$('#Matricula').val();
                    // cantidad = $("#grps tbody").find("tr").length;


                    // if (cantidad==1){busca_error=2;mensaje="No Puede Grabar Registros en blanco";}
                    /* if (Fecha_Solicitud==""){busca_error=1;mensaje="Fecha_Solicitud";}
                     if (Fecha_Desde==""){busca_error=1;mensaje="Fecha_Desde";}
                     if (Fecha_Hasta==""){busca_error=1;mensaje="Fecha_Hasta";}*/
                   
                     if ($("#Status_decision_Id option:selected").text()=="Seleccione"){busca_error=1;mensaje="Status Requisicion";}
                     if (Fecha==""){busca_error=1;mensaje="Fecha";}
                     if (Num_r==""){busca_error=1;mensaje="Numero Requisicion";}
                     if (Matricula==""){busca_error=1;mensaje="Matricula";}
                     if ($("#Unidad_requerente_Id option:selected").text()=="Seleccione"){busca_error=1;mensaje="Unidad";}
                     if ($("#Tipo_solicitud_Id option:selected").text()=="Seleccione"){busca_error=1;mensaje="Tipo de Requisicion";}
                     if ($("#Plantilla_Id option:selected").text()=="Seleccione"){busca_error=1;mensaje="Tipo de Plantilla";}

if(busca_error==0)
{                   
                        var z=0;
                     var texto ="";
                     var columns = new Array ();
                     var lista = jQuery("#grps").getDataIDs();
                     for(i=0;i<lista.length;i++)
                        {
                            rowData=jQuery("#grps").getRowData(lista[i]);
                            columns[z]=parseInt(rowData.Cantidad)+';'+rowData.Rubro_des+';'+parseInt(rowData.Costo);
                            z++;
                       }// cierra el for

   
    var jObject={};
    for(i in columns)
    {
        jObject[i] = columns[i];
    }
   

           
                      $.post("Graba.php",{jObject:  jObject,status:status,Fecha:Fecha,Num_r:Num_r,plantilla:plantilla,Unidad:Unidad,Fecha_Solicitud:Fecha_Solicitud,Fecha_Desde:Fecha_Desde,Fecha_Hasta:Fecha_Hasta,Tipo_Requisicion:Tipo_Requisicion,Identifica_accion:Identifica_accion,Fecha_Desde:Fecha_Desde,Fecha_Hasta:Fecha_Hasta,Matricula:Matricula},function(result)
                         {
                         alert(result);
                         $("#enlace").click();
                         });
                         // return false;
                       

}else{

if (busca_error==1){alert('Ingrese un Valor para el Campo '+mensaje);}
if (busca_error==2){alert(mensaje);}
}




                     }   // cierra el confirm   
                   
                   
                        
        });  // cierra la funcion clic
       
       



       
});
</script>
</head>





       


<body>

<table width="900" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td><a href="index.php?m=1&amp;p=0" id='enlace' name='enlace'>Volver al listado</a></td>
  </tr>
</table>
<br />
<form id="Forma_Solicitud" name="Forma_Solicitud" method="post" action="Solicitud.php">






<div id="Tabla"align="center">
  <p>&nbsp;</p>
  <table width="1013" border="1" align="center" cellpadding="3" cellspacing="0" class="srcTabla">
  <tr>
    <td colspan="9" align="center" valign="middle" nowrap="nowrap" bgcolor="#ECECEC"><div align="center"><strong>SOLICITUD DE REQUISICION </strong></div></td>
  </tr>
  <tr>
    <td><div align="left"><strong>Plantilla</strong></div></td>
    <td><span style=" float:left">
      <div id="Combo_Plantilla" style=" float:left"><?php LlenarCombo('"Plantilla_Id","Titulo_Plantilla"', 'Plantilla', 'Seleccione','Plantilla_Id') ?></div>
    </span></td>
    <td width="94"><strong>Tipo Requision:</strong></td>
    <td width="74"><strong><span style=" float:left">
      <?php LlenarCombo('"Tipo_solicitud_Id","Tipo_solicitud_Des"', 'Tipo_solicitud', 'Seleccione','Tipo_solicitud_Id') ?>
    </span></strong></td>
    <td colspan="2"><strong>Status Requisicion </strong></td>
    <td><div id="Combo_Status" style=" float:left"><?php LlenarCombo('"Status_decision_Id","Status_decision_Des"', 'Status_decision', 'Seleccione','Status_decision_Id') ?>
      </div></td>
    <td width="124"><strong>Fecha Transcripcion:</strong></td>
    <td width="148"><input  name="fechaR" type="text" id="fechaR"  onmouseout="this.value=formateafecha(this.value);"/>

</td>
  </tr>
  <tr>
    <td width="104"><strong>Numero Requisicion:</strong></td>
    <td width="146"><input type="text" name="Num_Reque" id="Num_Reque" />
    <div id="Combo_Solicitante" style=" float:left"></div>    </td>
    <td><span style=" float:left">
     <div id="Combo_Unidad" style=" float:left"></div>
    </span><strong>Unidad </strong></td>
    <td><span style=" float:left">
      <?php LlenarCombo('"Unidad_requerente_Id","Unidad_requerente_Des"', 'Unidad_requerente', 'Seleccione','Unidad_requerente_Id') ?>
    </span></td>
    <td width="75"><strong>Matricula</strong></td>
    <td width="86"><input type="text" name="Matricula" Id="Matricula" /></td>
    <td width="88"><strong>Fecha de Solicitud:</strong></td>
    <td colspan="2"><input name="fecha_Cambio" type="text" id="fecha_Cambio" />
     
      </td>
  </tr>
  <tr>
    <td><strong>Periodo:</strong></td>
    <td colspan="2"><span style=" float:left">
     
    </span><strong>Fecha Desde:</strong></td>
    <td><input name="Fecha_Desde" type="text" id="Fecha_Desde"/>
       </td>
    <td colspan="4"><strong>Fecha Hasta</strong>:
      <div id="Combo_Tipo_Requision" style=" float:left"></div>      <div id="Combo_Renglon" style=" float:left"></div></td>
    <td><input name="Fecha_Hasta" type="text" id="Fecha_Hasta"/>
      </td>
  </tr>
</table>
  <p>
    <input type="hidden" name="Renglon_Oculto" Id="Renglon_Oculto" value="<?php echo($_POST['Renglon_Oculto']); ?>" />
    <input type="hidden" name="Id_Renglon_Oculto" Id="Id_Renglon_Oculto"  value="<?php echo($_POST['Id_Renglon_Oculto']); ?>" />
  </p>
</div>


  <table id="grps"></table>
  <p>&nbsp;</p>
  <div id="pgrps"></div>
 
<div id="boton" align="center">
<input type="BUTTON" id="bedata" value="Grabar Requisicion" />
</div>
</form>
</body>

</html>
<?php }//Cierra Nivel de Seguridad ?>


****************************************************
CODIGO DEL ARCHIVO SUBE_PLANTILLA.PHP
****************************************************

<?php
extract($_POST);
extract($_GET);
if($_GET['Plantilla']!=0)
{
require('funciones/Conectar.php');
    $page = $_GET['page'];     // get the requested page
    $limit = $_GET['rows'];   // get how many rows we want to have into the grid
    $sidx = $_GET['sidx'];   //     get index row - i.e. user click to sort
    $sord = $_GET['sord'];  //     get the direction
    if(!$sidx) $sidx =1;   // connect to the database



$SQL_Funciones='Select'."''".' as "Cantidad", "Unidad_medida_Des","Rubro_Id",'."''".' as "Costo" From "Rubro" INNER JOIN "Unidad_medida" ON  "Unidad_medida"."Unidad_medida_Id"="Rubro"."Id_Unidad_Medida" WHERE "Id_Plantilla"'."='".$_GET['Plantilla']."'".'ORDER BY "Rubro_Des"';



//print_r($SQL_Funciones);
$Data_Funciones_N = $conn->Execute("$SQL_Funciones");
$count=$Data_Funciones_N->RecordCount();    
   
    if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; }
    if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1)
    $responce->page = $page;
    $responce->total = $total_pages;
    $responce->records = $count;
    $i=0;
                  while (!$Data_Funciones_N->EOF)
                  {
                    //$responce->rows[$i]['Codigo_Cuenta']=$Data_Funciones_N->fields[1];
                    $responce->rows[$i]['cell']=array($Data_Funciones_N->fields[0],$Data_Funciones_N->fields[1],$Data_Funciones_N->fields[2]);
                    $i++;
                    $Data_Funciones_N->MoveNext();
                 }
    $Data_Funciones_N->Close(); //opcional
    echo json_encode($responce);
}
 ?>   

viernes, 22 de febrero de 2013

Postgresql y Jqgrid Navegar celdas con tecla enter excel



Buenos Días hoy voy a demostrar como desplazarse dentro del jqgrid con la tecla enter y editar la celda automáticamente.



<?php if (!isset($_SESSION["mapa"])){?>
<link rel="stylesheet" type="text/css" href="css/estilo.css">
    <br/>
    <table width="400" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td align="center" background="images/blue.png"><strong class="Titulos">Debe Entrar con un usuario valido</strong></td>
  </tr>
  <tr>
    <td align="center"><a href="index.php" class="menu">Entrar</a></td>
  </tr>
</table>
<?php } else{ ?>

<!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=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link rel="stylesheet" type="text/css" href="scripts/calendar/calendar-blue.css"/>
<link rel="stylesheet" type="text/css" href="css/estilo.css">
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="scripts/Nomina.js"></script>
<script language="javascript" src="scripts/sisminalve.js" type="text/javascript"></script>
<script type="text/javascript" src="scripts/calendar/calendar.js"></script>
<script type="text/javascript" src="scripts/calendar/lang/calendar-es.js"></script>
<script type="text/javascript" src="scripts/calendar/calendar-setup.js"></script>
<?php
extract($_POST);
extract($_GET);
        include('funciones/Conectar.php');//Conexion a la Base de datos
        include('funciones/FuncionesListBox.php');
        include('funciones/globales.php');
        include('funciones/librerias.php');
       
?>
<script type="text/javascript">
$(function(){
 var identificador_rubro=$('#Renglon_Oculto').val();
 var Identifica_accion =<?php echo $_GET['rp'];?>;
 // Debes declarar estas variables para capturar el id de la fila y columna
var selICol; //iCol of selected cell
var selIRow; //iRow of selected cell



 if(Identifica_accion!=0)
 {


 $.getJSON('Busca_Data.php',{Num_Reque:Identifica_accion},function(solicitud){   
       
           
            //$('select[id="Tipo_solicitud_Id"] option:selected').val(solicitud.Tipo_solicitud_Id);
           
            $('#Tipo_solicitud_Id').val(solicitud.Tipo_solicitud_Id);
            $('#Status_decision_Id').val(solicitud.Status_Decision_Id);
            $('#Solicitante_Perfil_Id').val(solicitud.Solicitante_Id);
            $('#Unidad_requerente_Id').val(solicitud.Unidad_requerente_Id);
            //$('#Unidad_requerente_Id_a option:selected').val(solicitud.Unidad_requerente_Id_a);
            $('#fechaR').val(solicitud.Solicitud_maestro_fecha);
            $('#fecha_Cambio').val(solicitud.Solicitud_maestro_status_fecha);
            $('#Num_Reque').val(solicitud.Solicitud_Numero);
           
        });
       
   


 }// cierra el if identifica_accion

$("#enlace").click(function() {
     location.href = this.href; // ir al link
});


$("#Num_Reque").blur(function(){
  if($(this).val() == '') {
    $(this).after('<div class="error">Numero de Requisicion Requerido.</div>');
    hasError = true;
  }else{
      $.post("Valida_Reque.php",{Num_r:$(this).val()},function(result){if (result!=0){alert(result);$("#enlace").click();}});
  }
 
 
});







       // $.jgrid.formatter.integer.thousandsSeparator = ',';
        $.jgrid.formatter.number.thousandsSeparator = '.';
         $.jgrid.formatter.number.decimalSeparator = ',';
         $.jgrid.formatter.number.decimalPlaces = 2;
      //  $.jgrid.formatter.currency.thousandsSeparator = ',';
   
   
        var drenglon = (function () {
            var list = null;
           
            $.ajax({
                async: false,
                global: false,
                url: 'Renglon.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();

   
   
    var drubro = (function () {
            var list = null;
           
            $.ajax({
                async: false,
                global: false,
                url: 'Rubro.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();
   
   
    var dsistema = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Sistema.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();
       
        var dmedida = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Medida.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();   
       
   
           

    var dtamano = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Tamano.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();   

    var dmaduracion = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Maduracion.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();   
           
    var dcalidad = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Calidad.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();   

    var dpresentacion = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Presentacion.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();

    var dempaque = (function () {
            var list = null;

            $.ajax({
                async: false,
                global: false,
                url: 'Empaque.php',
                dataType: 'json',
                success: function (data) {
                    list = data;
                }
            });

            return list;
        })();

               
$("#grps").jqGrid({
url:'Carga_Datos.php?filtro='+<?php echo $_GET['rp'];?>,
datatype: 'json',
mtype: 'GET',
  colNames: ['Renglon','Rubro','Sistema','Medida','Cantidad', 'Tamano', 'Maduracion','Calidad','Presentacion','Empaque'],
          colModel: [
          { name: 'Renglon', index: 'Renglon', width: 80, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: drenglon,dataEvents: [{type: 'change',
                 fn: function(e)
                {
                        
                       
                       
                          $("#grps").setColProp("Rubro", {editoptions: { value: drubro}});
                           var v = parseInt($(e.target).val(), 10);
                              $.ajax({
                             url: "Rubro_Filtro.php?Id="+v,
                             dataType: "html",
                             success: function(data)
                             {
                           
                           
                             if ($(e.target).is(".FormElement"))
                                {
                                
                                   var form = $(e.target).closest("form.FormGrid");                                                      
                                   $("select#Rubro.FormElement", form[0]).html(data);
                                  
                                }else{
                                 // inline editing
                                  var row = $(e.target).closest("tr.jqgrow");
                                  var rowId = row.attr("id");
                                   $("select#" + rowId + "_Rubro", row[0]).html(data);
                               
                               
                              }// cierra el if
                             
                           }// cierra funcion de comprobacion de exito
                          
                          
                        }); // cierra el ajax
                       
                }//cierra funcion e
   
           }]//cierra evento change
   
   
     }// cierra editoptions
     }, // cierra la linea de sistema
    { name: 'Rubro', index: 'Rubro', width: 80, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: drubro},sortable: true},
     { name: 'Sistema', index: 'Sistema', width: 80, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: dsistema,dataEvents: [{type: 'change',
                 fn: function(e)
                {
                        
                       
                       
                          $("#grps").setColProp("Medida", {editoptions: { value: dmedida}});
                           var v = parseInt($(e.target).val(), 10);
                              $.ajax({
                             url: "Medida_Filtro.php?Id="+v,
                             dataType: "html",
                             success: function(data)
                             {
                           
                           
                             if ($(e.target).is(".FormElement"))
                                {
                                
                                   var form = $(e.target).closest("form.FormGrid");                                                      
                                   $("select#Medida.FormElement", form[0]).html(data);
                                  
                                }else{
                                 // inline editing
                                  var row = $(e.target).closest("tr.jqgrow");
                                  var rowId = row.attr("id");
                                   $("select#" + rowId + "_Medida", row[0]).html(data);
                               
                               
                              }// cierra el if
                             
                           }// cierra funcion de comprobacion de exito
                          
                          
                        }); // cierra el ajax
                       
                }//cierra funcion e
   
           }]//cierra evento change
   
   
     }// cierra editoptions
     }, // cierra la linea de sistema
   
     { name: 'Medida', index: 'Medida', width: 80, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: dmedida},sortable: true},
     { name: 'Cantidad', index: 'Cantidad', width: 80, align: 'left',editable: true,editrules:{required:true,number:true},formatter: 'number',edittype:'text',editoptions:{dataEvents: [
  
    {
   // Este codigo permite pasar a la celda    siguiente y editarla automaticamente, ademas controla que no se escriban caracteres que no sean numeros.
 type: 'keypress',
        fn: function(e) {
            var key = e.charCode || e.keyCode; // to support all browsers
             if (key == 13){setTimeout("jQuery('#grps').editCell(" + selIRow + " + 1, " + selICol + ", true);", 100);}
             if((key < 48 || key > 57) &&   key !== 46 && key !== 44 && key !== 8 &&  key !== 37 && key !== 39){ return false;}
        }// cierra la funcion e
    }// cierra el control del keypress

   
]   
     }// cierra editoptions
     }, // cierra la linea de sistema
   
   
   
   
   
   
   
      { name: 'Tamano', index: 'Tamano', width: 80, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: dtamano},sortable: true},
      { name: 'Maduracion', index: 'Maduracion', width: 80, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: dmaduracion},sortable: true},
      { name: 'Calidad', index: 'Calidad', width: 80, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: dcalidad},sortable: true},
     { name: 'Presentacion', index: 'Presentacion', width: 80, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: dpresentacion},sortable: true},
      { name: 'Empaque', index: 'Empaque', width: 80, align: 'left',editable: true,editrules:{required:true},formatter:'select',edittype:"select",editoptions:{value: dempaque},sortable: true},
      ],
   
    rownumbers:true,
    pager: '#pgrps',
    rowNum:15,
    rowList:[10,25,50,100],
    autowidth: true,
    viewrecords: true,
    width: "98%",
    height: "100%",
    editurl: "someurl.php",
    caption: 'Carga Asientos Contables',
    footerrow: true,
    cellEdit: true,
    cellurl:"otro.php",//Esta es una pagina vacia php
   




   

//importante agregar este codigo para capturar el id de la celda y columna.
beforeEditCell : function(rowid, cellname, value, iRow, iCol)
{
    selICol = iCol;
    selIRow = iRow;
},


afterSaveCell: function (rowid, cellname, value,iRow, iCol) {
                    if (cellname === 'Cantidad') {
                        var sum = jQuery("#grps").jqGrid('getCol', 'Cantidad', false, 'sum');
                        jQuery("#grps").jqGrid('footerData','set', {Rubro: 'Total:', Cantidad: sum});
                    }
                },
       

afterInsertRow:function() {
             var sum = jQuery("#grps").jqGrid('getCol', 'Cantidad', false, 'sum');
             jQuery("#grps").jqGrid('footerData','set', {Rubro: 'Total:', Cantidad: sum});
        },
 
gridComplete: function(){
             var sum = jQuery("#grps").jqGrid('getCol', 'Cantidad', false, 'sum');
             jQuery("#grps").jqGrid('footerData','set', {Rubro: 'Total:', Cantidad: sum});
        },

  });


jQuery("#grps").jqGrid('navGrid','#pgrps',{pdf:true}, //options
{reloadAfterSubmit:false,closeAfterEdit:true,recreateForm:true},// edit
{height:400,width:600,reloadAfterSubmit:false,closeAfterAdd:false,recreateForm:true}, // add options
{reloadAfterSubmit:false}, // del options
{multipleSearch:true,closeAfterSearch: true, closeOnEscape: true}

);






$("#bedata").click(function()
        {
       
       
        //jQuery("#grps").jqGrid('excelExport',{tag:"pdf","url":"querygrid.php"});
             
                if(!confirm(" Esta seguro  de Grabar los asientos?"))  {return false;}
                else {
                   
                     var busca_error =0;
                     var mensaje ="";
                     var status = $('#Status_decision_Id option:selected').val();
                     var Fecha = $('#fechaR').val();
                     var Num_r =$('#Num_Reque').val();
                     var Solicitante =$('#Solicitante_Perfil_Id').val();
                     var Unidad =$('#Unidad_requerente_Id option:selected').val();
                     var Fecha_Solicitud = $('#fecha_Cambio').val();
                    // var Destino = $('#Unidad_requerente_Id_a').val();
                     //var Destino ="";
                     var Fecha_Desde = $('#Fecha_Desde').val();
                     var Fecha_Hasta = $('#Fecha_Hasta').val();
                     var Tipo_Requisicion = $('#Tipo_solicitud_Id option:selected').val();
                     cantidad = $("#grps tbody").find("tr").length;


                     if (cantidad==1){busca_error=2;mensaje="No Puede Grabar Registros en blanco";}
                     if ($("#Status_decision_Id option:selected").text()=="Seleccione"){busca_error=1;mensaje="Status";}
                     if (Fecha==""){busca_error=1;mensaje="Fecha";}
                     if (Num_r==""){busca_error=1;mensaje="Numero Requisicion";}
                     if ($("#Solicitante_Perfil_Id option:selected").text()=="Seleccione"){busca_error=1;mensaje="Solicitante_Perfil";}
                     if ($("#Unidad_requerente_Id option:selected").text()=="Seleccione"){busca_error=1;mensaje="Unidad_requerente_Id";}
                     if (Fecha_Solicitud==""){busca_error=1;mensaje="Fecha_Solicitud";}
                    // if ($("#Unidad_requerente_Id_a option:selected").text()=="Seleccione"){busca_error=1;mensaje="Destino";}
                     if (Fecha_Desde==""){busca_error=1;mensaje="Fecha_Desde";}
                     if (Fecha_Hasta==""){busca_error=1;mensaje="Fecha_Hasta";}
                     if ($("#Tipo_solicitud_Id option:selected").text()=="Seleccione"){busca_error=1;mensaje="Tipo_solicitud";}

if(busca_error==0)
{                   
                        var z=0;
                     var texto ="";
                     var columns = new Array ();
                     var lista = jQuery("#grps").getDataIDs();
                     for(i=0;i<lista.length;i++)
                        {
                            rowData=jQuery("#grps").getRowData(lista[i]);
                            columns[z]=rowData.Renglon+';'+rowData.Rubro+';'+rowData.Sistema+';'+rowData.Medida+';'+parseInt(rowData.Cantidad)+';'+rowData.Tamano+';'+rowData.Maduracion+';'+rowData.Calidad+';'+rowData.Presentacion+';'+rowData.Empaque;
                            z++;
                       }// cierra el for

   
    var jObject={};
    for(i in columns)
    {
        jObject[i] = columns[i];
    }
   
        // window.open('pruebaz.php?Numero='+Num_r,'PDF','width=200,height=400');
        //window.open('pruebaz.php','PDF','width=200,height=400');
        //$.get("pruebaz.php", { 'z': jObject} );
        //$.get("pruebaz.php", {jObject});

       
           
                      $.post("Graba.php",{jObject:  jObject,status:status,Fecha:Fecha,Num_r:Num_r,Solicitante:Solicitante,Unidad:Unidad,Fecha_Solicitud:Fecha_Solicitud,Fecha_Desde:Fecha_Desde,Fecha_Hasta:Fecha_Hasta,Tipo_Requisicion:Tipo_Requisicion,Identifica_accion:Identifica_accion},function(result)
                         {
                         alert(result);
                         $("#enlace").click();
                         });
                         // return false;
                       

}else{

if (busca_error==1){alert('Ingrese un Valor para el Campo '+mensaje);}
if (busca_error==2){alert(mensaje);}
}




                     }   // cierra el confirm   
                   
                   
                        
        });  // cierra la funcion clic
       
       



       
});
</script>
</head>





       


<body>

<table width="900" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td><a href="index.php?m=1&amp;p=0" id='enlace' name='enlace'>Volver al listado</a></td>
  </tr>
</table>
<br />
<form id="Forma_Solicitud" name="Forma_Solicitud" method="post" action="Solicitud.php">






<div id="Tabla"align="center">
  <p>&nbsp;</p>
  <table width="900" border="1" align="center" cellpadding="3" cellspacing="0" class="srcTabla">
  <tr>
    <td colspan="9" align="center" valign="middle" nowrap="nowrap" bgcolor="#ECECEC"><div align="center"><strong>SOLICITUD DE REQUISICION </strong></div></td>
  </tr>
  <tr>
    <td colspan="5">&nbsp;</td>
    <td><strong>Status</strong></td>
    <td><div id="Combo_Status" style=" float:left">
      <?php LlenarCombo('"Status_decision_Id","Status_decision_Des"', 'Status_decision', 'Seleccione','Status_decision_Id') ?></div></td>
    <td width="29"><strong>Fecha:</strong></td>
    <td width="124"><input name="fechaR" type="text" id="fechaR" size="12" maxlength="10" value="<?php echo date("d/m/Y"); ?>" onkeyup = "this.value=formateafecha(this.value);"/>
      <img src="images/calendar.png" alt="Elija una fecha" name="cal_x_fecha_reg1" width="16" height="16" align="bottom" id="cal_x_fecha_reg1" style="cursor:pointer;cursor:hand;" onMouseOver="crearcalendar_d();" /></td>
  </tr>
  <tr>
    <td width="97"><strong>Numero Requisicion:</strong></td>
    <td width="98"><input type="text" name="Num_Reque" id="Num_Reque" />
    <div id="Combo_Solicitante" style=" float:left"></div>    </td>
    <td width="80"><strong>Solicitante:</strong></td>
    <td width="91"><span style=" float:left">
      <?php LlenarCombo('"Solicitante_Perfil_Id","Solicitante_Perfil_Des"', 'Solicitante_Perfil', 'Seleccione','Solicitante_Perfil_Id') ?>
    </span><span style=" float:left">
     <div id="Combo_Unidad" style=" float:left"></div>
    </span></td>
    <td width="128"><strong>Unidad </strong></td>
    <td width="76"><span style=" float:left">
      <?php LlenarCombo('"Unidad_requerente_Id","Unidad_requerente_Des"', 'Unidad_requerente', 'Seleccione','Unidad_requerente_Id') ?>
    </span></td>
    <td width="103"><strong>Fecha de Solicitud:</strong></td>
    <td colspan="2"><input name="fecha_Cambio" type="text" id="fecha_Cambio" size="12" maxlength="10" value="<?php echo date("d/m/Y"); ?>" onkeyup = "this.value=formateafecha(this.value);"/>
      <img src="images/calendar.png" alt="Elija una fecha" name="cal_x_fecha_reg" width="16" height="16" align="bottom" id="cal_x_fecha_reg" style="cursor:pointer;cursor:hand;" onmouseover="crearcalendar();" />
      <div id="Combo_Destino" style=" float:left"></div></td>
  </tr>
  <tr>
    <td><strong></strong></td>
    <td><span style=" float:left">
      <?php //LlenarCombo('"Unidad_requerente_Id","Unidad_requerente_Des"', 'Unidad_requerente', 'Seleccione','Unidad_requerente_Id_a') ?>
    </span></td>
    <td><strong>Fecha Desde:</strong></td>
    <td><input name="Fecha_Desde" type="text" id="Fecha_Desde" size="12" maxlength="10" value="<?php echo date("d/m/Y"); ?>" onkeyup = "this.value=formateafecha(this.value);"/>
      <img src="images/calendar.png" alt="Elija una fecha" name="cal_x_fecha_reg_23" width="16" height="16" align="bottom" id="cal_x_fecha_reg_23" style="cursor:pointer;cursor:hand;" onmouseover="crearcalendar_Fdesde();" /></td>
    <td><strong>Fecha Hasta</strong>: </td>
    <td><input name="Fecha_Hasta" type="text" id="Fecha_Hasta" size="12" maxlength="10" value="<?php echo date("d/m/Y"); ?>" onkeyup = "this.value=formateafecha(this.value);"/>
      <img src="images/calendar.png" alt="Elija una fecha" name="cal_x_fecha_reg_24" width="16" height="16" align="bottom" id="cal_x_fecha_reg_24" style="cursor:pointer;cursor:hand;" onmouseover="crearcalendar_Fhasta();" />
      <div id="Combo_Tipo_Requision" style=" float:left"></div></td>
    <td><strong>Tipo Requision: </strong></td>
    <td colspan="2"><span style=" float:left">
      <?php LlenarCombo('"Tipo_solicitud_Id","Tipo_solicitud_Des"', 'Tipo_solicitud', 'Seleccione','Tipo_solicitud_Id') ?>
      </span>
      <div id="Combo_Renglon" style=" float:left"></div></td></tr>
</table>
  <p>
    <input type="hidden" name="Renglon_Oculto" Id="Renglon_Oculto" value="<?php echo($_POST['Renglon_Oculto']); ?>" />
    <input type="hidden" name="Id_Renglon_Oculto" Id="Id_Renglon_Oculto"  value="<?php echo($_POST['Id_Renglon_Oculto']); ?>" />
  </p>
</div>


  <table id="grps"></table>
  <p>&nbsp;</p>
  <div id="pgrps"></div>
 
<div id="boton" align="center">
<input type="BUTTON" id="bedata" value="Grabar Requisicion y Generar Informe" />
</div>
</form>
</body>

</html>
<?php }//Cierra Nivel de Seguridad ?>