|
1 /***************************************************************************** |
|
2 * Copyright (C) 2018 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of BMS |
|
7 * |
|
8 * This is free software; you can redistribute it and/or modify it |
|
9 * under the terms of the GNU General Public License as published by the |
|
10 * Free Software Foundation; either version 2, or (at your option) any |
|
11 * later version. |
|
12 * |
|
13 * BrewCloud is distributed in the hope that it will be useful, but |
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with ThermFerm; see the file COPYING. If not, write to the Free |
|
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
21 *****************************************************************************/ |
|
22 |
|
23 |
|
24 $(document).ready(function () { |
|
25 var source = { |
|
26 datatype: "json", |
|
27 cache: false, |
|
28 datafields: [ |
|
29 { name: 'record', type: 'number' }, |
|
30 { name: 'st_name', type: 'string' }, |
|
31 { name: 'st_letter', type: 'string' }, |
|
32 { name: 'st_guide', type: 'string' }, |
|
33 { name: 'name', type: 'string' }, |
|
34 { name: 'est_og', type: 'float' }, |
|
35 { name: 'est_color', type: 'float' }, |
|
36 { name: 'est_ibu', type: 'float' }, |
|
37 ], |
|
38 id: 'record', |
|
39 url: "includes/db_recipes.php" |
|
40 }; |
|
41 var dataAdapter = new $.jqx.dataAdapter(source); |
|
42 // initialize jqxGrid |
|
43 $("#jqxgrid").jqxGrid({ |
|
44 width: 1280, |
|
45 height: 630, |
|
46 source: dataAdapter, |
|
47 groupable: true, |
|
48 theme: theme, |
|
49 showstatusbar: true, |
|
50 localization: getLocalization(), |
|
51 renderstatusbar: function (statusbar) { |
|
52 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
53 var addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Add</span></div>"); |
|
54 container.append(addButton); |
|
55 statusbar.append(container); |
|
56 addButton.jqxButton({ theme: theme, width: 120, height: 20 }); |
|
57 // add new recipe. |
|
58 addButton.click(function (event) { |
|
59 var url= "rec_new.php?return='rec_main.php'"; |
|
60 window.location.href = url; |
|
61 }); |
|
62 }, |
|
63 filterable: true, |
|
64 filtermode: 'excel', |
|
65 columns: [ |
|
66 { text: 'Stijlgids', datafield: 'st_guide', width: 120 }, |
|
67 { text: 'Letter', datafield: 'st_letter', width: 60 }, |
|
68 { text: 'Stijl', datafield: 'st_name', width: 150 }, |
|
69 { text: 'Naam', datafield: 'name' }, |
|
70 { text: 'OG', datafield: 'est_og', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, |
|
71 { text: 'EBC', datafield: 'est_color', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, |
|
72 { text: 'IBU', datafield: 'est_ibu', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, |
|
73 { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { |
|
74 return "Wijzig"; |
|
75 }, buttonclick: function (row) { |
|
76 var datarecord = dataAdapter.records[row]; |
|
77 var url= "rec_edit.php?record=" + datarecord.record + "&return='rec_main.php'"; |
|
78 window.location.href = url; |
|
79 } |
|
80 } |
|
81 ], |
|
82 groups: ['st_guide','st_letter' ] |
|
83 }); |
|
84 }); |