www/includes/db_inventory_equipments.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
child 840
ba607babc468
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.

27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 require($_SERVER['DOCUMENT_ROOT']."/config.php");
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require($_SERVER['DOCUMENT_ROOT']."/version.php");
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 #Connect to the database
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 if (! $connect) {
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 }
77
a9f8de2d7b2b Fixed most charset problems. Added fpdf library. Added inventory pdf creation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
10 mysqli_set_charset($connect, "utf8" );
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11
766
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
12 $response = array(
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
13 'error' => false,
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
14 'msg' => 'Ok',
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
15 );
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
16
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
17 if (isset($_POST['insert']) || isset($_POST['update'])) {
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
18 if (isset($_POST['insert'])) {
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
19 // INSERT COMMAND
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
20 $sql = "INSERT INTO `inventory_equipments` SET ";
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
21 }
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
22 if (isset($_POST['update'])) {
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
23 // UPDATE COMMAND
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
24 $sql = "UPDATE `inventory_equipments` SET ";
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
25 }
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
26
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 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
28 $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
29 } 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
30 $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
31 $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
32 }
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 .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']);
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
34 $sql .= "', boil_size='" . $_POST['boil_size'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
35 $sql .= "', batch_size='" . $_POST['batch_size'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
36 $sql .= "', tun_volume='" . $_POST['tun_volume'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
37 $sql .= "', tun_weight='" . $_POST['tun_weight'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
38 $sql .= "', tun_specific_heat='" . $_POST['tun_specific_heat'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
39 $sql .= "', tun_material='" . $_POST['tun_material'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
40 $sql .= "', tun_height='" . floatval($_POST['tun_height']) / 100.0;
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
41 $sql .= "', top_up_water='" . $_POST['top_up_water'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
42 $sql .= "', trub_chiller_loss='" . $_POST['trub_chiller_loss'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
43 $sql .= "', evap_rate='" . $_POST['evap_rate'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
44 $sql .= "', boil_time='" . $_POST['boil_time'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
45 ($_POST['calc_boil_volume'] == 'true') ? $sql .= "', calc_boil_volume='1" : $sql .= "', calc_boil_volume='0";
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
46 $sql .= "', top_up_kettle='" . $_POST['top_up_kettle'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
47 $sql .= "', hop_utilization='" . $_POST['hop_utilization'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
48 $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']);
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
49 $sql .= "', lauter_volume='" . $_POST['lauter_volume'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
50 $sql .= "', lauter_height='" . floatval($_POST['lauter_height']) / 100.0;
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
51 $sql .= "', lauter_deadspace='" . $_POST['lauter_deadspace'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
52 $sql .= "', kettle_volume='" . $_POST['kettle_volume'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
53 $sql .= "', kettle_height='" . floatval($_POST['kettle_height']) / 100.0;
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
54 $sql .= "', mash_volume='" . $_POST['mash_volume'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
55 $sql .= "', mash_max='" . $_POST['mash_max'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
56 $sql .= "', efficiency='" . $_POST['efficiency'];
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
57 if (isset($_POST['insert'])) {
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
58 $sql .= "';";
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
59 }
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
60 if (isset($_POST['update'])) {
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
61 $sql .= "' WHERE record='" . $_POST['record'] . "';";
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
62 }
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 $result = mysqli_query($connect, $sql);
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 if (! $result) {
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect));
766
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
66 $response['error'] = true;
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 766
diff changeset
67 $response['msg'] = "SQL fout: ".mysqli_error($connect);
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 }
766
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
69 exit(json_encode($response));
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
71 } else if (isset($_POST['delete'])) {
766
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
72 // DELETE COMMAND. check if this record is in use.
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
73 $sql = "SELECT name FROM `inventory_equipments` WHERE record='".$_POST['record']."';";
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
74 $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect));
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
75 if (! $result) {
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
76 syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect));
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
77 $response['error'] = true;
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 766
diff changeset
78 $response['msg'] = "SQL fout: ".mysqli_error($connect);
766
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
79 exit(json_encode($response));
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
80 }
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
81 if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
82 $sql = "SELECT eq_name FROM products WHERE eq_name='" . $row['name'] . "';";
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
83 $result2 = mysqli_query($connect, $sql);
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
84 $ar = mysqli_affected_rows($connect);
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
85 if ($ar > 0) {
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
86 $response['error'] = true;
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
87 $response['msg'] = "Installatie wordt ".$ar." maal gebruikt.";
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
88 exit(json_encode($response));
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
89 }
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
90 }
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
91 // Record not used, delete it.
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
92 $sql = "DELETE FROM `inventory_equipments` WHERE record='".$_POST['record']."';";
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 $result = mysqli_query($connect, $sql);
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 if (! $result) {
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect));
766
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
96 $response['error'] = true;
767
08c0343b622b Improved error handling for inventory equipments, fermentables, hops, miscs, suppliers, water and yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 766
diff changeset
97 $response['msg'] = "SQL fout: ".mysqli_error($connect);
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 }
766
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
99 exit(json_encode($response));
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 } else {
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 // SELECT COMMAND
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
103 $query = "SELECT * FROM inventory_equipments ORDER BY name";
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 $equipments[] = array(
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 'record' => $row['record'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 '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
109 'uuid' => $row['uuid'],
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 'boil_size' => $row['boil_size'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 'batch_size' => $row['batch_size'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 'tun_volume' => $row['tun_volume'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 'tun_weight' => $row['tun_weight'],
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
114 'tun_specific_heat' => $row['tun_specific_heat'],
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
115 'tun_material' => $row['tun_material'],
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
116 'tun_height' => floatval($row['tun_height']) * 100.0,
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 'top_up_water' => $row['top_up_water'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 'trub_chiller_loss' => $row['trub_chiller_loss'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 'evap_rate' => $row['evap_rate'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 'boil_time' => $row['boil_time'],
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
121 'calc_boil_volume' => $row['calc_boil_volume'],
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 'top_up_kettle' => $row['top_up_kettle'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 'hop_utilization' => $row['hop_utilization'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 'notes' => $row['notes'],
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 'lauter_volume' => $row['lauter_volume'],
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
126 'lauter_height' => floatval($row['lauter_height']) * 100.0,
115
ad31f4bd4036 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
127 'lauter_deadspace' => $row['lauter_deadspace'],
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 'kettle_volume' => $row['kettle_volume'],
209
dc30801e6961 Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
129 'kettle_height' => floatval($row['kettle_height']) * 100.0,
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 'mash_volume' => $row['mash_volume'],
149
ff45488d480e Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 116
diff changeset
131 'mash_max' => $row['mash_max'],
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 'efficiency' => $row['efficiency']
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 );
d702a41a7021 Added inventory equipments
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: 209
diff changeset
135 header("Content-type: application/json");
766
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
136 exit(json_encode($equipments));
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 }
766
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
138
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
139 syslog(LOG_NOTICE, "db_inventory_equipment: missing arguments");
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
140 $response['error'] = true;
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
141 $response['msg'] = "missing arguments";
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
142 echo json_encode($response);
86289b0c4a27 Version 0.3.38. Better error handling in inventory equipments. Check if equipment is in use before delete.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
143
27
d702a41a7021 Added inventory equipments
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 ?>

mercurial