production: time in production date

This commit is contained in:
Michał Zieliński
2025-10-06 20:13:50 +02:00
parent aae6334793
commit 0e8227fc82
3 changed files with 60 additions and 25 deletions

View File

@@ -36,7 +36,7 @@ if (!isset($_GET['ajaxAction'])) {
removePositions($_GET['ids']);
break;
case 'saveProductionDate':
saveProductionDate($_GET['id'], $_GET['date']);
saveProductionDate($_GET['id'], $_GET['date'], $_GET['time']);
break;
case 'saveProductDescription':
saveProductDescription($_GET['id'], $_GET['description']);
@@ -143,7 +143,8 @@ WHERE ps.deleted = 0 ";
$row['description'] = strlen($r['description']) > 0 ? substr($r['description'], 0, 30) : '';
$row['fullDescription'] = $r['description'];
$row['shippingTo'] = ($r['shipping_address_name'] == 'Adres korespondencyjny' ? '' : $r['shipping_address_name']);
$row['productionDate'] = $r['production_date'] == '0000-00-00' ? '' : $r['production_date'];
$row['productionDate'] = $r['production_date'] == '0000-00-00 00:00:00' ? '' : substr($r['production_date'], 0, 10);
$row['productionTime'] = $r['production_date'] == '0000-00-00 00:00:00' ? '' : substr($r['production_date'], 11, 5);
$row['productStockState'] = $r['stockState'] | 0;
$row['mainProductId'] = $r['main_product_id'];
$row['mainProductCode'] = strlen($r['main_product_code']) > 20 ? substr($r['main_product_code'], 0, 20) . "..." : $r['main_product_code'];
@@ -285,14 +286,15 @@ function removePositions($ids)
$db->query($query);
}
function saveProductionDate($id, $date)
function saveProductionDate($id, $date, $time)
{
$db = $GLOBALS['db'];
$date = date("Y-m-d", strtotime($date));
if ($date == '1970-01-01') {
$parsedDate = date("Y-m-d", strtotime($date));
if ($parsedDate == '1970-01-01') {
$db->query("UPDATE productionScheduler SET production_date=NULL WHERE id='$id'");
} else {
$db->query("UPDATE productionScheduler SET production_date='$date' WHERE id='$id'");
$parsetDateTime = date("Y-m-d H:i", strtotime($date. ' ' . $time));
$db->query("UPDATE productionScheduler SET production_date='$parsetDateTime' WHERE id='$id'");
}
}