From b9e2d6d869a313b0d65ffb647382f141fa9f0b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Wed, 13 Aug 2025 19:49:35 +0000 Subject: [PATCH 1/5] dropdowns --- include/language/en_us.EcmDropdownEditor.php | 6 +++++- include/language/pl_pl.EcmDropdownEditor.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/language/en_us.EcmDropdownEditor.php b/include/language/en_us.EcmDropdownEditor.php index 4aa90bfc..b58f44c1 100644 --- a/include/language/en_us.EcmDropdownEditor.php +++ b/include/language/en_us.EcmDropdownEditor.php @@ -1,5 +1,5 @@ array ( @@ -82,6 +82,7 @@ $customDoms = array ( 'c1477582-33b9-529d-bdd2-685250fc18d4' => 'Blister tablets 6pcs 6,5g', '31bf91c9-6176-a27a-9a4e-686f6b2597ee' => 'Liquid', '27c00505-f6cf-3ef1-3c1d-6880847a5893' => 'Powder', + 'a2ba9b76-8e2e-32c4-e9c8-689c6ac2dbb9' => 'Bottle 30 ml N-34B plastan', ), 'ecmproducts_brand_dom' => array ( @@ -231,6 +232,9 @@ $customDoms = array ( '8519dfc8-5eec-0233-7f84-54d1fe00e9fc' => 'Sets', '55020d96-73d5-7b29-3bab-654f4818e0cd' => 'Liquid Mixing', '9bc2bafc-0608-7bc7-468b-686a94772424' => 'Bisters', + 'be37016b-0aa4-678c-9c4a-689c3673af3e' => 'Packing Blisters Into Packaging', + 'e3e16e03-8e62-624e-f954-689c37059997' => 'Packing Tablets Into Jars', + '416a2b50-4979-bc35-c83c-689c8a6640ae' => 'Packing into tubes', ), 'payment_method_dom' => array ( diff --git a/include/language/pl_pl.EcmDropdownEditor.php b/include/language/pl_pl.EcmDropdownEditor.php index ec1927ab..648c96f2 100644 --- a/include/language/pl_pl.EcmDropdownEditor.php +++ b/include/language/pl_pl.EcmDropdownEditor.php @@ -1,5 +1,5 @@ array ( @@ -82,6 +82,7 @@ $customDoms = array ( 'c1477582-33b9-529d-bdd2-685250fc18d4' => 'Blister, tabletki 6szt. 6,5g', '31bf91c9-6176-a27a-9a4e-686f6b2597ee' => 'Płyn_WOD', '27c00505-f6cf-3ef1-3c1d-6880847a5893' => 'Proszek', + 'a2ba9b76-8e2e-32c4-e9c8-689c6ac2dbb9' => 'Butelka 30 ml N-34B plastan', ), 'ecmproducts_brand_dom' => array ( @@ -231,6 +232,9 @@ $customDoms = array ( '8519dfc8-5eec-0233-7f84-54d1fe00e9fc' => 'Zestawy', '55020d96-73d5-7b29-3bab-654f4818e0cd' => 'Mieszanie', '9bc2bafc-0608-7bc7-468b-686a94772424' => 'Blistrowanie', + 'be37016b-0aa4-678c-9c4a-689c3673af3e' => 'PBDO', + 'e3e16e03-8e62-624e-f954-689c37059997' => 'PTDS', + '416a2b50-4979-bc35-c83c-689c8a6640ae' => 'PWT', ), 'payment_method_dom' => array ( From e7f76c94d6657354546dcd3eee3ffbfb946ec24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Wed, 13 Aug 2025 22:35:40 +0200 Subject: [PATCH 2/5] Production improvements --- importE5EDISales.php | 2 +- .../productionSchedule/productionSchedule.php | 52 ++++--- .../productionSchedule/productionSchedule.tpl | 133 +++++++++--------- .../productsBySales/productsBySales.js | 3 +- .../productsBySales/productsBySales.php | 21 ++- .../productsBySales/productsBySales.tpl | 2 +- 6 files changed, 113 insertions(+), 100 deletions(-) diff --git a/importE5EDISales.php b/importE5EDISales.php index a8dda1f7..f8582102 100644 --- a/importE5EDISales.php +++ b/importE5EDISales.php @@ -12,7 +12,7 @@ chdir(realpath(dirname(__FILE__))); require_once('include/entryPoint.php'); require_once("include/database/MysqliManager.php"); -global $suger_config; +global $sugar_config; $config = $sugar_config['dbconfig']; $GLOBALS['db']->connect($config, true, $config['db_name']); diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php index ce4862ad..2600ae4b 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php @@ -57,26 +57,33 @@ function loadSchedulers($dateFrom = null, $dateTo = null, $ids = null) $db = $GLOBALS['db']; global $app_list_strings; - $query = "SELECT s.id as orderId, s.document_no, s.status, s.parent_name, s.parent_id, s.send_date, s.type, - p.code, p.name, ps.ecmproduct_id, ps.description, - si.quantity, p.vendor_part_no as kind, p.brand, p.part_no as size, p.shape, - p.ems_qty_in_stock as stockState, si.id as item_id, s.shipping_address_name, ps.production_date, - ps.quantity as scheduledQuantity, ps.id as id, - ps.main_id, - ps_main.ecmproduct_id as main_product_id, - p_main.code as main_product_code - FROM productionScheduler AS ps - LEFT JOIN ecmsaleitems AS si - ON ps.ecmsaleitem_id = si.id - LEFT JOIN ecmsales AS s - ON ps.ecmsale_id = s.id - INNER JOIN ecmproducts AS p - ON ps.ecmproduct_id = p.id - LEFT JOIN productionScheduler AS ps_main - ON ps.main_id = ps_main.id - LEFT JOIN ecmproducts AS p_main - ON ps_main.ecmproduct_id = p_main.id - WHERE ps.deleted = 0 "; + $query = " +SELECT s.id as orderId, s.document_no, s.status, s.parent_name, s.parent_id, s.send_date, s.type, + p.code, p.name, ps.ecmproduct_id, ps.description, + si.quantity, p.vendor_part_no as kind, p.brand, p.part_no as size, p.shape, + p.ems_qty_in_stock as stockState, si.id as item_id, s.shipping_address_name, ps.production_date, + ps.quantity as scheduledQuantity, ps.id as id, + ps.main_id, + ps_main.ecmproduct_id as main_product_id, + p_main.code as main_product_code, + GROUP_CONCAT(a.name SEPARATOR ', ') as actions +FROM productionScheduler AS ps + LEFT JOIN ecmsaleitems AS si + ON ps.ecmsaleitem_id = si.id + LEFT JOIN ecmsales AS s + ON ps.ecmsale_id = s.id + INNER JOIN ecmproducts AS p + ON ps.ecmproduct_id = p.id + LEFT JOIN productionScheduler AS ps_main + ON ps.main_id = ps_main.id + LEFT JOIN ecmproducts AS p_main + ON ps_main.ecmproduct_id = p_main.id + LEFT JOIN ecmproductactions pa + ON p.id = pa.ecmproduct_id + LEFT JOIN ecmactions a + ON pa.ecmaction_id = a.id +WHERE ps.deleted = 0 +GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.id"; if ($dateFrom != null && $dateTo != null) { $query .= " AND ( @@ -123,8 +130,9 @@ function loadSchedulers($dateFrom = null, $dateTo = null, $ids = null) $row['productionDate'] = $r['production_date'] == '0000-00-00' ? '' : $r['production_date']; $row['productStockState'] = $r['stockState'] | 0; $row['mainProductId'] = $r['main_product_id']; - $row['mainProductCode'] = $r['main_product_code']; - + $row['mainProductCode'] = strlen($r['main_product_code']) > 20 ? substr($r['main_product_code'], 0, 20) . "..." : $r['main_product_code']; + $row['mainProductFullCode'] = $r['main_product_code']; + $row['actions'] = $r['actions']; $data[] = $row; } return $data; diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl index 832a44a1..22ebdad4 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl @@ -151,6 +151,7 @@ Forma Marka Data wysyłki + Czynność Uwagi @@ -166,18 +167,19 @@ Usuń --> - - - {$ROW.productCode} - - - - {$ROW.productName} - + + + {$ROW.productCode} + + + + {$ROW.productName} + @@ -193,59 +195,64 @@ ); - -
- -
{$ROW.qty} -
- - - - {$ROW.productQty} - - - {$ROW.productStockState} - - - - {$ROW.orderNo} - - - - {$ROW.orderType} - - - {$ROW.orderStatus} - - - - {$ROW.mainProductCode} - - - - {$ROW.shippingTo} - - - {$ROW.productShape} - - - {$ROW.productBrand} - - - {$ROW.orderSendDate} - - -
- -
{$ROW.description} -
- - + +
+ +
{$ROW.qty} +
+ + + + {$ROW.productQty} + + + {$ROW.productStockState} + + + + {$ROW.orderNo} + + + + {$ROW.orderType} + + + {$ROW.orderStatus} + + + + {$ROW.mainProductCode} + + + + {$ROW.shippingTo} + + + {$ROW.productShape} + + + {$ROW.productBrand} + + + {$ROW.orderSendDate} + + + {$ROW.actions} + + +
+ +
{$ROW.description} +
+ + {/foreach} diff --git a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js index cae78c2c..83d6663f 100644 --- a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js +++ b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js @@ -331,6 +331,7 @@ function drawRawMaterials(data) { }); orders += ""; tr.append(orders); + tr.append("" + el.stockAddress + ""); $("#rawMaterialsTable > tbody").append(tr); }); @@ -492,7 +493,7 @@ function componentsTablePrototype() { return '
PozycjaIndeksNazwaIlośćStanZS E5TypStatusProdukt głównyOdbiorcaFormaMarkaData wysyłki
0
' } function rawMaterialsTablePrototype() { - return '
PozycjaIndeksNazwaIlośćJM.StanZamówionoDostawcaZamówienie
0
' + return '
PozycjaIndeksNazwaIlośćJM.StanZamówionoDostawcaZamówienieAdres magazynowy
0
' } function addToProductionScheduler(orderItemId) { showLoader("Trwa dodawanie elementu do harmonogramu produkcji..."); diff --git a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php index f50c971b..75eb3bda 100644 --- a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php +++ b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php @@ -99,6 +99,8 @@ if (!isset($_GET['ajaxAction'])) { $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['shippingToFull'] = $row['shippingTo']; + $row['shippingTo'] = strlen($row['shippingTo']) > 55 ? substr($row['shippingTo'], 0, 55) . "..." : $row['shippingTo']; $row['productionDate'] = $r['production_date']; $row['productStockState'] = $r['stockState'] | 0; $row['scheduled'] = $r['scheduled']; @@ -160,7 +162,6 @@ function findProduct($array, $value) } return -1; } - function getComponents($ids, $dateFrom, $dateTo) { $db = $GLOBALS['db']; @@ -235,7 +236,6 @@ function getComponents($ids, $dateFrom, $dateTo) } echo json_encode($componentsData); } - function getRawMaterials2($ids, $type) { global $app_list_strings; @@ -287,9 +287,12 @@ function getRawMaterials2($ids, $type) foreach ($grouppedRawMaterials as $material) { $product = $db->fetchByAssoc($db->query(" - SELECT p.id, p.code, p.name, p.group_ks, p.unit_id, p.ems_qty_in_stock as stockState + SELECT p.id, p.code, p.name, p.group_ks, p.unit_id, p.ems_qty_in_stock as stockState, + GROUP_CONCAT(s.stock_address SEPARATOR ', ') AS stock_addresses FROM ecmproducts AS p + LEFT JOIN ecmproducts_stock_addresses s ON p.id = s.ecmproduct_id WHERE p.id='" . $material['ecmproduct_id'] . "' + GROUP BY p.id ")); $ordered = $db->fetchByAssoc($db->query("SELECT SUM(poi.quantity) as ordered, GROUP_CONCAT(poi.ecmpurchaseorder_id SEPARATOR '|') AS orders FROM ecmpurchaseorderitems as poi @@ -329,11 +332,11 @@ function getRawMaterials2($ids, $type) $row['productGroupKS'] = $product['group_ks']; $row['orders'] = $orders; $row['productStockState'] = (!empty($product['stockState'])) ? $product['stockState'] : 0; + $row['stockAddress'] = (!empty($product['stock_addresses'])) ? $product['stock_addresses'] : ""; $response[] = $row; } return json_encode($response); } - function getRawMaterials($ids, $cids) { $db = $GLOBALS['db']; @@ -419,7 +422,6 @@ function getRawMaterials($ids, $cids) echo json_encode($rawMaterialsData); } - function getProductRawMaterials($productId, $quantity) { $db = $GLOBALS['db']; @@ -454,7 +456,6 @@ WHERE } return $response; } - function addToProductionScheduler($orderItemId) { $db = $GLOBALS['db']; @@ -472,7 +473,7 @@ function addToProductionScheduler($orderItemId) foreach ($products as $product) { if ($saleInfo['ecmproduct_id'] == $product['ecmproduct_id']) { $id = $masterId; - $mainId = null; + $mainId = $masterId; } else { $id = generateUuidV4(); $mainId = $masterId; @@ -483,7 +484,6 @@ function addToProductionScheduler($orderItemId) $db->query($query); } } - function addComponentToProductionScheduler($productId, $qty) { $db = $GLOBALS['db']; @@ -492,7 +492,6 @@ function addComponentToProductionScheduler($productId, $qty) generateUuidV4(), $qty, $current_user->id, $current_user->id, $productId); $db->query($query); } - function getComponents2($ids) { $db = $GLOBALS['db']; @@ -534,7 +533,7 @@ function getComponents2($ids) $row['orderId'] = $r['id']; $row['orderStatus'] = $app_list_strings['ecmsales_status_dom'][$r['status']]; $row['orderType'] = $app_list_strings['ecmsales_type_dom'][$r['type']]; - $row['orderParent'] = ($r['shipping_address_name'] == 'Adres korespondencyjny' ? '' : $r['shipping_address_name']); + $row['orderParent'] = (isset($r['shipping_address_name']) && $r['shipping_address_name'] != 'Adres korespondencyjny' ? $r['shipping_address_name'] : ''); $row['orderSendDate'] = $r['send_date']; $componentsData[] = $row; } @@ -574,7 +573,6 @@ function getComponents2($ids) * */ } - function getProductComponents($productId, $quantity) { $db = $GLOBALS['db']; @@ -614,7 +612,6 @@ HAVING return $response; } } - function generateUuidV4() { $data = openssl_random_pseudo_bytes(16); diff --git a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.tpl b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.tpl index cf27b785..29ef7a19 100644 --- a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.tpl +++ b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.tpl @@ -215,7 +215,7 @@ {$ROW.orderParent} - + {$ROW.shippingTo} From ac7e1b0c85bd21c506a19fdadf0675ca48b2366a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Thu, 14 Aug 2025 11:03:18 +0200 Subject: [PATCH 3/5] Production scheduler fix --- .../productionSchedule/productionSchedule.php | 28 +++++++++++++------ .../productionSchedule/productionSchedule.tpl | 4 ++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php index 2600ae4b..0c13d0ad 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php @@ -66,7 +66,8 @@ SELECT s.id as orderId, s.document_no, s.status, s.parent_name, s.parent_id, s.s ps.main_id, ps_main.ecmproduct_id as main_product_id, p_main.code as main_product_code, - GROUP_CONCAT(a.name SEPARATOR ', ') as actions + a.id AS action_id, + a.indeks AS action_index FROM productionScheduler AS ps LEFT JOIN ecmsaleitems AS si ON ps.ecmsaleitem_id = si.id @@ -78,12 +79,21 @@ FROM productionScheduler AS ps ON ps.main_id = ps_main.id LEFT JOIN ecmproducts AS p_main ON ps_main.ecmproduct_id = p_main.id - LEFT JOIN ecmproductactions pa - ON p.id = pa.ecmproduct_id + LEFT JOIN ( + SELECT epa.ecmproduct_id, epa.ecmaction_id + FROM ecmproductactions epa + JOIN ( + SELECT ecmproduct_id, MIN(position) AS min_pos + FROM ecmproductactions + GROUP BY ecmproduct_id + ) m + ON m.ecmproduct_id = epa.ecmproduct_id + AND m.min_pos = epa.position +) pa_first + ON pa_first.ecmproduct_id = p.id LEFT JOIN ecmactions a - ON pa.ecmaction_id = a.id -WHERE ps.deleted = 0 -GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.id"; + ON a.id = pa_first.ecmaction_id +WHERE ps.deleted = 0 "; if ($dateFrom != null && $dateTo != null) { $query .= " AND ( @@ -95,7 +105,8 @@ GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.id"; $query .= " AND ps.id IN ('" . join("','", $ids) . "')"; } - $query .= "ORDER BY s.delivery_date, s.register_date, s.document_no"; + $query .= "GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.id "; + $query .= "ORDER BY s.delivery_date, s.register_date, s.document_no;"; $rows = $db->query($query); $data = array(); @@ -132,7 +143,8 @@ GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.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['mainProductFullCode'] = $r['main_product_code']; - $row['actions'] = $r['actions']; + $row['action_id'] = $r['action_id']; + $row['action_index'] = $r['action_index']; $data[] = $row; } return $data; diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl index 22ebdad4..c7956587 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl @@ -241,7 +241,9 @@ {$ROW.orderSendDate} - {$ROW.actions} + + {$ROW.action_index} +
Date: Thu, 21 Aug 2025 21:01:51 +0200 Subject: [PATCH 4/5] Invoices - check empty prices --- modules/EcmInvoiceOuts/javascript/EcmInvoiceOuts3.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/EcmInvoiceOuts/javascript/EcmInvoiceOuts3.js b/modules/EcmInvoiceOuts/javascript/EcmInvoiceOuts3.js index 26d8381f..4383ab48 100644 --- a/modules/EcmInvoiceOuts/javascript/EcmInvoiceOuts3.js +++ b/modules/EcmInvoiceOuts/javascript/EcmInvoiceOuts3.js @@ -166,6 +166,11 @@ check_form = function(formname) { $(".loading_panel").css("display", "none"); return false; } + if (items[index].price_netto == 0) { + alert("Niedopuszczalna, zerowa cena netto."); + $(".loading_panel").css("display", "none"); + return false; + } } $("#total_netto").val($("#t_netto").val()); $("#total_brutto").val($("#t_brutto").val()); From 4bcaf85b6c3c66ef4cfab3ae73cada5dd9a177e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Tue, 26 Aug 2025 19:42:19 +0200 Subject: [PATCH 5/5] EDI improvements --- importE5EDISales.php | 6 +++--- modules/EcmSales/readXML.php | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/importE5EDISales.php b/importE5EDISales.php index f8582102..3988d9f6 100644 --- a/importE5EDISales.php +++ b/importE5EDISales.php @@ -61,8 +61,8 @@ function checkEDISales() $s->number = $number; $s->document_no = $s->formatNumber($number); $s->edi_file = $order; - $s->type = 'sales_order'; - $s->status = 's60'; + $s->type = 'abf8f342-13de-bb9f-7848-687897a3b953'; + $s->status = 's30'; $s->ecmlanguage = 'pl_pl'; $a = new Account(); $a->retrieve($s->parent_id); @@ -77,7 +77,7 @@ function checkEDISales() } $s->total_netto = $sum_netto; - if ($s->parent_id == 134 || $s->parent_id == '134') { + if ($s->parent_id == 134 || $s->parent_id == '134') { // carrefour $s->shop_number = null; } diff --git a/modules/EcmSales/readXML.php b/modules/EcmSales/readXML.php index 83fa0b76..6fa1f7b7 100644 --- a/modules/EcmSales/readXML.php +++ b/modules/EcmSales/readXML.php @@ -131,7 +131,17 @@ class readXML { } $this->register_date = date ( "d.m.Y", strtotime ( $this->nodes->{'Order-Header'}->OrderDate ) ); $this->delivery_date = date ( "d.m.Y", strtotime ( $this->nodes->{'Order-Header'}->ExpectedDeliveryDate ) ); - $this->assigned_user_id = $_SESSION ['authenticated_user_id']; + + $delivery_timestamp = strtotime($this->nodes->{'Order-Header'}->ExpectedDeliveryDate); + $delivery_day_of_week = date('N', $delivery_timestamp); // 1 = Monday, 7 = Sunday + if ($delivery_day_of_week == 1) { // Monday -> send on Friday + $send_timestamp = strtotime('-3 days', $delivery_timestamp); + } else { // send one day before + $send_timestamp = strtotime('-1 day', $delivery_timestamp); + } + $this->send_date = date("d.m.Y", $send_timestamp); + + $this->assigned_user_id = $_SESSION ['authenticated_user_id']; $this->position_list = array (); }