Advertisement
Guest User

Untitled

a guest
May 21st, 2015
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. <?php
  2. /**
  3. * PHP Grid Component
  4. *
  5. * @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
  6. * @version 1.5.2
  7. * @license: see license.txt included in package
  8. */
  9.  
  10. // include db config
  11. include_once("../../config.php");
  12.  
  13. // set up DB
  14. mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
  15. mysql_select_db(PHPGRID_DBNAME);
  16.  
  17. // include and create object
  18. include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
  19.  
  20. $g = new jqgrid();
  21.  
  22. $col = array();
  23. $col["title"] = "Id"; // caption of column
  24. $col["name"] = "client_id";
  25. $col["width"] = "30";
  26. $col["export"] = true;
  27. $cols[] = $col;
  28.  
  29. $col = array();
  30. $col["title"] = "Client";
  31. $col["name"] = "name";
  32. $col["width"] = "100";
  33. $col["editable"] = true;
  34. $cols[] = $col;
  35.  
  36. $col = array();
  37. $col["title"] = "Gender";
  38. $col["name"] = "gender";
  39. $col["width"] = "100";
  40. $col["editable"] = true;
  41. $cols[] = $col;
  42.  
  43. $col = array();
  44. $col["title"] = "Company";
  45. $col["name"] = "company";
  46. $col["width"] = "100";
  47. $col["editable"] = true;
  48. $cols[] = $col;
  49.  
  50. // $grid["sortname"] = 'client_id'; // by default sort grid by this field
  51. $grid["sortorder"] = "desc"; // ASC or DESC
  52. $grid["caption"] = "Client Data"; // caption of grid
  53. $grid["autowidth"] = true; // expand grid to screen width
  54. $grid["multiselect"] = false; // allow you to multi-select through checkboxes
  55. $grid["rowNum"] = 100; // allow you to multi-select through checkboxes
  56. $grid["rowList"] = array(100,200,500);
  57. // Predefined standard page formats: http://www.tcexam.org/doc/code/classTCPDF.html#a087d4df77e60b7054e97804069ed32c5
  58. // Orientation: landscape, portrait
  59.  
  60. $_SESSION["uid"] = "Abu Ghufran";
  61. $grid["export"] = array("format"=>"pdf", "filename"=>"my-file", "heading"=>"Invoice Details: ".$_SESSION["uid"], "orientation"=>"landscape", "paper"=>"a4");
  62.  
  63. // Setting RTL will export pdf as RTL also
  64. // $grid["direction"] = "rtl";
  65.  
  66. // export filtered data or all data
  67. $grid["export"]["range"] = "filtered"; // or "all"
  68. $grid["export"]["paged"] = "1";
  69. $g->set_options($grid);
  70.  
  71. // params are array(<function-name>,<class-object> or <null-if-global-func>)
  72. $e["on_render_pdf"] = array("set_pdf_format", null);
  73. $g->set_events($e);
  74.  
  75. function set_pdf_format($arr)
  76. {
  77. $pdf = $arr["pdf"];
  78. $data = $arr["data"];
  79.  
  80. // $pdf->SetFont('helvetica', '', 11);
  81. $pdf->SetHeaderCellsFillColor(30,70,99);
  82. $pdf->SetHeaderCellsFontColor(255,255,255);
  83.  
  84. /*
  85. PDF format customization API available here
  86. -------------------------------------------
  87. http://www.tcpdf.org/examples.php
  88. http://www.tcpdf.org/doc/code/classTCPDF.html
  89.  
  90. More Custom Addons API (see inc/tcpdf/class.TCPDF.EasyTable.php & jqgrid_dist.php)
  91. ----------------------------------------------------------------
  92. public function SetCellMinimumHeight($height)
  93. public function SetCellFixedHeight($height)
  94. public function SetHeaderCellFixedHeight($height)
  95. public function SetTableHeaderPerPage($var)
  96. public function SetTableHeaderFirstTablePerPageOnly($var)
  97. public function SetCellAlignment($ArrayCellAlignment)
  98. public function SetCellWidths($ArrayCellWidths)
  99. public function SetCellFillStyle($int)
  100. public function SetFillImageCell($fill)
  101. public function SetHCellSpace($var)
  102. public function SetVCellSpace($var)
  103. public function SetHeaderCellsFillColor($R,$G,$B)
  104. public function SetTableRowFillColors(Array $colorsArray)
  105. public function SetHeaderCellsFontColor($R,$G,$B)
  106. public function SetHeaderCellsFontStyle($var)
  107. public function SetCellFontColor($R,$G,$B)
  108. public function SetFooterExclusionZone($float)
  109. public function SetTableX($x)
  110. public function SetTableY($y)
  111. public function Header()
  112. public function Footer()
  113. */
  114. }
  115.  
  116.  
  117. $g->set_actions(array(
  118. "add"=>true, // allow/disallow add
  119. "edit"=>true, // allow/disallow edit
  120. "delete"=>true, // allow/disallow delete
  121. "rowactions"=>true, // show/hide row wise edit/del/save option
  122. "export"=>true, // show/hide export to excel option
  123. "autofilter" => true, // show/hide autofilter for search
  124. "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
  125. )
  126. );
  127.  
  128. // this db table will be used for add,edit,delete
  129. $g->table = "clients";
  130. // $g->select_command = "select id, name, description from audios";
  131.  
  132. // pass the cooked columns to grid
  133. $g->set_columns($cols);
  134.  
  135. // generate grid output, with unique grid name as 'list1'
  136. $out = $g->render("list1");
  137. ?>
  138. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  139. <html>
  140. <head>
  141. <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link>
  142. <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link>
  143.  
  144. <script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
  145. <script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  146. <script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
  147. <script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  148. </head>
  149. <body>
  150. <div style="margin:10px">
  151. <br>
  152. <?php echo $out?>
  153. </div>
  154. </body>
  155. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement