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

12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require($_SERVER['DOCUMENT_ROOT']."/config.php");
c26af32428a4 Added hops 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");
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
18
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
7
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 #Connect to the database
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 if (! $connect) {
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
c26af32428a4 Added hops 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: 37
diff changeset
13 mysqli_set_charset($connect, "utf8" );
12
c26af32428a4 Added hops 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
196
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
20 if (isset($_POST['insert']) || isset($_POST['update'])) {
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
21 if (isset($_POST['insert'])) {
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
22 $sql = "INSERT INTO `inventory_hops` SET ";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
23 }
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
24 if (isset($_POST['update'])) {
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
25 $sql = "UPDATE `inventory_hops` SET ";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
26 }
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
27
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']);
196
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
35 $sql .= "', alpha='" . $_POST['alpha'];
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
36 $sql .= "', beta='" . $_POST['beta'];
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
37 $sql .= "', humulene='" . $_POST['humulene'];
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
38 $sql .= "', caryophyllene='" . $_POST['caryophyllene'];
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
39 $sql .= "', cohumulone='" . $_POST['cohumulone'];
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
40 $sql .= "', myrcene='" . $_POST['myrcene'];
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
41 $sql .= "', hsi='" . $_POST['hsi'];
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
42 $sql .= "', type='" . array_search($_POST['type'], $hoptype);
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
43 $sql .= "', form='" . array_search($_POST['form'], $hopform);
196
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
44 $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']);
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
45 $sql .= "', origin='" . mysqli_real_escape_string($connect, $_POST['origin']);
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
46 $sql .= "', substitutes='" . mysqli_real_escape_string($connect, $_POST['substitutes']);
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
47 ($_POST['always_on_stock'] == 'true') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
48 $sql .= "', inventory='" . floatval($_POST['inventory']) / 1000.0;
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
49 $sql .= "', cost='" . $_POST['cost'] . "'";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
50 if ($_POST['production_date'] == '')
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
51 $sql .= ", production_date=NULL";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
52 else
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
53 $sql .= ", production_date='" . $_POST['production_date'] . "'";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
54 if ($_POST['tht_date'] == '')
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
55 $sql .= ", tht_date=NULL";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
56 else
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
57 $sql .= ", tht_date='" . $_POST['tht_date'] . "'";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
58 $sql .= ", total_oil='" . $_POST['total_oil'];
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
59 if (isset($_POST['insert'])) {
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
60 $sql .= "';";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
61 }
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
62 if (isset($_POST['update'])) {
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
63 $sql .= "' WHERE record='" . $_POST['record'] . "';";
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
64 }
18
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
65 $result = mysqli_query($connect, $sql);
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
66 if (! $result) {
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
67 syslog(LOG_NOTICE, "db_inventory_hops: ".$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
68 $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
69 $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
70 }
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
71 exit(json_encode($response));
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72
196
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
73 } else if (isset($_POST['delete'])) {
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
74 // DELETE COMMAND
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
75 $sql = "DELETE FROM `inventory_hops` WHERE record='".$_POST['record']."';";
18
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
76 $result = mysqli_query($connect, $sql);
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
77 if (! $result) {
395833e20f88 Better error messages in syslog
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
78 syslog(LOG_NOTICE, "db_inventory_hops: ".$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
79 $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
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: 715
diff changeset
81 }
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
82 exit(json_encode($response));
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 } else {
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 // SELECT COMMAND
196
531d5458782f Hops 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. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
86 $query = "SELECT * FROM inventory_hops ORDER BY origin,name";
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 $hops[] = array(
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 'record' => $row['record'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 '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
92 'uuid' => $row['uuid'],
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 'alpha' => $row['alpha'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 'beta' => $row['beta'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 'humulene' => $row['humulene'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 'caryophyllene' => $row['caryophyllene'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 'cohumulone' => $row['cohumulone'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 'myrcene' => $row['myrcene'],
13
b8c3ca152984 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents: 12
diff changeset
99 'hsi' => $row['hsi'],
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
100 'type' => $hoptype[$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: 296
diff changeset
101 'form' => $hopform[$row['form']],
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 'notes' => $row['notes'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 'origin' => $row['origin'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 'substitutes' => $row['substitutes'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 'always_on_stock' => $row['always_on_stock'],
33
2ee6ad5d6f14 More weight/volmes standards in the database.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
106 'inventory' => floatval($row['inventory']) * 1000.0,
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 'cost' => $row['cost'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 'production_date' => $row['production_date'],
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 'tht_date' => $row['tht_date'],
13
b8c3ca152984 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents: 12
diff changeset
110 'total_oil' => $row['total_oil']
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 );
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 }
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: 196
diff changeset
113 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
114 exit(json_encode($hops));
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 }
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
116
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
117 syslog(LOG_NOTICE, "db_inventory_hops: 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
118 $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
119 $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
120 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
121
12
c26af32428a4 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 ?>

mercurial