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
- */
- // second grid
- $grid = new jqgrid();
- $opt["caption"] = "Remittance Data";
- //set columns
- ## ------------------ ##
- ## CLIENT SIDE EVENTS ##
- ## ------------------ ##
- // just set the JS function name (should exist)
- //$opt["onSelectRow"] = "function(ids) { do_onselect(ids); }";
- $opt["loadComplete"] = "function(ids) { do_onload(ids); }";
- // to simulate, comment theh onselectrow event line
- // $opt["ondblClickRow"] = "function(id,row,col) { do_ondblclick(id,row,col); }";
- $grid->set_options($opt);
- $grid->table = "remittance";
- $g->select_command = "SELECT remittance_id, remittance.salesman_id, date, amount FROM remittance INNER JOIN salesman on salesman.salesman_id = remittance.salesman_id";
- $col = array();
- $col["title"] = "ID"; // caption of column
- $col["name"] = "remittance_id"; // grid column name, same as db field or alias from sql
- $col["width"] = "5";
- $col["editable"] = false;
- $col["search"] = false; // this column is not searchable
- $cols[] = $col;
- $col = array();
- $col["title"] = "Salesman"; // caption of column
- $col["name"] = "salesman_id"; // grid column name, same as db field or alias from sql
- $col["dbname"] = "salesman"; // this is required as we need to search in name field, not id
- $col["width"] = "20";
- $col["search"] = true; // this column is not searchable
- $col["editable"] = true;
- $col["edittype"] = "select"; // render as select
- # fetch data from database, with alias k for key, v for value
- $str = $g->get_dropdown_values("select distinct salesman_id as k, salesman_name as v from salesman");
- $col["editoptions"] = array("value"=>":;".$str);
- $col["formatter"] = "select"; // display label, not value
- $cols[] = $col;
- $col = array();
- $col["title"] = "Date"; // caption of column
- $col["name"] = "date"; // grid column name, same as db field or alias from sql
- $col["width"] = "20";
- $col["hidden"] = false;
- $col["editable"] = true;
- $col["formatter"] = "date";
- $cols[] = $col;
- $col = array();
- $col["title"] = "Amount"; // caption of column
- $col["name"] = "amount"; // grid column name, same as db field or alias from sql
- $col["width"] = "20";
- $col["hidden"] = false;
- $col["editable"] = true;
- $cols[] = $col;
- $grid->set_columns($cols);
- ## ------------------ ##
- ## SERVER SIDE EVENTS ##
- ## ------------------ ##
- // params are array(<function-name>,<class-object> or <null-if-global-func>,<continue-default-operation>)
- // if you pass last argument as true, functions will act as a data filter, and insert/update will be performed by grid
- $e["on_insert"] = array("add_remittance", null, true);
- $e["on_update"] = array("update_remittance", null, true);
- $e["on_delete"] = array("delete_remittance", null, true);
- $e["on_after_insert"] = array("after_inset_remittance", null, true); // return last inserted id for further working
- $e["on_data_display"] = array("filter_display_remittance", null, true);
- $grid->set_events($e);
- $grid->set_actions(array(
- "add"=>true, // allow/disallow add
- "edit"=>true, // allow/disallow edit
- "delete"=>false, // allow/disallow delete
- "inlineadd"=>false, // allow/disallow delete
- "rowactions"=>false, // show/hide row wise edit/del/save option
- "view"=>true, // allow/disallow view
- "autofilter" => true, // show/hide autofilter for search
- "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
- )
- );
- function update_remittance($data)
- {
- }
- function delete_remittance($data)
- {
- }
- function add_remittance($data)
- {
- }
- function after_insert_remittance($data)
- {
- }
- /**
- * Just update the passed argument, as it is passed by reference
- * Changes will be reflected in grid
- */
- function filter_display_remittance($data)
- {
- foreach($data["params"] as &$d)
- {
- foreach($d as $k=>$v)
- $d[$k] = strtoupper($d[$k]);
- }
- }
- $out2 = $grid->render("list2");
- ?>
- <script>
- function do_onload(id)
- {
- // remove all tooltip from cell
- $("#list2 td").attr('title','');
- //alert('Simulating, data on load event')
- }
- </script>
- <?php include_layout_template('header.php'); ?>
- <?php include_layout_template('menu.php'); ?>
- <!-- start page -->
- <div id="page">
- <!-- start content -->
- <h1 class="pagetitle">  </h1>
- <div style="margin:10px">
- <?php echo $out2?>
- </div>
- <!-- end content -->
- <?php include_layout_template('footer.php'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement