www/includes/db_inventory_yeasts.php

Thu, 10 Feb 2022 22:15:10 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 10 Feb 2022 22:15:10 +0100
changeset 785
aa79acfdf8a9
parent 767
08c0343b622b
permissions
-rw-r--r--

Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.

14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require($_SERVER['DOCUMENT_ROOT']."/config.php");
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 require($_SERVER['DOCUMENT_ROOT']."/version.php");
514
3c680d1dea35 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.
Michiel Broek <mbroek@mbse.eu>
parents: 512
diff changeset
5 require($_SERVER['DOCUMENT_ROOT']."/includes/constants.php");
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 #Connect to the database
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 if (! $connect) {
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 }
77
a9f8de2d7b2b Fixed most charset problems. Added fpdf library. Added inventory pdf creation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
12 mysqli_set_charset($connect, "utf8" );
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
14 $response = array(
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
15 'error' => false,
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
16 'msg' => 'Ok',
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
17 );
514
3c680d1dea35 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.
Michiel Broek <mbroek@mbse.eu>
parents: 512
diff changeset
18
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 // get data and store in a json array
198
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
20 if (isset($_POST['insert']) || isset($_POST['update'])) {
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
21 if (isset($_POST['insert'])) {
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
22 $sql = "INSERT INTO `inventory_yeasts` SET ";
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
23 }
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
24 if (isset($_POST['update'])) {
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
25 $sql = "UPDATE `inventory_yeasts` SET ";
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
26 }
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
27
785
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 767
diff changeset
28 if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) {
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 767
diff changeset
29 $sql .= "uuid='" . $_POST['uuid'];
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 767
diff changeset
30 } else {
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 767
diff changeset
31 $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 767
diff changeset
32 $sql .= "uuid='" . $uuid;
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 767
diff changeset
33 }
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 767
diff changeset
34 $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']);
514
3c680d1dea35 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.
Michiel Broek <mbroek@mbse.eu>
parents: 512
diff changeset
35 $sql .= "', type='" . array_search($_POST['type'], $yeasttype);
3c680d1dea35 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.
Michiel Broek <mbroek@mbse.eu>
parents: 512
diff changeset
36 $sql .= "', form='" . array_search($_POST['form'], $yeastform);
198
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
37 $sql .= "', laboratory='" . mysqli_real_escape_string($connect, $_POST['laboratory']);
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
38 $sql .= "', product_id='" . mysqli_real_escape_string($connect, $_POST['product_id']);
630
ffe0416614b3 Added short_desc to the yeast inventory database for short remarks in the yeastlab pdf list
Michiel Broek <mbroek@mbse.eu>
parents: 514
diff changeset
39 $sql .= "', short_desc='" . mysqli_real_escape_string($connect, $_POST['short_desc']);
198
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
40 $sql .= "', min_temperature='" . $_POST['min_temperature'];
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
41 $sql .= "', max_temperature='" . $_POST['max_temperature'];
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
42 $sql .= "', flocculation='" . $_POST['flocculation'];
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
43 $sql .= "', attenuation='" . $_POST['attenuation'];
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
44 $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']);
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
45 $sql .= "', best_for='" . mysqli_real_escape_string($connect, $_POST['best_for']);
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
46 $sql .= "', max_reuse='" . $_POST['max_reuse'];
201
f9b7e3f6be7c Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
47 $sql .= "', cells='" . floatval($_POST['cells']) * 1000000000.0;
313
9f45d09c2071 Added alcohol tolerance field in the yeasts database.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
48 $sql .= "', tolerance='" . $_POST['tolerance'];
512
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
49 ($_POST['sta1'] == 'true') ? $sql .= "', sta1='1" : $sql .= "', sta1='0";
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
50 ($_POST['bacteria'] == 'true') ? $sql .= "', bacteria='1" : $sql .= "', bacteria='0";
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
51 ($_POST['harvest_top'] == 'true') ? $sql .= "', harvest_top='1" : $sql .= "', harvest_top='0";
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
52 $sql .= "', harvest_time='" . $_POST['harvest_time'];
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
53 $sql .= "', pitch_temperature='" . floatval($_POST['pitch_temperature']);
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
54 ($_POST['pofpos'] == 'true') ? $sql .= "', pofpos='1" : $sql .= "', pofpos='0";
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
55 $sql .= "', zymocide='" . $_POST['zymocide'];
725
30346e5b9e12 Added pitch rate fields for gram/hl for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
56 $sql .= "', gr_hl_lo='" . $_POST['gr_hl_lo'];
30346e5b9e12 Added pitch rate fields for gram/hl for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
57 $sql .= "', sg_lo='" . floatval($_POST['sg_lo']);
30346e5b9e12 Added pitch rate fields for gram/hl for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
58 $sql .= "', gr_hl_hi='" . $_POST['gr_hl_hi'];
30346e5b9e12 Added pitch rate fields for gram/hl for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
59 $sql .= "', sg_hi='" . floatval($_POST['sg_hi']);
201
f9b7e3f6be7c Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
60 $sql .= "', inventory='" . $_POST['inventory'];
198
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
61 $sql .= "', cost='" . $_POST['cost'] . "'";
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
62 if ($_POST['production_date'] == '')
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
63 $sql .= ", production_date=NULL";
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
64 else
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
65 $sql .= ", production_date='" . $_POST['production_date'] . "'";
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
66 if ($_POST['tht_date'] == '')
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
67 $sql .= ", tht_date=NULL";
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
68 else
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
69 $sql .= ", tht_date='" . $_POST['tht_date'] . "'";
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
70 if (isset($_POST['insert'])) {
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
71 $sql .= ";";
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
72 }
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
73 if (isset($_POST['update'])) {
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
74 $sql .= " WHERE record='" . $_POST['record'] . "';";
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
75 }
18
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
76 $result = mysqli_query($connect, $sql);
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
77 if (! $result) {
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
78 syslog(LOG_NOTICE, "db_inventory_yeasts: ".$sql." result: ".mysqli_error($connect));
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
79 $response['error'] = true;
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
80 $response['msg'] = "SQL fout: ".mysqli_error($connect);
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
81 }
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
82 exit(json_encode($response));
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
198
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
84 } else if (isset($_POST['delete'])) {
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
85 // DELETE COMMAND
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
86 $sql = "DELETE FROM `inventory_yeasts` WHERE record='".$_POST['record']."';";
18
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
87 $result = mysqli_query($connect, $sql);
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
88 if (! $result) {
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
89 syslog(LOG_NOTICE, "db_inventory_yeasts: ".$sql." result: ".mysqli_error($connect));
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
90 $response['error'] = true;
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
91 $response['msg'] = "SQL fout: ".mysqli_error($connect);
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
92 }
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
93 exit(json_encode($response));
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 } else {
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 // SELECT COMMAND
198
f0ec83e1e01f Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
97 $query = "SELECT * FROM inventory_yeasts ORDER BY laboratory,product_id,name";
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 $yeasts[] = array(
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 'record' => $row['record'],
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 'name' => $row['name'],
785
aa79acfdf8a9 Added uuid field in inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts. Added uuid field in profiles mash, styles and water.
Michiel Broek <mbroek@mbse.eu>
parents: 767
diff changeset
103 'uuid' => $row['uuid'],
514
3c680d1dea35 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.
Michiel Broek <mbroek@mbse.eu>
parents: 512
diff changeset
104 'type' => $yeasttype[$row['type']],
3c680d1dea35 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.
Michiel Broek <mbroek@mbse.eu>
parents: 512
diff changeset
105 'form' => $yeastform[$row['form']],
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 'laboratory' => $row['laboratory'],
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 'product_id' => $row['product_id'],
630
ffe0416614b3 Added short_desc to the yeast inventory database for short remarks in the yeastlab pdf list
Michiel Broek <mbroek@mbse.eu>
parents: 514
diff changeset
108 'short_desc' => $row['short_desc'],
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 'min_temperature' => $row['min_temperature'],
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 'max_temperature' => $row['max_temperature'],
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 'flocculation' => $row['flocculation'],
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 'attenuation' => $row['attenuation'],
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 'notes' => $row['notes'],
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 'best_for' => $row['best_for'],
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 'max_reuse' => $row['max_reuse'],
201
f9b7e3f6be7c Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
116 'inventory' => $row['inventory'],
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 'cost' => $row['cost'],
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 'production_date' => $row['production_date'],
201
f9b7e3f6be7c Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
119 'tht_date' => $row['tht_date'],
313
9f45d09c2071 Added alcohol tolerance field in the yeasts database.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
120 'cells' => floatval($row['cells']) / 1000000000.0,
512
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
121 'tolerance' => $row['tolerance'],
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
122 'sta1' => $row['sta1'],
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
123 'bacteria' => $row['bacteria'],
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
124 'harvest_top' => $row['harvest_top'],
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
125 'harvest_time' => $row['harvest_time'],
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
126 'pitch_temperature' => floatval($row['pitch_temperature']),
4451af8b6295 Added new fields in inventory_yeasts for Kveik and extra generic flags. Currently these fields do nothing but adding extra information in the database. Added Brett, Kveik and Hybrid yeast types.
Michiel Broek <mbroek@mbse.eu>
parents: 313
diff changeset
127 'pofpos' => $row['pofpos'],
725
30346e5b9e12 Added pitch rate fields for gram/hl for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
128 'zymocide' => $row['zymocide'],
30346e5b9e12 Added pitch rate fields for gram/hl for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
129 'gr_hl_lo' => $row['gr_hl_lo'],
30346e5b9e12 Added pitch rate fields for gram/hl for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
130 'sg_lo' => floatval($row['sg_lo']),
30346e5b9e12 Added pitch rate fields for gram/hl for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
131 'gr_hl_hi' => $row['gr_hl_hi'],
30346e5b9e12 Added pitch rate fields for gram/hl for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
132 'sg_hi' => floatval($row['sg_hi'])
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 );
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 }
296
69fadd1aded2 Updated design document. Add content header application/json to all scripts that produce json output. Chart prints show the beer code and name in the header. Charts don't display the menu anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 201
diff changeset
135 header("Content-type: application/json");
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
136 exit(json_encode($yeasts));
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 }
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
138
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
139 syslog(LOG_NOTICE, "db_inventory_yeasts: missing arguments");
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
140 $response['error'] = true;
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
141 $response['msg'] = "missing arguments";
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
142 echo json_encode($response);
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 725
diff changeset
143
14
d9dfd703df83 Added yeast inventory screens
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 ?>

mercurial