productionScheduler - action time

This commit is contained in:
Michał Zieliński
2025-09-19 12:53:21 +02:00
parent 21bd1807f3
commit c447558d2a
3 changed files with 62 additions and 4 deletions

View File

@@ -67,12 +67,14 @@ $(document).ready(function () {
$("#selectAll").attr('checked', false); $("#selectAll").attr('checked', false);
$(".allCheck").prop('checked', false); $(".allCheck").prop('checked', false);
localStorage.setItem("productionSchedule_filter", $.tablesorter.getFilters($("#allTable"))); localStorage.setItem("productionSchedule_filter", $.tablesorter.getFilters($("#allTable")));
updateTimeSummary();
}); });
$("#allTable").bind("sortEnd", function () { $("#allTable").bind("sortEnd", function () {
try { try {
localStorage.setItem('productionSchedule_sort', localStorage.setItem('productionSchedule_sort',
$("#allTable")[0].config.sortList[0][0] + "|" + $("#allTable")[0].config.sortList[0][1]); $("#allTable")[0].config.sortList[0][0] + "|" + $("#allTable")[0].config.sortList[0][1]);
} catch (e) {} } catch (e) {}
updateTimeSummary();
}); });
setTimeout(() => { setTimeout(() => {
const filters = localStorage.getItem("productionSchedule_filter"); const filters = localStorage.getItem("productionSchedule_filter");
@@ -98,6 +100,7 @@ $(document).ready(function () {
} else { } else {
$(".allCheck").prop("checked", false); $(".allCheck").prop("checked", false);
} }
updateTimeSummary();
}); });
$("#duplicateBtn").click(() => duplicatePositions()); $("#duplicateBtn").click(() => duplicatePositions());
$("#deleteBtn").click(() => { removePositions(); }); $("#deleteBtn").click(() => { removePositions(); });
@@ -105,6 +108,9 @@ $(document).ready(function () {
$("#pdfBtn").click(() => { exportPDF(); }); $("#pdfBtn").click(() => { exportPDF(); });
$("#productionBtn").click(() => { window.alert("In progress."); }); $("#productionBtn").click(() => { window.alert("In progress."); });
$("#createInsideOrder").click(createInsideOrder); $("#createInsideOrder").click(createInsideOrder);
$(document).on('change', '.allCheck', function() {
updateTimeSummary();
});
}); });
function SetTab(tab_name) { function SetTab(tab_name) {
@@ -401,7 +407,6 @@ function createInsideOrder() {
$("#insideOrderProducts").val(products.join('*')); $("#insideOrderProducts").val(products.join('*'));
$("#createInsideOrderForm").submit(); $("#createInsideOrderForm").submit();
} }
function downloadFile(base64Data, fileName, mimeType) { function downloadFile(base64Data, fileName, mimeType) {
// Stwórz blob z danych base64 // Stwórz blob z danych base64
const byteCharacters = atob(base64Data); const byteCharacters = atob(base64Data);
@@ -436,3 +441,38 @@ function downloadFile(base64Data, fileName, mimeType) {
window.URL.revokeObjectURL(link.href); window.URL.revokeObjectURL(link.href);
}, 100); }, 100);
} }
function updateTimeSummary() {
var totalMinutes = 0;
var rows;
var checkedBoxes = $('.allCheck:checked');
if (checkedBoxes.length > 0) {
rows = checkedBoxes.closest('tr');
} else {
rows = $('#allTable tbody tr:visible');
}
rows.each(function() {
var actionTimeCell = $(this).find('td').eq(17);
var timeText = actionTimeCell.text().trim();
if (timeText && timeText.includes(':')) {
var timeParts = timeText.split(':');
if (timeParts.length === 2) {
var hours = parseInt(timeParts[0], 10) || 0;
var minutes = parseInt(timeParts[1], 10) || 0;
totalMinutes += (hours * 60) + minutes;
}
}
});
var totalHours = Math.floor(totalMinutes / 60);
var remainingMinutes = totalMinutes % 60;
var formattedTime = String(totalHours).padStart(2, '0') + ':' +
String(remainingMinutes).padStart(2, '0');
$('#timeSummary').html(formattedTime);
return formattedTime;
}

View File

@@ -68,7 +68,8 @@ SELECT s.id as orderId, s.document_no, s.status, s.parent_name, s.parent_id, s.s
p_main.code as main_product_code, p_main.code as main_product_code,
a.id AS action_id, a.id AS action_id,
a.indeks AS action_index, a.indeks AS action_index,
a.category AS action_category a.category AS action_category,
a.performance AS action_performance
FROM productionScheduler AS ps FROM productionScheduler AS ps
LEFT JOIN ecmsaleitems AS si LEFT JOIN ecmsaleitems AS si
ON ps.ecmsaleitem_id = si.id ON ps.ecmsaleitem_id = si.id
@@ -147,6 +148,12 @@ WHERE ps.deleted = 0 ";
$row['action_id'] = $r['action_id']; $row['action_id'] = $r['action_id'];
$row['action_index'] = $r['action_index']; $row['action_index'] = $r['action_index'];
$row['action_category'] = $app_list_strings['ecmactions_category_dom'][$r['action_category']]; $row['action_category'] = $app_list_strings['ecmactions_category_dom'][$r['action_category']];
$timeInHours = $r['action_performance'] / $r['scheduledQuantity'];
$hours = floor($timeInHours);
$minutes = round(($timeInHours - $hours) * 60);
$row['action_time'] = sprintf('%02d:%02d', $hours, $minutes);
$data[] = $row; $data[] = $row;
} }
return $data; return $data;
@@ -253,8 +260,8 @@ function duplicatePositions($ids)
$ids = explode("|", $ids); $ids = explode("|", $ids);
foreach ($ids as $id) { foreach ($ids as $id) {
$res = $db->fetchByAssoc($db->query("SELECT * FROM productionScheduler WHERE id ='$id'")); $res = $db->fetchByAssoc($db->query("SELECT * FROM productionScheduler WHERE id ='$id'"));
$query = sprintf("INSERT INTO productionScheduler VALUES ('%s', null, '%s', '%s', '%d', NOW(), NOW(), '%s', '%s', 0, '%s', '%d', '%s', '%s');", $query = sprintf("INSERT INTO productionScheduler VALUES ('%s', '%s', '%s', '%s', '%d', NOW(), NOW(), '%s', '%s', 0, '%s', '%d', '%s', '%s');",
generateUuidV4(), $res['ecmsaleitem_id'], $res['ecmsale_id'], $res['quantity'], $current_user->id, $current_user->id, $res['ecmproduct_id'], generateUuidV4(), $res['main_id'], $res['ecmsaleitem_id'], $res['ecmsale_id'], $res['quantity'], $current_user->id, $current_user->id, $res['ecmproduct_id'],
$res['is_component'], $res['production_date'], $res['description']); $res['is_component'], $res['production_date'], $res['description']);
$db->query($query); $db->query($query);
} }

View File

@@ -153,6 +153,7 @@
<th>Data wysyłki</th> <th>Data wysyłki</th>
<th>Czynność</th> <th>Czynność</th>
<th>Linia</th> <th>Linia</th>
<th>Czas</th>
<th>Uwagi</th> <th>Uwagi</th>
</tr> </tr>
</thead> </thead>
@@ -249,6 +250,9 @@
<td> <td>
{$ROW.action_category} {$ROW.action_category}
</td> </td>
<td>
{$ROW.action_time}
</td>
<td> <td>
<div id="edit-description-{$ROW.id}" class="ui-icon ui-icon-pencil" <div id="edit-description-{$ROW.id}" class="ui-icon ui-icon-pencil"
onclick="editDescription('{$ROW.id}')" style="display: inline-block;"></div> onclick="editDescription('{$ROW.id}')" style="display: inline-block;"></div>
@@ -262,6 +266,13 @@
</tr> </tr>
{/foreach} {/foreach}
</tbody> </tbody>
<tfoot>
<tr>
<td colspan="17" style="text-align: right;"></td>
<td id="timeSummary"></td>
<td></td>
</tr>
</tfoot>
</table> </table>
</div> </div>