fsnoya

grid mysqli

May 14th, 2018
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.35 KB | None | 0 0
  1. <?
  2. require_once('connection.php');
  3.  
  4. include_once("./phpgrid-full-v2.0/lib/inc/jqgrid_dist.php");
  5.  
  6. //LISTADO TOTALES
  7. // nombre del archivo excel
  8. $n_archivo_l = 'facturas_' . $n_dia . '_' . date('d-m-y');
  9. $fecha = date("Y-m-d");
  10.  
  11. $g = new jqgrid();
  12.  
  13. // $grid["url"] = ""; // your paramterized URL -- defaults to REQUEST_URI
  14. $grid["rowNum"] = '30'; // by default 20
  15. $grid["sortname"] = 'pago_fact ASC,fecha_fact'; // by default sort grid by this field
  16. $grid["sortorder"] = "asc"; // ASC or DESC
  17. $grid["caption"] = "$boton_panel[6]"; // caption of grid
  18. $grid["autowidth"] = true; // expand grid to screen width
  19. //$grid["width"] = 600;
  20. $grid["height"] = 410;
  21. $grid["multiselect"] = true; // allow you to multi-select through checkboxes
  22. $grid["hiddengrid"] = false;
  23. $grid["rowactions"] = false;
  24. $grid["edit_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
  25. $grid["add_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
  26.  
  27. // export PDF file params
  28. $grid["export"] = array("filename"=>$n_archivo_l, "heading"=>$n_archivo_l, "orientation"=>"portrait", "paper"=>"a4");
  29. // for excel, sheet header
  30. $grid["export"]["sheetname"] = $n_archivo_l;
  31.  
  32.  
  33. // export filtered data or all data
  34. $grid["export"]["range"] = "filtered"; // or "all"
  35.  
  36. // excel visual params
  37. $grid["cellEdit"] = true; // inline cell editing, like spreadsheet
  38. $grid["rownumbers"] = false;
  39. $grid["rownumWidth"] = 15;
  40.  
  41. $col = array();
  42. $col["title"] = "id_fact";
  43. $col["name"] = "id_fact";
  44. $col["width"] = "2";
  45. $col["export"] = false;
  46. $col["hidden"] = true; // hide column by default
  47. $cols[] = $col;
  48.  
  49. $col["title"] = "id_booking_fact";
  50. $col["name"] = "id_booking_fact";
  51. $col["width"] = "1";
  52. $col["export"] = false;
  53. $col["show"]["list"] = false;
  54. $col["show"]["add"] = true;
  55. $col["editable"] = true;
  56. $col["search"] = true;
  57. $cols[] = $col;
  58.  
  59. $col = array();
  60. $col["title"] = "factura";
  61. $col["name"] = "numero_fact";
  62. $col["width"] = "1";
  63. $col["export"] = false;
  64. $col["editable"] = true;
  65. $col["search"] = true;
  66. $cols[] = $col;
  67.  
  68. $col = array();
  69. $col["title"] = "apellidos";
  70. $col["name"] = "apellidos_fact";
  71. $col["width"] = "1";
  72. $col["export"] = false;
  73. $col["editable"] = true;
  74. $col["search"] = true;
  75. $cols[] = $col;
  76.  
  77. $col = array();
  78. $col["title"] = "nombre";
  79. $col["name"] = "nombre_fact";
  80. $col["width"] = "1";
  81. $col["export"] = false;
  82. $col["editable"] = true;
  83. $col["search"] = true;
  84. $cols[] = $col;
  85.  
  86. $col = array();
  87. $col["title"] = "valor";
  88. $col["name"] = "valor_fact";
  89. $col["width"] = "1";
  90. //$col["align"] = "center";
  91. $col["editable"] = true;
  92. $col["export"] = true;
  93. $col["search"] = true;
  94. $col["editable"] = true;
  95. $cols[] = $col;
  96.  
  97. $col["title"] = "fecha";
  98. $col["name"] = "fecha_fact";
  99. $col["width"] = "1";
  100. //$col["align"] = "center";
  101. $col["editable"] = true;
  102. $col["export"] = true;
  103. $col["hidden"] = false;
  104. $col["search"] = true;
  105. $col["editable"] = true;
  106. $cols[] = $col;
  107.  
  108. $col = array();
  109. $col["title"] = "fecha pago";
  110. $col["name"] = "fecha_pago";
  111. $col["editable"] = true;
  112. $col["width"] = "2";
  113. $col["export"] = true;
  114. $col["search"] = true;
  115. $cols[] = $col;
  116.  
  117. $col = array();
  118. $col["title"] = "periodo_factura";
  119. $col["name"] = "periodo_factura";
  120. $col["width"] = "3";
  121. $col["editable"] = true;
  122. $col["export"] = true;
  123. $col["search"] = true;
  124. $cols[] = $col;
  125.  
  126. $col = array();
  127. $col["title"] = "pagada?";
  128. $col["name"] = "pago_fact";
  129. $col["width"] = "1";
  130. $col["editable"] = true;
  131. $col["export"] = true;
  132. $col["search"] = true;
  133. $col["hidden"] = false;
  134. $cols[] = $col;
  135.  
  136. $col = array();
  137. $col["title"] = "ver";
  138. $col["name"] = "habitacion";
  139. $col["width"] = "1";
  140. $col["editable"] = true;
  141. $col["export"] = true;
  142. $col["search"] = true;
  143. $col["hidden"] = false;
  144. $cols[] = $col;
  145.  
  146. $g->set_options($grid);
  147.  
  148. $g->set_actions(array(
  149. "add"=>false, // allow/disallow add
  150. "edit"=>true, // allow/disallow edit
  151. "delete"=>true, // allow/disallow delete
  152. "rowactions"=>true, // show/hide row wise edit/del/save option
  153. "export_excel"=>true, // show/hide export to excel option - must set export xlsx params
  154. "export_pdf"=>false, // show/hide export to pdf option - must set pdf params
  155. "autofilter" => true, // show/hide autofilter for search
  156. "search" => 'simple', // show single/multi field search condition (e.g. simple or advance)
  157. "showhidecolumns" => false // show single/multi field search condition (e.g. simple or advance)
  158. )
  159. );
  160.  
  161.  
  162.  
  163. // you can provide custom SQL query to display data
  164. $g->select_command = "SELECT
  165. f.id_fact,
  166. f.id_booking_fact,
  167. f.numero_fact,
  168. f.id_resident_fact,
  169. f.valor_fact,
  170. f.fecha_fact,
  171. f.fecha_pago,
  172. f.periodo_factura,
  173. r.nombre_fact,
  174. r.apellidos_fact
  175.  
  176. FROM facturas_lista f LEFT JOIN residents r ON f.id_resident_fact = r.resident_id ";
  177.  
  178. // this db table will be used for add,edit,delete
  179. $g->table = "facturas_lista";
  180. // pass the cooked columns to grid
  181. $g->set_columns($cols);
  182.  
  183. $grid_id = "hola";
  184. // generate grid output, with unique grid name as 'list1'
  185. $residentes = $g->render($grid_id);
  186. /*
  187. $grid["edit_options"]["afterShowForm"] = 'function(hola) {
  188. jQuery("#sin comedor").inputmask("mm/dd/yyyy", {yearrange: { minyear: 2010, maxyear: 2020 }});
  189. jQuery("#Worth").inputmask("currency", {prefix:"$ ",groupSeparator:",",alias:"numeric",placeholder:"0",autoGroup:!0,digits:2,digitsOptional:!1,clearMaskOnLostFocus:!1});
  190. }';
  191. */
  192.  
  193. ?>
  194. <!doctype html>
  195. <html>
  196. <head>
  197. <meta charset="utf-8">
  198. <title>facturas</title>
  199. <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
  200. <!--para botón de icono de pantalla en el movil (android)-->
  201. <link href="apple-touch-icon.png" rel="apple-touch-icon" />
  202. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  203. <meta name="mobile-web-app-capable" content="yes">
  204. <meta name="theme-color" content="#43a047">
  205.  
  206. <style>
  207. input, select{
  208. width: auto;
  209. }
  210. input[type=checkbox] {
  211. display: block;
  212. width: 20px;
  213. height: 20px;
  214. }
  215. </style>
  216.  
  217.  
  218. <!--JQUERY-->
  219. <link rel="stylesheet" type="text/css" href="./phpgrid-full-v2.0/lib/js/themes/cupertino/jquery-ui.custom.css">
  220. <link rel="stylesheet" type="text/css" media="screen" href="./phpgrid-full-v2.0/lib/js/jqgrid/css/ui.jqgrid.css"></link>
  221.  
  222. <script src="./phpgrid-full-v2.0/lib/js/jquery.min.js" type="text/javascript"></script>
  223. <script src='./phpgrid-full-v2.0/lib/js/jqgrid/js/i18n/grid.locale-en.js' type='text/javascript' charset='UTF-8'></script>
  224. <script src='./phpgrid-full-v2.0/lib/js/jqgrid/js/i18n/grid.locale-es.js' type='text/javascript' charset='UTF-8'></script>
  225. <script type="text/javascript" src="./phpgrid-full-v2.0/lib/js/jqgrid/js/jquery.jqGrid.min.js"></script>
  226. <script src="./phpgrid-full-v2.0/lib/js/themes/jquery-ui.custom.min.js" type="text/javascript" ></script>
  227. </head>
  228.  
  229. <body>
  230.  
  231. <div id="div_lista_residentes" style=" width:100%; margin: 0 auto; clear:both; float:left; padding:10px 10px 20px 10px;" >
  232. <? echo $residentes ?>
  233. </div>
  234. <div id="b_volver" name="b_volver" style="width:90px; float:left;" class="boton_ui">
  235. volver
  236. </div>
  237. <script>
  238. $(document).ready(function() {
  239. $(function() {
  240. $( ".boton_ui").button();
  241. });
  242.  
  243. $('#b_volver').click(function(){
  244. window.close();
  245. });
  246.  
  247. });
  248. </script>
  249. </body>
  250. </html>
Advertisement
Add Comment
Please, Sign In to add comment