www/includes/db_inventory_water.php

changeset 785
aa79acfdf8a9
parent 767
08c0343b622b
--- a/www/includes/db_inventory_water.php	Sun Feb 06 20:06:46 2022 +0100
+++ b/www/includes/db_inventory_water.php	Thu Feb 10 22:15:10 2022 +0100
@@ -23,7 +23,13 @@
 		$sql  = "UPDATE `inventory_waters` SET ";
 	}
 
-	$sql .= "name='" . mysqli_real_escape_string($connect, $_POST['name']);
+	if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) {
+                $sql .= "uuid='" . $_POST['uuid'];
+        } else {
+                $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
+                $sql .= "uuid='" . $uuid;
+        }
+	$sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']);
 	($_POST['unlimited_stock'] == 'true') ? $sql .= "', unlimited_stock='1" : $sql .= "', unlimited_stock='0";
 	$sql .= "', calcium='" . $_POST['calcium'];
 	$sql .= "', bicarbonate='" . $_POST['bicarbonate'];
@@ -69,6 +75,7 @@
 		$waters[] = array(
 			'record' => $row['record'],
 			'name' => $row['name'],
+			'uuid' => $row['uuid'],
 			'unlimited_stock' => $row['unlimited_stock'],
 			'calcium' => $row['calcium'],
 			'bicarbonate' => $row['bicarbonate'],

mercurial