1208 $stage = $_POST['stage']; |
1208 $stage = $_POST['stage']; |
1209 $inventory_reduced = $_POST['inventory_reduced']; |
1209 $inventory_reduced = $_POST['inventory_reduced']; |
1210 if ($stage == $inventory_reduced) { |
1210 if ($stage == $inventory_reduced) { |
1211 return; |
1211 return; |
1212 } |
1212 } |
1213 syslog(LOG_NOTICE, "inventory_reduce() stage: ".$stage." inventory_reduced: ".$inventory_reduced); |
|
1214 |
1213 |
1215 /* Nothing to reduce yet, but just set the $inventory_reduced */ |
1214 /* Nothing to reduce yet, but just set the $inventory_reduced */ |
1216 if (($stage >= 1) && ($inventory_reduced < 1)) { |
1215 if (($stage >= 1) && ($inventory_reduced < 1)) { |
1217 $inventory_reduced = 1; |
1216 $inventory_reduced = 1; |
1218 $savethis = 1; |
1217 $savethis = 1; |
1302 |
1301 |
1303 /* |
1302 /* |
1304 * After the Primary fermentation |
1303 * After the Primary fermentation |
1305 */ |
1304 */ |
1306 if (($stage >= 4) && ($inventory_reduced < 4)) { |
1305 if (($stage >= 4) && ($inventory_reduced < 4)) { |
1307 syslog(LOG_NOTICE, "Reduce Primary inventory from " . $_POST['code'] . " " . $_POST['name']); |
|
1308 |
1306 |
1309 if (isset($_POST['fermentables'])) { |
1307 if (isset($_POST['fermentables'])) { |
1310 $array = $_POST['fermentables']; |
1308 $array = $_POST['fermentables']; |
1311 foreach($array as $key => $item) { |
1309 foreach($array as $key => $item) { |
1312 if ($item['f_added'] == 2) { // Fermentation |
1310 if ($item['f_added'] == 2) { // Fermentation |
1340 |
1338 |
1341 /* |
1339 /* |
1342 * After the Seconday fermentation |
1340 * After the Seconday fermentation |
1343 */ |
1341 */ |
1344 if (($stage >= 5) && ($inventory_reduced < 5)) { |
1342 if (($stage >= 5) && ($inventory_reduced < 5)) { |
1345 syslog(LOG_NOTICE, "Reduce Secondary inventory from " . $_POST['code'] . " " . $_POST['name']); |
|
1346 |
1343 |
1347 if (isset($_POST['yeasts'])) { |
1344 if (isset($_POST['yeasts'])) { |
1348 $array = $_POST['yeasts']; |
1345 $array = $_POST['yeasts']; |
1349 foreach($array as $key => $item) { |
1346 foreach($array as $key => $item) { |
1350 if ($item['y_use'] == 1) { // Secondary |
1347 if ($item['y_use'] == 1) { // Secondary |
1360 |
1357 |
1361 /* |
1358 /* |
1362 * After the Tertiary fermentation |
1359 * After the Tertiary fermentation |
1363 */ |
1360 */ |
1364 if (($stage >= 6) && ($inventory_reduced < 6)) { |
1361 if (($stage >= 6) && ($inventory_reduced < 6)) { |
1365 syslog(LOG_NOTICE, "Reduce Tertiary inventory from " . $_POST['code'] . " " . $_POST['name']); |
|
1366 |
1362 |
1367 if (isset($_POST['fermentables'])) { |
1363 if (isset($_POST['fermentables'])) { |
1368 $array = $_POST['fermentables']; |
1364 $array = $_POST['fermentables']; |
1369 foreach($array as $key => $item) { |
1365 foreach($array as $key => $item) { |
1370 if ($item['f_added'] == 3) { // Lagering |
1366 if ($item['f_added'] == 3) { // Lagering |
1407 /* |
1403 /* |
1408 * After packaging |
1404 * After packaging |
1409 * reduce sugars(4/5-bottle), yeasts(3-Bottle), miscs(5-bottling) |
1405 * reduce sugars(4/5-bottle), yeasts(3-Bottle), miscs(5-bottling) |
1410 */ |
1406 */ |
1411 if (($stage >= 6) && ($inventory_reduced < 7)) { |
1407 if (($stage >= 6) && ($inventory_reduced < 7)) { |
1412 syslog(LOG_NOTICE, "Reduce Packaging inventory from " . $_POST['code'] . " " . $_POST['name']); |
|
1413 |
1408 |
1414 if (isset($_POST['fermentables'])) { |
1409 if (isset($_POST['fermentables'])) { |
1415 $array = $_POST['fermentables']; |
1410 $array = $_POST['fermentables']; |
1416 foreach($array as $key => $item) { |
1411 foreach($array as $key => $item) { |
1417 if ($item['f_added'] >= 4) { // Bottling or Kegging |
1412 if ($item['f_added'] >= 4) { // Bottling or Kegging |
1452 /* |
1447 /* |
1453 * Save only if something was reduced. |
1448 * Save only if something was reduced. |
1454 */ |
1449 */ |
1455 if ($savethis == 1) { |
1450 if ($savethis == 1) { |
1456 $sql2 = "UPDATE products SET stage=".$stage.", inventory_reduced=".$inventory_reduced." WHERE record='".$_POST['record']."';"; |
1451 $sql2 = "UPDATE products SET stage=".$stage.", inventory_reduced=".$inventory_reduced." WHERE record='".$_POST['record']."';"; |
1457 syslog(LOG_NOTICE, $sql2); |
|
1458 $result2 = mysqli_query($connect, $sql2); |
1452 $result2 = mysqli_query($connect, $sql2); |
1459 $ar = mysqli_affected_rows($connect); |
1453 $ar = mysqli_affected_rows($connect); |
1460 if ($ar != 1) { |
1454 if ($ar != 1) { |
1461 syslog(LOG_NOTICE, $sql2." error, affected rows: ".$ar); |
1455 syslog(LOG_NOTICE, $sql2." error, affected rows: ".$ar); |
1462 } |
1456 } |