Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php session_start(); ?>
- <?php
- include('../login/includes/api.php');
- ?>
- <?php
- if(!is_logged_in()) {
- header('Location: ../login/login.php');
- exit;
- }
- ?>
- <?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
- */
- // include db config
- include_once("../config.php");
- // set up DB
- mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
- mysql_select_db(PHPGRID_DBNAME);
- // include and create object
- include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
- // master grid
- $grid = new jqgrid();
- $opt["caption"] = "Clients";
- $opt["height"] = "150";
- $opt["autowidth"] = true;
- $opt["sortorder"] = "desc";
- // following params will enable subgrid -- by default first column (PK) of parent is passed as param 'id'
- $opt["detail_grid_id"] = "list2";
- // extra params passed to detail grid, column name comma separated
- $opt["subgridparams"] = "client_id,client";
- $opt["multiselect"] = false;
- $opt["export"] = array("filename"=>"my-file", "sheetname"=>"Notes Report", "format"=>"pdf");
- $opt["export"]["range"] = "filtered";
- $opt["altRows"] = true;
- $opt["altclass"] = "myAltRowClass";
- $grid->set_options($opt);
- //$grid->table = "tbl_clients";
- // query for master
- $grid->select_command = "Select
- c.client_id,
- c.Adviser,
- c.Client,
- c.postcode,
- c.Phone,
- c.Email
- From
- tbl_clients c
- Where c.Adviser = '" . userValue(null, "username") . "'";
- $grid->set_actions(array(
- "add"=>false, // allow/disallow add
- "edit"=>true, // allow/disallow edit
- "delete"=>false, // allow/disallow delete
- "rowactions"=>false, // show/hide row wise edit/del/save option
- "export"=>true, // show/hide export to excel option
- "autofilter" => true, // show/hide autofilter for search
- "search" => "simple" // show single/multi field search condition (e.g. simple or advance)
- )
- );
- $out_master = $grid->render("list1");
- //////////// NOTES GRID////////////////////////////////////////
- $grid = new jqgrid();
- $opt = array();
- $opt["sortname"] = 'task_id'; // by default sort grid by this field
- $opt["sortorder"] = "desc"; // ASC or DESC
- $opt["height"] = ""; // autofit height of subgrid
- $opt["caption"] = "Client Notes"; // caption of grid
- $opt["multiselect"] = true; // allow you to multi-select through checkboxes
- $opt["reloadedit"] = true; // allow you to multi-select through checkboxes
- $opt["export"] = array("filename"=>"my-file", "sheetname"=>"test", "format"=>"pdf"); // export to excel parameters
- $opt["export"]["range"] = "filtered";
- $opt["altRows"] = true;
- $opt["height"] = "150";
- $opt["width"] = 495;
- $opt["altclass"] = "myAltRowClass";
- // reload master after detail update
- $opt["onAfterSave"] = "function(){ jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); }";
- $grid->set_options($opt);
- // receive id, selected row of parent grid
- $id = intval($_GET["rowid"]);
- $client = $_GET["Client"];
- $cid = intval($_GET["client_id"]);
- // for non-int fields as PK
- // $id = (empty($_GET["rowid"])?0:$_GET["rowid"]);
- // and use in sql for filteration
- $grid->select_command = "SELECT task_id,client_id,Client,subject,note,note_date FROM tbl_notes WHERE client_id = $id";
- // this db table will be used for add,edit,delete
- $grid->table = "tbl_notes";
- $col = array();
- $col["title"] = "ID"; // caption of column
- $col["name"] = "task_id"; // field name, must be exactly same as with SQL prefix or db field
- $col["width"] = "10";
- $col["hidden"] = false; // hide on grid
- $col["editable"] = false;
- $cols[] = $col;
- $col = array();
- $col["title"] = "CID"; // caption of column
- $col["name"] = "client_id"; // field name, must be exactly same as with SQL prefix or db field
- $col["width"] = "10";
- $col["hidden"] = true; // hide on grid
- $col["editable"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Subject";
- $col["name"] = "subject";
- $col["width"] = "100";
- $col["search"] = true;
- $col["editable"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Note";
- $col["name"] = "note";
- $col["sortable"] = false; // this column is not sortable
- $col["search"] = false; // this column is not searchable
- $col["editable"] = true;
- // $col["hidden"] = true;
- $col["edittype"] = "textarea"; // render as textarea on edit
- $col["formatter"] = "wysiwyg";
- $col["editoptions"] = array("rows"=>2, "cols"=>50); // with these attributes
- // $col["editrules"] = array("edithidden"=>true); // with these attributes
- $cols[] = $col;
- $grid->set_columns($cols);
- // expand grid to screen width
- //$grid["autowidth"] = true;
- //$g->set_options($grid);
- $e["on_insert"] = array("add_client", null, true);
- $e["on_update"] = array("update_client", null, true);
- $grid->set_events($e);
- $grid->set_actions(array(
- "add"=>true, // allow/disallow add
- "edit"=>true, // allow/disallow edit
- "delete"=>true, // allow/disallow delete
- "export"=>true, // show/hide export to excel option
- "inlineadd"=>true, // allow/disallow delete
- "rowactions"=>true, // show/hide row wise edit/del/save option
- "autofilter" => true, // show/hide autofilter for search
- "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
- )
- );
- function add_client(&$data)
- {
- $id = intval($_GET["rowid"]);
- $data["params"]["client_id"] = $id;
- $data["params"]["Client"] = $client;
- $data["params"]["subject"];
- $data["params"]["note"];
- }
- function update_client(&$data)
- {
- $id = intval($_GET["rowid"]);
- $data["params"]["client_id"] = $id;
- $data["params"]["Client"] = $client;
- $data["params"]["subject"];
- $data["params"]["note"];
- }
- // generate grid output, with unique grid name as 'list1'
- $out_detail = $grid->render("list2");
- // CLIENT TASKS GRID /////////////////////////////////////////////
- $grid = new jqgrid();
- $opt = array();
- $opt["sortname"] = 'id'; // by default sort grid by this field
- $opt["sortorder"] = "desc"; // ASC or DESC
- $opt["height"] = "150";
- $opt["width"] = "495";
- $opt["caption"] = "Client Tasks"; // caption of grid
- $grid->set_options($opt);
- $grid->set_actions(array(
- "add"=>true, // allow/disallow add
- "edit"=>true, // allow/disallow edit
- "delete"=>false, // allow/disallow delete
- "rowactions"=>false, // show/hide row wise edit/del/save option
- "export"=>true, // show/hide export to excel option
- "autofilter" => true, // show/hide autofilter for search
- "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
- )
- );
- // receive id, selected row of parent grid
- $id = intval($_GET["rowid"]);
- $cid = intval($_GET["client_id"]);
- // and use in sql for filteration
- $grid->select_command = "Select id,client_id,title,start From tbl_tasks WHERE client_id = $id";
- // this db table will be used for add,edit,delete
- $grid->table = "tbl_tasks";
- $col = array();
- $col["title"] = "ID"; // caption of column
- $col["name"] = "id"; // field name, must be exactly same as with SQL prefix or db field
- $col["width"] = "10";
- $col["hidden"] = true; // hide on grid
- $col["editable"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "ClientID"; // caption of column
- $col["name"] = "client_id"; // field name, must be exactly same as with SQL prefix or db field
- $col["width"] = "10";
- $col["hidden"] = true; // hide on grid
- $col["editable"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Date";
- $col["name"] = "start";
- $col["width"] = "100";
- $col["search"] = true;
- $col["editable"] = true;
- $col["formatter"] = "date";
- $col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d-m-Y');
- $cols[] = $col;
- $col = array();
- $col["title"] = "Task";
- $col["name"] = "title";
- $col["sortable"] = false; // this column is not sortable
- $col["search"] = false; // this column is not searchable
- $col["editable"] = true;
- // $col["hidden"] = true;
- $col["edittype"] = "textarea"; // render as textarea on edit
- $col["formatter"] = "wysiwyg";
- $col["editoptions"] = array("rows"=>2, "cols"=>50); // with these attributes
- // $col["editrules"] = array("edithidden"=>true); // with these attributes
- $cols[] = $col;
- // generate grid output, with unique grid name as 'list1'
- $out_list3 = $grid->render("list3");
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- <html>
- <head>
- <link rel="stylesheet" type="text/css" media="screen" href="../lib/js/themes/redmondG/jquery-ui.custom.css"></link>
- <link rel="stylesheet" type="text/css" media="screen" href="../lib/js/jqgrid/css/ui.jqgrid.css">
- <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
- <link rel="stylesheet" type="text/css" media="screen" href="../lib/js/jqgrid/css/ui.bootstrap.jqgrid.css">
- <script src="../lib/js/jquery.min.js" type="text/javascript"></script>
- <script src="../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
- <script src="../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
- <script src="../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
- <script src="../lib/js/ckeditor/ckeditor.js" type="text/javascript"></script>
- </head>
- <body>
- <style>
- .myAltRowClass { background-color: #EBFFFF; background-image: none; }
- </style>
- <div style="margin:10px">
- <?php echo $out_master ?>
- <br>
- <div style="float:left">
- <?php echo $out_detail?>
- </div>
- <div style="float:left; margin-left:20px">
- <?php echo $out_list3?>
- </div>
- <script>
- // insert key to add new row, tab to focus on save icon & press enter to save
- $(document).bind('keyup', 'insert', function(){
- jQuery('#list2_iladd').click();
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement