SHARE
TWEET

get_dropdown_value

gustavopucara May 28th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include_once("../conn/seguridad.php");
  3. include_once("../phpgrid/config.php");
  4. include_once("../conn/funciones_generales.php");
  5.  
  6. $codUsuario = $_SESSION['codUsuario'];
  7.  
  8. $themeid = apariencia($codUsuario);
  9. list($agregar, $editar, $borrar) = PermisoUsuario($_SESSION["codUsuario"], $_SERVER["PHP_SELF"]);
  10.  
  11. $caja = caja();
  12. $CaptionList2 = "FORMA DE PAGO";
  13. $CaptionList3 = "IMPUTACION";
  14. $formas = "E:EFECTIVO;C:CHEQUE;O:OTROS MEDIOS";
  15.  
  16. function add_Pagos($data) {
  17.     global $caja;
  18.     global $codUsuario;
  19.     $data["params"]["codProveedoresPagosCabecera"] = CodMax("proveedorespagoscabeceras", "codProveedoresPagosCabecera");
  20.     $data["params"]["fecha"] = substr($data["params"]["fecha"], 6, 4)."-".substr($data["params"]["fecha"], 3, 2)."-".substr($data["params"]["fecha"], 0, 2);
  21.     $data["params"]["caja"] = $caja;
  22.     $data["params"]["codUsuario"] = $codUsuario;
  23. }
  24. function upd_Pagos($data) {
  25.     $data["params"]["fecha"] = substr($data["params"]["fecha"], 6, 4)."-".substr($data["params"]["fecha"], 3, 2)."-".substr($data["params"]["fecha"], 0, 2);        
  26. }
  27. function del_Pagos($data) {
  28. }
  29. function add_Pagos_Formas($data) {
  30.     $data["params"]["codProveedoresPagosDetalle"] = CodMax("proveedorespagosdetalles", "codProveedoresPagosDetalle");
  31.     $data["params"]["codProveedoresPagosCabecera"] = $_GET["codProveedoresPagosCabecera"];
  32.     if ($data["params"]["formaPago"]=="C") {
  33.         if ($data["params"]["cheque"]=="") phpgrid_error("ERROR: Debe ingresar el numero del cheque");
  34.         if (!checkdate(substr($data["params"]["fechaCheque"], 3, 2), substr($data["params"]["fechaCheque"], 0, 2), substr($data["params"]["fechaCheque"], 4, 4))) phpgrid_error("ERROR: Debe ingresar una fecha valida");
  35.         $data["params"]["cheque"] = str_pad($data["params"]["cheque"], 8, "0", STR_PAD_LEFT);
  36.         $data["params"]["fechaCheque"] = substr($data["params"]["fechaCheque"], 6, 4)."-".substr($data["params"]["fechaCheque"], 3, 2)."-".substr($data["params"]["fechaCheque"], 0, 2);
  37.     } else {
  38.         $data["params"]["codBanco"] = ($data["params"]["formaPago"]=="E") ? 1 : 2;
  39.         $data["params"]["cheque"] = "";
  40.         $data["params"]["fechaCheque"] = "0000-00-00";
  41.     }
  42. }
  43. function upd_Pagos_Formas($data) {
  44.     if ($data["params"]["formaPago"]=="C") {
  45.         if ($data["params"]["cheque"]=="") phpgrid_error("ERROR: Debe ingresar el numero del cheque");
  46.         if (!checkdate(substr($data["params"]["fechaCheque"], 3, 2), substr($data["params"]["fechaCheque"], 0, 2), substr($data["params"]["fechaCheque"], 4, 4))) phpgrid_error("ERROR: Debe ingresar una fecha valida");
  47.         $data["params"]["cheque"] = str_pad($data["params"]["cheque"], 8, "0", STR_PAD_LEFT);
  48.         $data["params"]["fechaCheque"] = substr($data["params"]["fechaCheque"], 6, 4)."-".substr($data["params"]["fechaCheque"], 3, 2)."-".substr($data["params"]["fechaCheque"], 0, 2);
  49.     } else {
  50.         $data["params"]["codBanco"] = ($data["params"]["formaPago"]=="E") ? 1 : 2;
  51.         $data["params"]["cheque"] = "";
  52.         $data["params"]["fechaCheque"] = "0000-00-00";
  53.     }
  54. }
  55. function del_Pagos_Formas($data) {
  56.     global $mysqli;
  57.     $codProveedoresPagosCabecera = $_GET["codProveedoresPagosCabecera"];
  58.     $sql = "SELECT codProveedoresPagosImputacion FROM proveedorespagosimputacion WHERE codProveedoresPagosCabecera='$codProveedoresPagosCabecera'";
  59.     $result = $mysqli->query($sql);
  60.     if ($result->num_rows>0) phpgrid_error("ERROR: El recibo tiene comprobante/s imputados");
  61. }
  62. function add_Pagos_Imputacion($data) {
  63.     global $mysqli;
  64.     $data["params"]["codProveedoresPagosCabecera"] = $_GET["codProveedoresPagosCabecera"];
  65.     $codProveedor = $_GET["codProveedor"];
  66.     $sql = "SELECT totalComprobante+totalDescuento-totalAplicado saldo FROM proveedorespagoscabeceras WHERE codProveedoresPagosCabecera='{$data["params"]["codProveedoresPagosCabecera"]}'";
  67.     $result = $mysqli->query($sql);
  68.     if ($result->num_rows>0) {
  69.         $row = $result->fetch_object();
  70.         if ($data["params"]["totalImputacion"]<+$row->saldo) {
  71.             $sql = "SELECT codProveedor, totalComprobante-totalPagado deuda FROM proveedorescabeceras WHERE codProveedoresCabecera='{$data["params"]["codProveedoresCabecera"]}'";
  72.             $result = $mysqli->query($sql);
  73.             if ($result->num_rows>0) {
  74.                 $row = $result->fetch_object();
  75.                 if ($row->codProveedor==$codProveedor) {
  76.                     if ($data["params"]["totalImputacion"]>$row->deuda) phpgrid_error("ERROR: Total imputado supera deuda de la factura");
  77.                 } else {
  78.                     phpgrid_error("ERROR : El proveedor del recibo difiere del proveedor de la factura");
  79.                 }
  80.             }
  81.         } else {
  82.             phpgrid_error("ERROR: La imputacion supera a el saldo del recibo");
  83.         }
  84.     } else {
  85.         phpgrid_error("ERROR: Llame a Sistemas");
  86.     }            
  87.     $data["params"]["codProveedoresPagosImputacion"] = CodMax("proveedorespagosimputacion", "codProveedoresPagosImputacion");
  88. }
  89. function del_Pagos_Imputacion($data) {
  90. }
  91. // include and create object
  92. include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
  93.  
  94. // Database config file to be passed in phpgrid constructor
  95. $db_conf = array("type" => PHPGRID_DBTYPE, "server" => PHPGRID_DBHOST, "user" => PHPGRID_DBUSER, "password" => PHPGRID_DBPASS, "database" => PHPGRID_DBNAME );
  96.  
  97. $g = new jqgrid($db_conf);
  98.  
  99. $opt["caption"] = "PAGOS";
  100. $opt["toolbar"] = "bottom";
  101. $opt["sortname"] = "codProveedoresPagosCabecera";
  102. $opt["sortorder"] = "DESC";
  103. $opt["autowidth"] = true;
  104. $opt["rowNum"] = 5;
  105. $opt["height"] = "";
  106. $opt["detail_grid_id"] = "list2,list3";
  107. $opt["subgridparams"] = "codProveedoresPagosCabecera,codProveedor";
  108. $opt["add_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'580');
  109. $opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'580');
  110. $g->set_options($opt);
  111.  
  112. $g->set_actions(array("add"=>$agregar, "edit"=>$editar, "bulkedit"=>false, "delete"=>$borrar, "rowactions"=>false, "autofilter" => true, "search" => "simple"));
  113.  
  114. $e["on_insert"] = array("add_Pagos", null, true);
  115. $e["on_update"] = array("upd_Pagos", null, true);
  116. $e["on_delete"] = array("del_Pagos", null, true);
  117. $g->set_events($e);
  118.  
  119. $sql = "SELECT pc.codProveedoresPagosCabecera, pc.codProveedor, DATE_FORMAT(pc.fecha, '%d-%m-%Y') fecha, pc.caja, pc.totalEfectivo, pc.totalCheque, pc.totalOtro, pc.totalDescuento, pc.totalComprobante, pc.totalAplicado, pc.codUsuario, pr.razonSocial razonSocial
  120.         FROM ProveedoresPagoscabeceras pc
  121.         INNER JOIN proveedores pr ON pr.codProveedor=pc.codProveedor";
  122.  
  123. $g->select_command = $sql;
  124.  
  125. // set table for CRUD operations
  126. $g->table = "proveedorespagoscabeceras";  
  127.  
  128. $col = array();
  129. $col["title"] = "Id";
  130. $col["name"] = "codProveedoresPagosCabecera";
  131. $col["hidden"] = true;
  132. $col["autoid"] = false;
  133. $col["show"] = array("list"=>false, "add"=>true, "edit"=>true, "view"=>true);
  134. $cols[] = $col;
  135.  
  136. $col = array();
  137. $col["title"] = "Caja";
  138. $col["name"] = "caja";
  139. $col["editable"] = true;
  140. $col["hidden"] = true;
  141. $cols[] = $col;
  142.  
  143. $col = array();
  144. $col["title"] = "Proveedor";
  145. $col["name"] = "codProveedor";
  146. $col["editable"] = true;
  147. $col["hidden"] = true;
  148. $cols[] = $col;
  149.  
  150. $col = array();
  151. $col["title"] = "Nombre";
  152. $col["name"] = "razonSocial";
  153. $col["editable"] = true;
  154. $col["width"] = "120";
  155. $col["editoptions"] = array("size"=>50, "maxlength" => "50");
  156. $col["formatter"] = "autocomplete"; // autocomplete
  157. $col["formatoptions"] = array( "sql"=>"SELECT codProveedor as k, razonSocial as v from proveedores", "search_on"=>"razonSocial", "update_field" => "codProveedor");
  158. $cols[] = $col;
  159.  
  160. $col = array();
  161. $col["title"] = "Fecha";
  162. $col["name"] = "fecha";
  163. $col["editable"] = true;
  164. $col["editrules"] = array("required"=>true);
  165. $col["editoptions"] = array("size"=>10, "onKeyUp"=>"this.value=formateafecha(this.value)");
  166. $col["width"] = "30";
  167. $col["align"] = "center";  
  168. $cols[] = $col;
  169.  
  170. $col = array();
  171. $col["title"] = "Efectivo";
  172. $col["name"] = "totalEfectivo";
  173. $col["width"] = "30";
  174. $col["align"] = "right";  
  175. $cols[] = $col;
  176.  
  177. $col = array();
  178. $col["title"] = "Cheque";
  179. $col["name"] = "totalCheque";
  180. $col["width"] = "30";
  181. $col["align"] = "right";  
  182. $cols[] = $col;
  183.  
  184. $col = array();
  185. $col["title"] = "Otros";
  186. $col["name"] = "totalOtro";
  187. $col["width"] = "30";
  188. $col["align"] = "right";  
  189. $cols[] = $col;
  190.  
  191. $col = array();
  192. $col["title"] = "Descuento";
  193. $col["name"] = "totalDescuento";
  194. $col["width"] = "30";
  195. $col["align"] = "right";
  196. $col["editable"] = true;
  197. $col["editoptions"] = array("size"=>15, "maxlength"=>"15", "onkeypress"=>"if (event.keyCode < 46 || event.keyCode > 57) event.returnValue = false");
  198. $cols[] = $col;
  199.  
  200. $col = array();
  201. $col["title"] = "Total";
  202. $col["name"] = "totalComprobante";
  203. $col["width"] = "30";
  204. $col["align"] = "right";  
  205. $cols[] = $col;
  206.  
  207. $g->set_columns($cols);
  208.  
  209. // render grid
  210. $out_master = $g->render("list1");
  211.  
  212. $g = new jqgrid($db_conf);
  213.  
  214. $cols = array();
  215. $opt = array();
  216.  
  217. $opt["caption"] = $CaptionList2;
  218. $opt["toolbar"] = "bottom";
  219. $opt["sortname"] = "codProveedoresPagosDetalle";
  220. $opt["autowidth"] = true;
  221. $opt["rowNum"] = 5;
  222. $opt["height"] = "";
  223. $opt["add_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'580');
  224. $opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'580');
  225. $opt["loadComplete"] = "function(ids) {
  226.    if ($('#list1').jqGrid('getGridParam','selrow')) {
  227.        $('#list2').setCaption('$CaptionList2 - ' + jQuery('#list1').jqGrid('getCell', $('#list1').jqGrid('getGridParam','selrow'), 'razonSocial'));
  228.    } else {
  229.        $('#list2').setCaption('$CaptionList2');
  230.    }
  231. }";
  232. $opt["add_options"]["afterComplete"] = "function(){
  233.    var selr = jQuery('#list1').jqGrid('getGridParam','selrow');
  234.    jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]);
  235.    setTimeout( function(){
  236.        jQuery('#list1').setSelection(selr,true);
  237.        jQuery('#list2').trigger('reloadGrid',[{jqgrid_page:1}]);
  238.    },500);
  239. }";
  240. $opt["edit_options"]["afterComplete"] = $opt["add_options"]["afterComplete"];
  241. $opt["delete_options"]["afterComplete"] = $opt["add_options"]["afterComplete"];
  242.  
  243. $g->set_options($opt);
  244.  
  245. $g->set_actions(array("add"=>$agregar, "edit"=>$editar, "bulkedit"=>false, "delete"=>$borrar, "rowactions"=>false, "autofilter" => true, "search" => "simple"));
  246.  
  247. $e["on_insert"] = array("add_Pagos_Formas", null, true);
  248. $e["on_update"] = array("upd_Pagos_Formas", null, true);
  249. $e["on_delete"] = array("del_Pagos_Formas", null, true);
  250. $g->set_events($e);
  251.  
  252. $codProveedoresPagosCabecera = intval($_GET["codProveedoresPagosCabecera"]);
  253.  
  254. $sql = "SELECT pd.codProveedoresPagosDetalle, pd.formaPago, pd.codBanco, pd.cheque, DATE_FORMAT(pd.fechaCheque, '%d-%m-%Y') fechaCheque, pd.monto, pd.observacion, ba.banco
  255.        FROM ProveedoresPagosdetalles pd
  256.        INNER JOIN bancos ba ON ba.codBanco=pd.codBanco
  257.        WHERE pd.codProveedoresPagosCabecera='$codProveedoresPagosCabecera'";
  258.  
  259. $g->select_command = $sql;
  260.  
  261. // set table for CRUD operations
  262. $g->table = "proveedorespagosdetalles";  
  263.  
  264. $col["title"] = "Id";
  265. $col["name"] = "codProveedoresPagosDetalle";
  266. $col["hidden"] = true;
  267. $col["autoid"] = false;
  268. $col["show"] = array("list"=>false, "add"=>true, "edit"=>true, "view"=>true);
  269. $cols[] = $col;
  270.  
  271. $col = array();
  272. $col["title"] = "Banco";
  273. $col["name"] = "codBanco";
  274. $col["editable"] = true;
  275. $col["editrules"] = array("required"=>true);
  276. $col["hidden"] = true;
  277. $cols[] = $col;
  278.  
  279. $col = array();
  280. $col["title"] = "Forma";
  281. $col["name"] = "formaPago";
  282. $col["editoptions"] = array("value"=>$formas);
  283. $col["searchoptions"] = array("value"=>":;".$formas);
  284. $col["edittype"] = "select";
  285. $col["stype"] = "select";
  286. $col["formatter"] = "select";
  287. $col["editable"] = true;
  288. $col["width"] = "25";
  289. $cols[] = $col;
  290.  
  291. $col = array();
  292. $col["title"] = "Banco";
  293. $col["name"] = "banco";
  294. $col["editable"] = true;
  295. $col["width"] = "100";
  296. $col["editoptions"] = array("size"=>50, "maxlength" => "50");
  297. $col["formatter"] = "autocomplete"; // autocomplete
  298. $col["formatoptions"] = array( "sql"=>"SELECT codBanco as k, banco as v from bancos WHERE propio='S'", "search_on"=>"banco", "update_field" => "codBanco");
  299. $cols[] = $col;
  300.  
  301. $col = array();
  302. $col["title"] = "Cheque";
  303. $col["name"] = "cheque";
  304. $col["editable"] = true;
  305. $col["editoptions"] = array("size"=>10, "maxlength"=>"10", "onkeypress"=>"if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false");
  306. $col["width"] = "30";
  307. $col["align"] = "center";
  308. $cols[] = $col;
  309.  
  310. $col = array();
  311. $col["title"] = "Fecha";
  312. $col["name"] = "fechaCheque";
  313. $col["editable"] = true;
  314. $col["editoptions"] = array("size"=>10, "onKeyUp"=>"this.value=formateafecha(this.value)");
  315. $col["width"] = "30";
  316. $col["align"] = "center";  
  317. $cols[] = $col;
  318.  
  319. $col = array();
  320. $col["title"] = "Monto";
  321. $col["name"] = "monto";
  322. $col["editable"] = true;
  323. $col["editoptions"] = array("size"=>10, "maxlength"=>"10", "onkeypress"=>"if (event.keyCode < 46 || event.keyCode > 57) event.returnValue = false");
  324. $col["editrules"] = array("required"=>true);
  325. $col["width"] = "30";
  326. $col["align"] = "right";
  327. $cols[] = $col;
  328.  
  329. $col = array();
  330. $col["title"] = "Observacion";
  331. $col["name"] = "observacion";
  332. $col["editable"] = true;
  333. $col["editoptions"] = array("size"=>50, "maxlength" => "100");
  334. $col["width"] = 60;
  335. $cols[] = $col;
  336.  
  337. $g->set_columns($cols);
  338.  
  339. // render grid
  340. $out_detail_1 = $g->render("list2");
  341.  
  342. $g = new jqgrid($db_conf);
  343.  
  344. $cols = array();
  345. $opt = array();
  346.  
  347. $opt["caption"] = $CaptionList3;
  348. $opt["toolbar"] = "bottom";
  349. $opt["sortname"] = "codProveedoresPagosImputacion";
  350. $opt["autowidth"] = true;
  351. $opt["rowNum"] = 5;
  352. $opt["height"] = "";
  353. $opt["add_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'580');
  354. $opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'580');
  355. $opt["loadComplete"] = "function(ids) {
  356.    if ($('#list1').jqGrid('getGridParam','selrow')) {
  357.        $('#list3').setCaption('$CaptionList3 - ' + jQuery('#list1').jqGrid('getCell', $('#list1').jqGrid('getGridParam','selrow'), 'razonSocial'));
  358.    } else {
  359.        $('#list3').setCaption('$CaptionList3');
  360.    }
  361. }";
  362. $g->set_options($opt);
  363.  
  364. $g->set_actions(array("add"=>$agregar, "edit"=>false, "bulkedit"=>false, "delete"=>$borrar, "rowactions"=>false, "autofilter" => true, "search" => "simple"));
  365.  
  366. $e["on_insert"] = array("add_Pagos_Imputacion", null, true);
  367. $e["on_delete"] = array("del_Pagos_Imputacion", null, true);
  368. $g->set_events($e);
  369.  
  370. $codProveedoresPagosCabecera = intval($_GET["codProveedoresPagosCabecera"]);
  371. $codProveedore = intval($_GET["codProveedor"]);
  372.  
  373. $sql = "SELECT pi.codProveedoresPagosImputacion, pi.codProveedoresPagosCabecera, pi.codProveedoresCabecera, pi.totalImputacion, CONCAT(tl.tipoLetra, ' ',sucursal, ' ',numero, ' ',date_format(fecha, '%d-%m-%Y')) comprobante
  374.        FROM proveedorespagosimputacion pi
  375.        INNER JOIN proveedorescabeceras pc ON pc.codProveedoresCabecera=pi.codProveedoresCabecera
  376.        INNER JOIN tipoletras tl ON tl.codTipoLetra=pc.codTipoLetra
  377.        WHERE codProveedoresPagosCabecera='$codProveedoresPagosCabecera'";
  378.  
  379. $g->select_command = $sql;
  380.  
  381. // set table for CRUD operations
  382. $g->table = "proveedorespagosimputacion";  
  383.  
  384. $col = array();
  385. $col["title"] = "Id";
  386. $col["name"] = "codProveedoresPagosImputacion";
  387. $col["hidden"] = true;
  388. $col["autoid"] = false;
  389. $cols[] = $col;
  390.  
  391. $col = array();
  392. $col["title"] = "Comprobante";
  393. $col["name"] = "codProveedoresCabecera";
  394. $col["editable"] = true;
  395. $col["hidden"] = true;
  396. $cols[] = $col;
  397.  
  398. $col = array();
  399. $col["title"] = "Comprobante";
  400. $col["name"] = "comprobante";
  401. $col["editable"] = true;
  402. $col["width"] = "120";
  403. $col["editoptions"] = array("size"=>35, "maxlength" => "35");
  404. $col["formatter"] = "autocomplete";
  405. $col["formatoptions"] = array( "sql"=>"SELECT codProveedoresCabecera as k, CONCAT(tl.tipoLetra, ' ',sucursal, ' ',numero, ' ',date_format(fecha, '%d-%m-%Y'), ' ', totalComprobante-totalPagado) as v from proveedorescabeceras pc INNER JOIN tipoletras tl ON tl.codTipoLetra=pc.codTipoLetra", "search_on"=>"numero", "update_field" => "codProveedoresCabecera");
  406. $cols[] = $col;
  407.  
  408. $col = array();
  409. $col["title"] = "Imputacion";
  410. $col["name"] = "totalImputacion";
  411. $col["editable"] = true;
  412. $col["editoptions"] = array("size"=>10, "maxlength"=>"10", "onkeypress"=>"if (event.keyCode < 46 || event.keyCode > 57) event.returnValue = false");
  413. $col["editrules"] = array("required"=>true);
  414. $col["width"] = "30";
  415. $col["align"] = "right";
  416. $cols[] = $col;
  417.  
  418. $g->set_columns($cols);
  419.  
  420. // render grid
  421. $out_detail_2 = $g->render("list3");
  422.  
  423. ?>
  424.  
  425. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  426. <html>
  427. <head>
  428.     <link rel="stylesheet" type="text/css" media="screen" href="../phpgrid/lib/js/themes/<?php echo $themeid ?>/jquery-ui.custom.css"></link>    
  429.     <link rel="stylesheet" type="text/css" media="screen" href="../phpgrid/lib/js/jqgrid/css/ui.jqgrid.css"></link>    
  430.      
  431.     <script src="../js/utiles.js" type="text/javascript"></script>
  432.     <script src="../phpgrid/lib/js/jquery.min.js" type="text/javascript"></script>
  433.     <script src="../phpgrid/lib/js/jqgrid/js/i18n/grid.locale-es.js" type="text/javascript"></script>
  434.     <script src="../phpgrid/lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>    
  435.     <script src="../phpgrid/lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  436. </head>
  437. <body>
  438.     <div style="margin:10px">
  439.         <?php echo $out_master?>
  440.         <br>
  441.         <?php echo $out_detail_1?>
  442.         <br>
  443.         <?php echo $out_detail_2?>
  444.     </div>
  445. </body>
  446. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top