Some fixes :)

This commit is contained in:
2025-01-16 10:16:01 +00:00
parent 87010acdcc
commit a4a65d5b4f
9 changed files with 160 additions and 12 deletions

50
file_access_loger.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
$e5_accessLog = '/var/log/apache2/e5_access.log';
$twinpol_accessLog = '/var/log/apache2/twinpol_access.log';
function extractPathsFromLog($logFile) {
$paths = [];
if (file_exists($logFile)) {
$file = fopen($logFile, 'r');
if ($file) {
while (($line = fgets($file)) !== false) {
if (preg_match('/"GET (\/[^ ]+)/', $line, $matches)) {
// Remove part after file extension
$path = preg_replace('/(\.[a-zA-Z0-9]+)(\?.*)?$/', '$1', $matches[1]);
$paths[] = $path;
}
}
fclose($file);
} else {
echo "Error opening the log file.";
}
} else {
echo "Log file does not exist.";
}
return $paths;
}
$e5_paths = extractPathsFromLog($e5_accessLog);
$twinpol_paths = extractPathsFromLog($twinpol_accessLog);
$conn = new mysqli('localhost', 'root', '5z#JaL', 'mz_logs');
if (!$conn->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();
}
?>

43
file_copy_systems.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
$conn = new mysqli('localhost', 'root', '5z#JaL', 'mz_logs');
if ($conn->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;

25
file_logger.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
register_shutdown_function(function() {
$system = '';
if (strpos($_SERVER['HTTP_HOST'], 'crm.e5.pl') !== false) {
$system = 'e5';
} elseif (strpos($_SERVER['HTTP_HOST'], 'crm.twinpol.com') !== false) {
$system = 'twinpol';
} else {
$systwm = 'other';
}
$files = get_included_files();
$conn = new mysqli('localhost', 'root', '5z#JaL', 'mz_logs');
if (!$conn->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();
}
});
?>

View File

@@ -1,5 +1,5 @@
<?php
// created: 2024-11-14 14:11:52
// created: 2024-12-20 08:25:23
$customDoms = array (
'ecmproducts_attribute_dom' =>
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 (

View File

@@ -1,5 +1,5 @@
<?php
// created: 2024-11-14 14:11:52
// created: 2024-12-20 08:25:23
$customDoms = array (
'ecmproducts_attribute_dom' =>
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 (

View File

@@ -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("&#039;", "'", $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);

View File

@@ -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());
},
});

View File

@@ -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'];

View File

@@ -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;