Wed, 16 Oct 2019 21:05:03 +0200
Added dutch array strings to a global php script. Changed fermentables, hops, yeast and misc inventory scripts to use these strings between the database scripts and javascript scripts. This makes filtering on types strings useable. Added these changes to the product/recipe forum and print exports too.
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
235
0a063ac5d7f5
Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
151
diff
changeset
|
2 | * Copyright (C) 2018-2019 |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of BMS |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * BrewCloud is distributed in the hope that it will be useful, but |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | $(document).ready(function () { |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | var source = { |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | datatype: "json", |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | cache: false, |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | datafields: [ |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | { name: 'record', type: 'number' }, |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
30 | { name: 'name', type: 'string' }, |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | { name: 'code', type: 'string' }, |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | { name: 'birth', type: 'string' }, |
235
0a063ac5d7f5
Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
151
diff
changeset
|
33 | { name: 'stage', type: 'int' }, |
321
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
34 | { name: 'brew_date', type: 'string' }, |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
35 | { name: 'package_date', type: 'string' }, |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | ], |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | id: 'record', |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | url: "includes/db_product.php?select=inprod" |
467
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
39 | }, |
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
40 | dataAdapter = new $.jqx.dataAdapter(source); |
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
41 | |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | // initialize jqxGrid |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | $("#jqxgrid").jqxGrid({ |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | width: 1280, |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | height: 630, |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | source: dataAdapter, |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | theme: theme, |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | showstatusbar: true, |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | renderstatusbar: function (statusbar) { |
467
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
50 | var container, addButton; |
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
51 | container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
52 | 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>"); |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | container.append(addButton); |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | statusbar.append(container); |
235
0a063ac5d7f5
Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
151
diff
changeset
|
55 | addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | // add new recipe. |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | addButton.click(function (event) { |
467
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
58 | window.location.href = "prod_new.php?return=prod_inprod.php"; |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | }); |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | }, |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | columns: [ |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | { text: 'Datum', datafield: 'birth', width: 120 }, |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | { text: 'Code', datafield: 'code', width: 120 }, |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
64 | { text: 'Naam', datafield: 'name' }, |
321
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
65 | { text: 'Fase', datafield: 'stage', width: 200, |
235
0a063ac5d7f5
Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
151
diff
changeset
|
66 | cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
467
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
67 | var fase, d, date1, date2, date1_unixtime, date2_unixtime, timeDifference, timeDifferenceInDays; |
321
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
68 | // 2 = brew, 6 = package, 7 = carbonation, 8 = mature, 9 = taste |
467
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
69 | fase = StageData[value].nl; |
321
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
70 | if (value == 2) { |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
71 | fase = StageData[value].nl + " op " + rowdata.brew_date; |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
72 | } |
324
d49da6d0b451
Fix for ugly fermentables in stock notation below 1 kg. Don't show days for in production list on the package day.
Michiel Broek <mbroek@mbse.eu>
parents:
321
diff
changeset
|
73 | if (value == 7 || value == 8) { |
467
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
74 | d = new Date(); |
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
75 | date2 = rowdata.package_date; |
321
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
76 | date2 = date2.split('-'); |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
77 | // Now we convert the array to a Date object |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
78 | date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate()); |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
79 | date2 = new Date(date2[0], date2[1]-1, date2[2]); |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
80 | // We use the getTime() method and get the unixtime |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
81 | date1_unixtime = parseInt(date1.getTime() / 1000); |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
82 | date2_unixtime = parseInt(date2.getTime() / 1000); |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
83 | // This is the calculated difference in seconds |
467
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
84 | timeDifference = date1_unixtime - date2_unixtime; |
339
da1f4525169d
Round days for brews that overlap summer/wintertime changes.
Michiel Broek <mbroek@mbse.eu>
parents:
330
diff
changeset
|
85 | // Round the result for brews that overlap summer/wintertime changes. |
467
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
86 | timeDifferenceInDays = Math.round(timeDifference / 60 / 60 / 24); |
321
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
87 | if (timeDifferenceInDays >= 14) |
330
eebe99e9fd99
Corrected mature days count.
Michiel Broek <mbroek@mbse.eu>
parents:
324
diff
changeset
|
88 | fase = StageData[value].nl + " dag " + (timeDifferenceInDays - 14) + " van 28"; |
321
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
89 | else |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
90 | fase = StageData[value].nl + " dag " + timeDifferenceInDays + " van 14"; |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
91 | } |
4116e6184609
The products in production list now shows carbonation and mature period. Also the planned brewdate.
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
92 | return "<span style='margin: 3px; margin-top: 6px; float: left;'>" + fase + "</span>"; |
235
0a063ac5d7f5
Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
151
diff
changeset
|
93 | } |
0a063ac5d7f5
Recipes in progress loading uses indexes. Recipe from database has added inventory information for the ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
151
diff
changeset
|
94 | }, |
286
124af734af68
Version 0.1.0. Removed localization because it was messy, parts were localized and others not. In production and recipes ingredients not in stock are marked in red.
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
95 | { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | return "Wijzig"; |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | }, buttonclick: function (row) { |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | var datarecord = dataAdapter.records[row]; |
467
f8d16480a6a7
Code optimisation for compressed javascript
Michiel Broek <mbroek@mbse.eu>
parents:
339
diff
changeset
|
99 | window.location.href = "prod_edit.php?record=" + datarecord.record + "&select=inprod&return=prod_inprod.php"; |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | } |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | } |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | ], |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | }); |
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | }); |