Advertisement
Guest User

Export all

a guest
Apr 2nd, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.50 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. // export PDF file params
  36. $grid["export"] = array("filename"=>"my-file", "heading"=>"Invoice Details", "orientation"=>"landscape", "paper"=>"a4");
  37. // for excel, sheet header
  38. $grid["export"]["sheetname"] = "Invoice Details";
  39.  
  40. // export filtered data or all data
  41. $grid["export"]["range"] = "filtered"; // or "all"
  42.  
  43. $g->set_options($grid);
  44.  
  45. $g->set_actions(array( 
  46.                         "add"=>false, // allow/disallow add
  47.                         "edit"=>false, // allow/disallow edit
  48.                         "delete"=>true, // allow/disallow delete
  49.                         "rowactions"=>true, // show/hide row wise edit/del/save option
  50.                         "export_excel"=>true, // export excel button
  51.                         "export_pdf"=>true, // export pdf button
  52.                         "export_csv"=>true, // export csv button
  53.                         "autofilter" => true, // show/hide autofilter for search
  54.                         "showhidecolumns" => true, // show/hide autofilter for search
  55.                         "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
  56.                     )
  57.                 );
  58.  
  59. // set database table for CRUD operations
  60. $g->table = "tbl_contacts";
  61.  
  62. // caption of column
  63. $col = array();
  64. $col["title"] = "ID"; // caption of column
  65. $col["name"] = "ContactID"; // grid column name
  66. $col["editable"] = false;
  67. $col["hidden"] = false; // hide on grid
  68. $col["width"] = "15";
  69. $cols[] = $col;
  70.  
  71.  
  72. $col = array();
  73. $col["title"] = "Name"; // caption of column
  74. $col["name"] = "ContactFullName"; // grid column name
  75. $col["editable"] = true;
  76. $cols[] = $col;
  77.  
  78. $col = array();
  79. $col["title"] = "Address1"; // caption of column
  80. $col["name"] = "ContactAddress1"; // grid column name
  81. $col["hidden"] = true; // hide on grid
  82. $col["editable"] = true;
  83. $col["editrules"] = array("edithidden"=>true); // show on add
  84. $cols[] = $col;
  85.  
  86. $col = array();
  87. $col["title"] = "Address2"; // caption of column
  88. $col["name"] = "ContactAddress2"; // grid column name
  89. $col["hidden"] = true; // hide on grid
  90. $col["editable"] = true;
  91. $col["editrules"] = array("edithidden"=>true);  // show on add
  92. $cols[] = $col;
  93.  
  94. $col = array();
  95. $col["title"] = "Address3"; // caption of column
  96. $col["name"] = "ContactAddress3"; // grid column name
  97. $col["hidden"] = true; // hide on grid
  98. $col["editable"] = true;
  99. $col["editrules"] = array("edithidden"=>true);  // show on add
  100. $cols[] = $col;
  101.  
  102. $col = array();
  103. $col["title"] = "Town"; // caption of column
  104. $col["name"] = "ContactTown"; // grid column name
  105. $col["hidden"] = true; // hide on grid
  106. $col["editable"] = true;
  107. $col["editrules"] = array("edithidden"=>true);  // show on add
  108. $cols[] = $col;
  109.  
  110. $col = array();
  111. $col["title"] = "PostCode"; // caption of column
  112. $col["name"] = "ContactPostCode"; // grid column name
  113. $col["editable"] = true;
  114. $col["width"] = "40";
  115. $cols[] = $col;
  116.  
  117. $col = array();
  118. $col["title"] = "Landline"; // caption of column
  119. $col["name"] = "ContactLandline"; // grid column name
  120. $col["editable"] = true;
  121. $col["width"] = "60";
  122. $cols[] = $col;
  123.  
  124. $col = array();
  125. $col["title"] = "Mobile"; // caption of column
  126. $col["name"] = "ContactMobile"; // grid column name
  127. $col["editable"] = true;
  128. $col["width"] = "60";
  129. $cols[] = $col;
  130.  
  131. $col = array();
  132. $col["title"] = "Email"; // caption of column
  133. $col["name"] = "ContactEmail"; // grid column name
  134. $col["editable"] = true;
  135. $cols[] = $col;
  136.  
  137. // pass the cooked columns to grid
  138. $g->set_columns($cols);
  139.  
  140. // expand grid to screen width
  141. $grid["autowidth"] = true;
  142.  
  143. // include to make grid changes
  144. $grid["sortname"] = 'ContactFullName'; // by default sort grid by this field
  145. $grid["sortorder"] = "asc"; // ASC or DESC
  146. $grid["rowNum"] = 20; // by default 20
  147. $grid["autowidth"] = true;
  148. $grid["height"] = "525";
  149. $grid["altRows"] = true;
  150. $grid["altclass"] = "myAltRowClass";
  151. $g->set_options($grid);
  152.  
  153. // render grid
  154. $out = $g->render("list1");
  155.  
  156. ?>
  157. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  158. <html>
  159. <head>
  160.     <link rel="stylesheet" type="text/css" media="screen" href="../lib/js/themes/redmondG/jquery-ui.custom.css"></link>    
  161.     <link rel="stylesheet" type="text/css" media="screen" href="../lib/js/jqgrid/css/ui.jqgrid.css">
  162.     <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
  163.     <link rel="stylesheet" type="text/css" media="screen" href="../lib/js/jqgrid/css/ui.bootstrap.jqgrid.css">      
  164.  
  165.     <script src="../lib/js/jquery.min.js" type="text/javascript"></script>
  166.     <script src="../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  167.     <script src="../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>    
  168.     <script src="../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  169. </head>
  170. <body>
  171.     <style>
  172.     .myAltRowClass { background-color: #EBFFFF; background-image: none; }
  173.     </style>
  174.     <div style="margin:10px">
  175.     <?php echo $out?>
  176.    
  177.    
  178.     </div>
  179. </body>
  180. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement