Advertisement
Guest User

Lecturas

a guest
Aug 8th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 25.55 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. require_once("plantilla.php");
  4. checkLogin();
  5.  
  6. $anyoagua = isset($_REQUEST["anyo"])? (int)$_REQUEST["anyo"] : 2017;
  7.  
  8. displayForm($anyoagua);
  9.  
  10.  
  11. function displayForm($anyoagua) {
  12.  
  13.     mysql_connect(DB_DSN_GRID,DB_USER_GRID ,DB_PASS_GRID);
  14.     mysql_select_db(DB_DB_GRID);
  15.  
  16.     include("../lib/inc/jqgrid_dist.php");
  17.    
  18.    
  19.     global $anyoagua;
  20.        
  21.     $g = new jqgrid();
  22.    
  23.     //ID lectura
  24.     $col = array();
  25.     $col["title"] = "ID"; // caption of column
  26.     $col["name"] = "la_id"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  27.     $col["width"] = "4";
  28.     $col["editable"] = false;
  29.     $col["export"]=false;
  30.     $col["hidden"] = true;
  31.     $col["editrules"] = array("edithidden"=>true);  
  32.     $cols[] = $col;
  33.    
  34.  
  35.            
  36.     //FECHA
  37.     $col = array();
  38.     $col["title"] = "FECHA"; // caption of column
  39.     $col["name"] = "la_fecha"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  40.     $col["width"] = "9";
  41.     $col["editable"] = true;
  42.     $col["formatter"] = "date";
  43.     $col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d/m/Y');
  44.     $cols[] = $col;
  45.    
  46.    
  47.    
  48.     //UDS c1
  49.     $col = array();
  50.     $col["title"] = "L.COLONIA1"; // caption of column
  51.     $col["name"] = "la_uds_colonia1"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  52.     $col["width"] = "9";
  53.     $col["editable"] = true;
  54.     //$col["formatter"] = "number";
  55.     $col["editoptions"] = array("size"=>12);
  56.     //$col["formatoptions"] = array("thousandsSeparator" =>".");
  57.     $col["align"] = "right";   
  58.     $col["editoptions"]["autocomplete"] = "false";
  59.     $cols[] = $col;
  60.    
  61.     //CONSUMO c1
  62.     $col = array();
  63.     $col["title"] = ""; // caption of column
  64.     $col["name"] = "la_consumo_colonia1"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  65.     $col["width"] = "9";
  66.     $col["editable"] = false;
  67.     //$col["formatter"] = "number";
  68.     $col["editoptions"] = array("size"=>12);
  69.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  70.     $col["align"] = "right";
  71.     $col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
  72.     $col["summaryTpl"] = '<b>Total: {0}</b>'; // display html for summary row - work when "groupSummary" is set true. search below
  73.     $cols[] = $col;
  74.     /*
  75.     $col["summaryType"] = function (val, name, record) {
  76.         // val.totalCount += 1;
  77.         // if (record[name]) {
  78.             // val.checkedCount += 1;
  79.             // val.max = true;
  80.         // }
  81.         // return val;
  82.         return 3;
  83.     }
  84.     */
  85.    
  86.  
  87.    
  88.     //UDS c2
  89.     $col = array();
  90.     $col["title"] = "L.COLONIA2"; // caption of column
  91.     $col["name"] = "la_uds_colonia2"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  92.     $col["width"] = "9";
  93.     $col["editable"] = true;
  94.     //$col["formatter"] = "number";
  95.     $col["editoptions"] = array("size"=>12);
  96.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  97.     $col["align"] = "right";
  98.     $col["editoptions"]["autocomplete"] = "false";
  99.     $cols[] = $col;
  100.    
  101.     //CONSUMO c2
  102.     $col = array();
  103.     $col["title"] = ""; // caption of column
  104.     $col["name"] = "la_consumo_colonia2"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  105.     $col["width"] = "9";
  106.     $col["editable"] = false;
  107.     //$col["formatter"] = "number";
  108.     $col["editoptions"] = array("size"=>12);
  109.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  110.     $col["align"] = "right";
  111.     $col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
  112.     $col["summaryTpl"] = '<b>Total: {0}</b>'; // display html for summary row - work when "groupSummary" is set true. search below
  113.     $cols[] = $col;
  114.    
  115.     //UDS MIRALLES
  116.     $col = array();
  117.     $col["title"] = "L.MIRALLES"; // caption of column
  118.     $col["name"] = "la_uds_miralles"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  119.     $col["width"] = "9";
  120.     $col["editable"] = true;
  121.     //$col["formatter"] = "number";
  122.     $col["editoptions"] = array("size"=>12);
  123.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  124.     $col["align"] = "right";
  125.     $col["editoptions"]["autocomplete"] = "false";
  126.     $cols[] = $col;
  127.    
  128.     //CONSUMO MIRALLES
  129.     $col = array();
  130.     $col["title"] = ""; // caption of column
  131.     $col["name"] = "la_consumo_miralles"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  132.     $col["width"] = "9";
  133.     $col["editable"] = false;
  134.     //$col["formatter"] = "number";
  135.     $col["editoptions"] = array("size"=>12);
  136.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  137.     $col["align"] = "right";
  138.     $col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
  139.     $col["summaryTpl"] = '<b>Total: {0}</b>'; // display html for summary row - work when "groupSummary" is set true. search below
  140.     $cols[] = $col;
  141.    
  142.     //UDS BORDILS
  143.     $col = array();
  144.     $col["title"] = "L.BORDILS"; // caption of column
  145.     $col["name"] = "la_uds_bordils"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  146.     $col["width"] = "9";
  147.     $col["editable"] = true;
  148.     //$col["formatter"] = "number";
  149.     $col["editoptions"] = array("size"=>12);
  150.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  151.     $col["align"] = "right";
  152.     $col["editoptions"]["autocomplete"] = "false";
  153.     $cols[] = $col;
  154.    
  155.     //CONSUMO BORDILS
  156.     $col = array();
  157.     $col["title"] = ""; // caption of column
  158.     $col["name"] = "la_consumo_bordils"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  159.     $col["width"] = "9";
  160.     $col["editable"] = false;
  161.     //$col["formatter"] = "number";
  162.     $col["editoptions"] = array("size"=>12);
  163.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  164.     $col["align"] = "right";
  165.     $col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
  166.     $col["summaryTpl"] = '<b>Total: {0}</b>'; // display html for summary row - work when "groupSummary" is set true. search below
  167.     $cols[] = $col;
  168.    
  169.     //UDS RUBIO
  170.     $col = array();
  171.     $col["title"] = "L.RUBIO"; // caption of column
  172.     $col["name"] = "la_uds_rubio"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  173.     $col["width"] = "9";
  174.     $col["editable"] = true;
  175.     //$col["formatter"] = "number";
  176.     $col["editoptions"] = array("size"=>12);
  177.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  178.     $col["align"] = "right";
  179.     $col["editoptions"]["autocomplete"] = "false";
  180.     $cols[] = $col;
  181.    
  182.     //CONSUMO RUBIO
  183.     $col = array();
  184.     $col["title"] = ""; // caption of column
  185.     $col["name"] = "la_consumo_rubio"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  186.     $col["width"] = "9";
  187.     $col["editable"] = false;
  188.     //$col["formatter"] = "number";
  189.     $col["editoptions"] = array("size"=>12);
  190.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  191.     $col["align"] = "right";
  192.     $col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
  193.     $col["summaryTpl"] = '<b>Total: {0}</b>'; // display html for summary row - work when "groupSummary" is set true. search below  
  194.     $cols[] = $col;
  195.    
  196.     //UDS BAGU
  197.     $col = array();
  198.     $col["title"] = "L.BAGU"; // caption of column
  199.     $col["name"] = "la_uds_bagu"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  200.     $col["width"] = "9";
  201.     $col["editable"] = true;
  202.     //$col["formatter"] = "number";
  203.     $col["editoptions"] = array("size"=>12);
  204.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  205.     $col["align"] = "right";
  206.     $col["editoptions"]["autocomplete"] = "false";
  207.     $cols[] = $col;
  208.    
  209.     //CONSUMO BAGU
  210.     $col = array();
  211.     $col["title"] = ""; // caption of column
  212.     $col["name"] = "la_consumo_bagu"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  213.     $col["width"] = "9";
  214.     $col["editable"] = false;
  215.     //$col["formatter"] = "number";
  216.     $col["editoptions"] = array("size"=>12);
  217.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  218.     $col["align"] = "right";
  219.     $col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
  220.     $col["summaryTpl"] = '<b>Total: {0}</b>'; // display html for summary row - work when "groupSummary" is set true. search below  
  221.     $cols[] = $col;
  222.    
  223.     //UDS APARICI
  224.     $col = array();
  225.     $col["title"] = "L.APARICI"; // caption of column
  226.     $col["name"] = "la_uds_aparici"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  227.     $col["width"] = "9";
  228.     $col["editable"] = true;
  229.     //$col["formatter"] = "number";
  230.     $col["editoptions"] = array("size"=>12);
  231.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  232.     $col["align"] = "right";
  233.     $col["editoptions"]["autocomplete"] = "false";
  234.     $cols[] = $col;
  235.    
  236.     //CONSUMO APARICI
  237.     $col = array();
  238.     $col["title"] = ""; // caption of column
  239.     $col["name"] = "la_consumo_aparici"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  240.     $col["width"] = "9";
  241.     $col["editable"] = false;
  242.     //$col["formatter"] = "number";
  243.     $col["editoptions"] = array("size"=>12);
  244.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  245.     $col["align"] = "right";
  246.     $col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
  247.     $col["summaryTpl"] = '<b>Total: {0}</b>'; // display html for summary row - work when "groupSummary" is set true. search below  
  248.     $cols[] = $col;
  249.    
  250.    
  251.    
  252.     //UDS TOTAL
  253.     $col = array();
  254.     $col["title"] = "L.TOTAL"; // caption of column
  255.     $col["name"] = "la_uds_total"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  256.     $col["width"] = "9";
  257.     $col["editable"] = true;
  258.     //$col["formatter"] = "number";
  259.     $col["editoptions"] = array("size"=>12);
  260.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  261.     $col["align"] = "right";
  262.     $col["editoptions"]["autocomplete"] = "false";
  263.     $cols[] = $col;
  264.    
  265.     //CONSUMO TOTAL
  266.     $col = array();
  267.     $col["title"] = ""; // caption of column
  268.     $col["name"] = "la_consumo_total"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  269.     $col["width"] = "9";
  270.     $col["editable"] = false;
  271.     //$col["formatter"] = "number";
  272.     $col["editoptions"] = array("size"=>12);
  273.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  274.     $col["align"] = "right";
  275.     $col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
  276.     $col["summaryTpl"] = '<b>Total: {0}</b>'; // display html for summary row - work when "groupSummary" is set true. search below
  277.     $cols[] = $col;
  278.    
  279.    
  280.    
  281.     //UDS BALSA
  282.     $col = array();
  283.     $col["title"] = "L.BALSA"; // caption of column
  284.     $col["name"] = "la_uds_balsa"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  285.     $col["width"] = "9";
  286.     $col["editable"] = true;
  287.     //$col["formatter"] = "number";
  288.     $col["editoptions"] = array("size"=>12);
  289.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  290.     $col["align"] = "right";
  291.     $col["editoptions"]["autocomplete"] = "false";
  292.     $cols[] = $col;
  293.    
  294.     //CONSUMO BALSA
  295.     $col = array();
  296.     $col["title"] = ""; // caption of column
  297.     $col["name"] = "la_consumo_balsa"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  298.     $col["width"] = "9";
  299.     $col["editable"] = false;
  300.     //$col["formatter"] = "number";
  301.     $col["editoptions"] = array("size"=>12);
  302.     $col["formatoptions"] = array("thousandsSeparator" =>".");
  303.     $col["align"] = "right";
  304.     $col["summaryType"] = "sum"; // available grouping fx: sum, count, min, max, avg
  305.     $col["summaryTpl"] = '<b>Total: {0}</b>'; // display html for summary row - work when "groupSummary" is set true. search below
  306.     $cols[] = $col;
  307.    
  308.     //MESAÑO
  309.     $col = array();
  310.     $col["title"] = "MESAÑO"; // caption of column
  311.     $col["name"] = "la_mes_anyo"; //grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  312.     $col["width"] = "9";
  313.     $col["editable"] = false;
  314.     //$col["formatter"] = "";
  315.     $col["editoptions"] = array("size"=>12);
  316.     //$col["formatoptions"] = array("thousandsSeparator" =>".");
  317.     $col["align"] = "right";
  318.     $cols[] = $col;
  319.    
  320.    
  321.    
  322.    
  323.    
  324.    
  325.         // set few params
  326.     $grid["caption"] = "LECTURAS AGUA";
  327.     $grid["altRows"]=true;
  328.     $grid["altclass"]="myAltRowClass";
  329.     $grid["autowidth"]=true;
  330.     $grid["toolbar"] = "top";
  331.     $grid["add_options"] = array('width'=>'680');
  332.     $grid["edit_options"] = array('width'=>'680');
  333.     $grid["add_options"] ["success_msg"] = "Registro añadido con éxito!";
  334.     $grid["edit_options"] ["success_msg"] = "Registro actualizado con éxto!";
  335.     $grid["delete_options"] ["success_msg"] = "Registro eliminado con éxito!";
  336.     $grid["form"]["nav"]  = true;
  337.     $grid["sortname"] = 'la_fecha';
  338.     $grid["sortorder"] = 'asc';
  339.     $grid["footerrow"] = true; // Show footer row
  340.     $grid["userDataOnFooter"] = true; // Fill footer row with userdata (with on_data_display event)
  341.    
  342.     $grid["grouping"] = true; //  
  343.     $grid["groupingView"]["groupField"] = array("la_mes_anyo"); // specify column name to group listing
  344.     $grid["groupingView"]["groupColumnShow"] = array(false); // either show grouped column in list or not (default: true)
  345.     $grid["groupingView"]["groupText"] = array("<b>{0}</b>"); // {0} is grouped value, {1} is count in group
  346.     $grid["groupingView"]["groupOrder"] = array("asc"); // show group in asc or desc order
  347.     $grid["groupingView"]["groupDataSorted"] = array(true); // show sorted data within group
  348.     $grid["groupingView"]["groupSummary"] = array(true); // work with summaryType, summaryTpl, see column: $col["name"] = "total";
  349.     $grid["groupingView"]["groupCollapse"] = false; // Turn true to show group collapse (default: false)
  350.     $grid["groupingView"]["showSummaryOnHide"] = true; // show summary row even if group collapsed (hide)
  351.     $grid["export"] = array("filename"=>"Lecturas Agua", "heading"=>"Lecturas Agua", "orientation"=>"landscape", "paper"=>"a4");
  352.     $grid["export"]["range"] = "filtered";
  353.     // for excel, sheet header
  354.     $grid["export"]["sheetname"] = "Lecturas Agua";
  355.     $grid["rowNum"]=500;
  356.     $grid["rowList"]=array();
  357.    
  358.     $g->set_options($grid);
  359.  
  360.    
  361.     $g->set_actions(array(    
  362.                             "add"=>true, // allow/disallow add
  363.                             "edit"=>true, // allow/disallow edit
  364.                             "delete"=>true, // allow/disallow delete
  365.                             "clone"=>false, // allow/disallow clone
  366.                             "rowactions"=>false, // show/hide row wise edit/del/save option
  367.                             "autofilter" => true, // show/hide autofilter for search
  368.                                "export_excel"=>true, // export excel button
  369.                             "export_pdf"=>true, // export pdf button
  370.                             "export_csv"=>true, // export csv button
  371.                             "search" => "advance", // show single/multi field search condition (e.g. simple or advance)
  372.                             "showhidecolumns" => true
  373.                         )
  374.                     );
  375.                    
  376.  
  377.    
  378.     //$g->select_command = "SELECT *,concat(convert(month(la_fecha),char),'-',convert(year(la_fecha),char)) as la_mes_anyo from lect_contadoresagua";
  379.     $g->select_command = "SELECT *,concat(convert(year(la_fecha),char),'-',lpad(convert(month(la_fecha),char(2)),2,'0')) as la_mes_anyo from lect_contadoresagua where year(la_fecha)=" . $anyoagua;
  380.  
  381.                        
  382.     // set database table for CRUD operations
  383.     $g->table = "lect_contadoresagua";
  384.  
  385.     // pass the cooked columns to grid
  386.     $g->set_columns($cols);
  387.    
  388.        
  389.     // group columns header
  390.     $g->set_group_header( array(
  391.                             "useColSpanStyle"=>true,
  392.                             "groupHeaders"=>array(
  393.                                 array(
  394.                                     "startColumnName"=>'la_uds_colonia1', // group starts from this column
  395.                                     "numberOfColumns"=>2, // group span to next 2 columns
  396.                                     "titleText"=>'COLONIA1' // caption of group header
  397.                                 ),
  398.                                 array(
  399.                                     "startColumnName"=>'la_uds_colonia2', // group starts from this column
  400.                                     "numberOfColumns"=>2, // group span to next 2 columns
  401.                                     "titleText"=>'COLONIA2' // caption of group header
  402.                                 ),
  403.                                 array(
  404.                                     "startColumnName"=>'la_uds_miralles', // group starts from this column
  405.                                     "numberOfColumns"=>2, // group span to next 2 columns
  406.                                     "titleText"=>'MIRALLES' // caption of group header
  407.                                 ),
  408.                                 array(
  409.                                     "startColumnName"=>'la_uds_bordils', // group starts from this column
  410.                                     "numberOfColumns"=>2, // group span to next 2 columns
  411.                                     "titleText"=>'BORDILS' // caption of group header
  412.                                 ),
  413.                                 array(
  414.                                     "startColumnName"=>'la_uds_rubio', // group starts from this column
  415.                                     "numberOfColumns"=>2, // group span to next 2 columns
  416.                                     "titleText"=>'RUBIO' // caption of group header
  417.                                 ),
  418.                                 array(
  419.                                     "startColumnName"=>'la_uds_bagu', // group starts from this column
  420.                                     "numberOfColumns"=>2, // group span to next 2 columns
  421.                                     "titleText"=>'BAGU' // caption of group header
  422.                                 ),
  423.                                 array(
  424.                                     "startColumnName"=>'la_uds_aparici', // group starts from this column
  425.                                     "numberOfColumns"=>2, // group span to next 2 columns
  426.                                     "titleText"=>'APARICI' // caption of group header
  427.                                 ),
  428.                                 array(
  429.                                     "startColumnName"=>'la_uds_total', // group starts from this column
  430.                                     "numberOfColumns"=>2, // group span to next 2 columns
  431.                                     "titleText"=>'TOTAL' // caption of group header
  432.                                 ),
  433.                                 array(
  434.                                     "startColumnName"=>'la_uds_balsa', // group starts from this column
  435.                                     "numberOfColumns"=>2, // group span to next 2 columns
  436.                                     "titleText"=>'BALSA' // caption of group header
  437.                                 )
  438.                             )
  439.                         )
  440.                     );     
  441.        
  442.        
  443.     $e["on_insert"] = array("add_lectura", null, false);           
  444.     $e["on_data_display"] = array("filter_display", null, true);
  445.     $e["on_render_pdf"] = array("set_pdf_format", null);
  446.  
  447.     $g->set_events($e);
  448.    
  449.    
  450.     function filter_display($data)  //pre_render en http://www.phpgrid.org/demo/demos/appearance/footer-row.phps
  451.     {
  452.         // grand sum total and show in footer user data
  453.         $totalc1 = 0;
  454.         $totalc2 = 0;
  455.         $totalmiralles=0;
  456.         $totalbordils=0;
  457.         $totalrubio=0;
  458.         $totalbagu=0;
  459.         $totalaparici=0;
  460.         $totaltotal=0;
  461.         $totalbalsa=0;
  462.         foreach($data["params"] as $d)
  463.         {
  464.             $totalc1 += $d["la_consumo_colonia1"];
  465.             $totalc2 += $d["la_consumo_colonia2"];
  466.             $totalmiralles += $d["la_consumo_miralles"];
  467.             $totalbordils += $d["la_consumo_bordils"];
  468.             $totalrubio += $d["la_consumo_rubio"];
  469.             $totalbagu += $d["la_consumo_bagu"];
  470.             $totalaparici += $d["la_consumo_aparici"];
  471.             $totaltotal += $d["la_consumo_total"];
  472.             $totalbalsa += $d["la_consumo_balsa"];
  473.         }
  474.  
  475.         //$data["params"]["userdata"] = array("la_consumo_colonia1"=>"Total: ".$total);
  476.         $data["params"]["userdata"] = array("la_id"=>" ",      
  477.                     "la_fecha"=>null,
  478.                     "la_uds_colonia1"=>$totalc1*21 . "€",
  479.                     "la_consumo_colonia1"=> $totalc1 ,
  480.                     "la_uds_colonia2"=>$totalc2*21 . "€",
  481.                     "la_consumo_colonia2"=>$totalc2 ,
  482.                     "la_uds_miralles"=>$totalmiralles*21 . "€",
  483.                     "la_consumo_miralles"=>$totalmiralles ,
  484.                     "la_uds_bordils"=>$totalbordils*21 . "€",
  485.                     "la_consumo_bordils"=>$totalbordils ,
  486.                     "la_uds_rubio"=>$totalrubio*21 . "€",
  487.                     "la_consumo_rubio"=>$totalrubio ,
  488.                     "la_uds_bagu"=>$totalbagu*21 . "€",
  489.                     "la_consumo_bagu"=>$totalbagu ,
  490.                     "la_uds_aparici"=>$totalaparici*21 . "€",
  491.                     "la_consumo_aparici"=>$totalaparici ,
  492.                     "la_uds_total"=>$totaltotal*21 . "€",
  493.                     "la_consumo_total"=>$totaltotal ,
  494.                     "la_uds_balsa"=>$totalbalsa*0.9 . "€",
  495.                     "la_consumo_balsa"=>$totalbalsa  ,
  496.                     "la_mes_anyo"=>" ",
  497.                     "la_preciohragua"=>" ");
  498.     }
  499.  
  500.     function add_lectura($data) {      
  501.        
  502.         $idlectura = $data["params"]["la_id"];     
  503.         $fechalectura =$data["params"]["la_fecha"];
  504.         $lecturaactualc1 =$data["params"]["la_uds_colonia1"];  
  505.         $lecturaactualc2 =$data["params"]["la_uds_colonia2"];  
  506.         $lecturaactualmiralles =$data["params"]["la_uds_miralles"];
  507.         $lecturaactualbordils =$data["params"]["la_uds_bordils"];  
  508.         $lecturaactualrubio =$data["params"]["la_uds_rubio"];  
  509.         $lecturaactualbagu =$data["params"]["la_uds_bagu"];
  510.         $lecturaactualaparici =$data["params"]["la_uds_aparici"];  
  511.         $lecturaactualtotal =$data["params"]["la_uds_total"];  
  512.         $lecturaactualbalsa =$data["params"]["la_uds_balsa"];  
  513.        
  514.  
  515.         $row = mysql_fetch_row(mysql_query("select la_fecha,la_uds_colonia1 from lect_contadoresagua where la_fecha<'{$fechalectura}' and la_uds_colonia1<>0 order by la_fecha DESC limit 1"));
  516.         $lecturaanterior = $row[1];                
  517.         $consumoactualc1 = $lecturaactualc1-$lecturaanterior;          
  518.  
  519.         $row = mysql_fetch_row(mysql_query("select la_fecha,la_uds_colonia2 from lect_contadoresagua where la_fecha<'{$fechalectura}' and la_uds_colonia2<>0 order by la_fecha DESC limit 1"));
  520.         $lecturaanterior = $row[1];                
  521.         $consumoactualc2 = $lecturaactualc2-$lecturaanterior;          
  522.  
  523.         $row = mysql_fetch_row(mysql_query("select la_fecha,la_uds_miralles from lect_contadoresagua where la_fecha<'{$fechalectura}' and la_uds_miralles<>0 order by la_fecha DESC limit 1"));
  524.         $lecturaanterior = $row[1];                
  525.         $consumoactualmiralles = $lecturaactualmiralles-$lecturaanterior;          
  526.  
  527.         $row = mysql_fetch_row(mysql_query("select la_fecha,la_uds_bordils from lect_contadoresagua where la_fecha<'{$fechalectura}' and la_uds_bordils<>0 order by la_fecha DESC limit 1"));
  528.         $lecturaanterior = $row[1];                
  529.         $consumoactualbordils = $lecturaactualbordils-$lecturaanterior;        
  530.  
  531.         $row = mysql_fetch_row(mysql_query("select la_fecha,la_uds_rubio from lect_contadoresagua where la_fecha<'{$fechalectura}' and la_uds_rubio<>0 order by la_fecha DESC limit 1"));
  532.         $lecturaanterior = $row[1];                
  533.         $consumoactualrubio = $lecturaactualrubio-$lecturaanterior;        
  534.        
  535.         $row = mysql_fetch_row(mysql_query("select la_fecha,la_uds_bagu from lect_contadoresagua where la_fecha<'{$fechalectura}' and la_uds_bagu<>0 order by la_fecha DESC limit 1"));
  536.         $lecturaanterior = $row[1];                
  537.         $consumoactualbagu = $lecturaactualbagu-$lecturaanterior;          
  538.  
  539.         $row = mysql_fetch_row(mysql_query("select la_fecha,la_uds_aparici from lect_contadoresagua where la_fecha<'{$fechalectura}' and la_uds_aparici<>0 order by la_fecha DESC limit 1"));
  540.         $lecturaanterior = $row[1];                
  541.         $consumoactualaparici = $lecturaactualaparici-$lecturaanterior;        
  542.  
  543.         $row = mysql_fetch_row(mysql_query("select la_fecha,la_uds_total from lect_contadoresagua where la_fecha<'{$fechalectura}' and la_uds_total<>0 order by la_fecha DESC limit 1"));
  544.         $lecturaanterior = $row[1];                
  545.         $consumoactualtotal = $lecturaactualtotal-$lecturaanterior;        
  546.  
  547.         $row = mysql_fetch_row(mysql_query("select la_fecha,la_uds_balsa from lect_contadoresagua where la_fecha<'{$fechalectura}' and la_uds_balsa<>0 order by la_fecha DESC limit 1"));
  548.         $lecturaanterior = $row[1];                
  549.         $consumoactualbalsa = $lecturaactualbalsa-$lecturaanterior;        
  550.  
  551.        
  552.        
  553.        
  554.         mysql_query("insert into lect_contadoresagua(la_fecha,la_uds_colonia1,la_consumo_colonia1,la_uds_colonia2,la_consumo_colonia2,la_uds_miralles, la_consumo_miralles, la_uds_bordils, la_consumo_bordils,
  555.         la_uds_rubio, la_consumo_rubio, la_uds_bagu, la_consumo_bagu, la_uds_aparici, la_consumo_aparici, la_uds_total, la_consumo_total, la_uds_balsa, la_consumo_balsa, la_preciohragua)
  556.         values('{$fechalectura}','{$lecturaactualc1}','{$consumoactualc1}','{$lecturaactualc2}','{$consumoactualc2}','{$lecturaactualmiralles}','{$consumoactualmiralles}',
  557.         '{$lecturaactualbordils}','{$consumoactualbordils}','{$lecturaactualrubio}','{$consumoactualrubio}','{$lecturaactualbagu}','{$consumoactualbagu}','{$lecturaactualaparici}','{$consumoactualaparici}',
  558.         '{$lecturaactualtotal}','{$consumoactualtotal}','{$lecturaactualbalsa}','{$consumoactualbalsa}','{$_SESSION["DATOSCONFIGURACION"]->getValue("c_preciohragua")}')");    
  559.        
  560.            
  561.     }
  562.  
  563.    
  564.    
  565.     function set_pdf_format($arr)  // render_pdf en http://www.phpgrid.org/demo/demos/appearance/footer-row.phps
  566.     {
  567.         $pdf = $arr["pdf"];
  568.         $data = $arr["data"];
  569.         $pdf->SetFont('courier', '', 8);
  570.         $pdf->SetLineWidth(0.005);
  571.         $amples = array(19,19,8,19,8,19,8,18,8,15,8,17,8,18,8,16,9,15,9,15);
  572.         $pdf->SetCellWidths($amples);
  573.         $alineament = array('L','R','L','R','L','R','L','R','L','R','L','R','L','R','L','R','L','R','L','L');
  574.         $pdf->SetCellAlignment($alineament);
  575.         $pdf->SetHeaderCellsFillColor(225,225,225);
  576.     }              
  577.    
  578.     // render grid and get html/js output
  579.     $out = $g->render("list1");
  580.    
  581.     fnAsignarEncabezado("LECTURAS AGUA"); //carga encabezado   
  582.  
  583.     fnMenuPrincipal(); 
  584.    
  585.     php echo $out;
  586.      
  587. fnCerrarPaginaSinCalendario();  //cierra el contenido, el body y el html   
  588. }
  589. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement