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");
- $g = new jqgrid();
- // set few params
- $grid["caption"] = "OWS Business";
- $g->set_options($grid);
- // Predefined standard page formats: http://www.tcexam.org/doc/code/classTCPDF.html#a087d4df77e60b7054e97804069ed32c5
- // Orientation: landscape, portrait
- $grid["export"] = array("format"=>"pdf", "filename"=>"my-file", "heading"=>"Invoice Details", "orientation"=>"landscape", "paper"=>"a4");
- // for excel, sheet header
- //$grid["export"]["sheetname"] = "Invoice Details";
- $grid["export"]["render_type"] = "html";
- // export pdf using html renderer
- $grid["export"]["render_type"] = "html";
- // export filtered data or all data
- $grid["export"]["range"] = "all"; // or "all"
- $g->set_options($grid);
- // params are array(<function-name>,<class-object> or <null-if-global-func>)
- $e["on_render_pdf"] = array("set_pdf_format", null);
- $g->set_events($e);
- function set_pdf_format($param)
- {
- $grid = $param["grid"];
- $arr = $param["data"];
- $html .= "<h1>".$grid->options["export"]["heading"]."</h1>";
- $html .= '<table border="0" cellpadding="4" cellspacing="2">';
- $i = 0;
- foreach($arr as $v)
- {
- $shade = ($i++ % 2) ? 'bgcolor="#efefef"' : '';
- $html .= "<tr>";
- foreach($v as $d)
- {
- // bold header
- if ($i == 1)
- $html .= "<td bgcolor=\"lightgrey\"><strong>$d</strong></td>";
- else
- $html .= "<td $shade>$d</td>";
- }
- $html .= "</tr>";
- }
- $html .= "</table>";
- return $html;
- }
- $g->set_actions(array(
- "add"=>true, // allow/disallow add
- "edit"=>true, // allow/disallow edit
- "delete"=>true, // allow/disallow delete
- "rowactions"=>true, // show/hide row wise edit/del/save option
- "export"=>true, // show/hide export to excel option
- //"export_csv"=>true, // export csv button
- "autofilter" => true, // show/hide autofilter for search
- "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
- )
- );
- // set database table for CRUD operations
- $g->table = "tbl_contacts";
- // caption of column
- $col = array();
- $col["title"] = "ID"; // caption of column
- $col["name"] = "ContactID"; // grid column name
- $col["editable"] = false;
- $col["hidden"] = false; // hide on grid
- $col["width"] = "15";
- $cols[] = $col;
- $col = array();
- $col["title"] = "Name"; // caption of column
- $col["name"] = "ContactFullName"; // grid column name
- $col["editable"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Address1"; // caption of column
- $col["name"] = "ContactAddress1"; // grid column name
- $col["hidden"] = true; // hide on grid
- $col["editable"] = true;
- $col["editrules"] = array("edithidden"=>true); // show on add
- $cols[] = $col;
- $col = array();
- $col["title"] = "Address2"; // caption of column
- $col["name"] = "ContactAddress2"; // grid column name
- $col["hidden"] = true; // hide on grid
- $col["editable"] = true;
- $col["editrules"] = array("edithidden"=>true); // show on add
- $cols[] = $col;
- $col = array();
- $col["title"] = "Address3"; // caption of column
- $col["name"] = "ContactAddress3"; // grid column name
- $col["hidden"] = true; // hide on grid
- $col["editable"] = true;
- $col["editrules"] = array("edithidden"=>true); // show on add
- $cols[] = $col;
- $col = array();
- $col["title"] = "Town"; // caption of column
- $col["name"] = "ContactTown"; // grid column name
- $col["hidden"] = true; // hide on grid
- $col["editable"] = true;
- $col["editrules"] = array("edithidden"=>true); // show on add
- $cols[] = $col;
- $col = array();
- $col["title"] = "PostCode"; // caption of column
- $col["name"] = "ContactPostCode"; // grid column name
- $col["editable"] = true;
- $col["width"] = "40";
- $cols[] = $col;
- $col = array();
- $col["title"] = "Landline"; // caption of column
- $col["name"] = "ContactLandline"; // grid column name
- $col["editable"] = true;
- $col["width"] = "60";
- $cols[] = $col;
- $col = array();
- $col["title"] = "Mobile"; // caption of column
- $col["name"] = "ContactMobile"; // grid column name
- $col["editable"] = true;
- $col["width"] = "60";
- $cols[] = $col;
- $col = array();
- $col["title"] = "Email"; // caption of column
- $col["name"] = "ContactEmail"; // grid column name
- $col["editable"] = true;
- $cols[] = $col;
- // pass the cooked columns to grid
- $g->set_columns($cols);
- // expand grid to screen width
- $grid["autowidth"] = true;
- // include to make grid changes
- $grid["sortname"] = 'ContactFullName'; // by default sort grid by this field
- $grid["sortorder"] = "asc"; // ASC or DESC
- $grid["rowNum"] = 20; // by default 20
- $grid["autowidth"] = true;
- $grid["height"] = "525";
- $grid["altRows"] = true;
- $grid["altclass"] = "myAltRowClass";
- $g->set_options($grid);
- // render grid
- $out = $g->render("list1");
- ?>
- <!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>
- </head>
- <body>
- <style>
- .myAltRowClass { background-color: #EBFFFF; background-image: none; }
- </style>
- <div style="margin:10px">
- <?php echo $out?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement