Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2015
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.37 KB | None | 0 0
  1. <?php session_start(); ?>
  2. <?php
  3. include('../login/includes/api.php');
  4. ?>
  5. <?php
  6. if(!is_logged_in()) {
  7.     header('Location: ../login/login.php');
  8.     exit;
  9. }
  10. ?>
  11. <?php
  12. /**
  13.  * PHP Grid Component
  14.  *
  15.  * @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
  16.  * @version 1.5.2
  17.  * @license: see license.txt included in package
  18.  */
  19.  
  20. // include db config
  21. include_once("../config.php");
  22.  
  23. // set up DB
  24. mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
  25. mysql_select_db(PHPGRID_DBNAME);
  26.  
  27. // include and create object
  28. include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
  29. $g = new jqgrid();
  30.  
  31. // set few params
  32. $grid["caption"] = "OWS Business";
  33. $g->set_options($grid);
  34.  
  35. // Predefined standard page formats: http://www.tcexam.org/doc/code/classTCPDF.html#a087d4df77e60b7054e97804069ed32c5
  36. // Orientation: landscape, portrait
  37. $grid["export"] = array("format"=>"pdf", "filename"=>"my-file", "heading"=>"Invoice Details", "orientation"=>"landscape", "paper"=>"a4");
  38.  
  39. // for excel, sheet header
  40. $grid["export"]["sheetname"] = "Invoice Details";
  41.  
  42. $grid["export"]["render_type"] = "html";
  43.  
  44. // export pdf using html renderer
  45. $grid["export"]["render_type"] = "html";
  46.  
  47. // export filtered data or all data
  48. $grid["export"]["range"] = "all"; // or "all"
  49. $g->set_options($grid);
  50.  
  51. // params are array(<function-name>,<class-object> or <null-if-global-func>)
  52. $e["on_render_pdf"] = array("set_pdf_format", null);
  53. $g->set_events($e);
  54.  
  55. function set_pdf_format($param)
  56. {
  57.     $grid = $param["grid"];
  58.     $arr = $param["data"];
  59.  
  60.     $html .= "<h1>".$grid->options["export"]["heading"]."</h1>";
  61.     $html .= '<table border="0" cellpadding="4" cellspacing="2">';
  62.    
  63.     $i = 0;
  64.     foreach($arr as $v)
  65.     {
  66.         $shade = ($i++ % 2) ? 'bgcolor="#efefef"' : '';
  67.         $html .= "<tr>";
  68.         foreach($v as $d)
  69.         {
  70.             // bold header
  71.             if  ($i == 1)
  72.                 $html .= "<td bgcolor=\"lightgrey\"><strong>$d</strong></td>";
  73.             else
  74.                 $html .= "<td $shade>$d</td>";
  75.         }
  76.         $html .= "</tr>";
  77.     }
  78.  
  79.     $html .= "</table>";
  80.    
  81.     return $html;
  82. }
  83.  
  84.  
  85. $g->set_actions(array( 
  86.                         "add"=>true, // allow/disallow add
  87.                         "edit"=>true, // allow/disallow edit
  88.                         "delete"=>true, // allow/disallow delete
  89.                         "rowactions"=>true, // show/hide row wise edit/del/save option
  90.                         "export_pdf"=>true, // show/hide export to excel option
  91.                         "export_csv"=>true, // export csv button
  92.                         "autofilter" => true, // show/hide autofilter for search
  93.                         "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
  94.                     )
  95.                 );
  96. // set database table for CRUD operations
  97. $g->table = "tbl_contacts";
  98.  
  99. // caption of column
  100. $col = array();
  101. $col["title"] = "ID"; // caption of column
  102. $col["name"] = "ContactID"; // grid column name
  103. $col["editable"] = false;
  104. $col["hidden"] = false; // hide on grid
  105. $col["width"] = "15";
  106. $cols[] = $col;
  107.  
  108.  
  109. $col = array();
  110. $col["title"] = "Name"; // caption of column
  111. $col["name"] = "ContactFullName"; // grid column name
  112. $col["editable"] = true;
  113. $cols[] = $col;
  114.  
  115. $col = array();
  116. $col["title"] = "Address1"; // caption of column
  117. $col["name"] = "ContactAddress1"; // grid column name
  118. $col["hidden"] = true; // hide on grid
  119. $col["editable"] = true;
  120. $col["editrules"] = array("edithidden"=>true); // show on add
  121. $cols[] = $col;
  122.  
  123. $col = array();
  124. $col["title"] = "Address2"; // caption of column
  125. $col["name"] = "ContactAddress2"; // grid column name
  126. $col["hidden"] = true; // hide on grid
  127. $col["editable"] = true;
  128. $col["editrules"] = array("edithidden"=>true);  // show on add
  129. $cols[] = $col;
  130.  
  131. $col = array();
  132. $col["title"] = "Address3"; // caption of column
  133. $col["name"] = "ContactAddress3"; // grid column name
  134. $col["hidden"] = true; // hide on grid
  135. $col["editable"] = true;
  136. $col["editrules"] = array("edithidden"=>true);  // show on add
  137. $cols[] = $col;
  138.  
  139. $col = array();
  140. $col["title"] = "Town"; // caption of column
  141. $col["name"] = "ContactTown"; // grid column name
  142. $col["hidden"] = true; // hide on grid
  143. $col["editable"] = true;
  144. $col["editrules"] = array("edithidden"=>true);  // show on add
  145. $cols[] = $col;
  146.  
  147. $col = array();
  148. $col["title"] = "PostCode"; // caption of column
  149. $col["name"] = "ContactPostCode"; // grid column name
  150. $col["editable"] = true;
  151. $col["width"] = "40";
  152. $cols[] = $col;
  153.  
  154. $col = array();
  155. $col["title"] = "Landline"; // caption of column
  156. $col["name"] = "ContactLandline"; // grid column name
  157. $col["editable"] = true;
  158. $col["width"] = "60";
  159. $cols[] = $col;
  160.  
  161. $col = array();
  162. $col["title"] = "Mobile"; // caption of column
  163. $col["name"] = "ContactMobile"; // grid column name
  164. $col["editable"] = true;
  165. $col["width"] = "60";
  166. $cols[] = $col;
  167.  
  168. $col = array();
  169. $col["title"] = "Email"; // caption of column
  170. $col["name"] = "ContactEmail"; // grid column name
  171. $col["editable"] = true;
  172. $cols[] = $col;
  173.  
  174. // pass the cooked columns to grid
  175. $g->set_columns($cols);
  176.  
  177. // expand grid to screen width
  178. $grid["autowidth"] = true;
  179.  
  180. // include to make grid changes
  181. $grid["sortname"] = 'ContactFullName'; // by default sort grid by this field
  182. $grid["sortorder"] = "asc"; // ASC or DESC
  183. $grid["rowNum"] = 20; // by default 20
  184. $grid["autowidth"] = true;
  185. $grid["height"] = "525";
  186. $grid["altRows"] = true;
  187. $grid["altclass"] = "myAltRowClass";
  188. $g->set_options($grid);
  189.  
  190. // render grid
  191. $out = $g->render("list1");
  192.  
  193. ?>
  194. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  195. <html>
  196. <head>
  197.     <link rel="stylesheet" type="text/css" media="screen" href="../lib/js/themes/redmondG/jquery-ui.custom.css"></link>    
  198.     <link rel="stylesheet" type="text/css" media="screen" href="../lib/js/jqgrid/css/ui.jqgrid.css">
  199.     <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
  200.     <link rel="stylesheet" type="text/css" media="screen" href="../lib/js/jqgrid/css/ui.bootstrap.jqgrid.css">      
  201.  
  202.     <script src="../lib/js/jquery.min.js" type="text/javascript"></script>
  203.     <script src="../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  204.     <script src="../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>    
  205.     <script src="../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  206. </head>
  207. <body>
  208.     <style>
  209.     .myAltRowClass { background-color: #EBFFFF; background-image: none; }
  210.     </style>
  211.     <div style="margin:10px">
  212.     <?php echo $out?>
  213.    
  214.    
  215.     </div>
  216. </body>
  217. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement