production: time in production date
This commit is contained in:
@@ -8,7 +8,7 @@ $(document).ready(function () {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
format: function (s, table, cell) {
|
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,
|
parsed: false,
|
||||||
type: "text"
|
type: "text"
|
||||||
@@ -304,9 +304,37 @@ function removePositions() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function saveProductionDate(id) {
|
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({
|
$.ajax({
|
||||||
method: "get",
|
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) {
|
function editDescription(id) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ if (!isset($_GET['ajaxAction'])) {
|
|||||||
removePositions($_GET['ids']);
|
removePositions($_GET['ids']);
|
||||||
break;
|
break;
|
||||||
case 'saveProductionDate':
|
case 'saveProductionDate':
|
||||||
saveProductionDate($_GET['id'], $_GET['date']);
|
saveProductionDate($_GET['id'], $_GET['date'], $_GET['time']);
|
||||||
break;
|
break;
|
||||||
case 'saveProductDescription':
|
case 'saveProductDescription':
|
||||||
saveProductDescription($_GET['id'], $_GET['description']);
|
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['description'] = strlen($r['description']) > 0 ? substr($r['description'], 0, 30) : '';
|
||||||
$row['fullDescription'] = $r['description'];
|
$row['fullDescription'] = $r['description'];
|
||||||
$row['shippingTo'] = ($r['shipping_address_name'] == 'Adres korespondencyjny' ? '' : $r['shipping_address_name']);
|
$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['productStockState'] = $r['stockState'] | 0;
|
||||||
$row['mainProductId'] = $r['main_product_id'];
|
$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'];
|
$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);
|
$db->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveProductionDate($id, $date)
|
function saveProductionDate($id, $date, $time)
|
||||||
{
|
{
|
||||||
$db = $GLOBALS['db'];
|
$db = $GLOBALS['db'];
|
||||||
$date = date("Y-m-d", strtotime($date));
|
$parsedDate = date("Y-m-d", strtotime($date));
|
||||||
if ($date == '1970-01-01') {
|
if ($parsedDate == '1970-01-01') {
|
||||||
$db->query("UPDATE productionScheduler SET production_date=NULL WHERE id='$id'");
|
$db->query("UPDATE productionScheduler SET production_date=NULL WHERE id='$id'");
|
||||||
} else {
|
} 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,23 +179,28 @@
|
|||||||
{$ROW.productName}
|
{$ROW.productName}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="production-date-{$ROW.id}" name="production-date-{$ROW.id}" type="text"
|
<div style="white-space: nowrap">
|
||||||
maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}"
|
<input id="production-date-{$ROW.id}" name="production-date-{$ROW.id}" type="text"
|
||||||
autocomplete="off"
|
maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}"
|
||||||
id="production-date-{$ROW.id}" onchange="saveProductionDate('{$ROW.id}')">
|
autocomplete="off"
|
||||||
<img id="production-date-trigger-{$ROW.id}" src="themes/default/images/jscalendar.gif"
|
id="production-date-{$ROW.id}" onchange="saveProductionDate('{$ROW.id}')">
|
||||||
style="width: 13px;">
|
<img id="production-date-trigger-{$ROW.id}" src="themes/default/images/jscalendar.gif"
|
||||||
<script language="JavaScript" type="text/javascript">
|
style="width: 13px;">
|
||||||
Calendar.setup({ldelim}
|
<script language="JavaScript" type="text/javascript">
|
||||||
inputField: "production-date-{$ROW.id}",
|
Calendar.setup({ldelim}
|
||||||
daFormat: "%Y-%m-%d",
|
inputField: "production-date-{$ROW.id}",
|
||||||
button: "production-date-trigger-{$ROW.id}",
|
daFormat: "%Y-%m-%d",
|
||||||
singleClick: true,
|
button: "production-date-trigger-{$ROW.id}",
|
||||||
dateStr: "",
|
singleClick: true,
|
||||||
step: 1
|
dateStr: "",
|
||||||
{rdelim}
|
step: 1
|
||||||
);
|
{rdelim}
|
||||||
</script>
|
);
|
||||||
|
</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>
|
||||||
<td style="white-space: nowrap;">
|
<td style="white-space: nowrap;">
|
||||||
<div id="edit-{$ROW.id}" class="ui-icon ui-icon-pencil"
|
<div id="edit-{$ROW.id}" class="ui-icon ui-icon-pencil"
|
||||||
|
|||||||
Reference in New Issue
Block a user