From a4a65d5b4f56e63c3f882cb847e34123b64a6c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Thu, 16 Jan 2025 10:16:01 +0000 Subject: [PATCH] Some fixes :) --- file_access_loger.php | 50 +++++++++++++++++++ file_copy_systems.php | 43 ++++++++++++++++ file_logger.php | 25 ++++++++++ include/language/en_us.EcmDropdownEditor.php | 3 +- include/language/pl_pl.EcmDropdownEditor.php | 3 +- modules/EcmProducts/stockAddress.php | 6 +-- .../productionSchedule/productionSchedule.js | 27 +++++++++- .../productionSchedule/productionSchedule.php | 11 ++-- modules/EcmStockDocIns/Save.php | 4 +- 9 files changed, 160 insertions(+), 12 deletions(-) create mode 100644 file_access_loger.php create mode 100644 file_copy_systems.php create mode 100644 file_logger.php diff --git a/file_access_loger.php b/file_access_loger.php new file mode 100644 index 00000000..9411f4ce --- /dev/null +++ b/file_access_loger.php @@ -0,0 +1,50 @@ +connect_error) { + $stmt = $conn->prepare("INSERT IGNORE INTO php_files_log (system, path) VALUES (?, ?)"); + $stmt->bind_param("ss", $system, $file); + + $system = 'e5'; + foreach ($e5_paths as $file) { + $stmt->execute(); + } + + $system = 'twinpol'; + foreach ($twinpol_paths as $file) { + $stmt->execute(); + } + + $stmt->close(); + $conn->close(); +} + +?> \ No newline at end of file diff --git a/file_copy_systems.php b/file_copy_systems.php new file mode 100644 index 00000000..6ed3e777 --- /dev/null +++ b/file_copy_systems.php @@ -0,0 +1,43 @@ +connect_error) { + die('Connection failed: ' . $conn->connect_error); + } + + $system = 'e5'; + $stmt = $conn->prepare("SELECT path FROM php_files_log WHERE system = ?"); + $stmt->bind_param("s", $system); + // loop through stmt results + $stmt->execute(); + $stmt->bind_result($path); + while ($stmt->fetch()) { + $files[] = $path; + } + $stmt->close(); + $conn->close(); + + foreach ($files as $file) { + // if file starts from /index.php remove it + if (strpos($file, '/index.php') === 0) { + $file = str_replace('/index.php', '', $file); + } + + // if file doesn't have extension (any) leave it + if (strpos($file, '.') === false) { + continue; + } + + // if ! file starts from /var/www add it in front + if (strpos($file, '/var/www/crm.e5.pl') !== 0) { + $file = '/var/www/crm.e5.pl' . $file; + } + + // check if file exists + if (!file_exists($file)) { + echo 'File does not exist: ' . $file . PHP_EOL; + continue; + } + } + + + exit; diff --git a/file_logger.php b/file_logger.php new file mode 100644 index 00000000..d9153d75 --- /dev/null +++ b/file_logger.php @@ -0,0 +1,25 @@ +connect_error) { + $stmt = $conn->prepare("INSERT IGNORE INTO php_files_log (system, path) VALUES (?, ?)"); + $stmt->bind_param("ss", $system, $file); + + foreach ($files as $file) { + $stmt->execute(); + } + + $stmt->close(); + $conn->close(); + } +}); +?> \ No newline at end of file diff --git a/include/language/en_us.EcmDropdownEditor.php b/include/language/en_us.EcmDropdownEditor.php index 4432d9b2..88db959c 100644 --- a/include/language/en_us.EcmDropdownEditor.php +++ b/include/language/en_us.EcmDropdownEditor.php @@ -1,5 +1,5 @@ array ( @@ -152,6 +152,7 @@ $customDoms = array ( 'e00b0e4a-ba66-796d-3bcb-66d89240c2cd' => 'Printus', '661bc56d-f77f-6d98-98be-672a06cf59ee' => 'AVCedukacja', '8d09cc5f-2348-6d22-80dc-6736057e390d' => 'Seltino', + '7ceeacc7-e79b-4eb0-2aa3-676529593a3c' => 'PureNest', ), 'ecmproducts_category_dom' => array ( diff --git a/include/language/pl_pl.EcmDropdownEditor.php b/include/language/pl_pl.EcmDropdownEditor.php index 8acd75e2..153bac26 100644 --- a/include/language/pl_pl.EcmDropdownEditor.php +++ b/include/language/pl_pl.EcmDropdownEditor.php @@ -1,5 +1,5 @@ array ( @@ -152,6 +152,7 @@ $customDoms = array ( 'e00b0e4a-ba66-796d-3bcb-66d89240c2cd' => 'Printus', '661bc56d-f77f-6d98-98be-672a06cf59ee' => 'AVCedukacja', '8d09cc5f-2348-6d22-80dc-6736057e390d' => 'Seltino', + '7ceeacc7-e79b-4eb0-2aa3-676529593a3c' => 'PureNest', ), 'ecmproducts_category_dom' => array ( diff --git a/modules/EcmProducts/stockAddress.php b/modules/EcmProducts/stockAddress.php index c4911210..a854177e 100644 --- a/modules/EcmProducts/stockAddress.php +++ b/modules/EcmProducts/stockAddress.php @@ -11,7 +11,7 @@ // check if product exists $productId = $db->fetchByAssoc($db->query("SELECT id FROM ecmproducts WHERE id = '$productId'"))['id']; if ($productId == null) { - echo json_encode(array('status' => 'Error', 'msg' => 'Nie znalaziono aktywnego produktu w bazie: '.$index )); + echo json_encode(array('status' => 'Error', 'msg' => 'Nie znalaziono produktu w bazie: '.$index )); } // check if location is empty $location = $db->fetchByAssoc($db->query("SELECT stock_address FROM ecmproducts_stock_addresses WHERE stock_address = '$address'")); @@ -35,7 +35,7 @@ break; } } else { - $pRes = $db->query("SELECT DISTINCT id, code FROM ecmproducts WHERE deleted=0 AND status != 'end_of_life';"); + $pRes = $db->query("SELECT DISTINCT id, code FROM ecmproducts WHERE deleted=0;"); $codes = array(); while ($p = $db -> fetchByAssoc($pRes)) { $index = str_replace("'", "'", $p['code']); @@ -63,7 +63,7 @@ $res = $db->query(" SELECT a.ecmproduct_id, a.stock_address, a.is_not_full, p.name, p.code FROM ecmproducts_stock_addresses AS a INNER JOIN ecmproducts as p ON p.id=a.ecmproduct_id - WHERE p.id='$id' AND p.deleted=0 AND p.active=1;"); + WHERE p.id='$id' AND p.deleted=0;"); $addresses = array(); while ($r = $db -> fetchByAssoc($res)) { array_push($addresses, $r); diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js index b994dff6..ea231115 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js @@ -7,7 +7,7 @@ $(document).ready(function () { return false; }, format: function (s, table, cell) { - return $(cell).find("input[id^=production-date]").val() || "1970-01-01"; + return $(cell).find("input[id^=production-date]").val() || "2222-01-01"; }, parsed: false, type: "text" @@ -62,6 +62,29 @@ $(document).ready(function () { 3: { sorter: "production_date" }, }, }); + $("#allTable").bind('filterEnd', function () { + localStorage.setItem("productionSchedule_filter", $.tablesorter.getFilters($("#allTable"))); + }); + $("#allTable").bind("sortEnd", function () { + try { + localStorage.setItem('productionSchedule_sort', + $("#allTable")[0].config.sortList[0][0] + "|" + $("#allTable")[0].config.sortList[0][1]); + } catch (e) {} + }); + setTimeout(() => { + const filters = localStorage.getItem("productionSchedule_filter"); + if (filters) { + $.tablesorter.setFilters($('#allTable'), filters.split(','), true); + } + const sort = localStorage.getItem("productionSchedule_sort"); + if (sort) { + try { + var tmp = sort.split("|"); + $("#allTable")[0].config.sortList = [[parseInt(tmp[0]), parseInt(tmp[1])]]; + $.tablesorter.sortOn($("#allTable")[0].config, [[parseInt(tmp[0]), parseInt(tmp[1])]]); + } catch (e) { } + } + }, 500); $("#duplicateBtn").click(() => duplicatePositions()); $("#deleteBtn").click(() => { removePositions(); }); $("#excelBtn").click(() => { exportExcel(); }); @@ -153,7 +176,7 @@ function saveDescription(id) { $.ajax({ method: "get", url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductDescription&id=" + id + "&description=" + $("#descriptionInput-" + id).val(), - success: function (data) { + success: function () { $("#description-" + id).html($("#descriptionInput-" + id).val()); }, }); diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php index f27f326a..1cf71130 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php @@ -20,7 +20,7 @@ if (!isset($_GET['ajaxAction'])) { $dateTo = date("Y-m-d", strtotime("+ 1 month")); } - $query = "SELECT s.id, s.document_no, s.status, s.parent_name, s.parent_id, s.send_date, s.type, + $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, ss.quantity as stockState, si.id as item_id, s.shipping_address_name, ps.production_date, @@ -34,9 +34,14 @@ if (!isset($_GET['ajaxAction'])) { ON ps.ecmproduct_id = p.id LEFT JOIN ecmstockstates AS ss ON ss.product_id = ps.ecmproduct_id AND ss.stock_id = 'c7afd71a-4c3a-bde4-138d-4acaee1644e4' - WHERE ps.deleted = 0 AND ps.production_date >= '$dateFrom' AND ps.production_date <= '$dateTo' + WHERE ps.deleted = 0 AND + ( + (ps.production_date >= '$dateFrom' AND ps.production_date <= '$dateTo') + OR ps.production_date IS NULL OR ps.production_date = '0000-00-00') ORDER BY s.delivery_date, s.register_date, s.document_no"; + //echo $query; + $rows = $db->query($query); $data = array(); $i = 0; @@ -57,7 +62,7 @@ if (!isset($_GET['ajaxAction'])) { $row['productShape'] = $app_list_strings['ecmproducts_shape_dom'][$r['shape']]; $row['productBrand'] = $app_list_strings['ecmproducts_brand_dom'][$r['brand']]; $row['orderNo'] = $r['document_no']; - $row['orderId'] = $r['id']; + $row['orderId'] = $r['orderId']; $row['orderStatus'] = $app_list_strings['ecmsales_status_dom'][$r['status']]; $row['orderType'] = $app_list_strings['ecmsales_type_dom'][$r['type']]; $row['orderParent'] = $r['parent_name']; diff --git a/modules/EcmStockDocIns/Save.php b/modules/EcmStockDocIns/Save.php index cf04e43e..30439743 100755 --- a/modules/EcmStockDocIns/Save.php +++ b/modules/EcmStockDocIns/Save.php @@ -215,9 +215,9 @@ if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); $return_id = $focus->id; - if ($focus->out_module == 'EcmPurchaseOrders') { + if (isset($focus->po_id)) { $db = $GLOBALS['db']; - $db->query("UPDATE ecmpurchaseorders SET status='deliver' WHERE id='".$focus->out_id."';"); + $db->query("UPDATE ecmpurchaseorders SET status='deliver' WHERE id='".$focus->po_id."';"); } echo $return_id;