www/includes/db_inventory_fermentables.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.

11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require($_SERVER['DOCUMENT_ROOT']."/config.php");
d341f0a91a91 Added fermentable inventory
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: 296
diff changeset
5 require($_SERVER['DOCUMENT_ROOT']."/includes/constants.php");
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 #Connect to the database
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 if (! $connect) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 }
77
a9f8de2d7b2b Fixed most charset problems. Added fpdf library. Added inventory pdf creation.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
13 mysqli_set_charset($connect, "utf8" );
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
15 $response = array(
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
16 'error' => false,
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
17 'msg' => 'Ok',
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
18 );
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
19
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 // get data and store in a json array
195
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
21 if (isset($_POST['insert']) || isset($_POST['update'])) {
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
22 if (isset($_POST['insert'])) {
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
23 $sql = "INSERT INTO `inventory_fermentables` SET ";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
24 }
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
25 if (isset($_POST['update'])) {
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
26 $sql = "UPDATE `inventory_fermentables` SET ";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
27 }
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
28
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
29 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
30 $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
31 } 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
32 $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
33 $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
34 }
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
35 $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: 296
diff changeset
36 $sql .= "', type='" . array_search($_POST['type'], $fermentabletype);
195
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
37 $sql .= "', yield='" . $_POST['yield'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
38 $sql .= "', color='" . $_POST['color'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
39 ($_POST['add_after_boil'] == 'true') ? $sql .= "', add_after_boil='1" : $sql .= "', add_after_boil='0";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
40 $sql .= "', origin='" . mysqli_real_escape_string($connect, $_POST['origin']);
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
41 $sql .= "', supplier='" . mysqli_real_escape_string($connect, $_POST['supplier']);
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
42 $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']);
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
43 $sql .= "', coarse_fine_diff='" . $_POST['coarse_fine_diff'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
44 $sql .= "', moisture='" . $_POST['moisture'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
45 $sql .= "', diastatic_power='" . $_POST['diastatic_power'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
46 $sql .= "', protein='" . $_POST['protein'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
47 $sql .= "', dissolved_protein='" . $_POST['dissolved_protein'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
48 $sql .= "', max_in_batch='" . $_POST['max_in_batch'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
49 ($_POST['recommend_mash'] == 'true') ? $sql .= "', recommend_mash='1" : $sql .= "', recommend_mash='0";
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: 296
diff changeset
50 $sql .= "', added='" . array_search($_POST['added'], $added);
195
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
51 ($_POST['always_on_stock'] == 'true') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
52 $sql .= "', di_ph='" . $_POST['di_ph'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
53 $sql .= "', acid_to_ph_57='" . $_POST['acid_to_ph_57'];
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: 296
diff changeset
54 $sql .= "', graintype='" . array_search($_POST['graintype'], $graintype);
195
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
55 $sql .= "', inventory='" . $_POST['inventory'];
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
56 $sql .= "', cost='" . $_POST['cost'] . "'";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
57 if ($_POST['production_date'] == '')
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
58 $sql .= ", production_date=NULL";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
59 else
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
60 $sql .= ", production_date='" . $_POST['production_date'] . "'";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
61 if ($_POST['tht_date'] == '')
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
62 $sql .= ", tht_date=NULL";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
63 else
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
64 $sql .= ", tht_date='" . $_POST['tht_date'] . "'";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
65 if (isset($_POST['insert'])) {
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
66 $sql .= ";";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
67 }
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
68 if (isset($_POST['update'])) {
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
69 $sql .= " WHERE record='" . $_POST['record'] . "';";
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
70 }
18
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
71 $result = mysqli_query($connect, $sql);
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
72 if (! $result) {
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
73 syslog(LOG_NOTICE, "db_inventory_fermentables: ".$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: 715
diff changeset
74 $response['error'] = true;
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
75 $response['msg'] = "SQL fout: ".mysqli_error($connect);
18
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
76 }
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
77 exit(json_encode($response));
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78
195
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
79 } else if (isset($_POST['delete'])) {
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
80 // DELETE COMMAND
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
81 $sql = "DELETE FROM `inventory_fermentables` WHERE record='".$_POST['record']."';";
18
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
82 $result = mysqli_query($connect, $sql);
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
83 if (! $result) {
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
84 syslog(LOG_NOTICE, "db_inventory_fermentables: ".$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: 715
diff changeset
85 $response['error'] = true;
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
86 $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: 715
diff changeset
87 }
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
88 exit(json_encode($response));
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 } else {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 // SELECT COMMAND
195
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
92 $query = "SELECT * FROM inventory_fermentables ORDER BY supplier,name";
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 $fermentables[] = array(
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 'record' => $row['record'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 '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
98 '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: 296
diff changeset
99 'type' => $fermentabletype[$row['type']],
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 'yield' => $row['yield'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 'color' => $row['color'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 'add_after_boil' => $row['add_after_boil'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 'origin' => $row['origin'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 'supplier' => $row['supplier'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 'notes' => $row['notes'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 'coarse_fine_diff' => $row['coarse_fine_diff'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 'moisture' => $row['moisture'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 'diastatic_power' => $row['diastatic_power'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 'protein' => $row['protein'],
195
2ac491548d8d Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
110 'dissolved_protein' => $row['dissolved_protein'],
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 'max_in_batch' => $row['max_in_batch'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 'recommend_mash' => $row['recommend_mash'],
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: 296
diff changeset
113 'added' => $added[$row['added']],
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 'always_on_stock' => $row['always_on_stock'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 'di_ph' => $row['di_ph'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 'acid_to_ph_57' => $row['acid_to_ph_57'],
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: 296
diff changeset
117 'graintype' => $graintype[$row['graintype']],
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 'inventory' => $row['inventory'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 'cost' => $row['cost'],
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 'production_date' => $row['production_date'],
39
400aae9fb0c8 Some small fixes
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
121 'tht_date' => $row['tht_date']
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 );
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 }
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: 195
diff changeset
124 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: 715
diff changeset
125 exit(json_encode($fermentables));
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 }
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
127
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
128 syslog(LOG_NOTICE, "db_inventory_fermentables: missing arguments");
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
129 $response['error'] = true;
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
130 $response['msg'] = "missing arguments";
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
131 echo json_encode($response);
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
132
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 ?>

mercurial