Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require_once('../../includes/initialize.php');?>
- <?php
- /**
- * PHP Grid Component
- *
- * @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
- * @version 1.5.2
- * @license: see license.txt included in package
- */
- $g = new jqgrid();
- $opt["rowNum"] = 10; // by default 20
- //$opt["sortname"] = 'id'; // by default sort grid by this field
- $opt["sortorder"] = "desc"; // ASC or DESC
- $opt["caption"] = "Remittance"; // caption of grid
- $opt["autowidth"] = false; // expand grid to screen width
- $opt["multiselect"] = true; // allow you to multi-select through checkboxes
- $opt["footerrow"] = true;
- $opt["reloadedit"] = true;
- $g->set_options($opt);
- $g->set_actions(array(
- "add"=>false, // allow/disallow add
- "edit"=>false, // allow/disallow edit
- "delete"=>false, // allow/disallow delete
- "rowactions"=>false, // show/hide row wise edit/del/save option
- "search" => "advance", // show single/multi field search condition (e.g. simple or advance)
- "autofilter" => true
- )
- );
- // you can provide custom SQL query to display data
- $g->select_command = "SELECT remittance_id,salesman_id, amount, date, (SELECT sum(amount) from remittance) AS table_total FROM remittance";
- // this db table will be used for add,edit,delete
- $g->table = "remittance";
- $col = array();
- $col["title"] = "Id"; // caption of column
- $col["name"] = "remittance_id";
- $col["width"] = "15";
- $col["search"] = false;
- $col["editable"] = false;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Salesman";
- $col["name"] = "salesman_id";
- $col["width"] = "100";
- $col["search"] = true;
- $col["editable"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Date";
- $col["name"] = "date";
- $col["width"] = "50";
- $col["editable"] = false; // this column is editable
- $col["formatter"] = "date"; // format as date
- $col["search"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Amount";
- $col["name"] = "amount";
- $col["width"] = "50";
- $col["search"] = true;
- $col["editable"] = false; // this column is editable
- $col["formatter"] = "currency";
- $col["formatoptions"] = array("prefix" => "P",
- "suffix" => '',
- "thousandsSeparator" => ",",
- "decimalSeparator" => ".",
- "decimalPlaces" => '2');
- $cols[] = $col;
- // virtual column for running total
- $col = array();
- $col["title"] = "running_total";
- $col["name"] = "running_total";
- $col["width"] = "100";
- $col["hidden"] = true;
- $col[] = $col;
- // virtual column for grand total
- $col = array();
- $col["title"] = "table_total";
- $col["name"] = "table_total";
- $col["width"] = "100";
- $col["hidden"] = true;
- $col[] = $col;
- // pass the cooked columns to grid
- $g->set_columns($cols);
- // running total calculation
- $e = array();
- $e["on_data_display"] = array("pre_render","",true);
- $e["js_on_select_row"] = "grid_onselect";
- $e["js_on_load_complete"] = "grid_onload";
- $g->set_events($e);
- function pre_render($data)
- {
- $rows = $_GET["jqgrid_page"] * $_GET["rows"];
- $sidx = $_GET['sidx']; // get index row - i.e. user click to sort
- $sord = $_GET['sord']; // get the direction
- // same sql as in select_command
- $rs = mysql_fetch_assoc(mysql_query("SELECT SUM(amount) as s FROM (SELECT total FROM remittance ORDER BY $sidx $sord LIMIT $rows) AS tmp"));
- foreach($data["params"] as &$d)
- {
- $d["running_total"] = $rs["s"];
- }
- }
- // generate grid output, with unique grid name as 'list1'
- $out = $g->render("list1");
- ?>
- <?php include_layout_template('header.php'); ?>
- <?php include_layout_template('menu.php'); ?>
- <!-- start page -->
- <div id="page">
- <!-- start content -->
- <script>
- // e.g. to show footer summary
- function grid_onload()
- {
- var grid = $("#list1");
- // sum of displayed result
- sum = grid.jqGrid('getCol', 'Amount', false, 'sum'); // 'sum, 'avg', 'count' (use count-1 as it count footer row).
- // sum of running total records
- sum_running = grid.jqGrid('getCol', 'running_total')[0];
- // sum of total records
- sum_table = grid.jqGrid('getCol', 'table_total')[0];
- // record count
- c = grid.jqGrid('getCol', 'Id', false, 'sum');
- grid.jqGrid('footerData','set', {Id: 'Total: ' + sum, Date: 'Sub Total: '+sum_running, Amount: 'Grand Total: '+sum_table});
- };
- // e.g. to update footer summary on selection
- function grid_onselect()
- {
- var grid = $("#list1");
- var t = 0;
- var selr = grid.jqGrid('getGridParam','selarrrow'); // array of id's of the selected rows when multiselect options is true. Empty array if not selection
- for (var x=0;x<selr.length;x++)
- {
- t += parseInt(grid.jqGrid('getCell', selr[x], 'total'));
- }
- grid.jqGrid('footerData','set', {Date: 'Total: '+t});
- };
- </script>
- <h6 class="pagetitle">  </h6>
- <div id="tabs">
- <ul>
- <li><a href="#tabs-1">Remittance</a></li>
- <li><a href="#tabs-2">Report B</a></li>
- <li><a href="#tabs-3">Report C</a></li>
- </ul>
- <div id="tabs-1">
- <?php echo $out ?>
- </div>
- <div id="tabs-2">
- <?php //echo $out2?>
- </div>
- <div id="tabs-3">
- <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
- <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
- <?php //echo $out_third?>
- </div>
- </div>
- <script>
- $(function() {
- $( "#tabs" ).tabs();
- });
- </script>
- </div>
- <!-- end content -->
- <?php include_layout_template('footer.php'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement