diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js index 99814865..114a8b04 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js @@ -67,12 +67,14 @@ $(document).ready(function () { $("#selectAll").attr('checked', false); $(".allCheck").prop('checked', false); localStorage.setItem("productionSchedule_filter", $.tablesorter.getFilters($("#allTable"))); + updateTimeSummary(); }); $("#allTable").bind("sortEnd", function () { try { localStorage.setItem('productionSchedule_sort', $("#allTable")[0].config.sortList[0][0] + "|" + $("#allTable")[0].config.sortList[0][1]); } catch (e) {} + updateTimeSummary(); }); setTimeout(() => { const filters = localStorage.getItem("productionSchedule_filter"); @@ -98,6 +100,7 @@ $(document).ready(function () { } else { $(".allCheck").prop("checked", false); } + updateTimeSummary(); }); $("#duplicateBtn").click(() => duplicatePositions()); $("#deleteBtn").click(() => { removePositions(); }); @@ -105,6 +108,9 @@ $(document).ready(function () { $("#pdfBtn").click(() => { exportPDF(); }); $("#productionBtn").click(() => { window.alert("In progress."); }); $("#createInsideOrder").click(createInsideOrder); + $(document).on('change', '.allCheck', function() { + updateTimeSummary(); + }); }); function SetTab(tab_name) { @@ -401,7 +407,6 @@ function createInsideOrder() { $("#insideOrderProducts").val(products.join('*')); $("#createInsideOrderForm").submit(); } - function downloadFile(base64Data, fileName, mimeType) { // Stwórz blob z danych base64 const byteCharacters = atob(base64Data); @@ -436,3 +441,38 @@ function downloadFile(base64Data, fileName, mimeType) { window.URL.revokeObjectURL(link.href); }, 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; +} diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php index 9464b902..c3db949e 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php @@ -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, a.id AS action_id, a.indeks AS action_index, - a.category AS action_category + a.category AS action_category, + a.performance AS action_performance FROM productionScheduler AS ps LEFT JOIN ecmsaleitems AS si ON ps.ecmsaleitem_id = si.id @@ -147,6 +148,12 @@ WHERE ps.deleted = 0 "; $row['action_id'] = $r['action_id']; $row['action_index'] = $r['action_index']; $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; } return $data; @@ -253,8 +260,8 @@ function duplicatePositions($ids) $ids = explode("|", $ids); foreach ($ids as $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');", - generateUuidV4(), $res['ecmsaleitem_id'], $res['ecmsale_id'], $res['quantity'], $current_user->id, $current_user->id, $res['ecmproduct_id'], + $query = sprintf("INSERT INTO productionScheduler VALUES ('%s', '%s', '%s', '%s', '%d', NOW(), NOW(), '%s', '%s', 0, '%s', '%d', '%s', '%s');", + 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']); $db->query($query); } diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl index 1b364529..04238824 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl @@ -153,6 +153,7 @@