production: time in production date
This commit is contained in:
@@ -8,7 +8,7 @@ $(document).ready(function () {
|
||||
return false;
|
||||
},
|
||||
format: function (s, table, cell) {
|
||||
return $(cell).find("input[id^=production-date]").val() || "2222-01-01";
|
||||
return $(cell).find("input[id^=production-date]").val() + " " + $(cell).find("input[id^=production-time]").val() || "2222-01-01";
|
||||
},
|
||||
parsed: false,
|
||||
type: "text"
|
||||
@@ -304,9 +304,37 @@ function removePositions() {
|
||||
});
|
||||
}
|
||||
function saveProductionDate(id) {
|
||||
let date = $("#production-date-" + id).val();
|
||||
let time = $("#production-time-" + id).val();
|
||||
|
||||
if (date.length !== 10) {
|
||||
$("#production-date-" + id).val('');
|
||||
$("#production-time-" + id).val('');
|
||||
date = '';
|
||||
time = '';
|
||||
} else {
|
||||
if (time.length === 5) {
|
||||
// Sprawdź format HH:mm
|
||||
const timeRegex = /^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/;
|
||||
if (!timeRegex.test(time)) {
|
||||
time = "06:00";
|
||||
}
|
||||
} else if (time.length === 4) {
|
||||
// Wstaw : pomiędzy i sprawdź format
|
||||
time = time.substring(0, 2) + ":" + time.substring(2);
|
||||
const timeRegex = /^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/;
|
||||
if (!timeRegex.test(time)) {
|
||||
time = "06:00";
|
||||
}
|
||||
} else {
|
||||
time = "06:00";
|
||||
}
|
||||
}
|
||||
$("#production-time-" + id).val(time);
|
||||
|
||||
$.ajax({
|
||||
method: "get",
|
||||
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductionDate&id=" + id + "&date=" + $("#production-date-" + id).val(),
|
||||
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductionDate&id=" + id + "&date=" + encodeURIComponent(date) + "&time=" + encodeURIComponent(time),
|
||||
});
|
||||
}
|
||||
function editDescription(id) {
|
||||
|
||||
@@ -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'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +179,7 @@
|
||||
{$ROW.productName}
|
||||
</td>
|
||||
<td>
|
||||
<div style="white-space: nowrap">
|
||||
<input id="production-date-{$ROW.id}" name="production-date-{$ROW.id}" type="text"
|
||||
maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}"
|
||||
autocomplete="off"
|
||||
@@ -196,6 +197,10 @@
|
||||
{rdelim}
|
||||
);
|
||||
</script>
|
||||
</div>
|
||||
<input type="text"
|
||||
maxlength="10" size="11" tabindex="" title="" id="production-time-{$ROW.id}" name="production-time-{$ROW.id}"
|
||||
autocomplete="off" value="{$ROW.productionTime}" onchange="saveProductionDate('{$ROW.id}')">
|
||||
</td>
|
||||
<td style="white-space: nowrap;">
|
||||
<div id="edit-{$ROW.id}" class="ui-icon ui-icon-pencil"
|
||||
|
||||
Reference in New Issue
Block a user