Commit old changes

This commit is contained in:
2024-12-03 09:55:11 +00:00
parent 6a37a77895
commit 87010acdcc
19 changed files with 3167 additions and 1320 deletions

View File

@@ -49,10 +49,10 @@
$newPositionList = array();
$total_netto = 0; $total_brutto = 0; $total_discount = 0; $vats = array();
foreach ( $sale->position_list as $product ) {
echo 'Produkt: '.$product->product_code.'';
$p = getProduct($product->product_code);
echo 'Produkt: '.$product->product_code;
$p = getProduct(trim($product->product_code));
if (!$p) {
echo '&nbsp;&nbsp;Produkt nie istnieje w bazie E5<br>';
echo '&nbsp;&nbsp;(produkt nie istnieje w bazie E5)<br>';
$gotAllProducts = false;
continue;
} else {

View File

@@ -1,5 +1,5 @@
<?php
// created: 2024-09-12 06:58:07
// created: 2024-11-14 14:11:52
$customDoms = array (
'ecmproducts_attribute_dom' =>
array (
@@ -71,6 +71,7 @@ $customDoms = array (
'349b50d1-0a7b-b3bd-e72e-662b42ca98ae' => 'Foam 400ml',
'cb66a685-53e1-5f87-0a25-66967c7cb63b' => 'Doypack 210x285mm',
'75f4bd2a-51a8-0767-635e-66dde15af79e' => 'Foam 200ml',
'225115e4-1ce2-9a98-b7a0-672930e3318c' => 'Blister tabletki 10szt. 2 g',
),
'ecmproducts_brand_dom' =>
array (
@@ -149,6 +150,8 @@ $customDoms = array (
'd5f819ff-297b-c0d8-cfcd-66d0d0103806' => 'EcoExpert',
'4144e574-4870-fa26-25a0-66d85b094f7b' => 'Office Discount',
'e00b0e4a-ba66-796d-3bcb-66d89240c2cd' => 'Printus',
'661bc56d-f77f-6d98-98be-672a06cf59ee' => 'AVCedukacja',
'8d09cc5f-2348-6d22-80dc-6736057e390d' => 'Seltino',
),
'ecmproducts_category_dom' =>
array (

View File

@@ -1,5 +1,5 @@
<?php
// created: 2024-09-12 06:58:07
// created: 2024-11-14 14:11:52
$customDoms = array (
'ecmproducts_attribute_dom' =>
array (
@@ -71,6 +71,7 @@ $customDoms = array (
'349b50d1-0a7b-b3bd-e72e-662b42ca98ae' => 'Pianka 400ml',
'cb66a685-53e1-5f87-0a25-66967c7cb63b' => 'Doypack 210x285mm',
'75f4bd2a-51a8-0767-635e-66dde15af79e' => 'Pianka 200ml',
'225115e4-1ce2-9a98-b7a0-672930e3318c' => 'Blister tabletki 10szt. 2 g',
),
'ecmproducts_brand_dom' =>
array (
@@ -149,6 +150,8 @@ $customDoms = array (
'd5f819ff-297b-c0d8-cfcd-66d0d0103806' => 'EcoExpert',
'4144e574-4870-fa26-25a0-66d85b094f7b' => 'Office Discount',
'e00b0e4a-ba66-796d-3bcb-66d89240c2cd' => 'Printus',
'661bc56d-f77f-6d98-98be-672a06cf59ee' => 'AVCedukacja',
'8d09cc5f-2348-6d22-80dc-6736057e390d' => 'Seltino',
),
'ecmproducts_category_dom' =>
array (

View File

@@ -58,14 +58,22 @@ $viewdefs [$module_name] = array (
0 => array (
'name' => 'category',
'label' => 'LBL_CATEGORY'
)
),
1 => array (
'name' => 'shape',
'label' => 'Forma'
)
),
2 => array (
0 => array (
'name' => 'time',
'customCode' => '<span id="mojtime">{$fields.time.value}</span>',
'label' => 'LBL_TIME'
)
),
1 => array (
'name' => 'performance',
'label' => 'Wydajność'
)
),
3 => array (
0 => array (

View File

@@ -1,31 +1,31 @@
<?php
$module_name = 'EcmActions';
$viewdefs [$module_name] = array (
'EditView' => array (
'templateMeta' => array (
'maxColumns' => '2',
'widths' => array (
0 => array (
'label' => '10',
'field' => '30'
),
1 => array (
'label' => '10',
'field' => '30'
)
),
'useTabs' => false,
'tabDefs' => array (
'DEFAULT' => array (
'newTab' => false,
'panelDefault' => 'expanded'
),
'LBL_EDITVIEW_PANEL1' => array (
'newTab' => false,
'panelDefault' => 'expanded'
)
),
'javascript' => '
$viewdefs [$module_name] = array(
'EditView' => array(
'templateMeta' => array(
'maxColumns' => '2',
'widths' => array(
0 => array(
'label' => '10',
'field' => '30'
),
1 => array(
'label' => '10',
'field' => '30'
)
),
'useTabs' => false,
'tabDefs' => array(
'DEFAULT' => array(
'newTab' => false,
'panelDefault' => 'expanded'
),
'LBL_EDITVIEW_PANEL1' => array(
'newTab' => false,
'panelDefault' => 'expanded'
)
),
'javascript' => '
<script type="text/javascript" src="include/javascript/popup_parent_helper.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/jsolait/init.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/jsolait/lib/urllib.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>
@@ -33,63 +33,73 @@ $viewdefs [$module_name] = array (
<script type="text/javascript" src="include/javascript/jsclass_async.js"></script>
<script type="text/javascript" src="include/JSON.js?s={$SUGAR_VERSION}"></script>
<script type="text/javascript" src="modules/EcmActions/js/EditViewDocumentReady.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>',
'includes' => array (
0 => array (
'file' => 'include/JSON.js'
)
)
),
'panels' => array (
'default' => array (
0 => array (
0 => array (
'name' => 'name',
'label' => 'LBL_NAME',
'tabIndex' => '100',
'displayParams' => array (
'size' => 40
)
),
1 => array (
'name' => 'indeks',
'label' => 'LBL_INDEKS',
'tabindex' => '120',
)
),
1 => array (
0 => array (
'name' => 'category',
'label' => 'LBL_CATEGORY',
'tabIndex' => '101',
)
),
2 => array (
0 => array (
'name' => 'time',
'customCode' => "{include file='modules/EcmActions/tpl/EditViewTime.tpl'}",
'label' => 'LBL_TIME',
'tabIndex' => '105',
)
),
3 => array (
0 => array (
'name' => 'cost_action',
'label' => 'LBL_COST_ACTION',
'tabIndex' => '106',
)
),
4 => array (
0 => array (
'name' => 'cost_hour',
'label' => 'LBL_COST_HOUR',
'tabIndex' => '107',
)
),
6 => array (
0 => 'description'
)
)
)
)
);
'includes' => array(
0 => array(
'file' => 'include/JSON.js'
)
)
),
'panels' => array(
'default' => array(
0 => array(
0 => array(
'name' => 'name',
'label' => 'LBL_NAME',
'tabIndex' => '100',
'displayParams' => array(
'size' => 40
)
),
1 => array(
'name' => 'indeks',
'label' => 'LBL_INDEKS',
'tabindex' => '120',
)
),
1 => array(
0 => array(
'name' => 'category',
'label' => 'LBL_CATEGORY',
'tabIndex' => '101',
),
1 => array(
'name' => 'shape',
'label' => 'Forma',
'tabIndex' => '101',
)
),
2 => array(
0 => array(
'name' => 'time',
'customCode' => "{include file='modules/EcmActions/tpl/EditViewTime.tpl'}",
'label' => 'LBL_TIME',
'tabIndex' => '105',
),
1 => array (
'name' => 'performance',
'label' => 'Wydajność',
'tabIndex' => '101',
)
),
3 => array(
0 => array(
'name' => 'cost_action',
'label' => 'LBL_COST_ACTION',
'tabIndex' => '106',
)
),
4 => array(
0 => array(
'name' => 'cost_hour',
'label' => 'LBL_COST_HOUR',
'tabIndex' => '107',
)
),
6 => array(
0 => 'description'
)
)
)
)
)
?>

View File

@@ -129,7 +129,20 @@ $dictionary ['EcmAction'] = array (
'size' => '20',
'enable_range_search' => false,
'precision' => '2'
)
),
'shape' => array(
'name' => 'shape',
'options' => 'ecmproducts_shape_dom',
'vname' => 'Forma',
'len' => 36,
'type' => 'enum'
),
'performance' => array(
'name' => 'performance',
'vname' => 'Wydajność',
'type' => 'decimal',
'len' => '15,2',
),
),
'relationships' => array (),
'optimistic_locking' => true,

View File

@@ -114,12 +114,12 @@ function isAddressValid(id) {
return false;
}
const segments = $(id).val().split(".");
if (parseInt(segments[0]) > 17) {
$(id + "Error").html("Błąd pierwszego segmentu [zakres 01-20]");
if (parseInt(segments[0]) > 99) {
$(id + "Error").html("Błąd pierwszego segmentu [zakres 01-99]");
return false;
}
if (parseInt(segments[1]) > 15) {
$(id + "Error").html("Błąd drugiego segmentu [zakres 01-15]");
if (parseInt(segments[1]) > 99) {
$(id + "Error").html("Błąd drugiego segmentu [zakres 01-99]");
return false;
}
return true;
@@ -138,24 +138,24 @@ $(document).ready(function () {
$("#address").mask("AB.CD.E.F", {
placeholder: "__.__._._",
translation: {
A: { pattern: /[0-2]/ },
A: { pattern: /[0-9]/ },
B: { pattern: /[0-9]/ },
C: { pattern: /[0-1]/ },
C: { pattern: /[0-9]/ },
D: { pattern: /[0-9]/ },
E: { pattern: /[1-5]/ },
F: { pattern: /[0-5]/ },
E: { pattern: /[1-9]/ },
F: { pattern: /[0-9]/ },
}
});
if ($("#newAddress")) {
$("#newAddress").mask("AB.CD.E.F", {
placeholder: "__.__._._",
translation: {
A: { pattern: /[0-2]/ },
A: { pattern: /[0-9]/ },
B: { pattern: /[0-9]/ },
C: { pattern: /[0-1]/ },
C: { pattern: /[0-9]/ },
D: { pattern: /[0-9]/ },
E: { pattern: /[1-5]/ },
F: { pattern: /[0-5]/ },
E: { pattern: /[1-9]/ },
F: { pattern: /[0-9]/ },
}
});
$("#newAddress").focus(() => $("#newAddressError").html(""));

View File

@@ -35,7 +35,7 @@
break;
}
} else {
$pRes = $db->query("SELECT DISTINCT id, code FROM ecmproducts WHERE deleted=0 AND active=1");
$pRes = $db->query("SELECT DISTINCT id, code FROM ecmproducts WHERE deleted=0 AND status != 'end_of_life';");
$codes = array();
while ($p = $db -> fetchByAssoc($pRes)) {
$index = str_replace("&#039;", "'", $p['code']);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,190 @@
/*jshint esversion: 6 */
$(document).ready(function () {
$.tablesorter.addParser({
id: "production_date",
is: function () {
return false;
},
format: function (s, table, cell) {
return $(cell).find("input[id^=production-date]").val() || "1970-01-01";
},
parsed: false,
type: "text"
});
$("#allTable").tablesorter({
sortList: [[3, 1]],
theme: "blue",
widthFixed: true,
widgets: ["filter", "zebra", "stickyHeaders"],
fixedWidth: true,
widgetOptions: {
resizable: false,
filter_formatter: {
7: function (cell, index) {
return $.tablesorter.filterFormatter.select2(cell, index, {
match: true
});
},
8: function (cell, index) {
return $.tablesorter.filterFormatter.select2(cell, index, {
match: true
});
},
9: function (cell, index) {
return $.tablesorter.filterFormatter.select2(cell, index, {
match: true
});
},
10: function (cell, index) {
return $.tablesorter.filterFormatter.select2(cell, index, {
match: true
});
},
12: function (cell, index) {
return $.tablesorter.filterFormatter.select2(cell, index, {
match: true
});
},
13: function (cell, index) {
return $.tablesorter.filterFormatter.select2(cell, index, {
match: true
});
},
},
filter_functions: {
3: function (e, f, i) {
return f.includes(i);
}
}
},
headers: {
3: { sorter: "production_date" },
},
});
$("#duplicateBtn").click(() => duplicatePositions());
$("#deleteBtn").click(() => { removePositions(); });
$("#excelBtn").click(() => { exportExcel(); });
$("#pdfBtn").click(() => { window.alert("In progress."); });
$("#productionBtn").click(() => { window.alert("In progress."); });
});
function editQty(id) {
$("#edit-" + id).css("display", "none");
$("#qty-" + id).css("display", "none");
$("#qtyInput-" + id).css("display", "inline");
$("#qtyInput-" + id).select();
$("#save-" + id).css("display", "inline-block");
}
function saveQty(id) {
showLoader("Trwa aktualizacja...");
$("#edit-" + id).css("display", "inline-block");
$("#qty-" + id).css("display", "inline");
$("#qtyInput-" + id).css("display", "none");
$("#save-" + id).css("display", "none");
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveQty&id=" + id + "&qty=" + $("#qtyInput-" + id).val(),
success: function () {
$("#qty-" + id).html($("#qtyInput-" + id).val());
hideLoader();
},
});
}
function duplicatePositions() {
var ids = [];
$("input.allCheck:checkbox:checked").each(function () {
ids.push($(this).val());
});
if (ids.length === 0) {
window.alert("Wybierz pozycje zamówień");
return;
}
var userResponse = window.confirm("Zduplikować pozycje?");
if (!userResponse) { return; }
showLoader("Duplikowanie...");
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=duplicatePositions&ids=" + ids.join("|"),
success: function () {
window.location.reload();
},
});
}
function removePositions() {
var ids = [];
$("input.allCheck:checkbox:checked").each(function () {
ids.push($(this).val());
});
if (ids.length === 0) {
window.alert("Wybierz pozycje zamówień");
return;
}
var userResponse = window.confirm("Usunąć pozycje?");
if (!userResponse) { return; }
showLoader("Usuwanie...");
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=removePositions&ids=" + ids.join("|"),
success: function ()
{
window.location.reload();
},
});
}
function saveProductionDate(id) {
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductionDate&id=" + id + "&date=" + $("#production-date-" + id).val(),
});
}
function editDescription(id) {
$("#edit-description-" + id).css("display", "none");
$("#description-" + id).css("display", "none");
$("#descriptionInput-" + id).css("display", "inline");
$("#descriptionInput-" + id).select();
$("#save-description-" + id).css("display", "inline-block");
}
function saveDescription(id) {
$("#edit-description-" + id).css("display", "inline-block");
$("#description-" + id).css("display", "inline");
$("#descriptionInput-" + id).css("display", "none");
$("#save-description-" + id).css("display", "none");
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductDescription&id=" + id + "&description=" + $("#descriptionInput-" + id).val(),
success: function (data) {
$("#description-" + id).html($("#descriptionInput-" + id).val());
},
});
}
function showLoader(msg = "Pobieranie danych") {
$.blockUI({
css: {
border: "none",
padding: "15px",
backgroundColor: "#000",
"-webkit-border-radius": "10px",
"-moz-border-radius": "10px",
opacity: 0.5,
"font-weight": "bold",
"font-size": "16px",
color: "#fff",
},
message: msg
});
}
function hideLoader() {
$.unblockUI();
}
function exportExcel() {
showLoader("Generowanie pliku...");
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportExcel",
success: function (data)
{
window.console.log(data);
},
});
}

View File

@@ -0,0 +1,172 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
$db = $GLOBALS['db'];
global $app_list_strings;
if (!isset($_GET['ajaxAction'])) {
if (isset($_GET['date_from'])) {
$dateFrom = date("Y-m-d", strtotime($_GET['date_from']));
} else {
$dateFrom = date("Y-m-d");
}
if (isset($_GET['date_to'])) {
$dateTo = date("Y-m-d", strtotime($_GET['date_to']));
} else {
$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,
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,
ps.quantity as scheduledQuantity, ps.id as id
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 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'
ORDER BY s.delivery_date, s.register_date, s.document_no";
$rows = $db->query($query);
$data = array();
$i = 0;
while ($r = $db->fetchByAssoc($rows)) {
$row = array();
$i++;
$row['position'] = $i;
$row['id'] = $r['id'];
$row['productName'] = strlen($r['name']) > 55 ? substr($r['name'], 0, 55) . "..." : $r['name'];
$row['productFullName'] = $r['name'];
$row['productCode'] = strlen($r['code']) > 20 ? substr($r['code'], 0, 20) . "..." : $r['code'];
$row['productFullCode'] = $r['code'];
$row['productId'] = $r['ecmproduct_id'];
$row['productQty'] = $r['quantity'];
$row['qty'] = $r['scheduledQuantity'];
$row['productKind'] = $r['kind'];
$row['productSize'] = $r['size'];
$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['orderStatus'] = $app_list_strings['ecmsales_status_dom'][$r['status']];
$row['orderType'] = $app_list_strings['ecmsales_type_dom'][$r['type']];
$row['orderParent'] = $r['parent_name'];
$row['orderParentId'] = $r['parent_id'];
$row['orderSendDate'] = $r['send_date'];
$row['orderItemId'] = $r['item_id'];
$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['productionDate'] = $r['production_date'] == '0000-00-00' ? '' : $r['production_date'];
$row['productStockState'] = $r['stockState'] | 0;
$data[] = $row;
}
$smarty = new Sugar_Smarty();
$smarty->assign("data", $data);
$smarty->assign("dateFrom", $GLOBALS['timedate']->to_display_date($dateFrom));
$smarty->assign("dateTo", $GLOBALS['timedate']->to_display_date($dateTo));
echo $smarty->display('modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl');
} else {
switch ($_GET['ajaxAction']) {
case 'saveQty':
saveQty($_GET['id'], $_GET['qty']);
break;
case 'duplicatePositions':
duplicatePositions($_GET['ids']);
break;
case 'removePositions':
removePositions($_GET['ids']);
break;
case 'saveProductionDate':
saveProductionDate($_GET['id'], $_GET['date']);
break;
case 'saveProductDescription':
saveProductDescription($_GET['id'], $_GET['description']);
break;
case 'exportExcel':
exportExcel();
break;
}
}
function saveQty($id, $qty)
{
$db = $GLOBALS['db'];
$query = sprintf("UPDATE productionScheduler SET quantity='%d' WHERE id='%s'", $qty, $id);
$db->query($query);
}
function duplicatePositions($ids)
{
$db = $GLOBALS['db'];
global $current_user;
$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', '%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'],
$res['is_component'], $res['production_date'], $res['description']);
$db->query($query);
}
}
function removePositions($ids)
{
$db = $GLOBALS['db'];
global $current_user;
$ids = explode("|", $ids);
$query = sprintf("UPDATE productionScheduler SET deleted=1, modified_user_id='%s', date_modified=NOW() WHERE id IN ('%s')",
$current_user->id, join("','", $ids));
$db->query($query);
}
function saveProductionDate($id, $date)
{
$db = $GLOBALS['db'];
$date = date("Y-m-d", strtotime($date));
if ($date == '1970-01-01') {
$db->query("UPDATE productionScheduler SET production_date=NULL WHERE id='$id'");
} else {
$db->query("UPDATE productionScheduler SET production_date='$date' WHERE id='$id'");
}
}
function saveProductDescription($id, $description)
{
$db = $GLOBALS['db'];
$description = mysql_escape_string($description);
$db->query("UPDATE productionScheduler SET description='$description' WHERE id='$id'");
echo "UPDATE productionScheduler SET description='$description' WHERE id='$id'";
}
function exportExcel() {
echo 'bhhh';
require_once 'modules/EcmReports/BimIT-Reports/lib/xlsxGenerator.php';
echo 'qqqqqq';
$books = [
['ISBN', 'title', 'author', 'publisher', 'ctry' ],
[618260307, 'The Hobbit', 'J. R. R. Tolkien', 'Houghton Mifflin', 'USA'],
[908606664, 'Slinky Malinki', 'Lynley Dodd', 'Mallinson Rendel', 'NZ']
];
echo 'a';
$xlsx = Shuchkin\SimpleXLSXGen::fromArray( $books );
echo json_encode($xlsx);
$xlsx->saveAs('books.xlsx');
echo 'done';
}
function generateUuidV4()
{
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}

View File

@@ -0,0 +1,202 @@
<script type="text/javascript" src="modules/EcmReports/javascript/jquery.js"></script>
<link rel="stylesheet" href="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/css/theme.blue.min.css">
<script type="text/javascript"
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/jquery.tablesorter.js"></script>
<script type="text/javascript"
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/jquery.tablesorter.widgets.js">
</script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.js"></script>
<script type="text/javascript"
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/widgets/widget-filter-formatter-select2.min.js">
</script>
<script type="text/javascript" src="modules/EcmReports/javascript/jquery.blockUI.js"></script>
<script type="text/javascript" src="modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js"></script>
<!-- HEADER -->
<table id="tableMenu" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<img src="themes/Sugar5/images/CaseReports.gif" style="margin-top: 3px; margin-right: 3px;" width="16"
height="16">
</td>
<td>
<h2>Harmonogram Produkcji</h2>
</td>
</tr>
</table>
<br>
<!-- SEARCH -->
<form action="index.php" method="get" name="searchProductBySales">
<input type="hidden" name="module" value="EcmReports"/>
<input type="hidden" name="action" value="index"/>
<input type="hidden" name="reportName" value="productionSchedule"/>
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td class="dataLabel" width="5%" nowrap="nowrap">
Data produkcji: od
&nbsp;
<input id="date_from" name="date_from" type="text" maxlength="10" size="11" tabindex="" title=""
value="{$dateFrom}" autocomplete="off">
<img id="date_from_trigger" src="themes/default/images/jscalendar.gif">
<script language="JavaScript" type="text/javascript">
Calendar.setup({ldelim}
inputField: "date_from",
daFormat: "%d.%m.%Y",
button: "date_from_trigger",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
);
</script>
&nbsp;
do
&nbsp;
<input autocomplete="off" name="date_to" id="date_to" value="{$dateTo}" title="" tabindex="" size="11"
maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger">
<script language="JavaScript" type="text/javascript">
Calendar.setup({ldelim}
inputField: "date_to",
daFormat: "%d.%m.%Y",
button: "date_to_trigger",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
);
</script>
&nbsp;&nbsp;<input class="button" id="submitForm" name="submit" value="Filtruj" type="submit">
</td>
</tr>
</table>
</form>
<input class="button" id="duplicateBtn" value="Duplikuj" type="button">
<input class="button" id="deleteBtn" value="Usuń" type="button">&nbsp;&nbsp;&nbsp;
<input class="button" id="excelBtn" value="Excel" type="button">
<input class="button" id="pdfBtn" value="PDF" type="button">
<input class="button" id="productionBtn" value="RW/PW" type="button">
<div id="1">
<table id="allTable">
<thead>
<tr>
<th>&nbsp;</th>
<th>Indeks</th>
<th>Nazwa</th>
<th>Data produkcji</th>
<th>Ilość</th>
<th>Ilość ZS</th>
<th>Stan</th>
<th>ZS E5</th>
<th>Typ</th>
<th>Status</th>
<th>Zamawiający</th>
<th>Odbiorca</th>
<th>Forma</th>
<th>Marka</th>
<th>Data wysyłki</th>
<th>Uwagi</th>
</tr>
</thead>
<tbody aria-live="polite" aria-relevant="all">
{foreach from=$data item=ROW name=loop}
<tr>
<td>
<input type="checkbox" value="{$ROW.id}" class="allCheck"/>
<!--
<img src="modules/EcmQuotes/images/add_position.gif" style="margin-top: 3px; margin-right: 3px; cursor: pointer" width="12" alt="Duplikuj" onclick="duplicatePosition('{$ROW.id}')">
<img src="modules/EcmQuotes/images/deleterow.gif" style="margin-top: 3px; margin-right: 3px; cursor: pointer" width="12" alt="Usuń" onclick="removePosition('{$ROW.id}')">
-->
</td>
<td>
<a title="{$ROW.productFullCode}" target="_blank"
href="index.php?module=EcmProducts&action=DetailView&record={$ROW.productId}">
{$ROW.productCode}
</a>
</td>
<td title="{$ROW.productFullName}">
{$ROW.productName}
</td>
<td>
<input id="production-date-{$ROW.id}" name="production-date-{$ROW.id}" type="text"
maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}" autocomplete="off"
id="production-date-{$ROW.id}" onchange="saveProductionDate('{$ROW.id}')">
<img id="production-date-trigger-{$ROW.id}" src="themes/default/images/jscalendar.gif"
style="width: 13px;">
<script language="JavaScript" type="text/javascript">
Calendar.setup({ldelim}
inputField: "production-date-{$ROW.id}",
daFormat: "%Y-%m-%d",
button: "production-date-trigger-{$ROW.id}",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
);
</script>
</td>
<td style="white-space: nowrap;">
<div id="edit-{$ROW.id}" class="ui-icon ui-icon-pencil"
onclick="editQty('{$ROW.id}')" style="display: inline-block;"></div>
<div id="save-{$ROW.id}" class="ui-icon ui-icon-check"
onclick="saveQty('{$ROW.id}')" style="display: none;"></div>
<div id="qty-{$ROW.id}" style="display: inline; width: 300px;">{$ROW.qty}
</div>
<input id="qtyInput-{$ROW.id}" value="{$ROW.qty}" style="width: 50px; display: none;" type="number"/>
</td>
<td>
{$ROW.productQty}
</td>
<td>
{$ROW.productStockState}
</td>
<td>
<a target="_blank" href="index.php?module=EcmSales&action=DetailView&record={$ROW.orderId}">
{$ROW.orderNo}
</a>
</td>
<td>
{$ROW.orderType}
</td>
<td>
{$ROW.orderStatus}
</td>
<td>
<a target="_blank" href="index.php?module=Accounts&action=DetailView&record={$ROW.orderParentId}">
{$ROW.orderParent}
</a>
</td>
<td>
{$ROW.shippingTo}
</td>
<td>
{$ROW.productShape}
</td>
<td>
{$ROW.productBrand}
</td>
<td>
{$ROW.orderSendDate}
</td>
<td>
<div id="edit-description-{$ROW.id}" class="ui-icon ui-icon-pencil"
onclick="editDescription('{$ROW.id}')" style="display: inline-block;"></div>
<div id="save-description-{$ROW.id}" class="ui-icon ui-icon-check"
onclick="saveDescription('{$ROW.id}')" style="display: none;"></div>
<div id="description-{$ROW.id}" style="display: inline; width: 300px;">{$ROW.description}
</div>
<textarea id="descriptionInput-{$ROW.id}"
style="display: none;">{$ROW.fullDescription}</textarea>
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>

View File

@@ -1,15 +1,4 @@
$(document).ready(function () {
$.tablesorter.addParser({
id: 'production_date',
is: function (s, table, cell, $cell) {
return false;
},
format: function (s, table, cell, cellIndex) {
return $(cell).find("input[id^=production-date]").val() || "1970-01-01";
},
parsed: false,
type: 'text'
});
$("#allTable").tablesorter({
sortList: [[13, 1]],
theme: 'blue',
@@ -51,9 +40,6 @@ $(document).ready(function () {
},
},
},
headers: {
16: { sorter: 'production_date'},
},
});
$("#allTable").bind('filterEnd', function (event, config) {
updateAllPositions();
@@ -202,7 +188,14 @@ function drawComponents(data) {
$("#componentsTableContainer").html(componentsTablePrototype());
data.forEach((el, index) => {
var tr = $("<tr></tr>");
tr.append("<td><input type=\"checkbox\" value=" + el.productId + " class=\"componentCheck\" /></td>");
var position = "<td><input type=\"checkbox\" value=" + el.productId + " class=\"componentCheck\" />";
if (el.scheduled > 0) {
position += '<div style="background-color: green; width: 8px; height: 8px; border-radius: 50%; margin-top: 2px; margin-left: 2px;"></div>'
} else {
position += '<br>';
}
position += "<img src=\"modules/EcmQuotes/images/add_position.gif\" style=\"margin-top: 3px; margin-right: 3px; cursor: pointer\" width=\"12\" alt=\"\" onclick=\"addComponentToProductionScheduler('"+el.productId+"','"+el.productQty+"')\">";
tr.append(position);
tr.append("<td>" + (index + 1) + "</td>");
tr.append("<td><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.productId + "\">" + el.productCode + "</a></td>");
tr.append("<td title=\"" + el.productFullName +"\">" + el.productName + "</td>");
@@ -286,7 +279,6 @@ function getRawMaterials() {
cids
},
success: function (data) {
console.log(data);
var result = JSON.parse(data);
RawMaterials = result;
drawRawMaterials(result);
@@ -416,46 +408,21 @@ function orderRawMaterials() {
$("#orderRawMaterialsForm").submit();
}
}
function saveProductionDate(id) {
$.ajax({
method: 'get',
url: $(location).attr('href') + "&to_pdf=1&ajaxAction=saveProductionDate&itemId=" + id + "&date=" + $("#production-date-" + id).val(),
});
}
function editComment(positionId) {
$("#edit-" + positionId).css("display", "none");
$("#description-" + positionId).css("display", "none");
$("#descriptionInput-" + positionId).css("display", "inline");
$("#descriptionInput-" + positionId).select();
$("#save-" + positionId).css("display", "inline-block");
}
function saveComment(id) {
$("#edit-" + id).css("display", "inline-block");
$("#description-" + id).css("display", "inline");
$("#descriptionInput-" + id).css("display", "none");
$("#save-" + id).css("display", "none");
$.ajax({
method: 'get',
url: $(location).attr('href') + "&to_pdf=1&ajaxAction=saveProductDescription&itemId=" + id + "&description=" + $("#descriptionInput-" + id).val(),
success: function (data) {
$("#description-" + id).html($("#descriptionInput-" + id).val());
},
});
}
function showLoader() {
function showLoader(msg = "Pobieranie danych") {
$.blockUI({
css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
'font-weight': 'bold',
'font-size': '16px',
color: '#fff',
border: "none",
padding: "15px",
backgroundColor: "#000",
"-webkit-border-radius": "10px",
"-moz-border-radius": "10px",
opacity: 0.5,
"font-weight": "bold",
"font-size": "16px",
color: "#fff",
},
message: "Pobieranie danych..."
message: msg
});
}
function hideLoader() {
@@ -502,4 +469,28 @@ function componentsTablePrototype() {
}
function rawMaterialsTablePrototype() {
return '<table id="rawMaterialsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllRawMaterials" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>JM.</th><th>Stan</th><th>Zamówiono</th><th>Dostawca</th><th>Zamówienie</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody><tfoot><tr><td colspan=4></td><td id="rawMaterialsTableSum">0</td><td colspan="5"></td></tr></tfoot></table>'
}
function addToProductionScheduler(orderItemId) {
showLoader("Trwa dodawanie elementu do harmonogramu produkcji...");
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=addToProductionScheduler&itemId=" + orderItemId,
success: function ()
{
hideLoader();
window.alert("Dodano do harmonogramu produkcji.");
},
});
}
function addComponentToProductionScheduler(productId, qty) {
showLoader("Trwa dodawanie elementu do harmonogramu produkcji...");
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=addComponentToProductionScheduler&productId=" + productId + "&qty=" + qty,
success: function ()
{
hideLoader();
window.alert("Dodano do harmonogramu produkcji.");
},
});
}

View File

@@ -1,4 +1,4 @@
<?
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
@@ -29,7 +29,8 @@ if (!isset($_GET['ajaxAction'])) {
$allQuery = "SELECT s.id, s.document_no, s.status, s.parent_name, s.parent_id, s.send_date, s.type,
s.register_date, s.delivery_date, si.code, si.name, si.ecmproduct_id, si.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, si.production_date
ss.quantity as stockState, si.id as item_id, s.shipping_address_name, si.production_date,
COUNT(ps.id) AS scheduled
FROM ecmsaleitems AS si
INNER JOIN ecmsales AS s
ON s.id = si.ecmsale_id
@@ -37,6 +38,8 @@ if (!isset($_GET['ajaxAction'])) {
ON si.ecmproduct_id = p.id
LEFT JOIN ecmstockstates AS ss
ON ss.product_id = si.ecmproduct_id AND ss.stock_id = 'c7afd71a-4c3a-bde4-138d-4acaee1644e4'
LEFT JOIN productionScheduler AS ps
ON si.id = ps.ecmsaleitem_id AND ps.deleted=0
WHERE s.delivery_date > '$dateFrom'";
if (is_array($_GET['exclude']) && count($_GET['exclude']) > 0) {
foreach ($_GET['exclude'] as $name) {
@@ -66,7 +69,7 @@ if (!isset($_GET['ajaxAction'])) {
$allQuery .= " OR s.delivery_date IS NULL";
$typesWhere = " OR s.delivery_date IS NULL";
}
$allQuery .= " ORDER BY s.delivery_date ASC, s.register_date ASC, s.document_no ASC";
$allQuery .= "GROUP BY si.id ORDER BY s.delivery_date, s.register_date, s.document_no";
$rows = $db->query($allQuery);
$allData = array();
@@ -100,6 +103,7 @@ if (!isset($_GET['ajaxAction'])) {
$row['shippingTo'] = ($r['shipping_address_name'] == 'Adres korespondencyjny' ? '' : $r['shipping_address_name']);
$row['productionDate'] = $r['production_date'];
$row['productStockState'] = $r['stockState'] | 0;
$row['scheduled'] = $r['scheduled'];
if ($_GET['hideReadyProducts'] == "false" || $row['productQty'] > $row['productStockState']) {
$allData[] = $row;
@@ -135,12 +139,16 @@ if (!isset($_GET['ajaxAction'])) {
break;
case 'getRawMaterials':
echo getRawMaterials($_POST['ids'], $_POST['cids']);
case 'saveProductionDate':
saveProductionDate($_GET['itemId'], $_GET['date']);
break;
case 'saveProductDescription':
saveProductDescription($_GET['itemId'], $_GET['description']);
break;
case 'addToProductionScheduler':
addToProductionScheduler($_GET['itemId']);
break;
case 'addComponentToProductionScheduler':
addComponentToProductionScheduler($_GET['productId'], $_GET['qty']);
break;
}
}
@@ -169,13 +177,16 @@ function getComponents($ids, $dateFrom, $dateTo)
$rows = $db->query($productsQuery);
$componentsData = array();
while ($r = $db->fetchByAssoc($rows)) {
$componentsQuery = "SELECT p.code, p.name, c.quantity, p.unit_id, c.ecmcomponent_id, ss.quantity as stockState, p.group_ks
$componentsQuery = "SELECT p.code, p.name, c.quantity, p.unit_id, c.ecmcomponent_id, ss.quantity as stockState,
p.group_ks, COUNT(ps.id) AS scheduled
FROM ecmproductcomponents as c
INNER JOIN ecmproducts AS p
ON p.id = c.ecmcomponent_id
LEFT JOIN ecmstockstates AS ss
ON ss.product_id = p.id AND ss.stock_id = '368479db-22c5-0220-3a14-4bc426b1c709'
WHERE c.ecmproduct_id = '" . $r['ecmproduct_id'] . "'";
LEFT JOIN productionScheduler AS ps
ON p.id = ps.ecmproduct_id AND ps.is_component = 1 AND ps.deleted=0
WHERE c.ecmproduct_id = '" . $r['ecmproduct_id'] . "' GROUP BY p.id";
$crows = $db->query($componentsQuery);
while ($cr = $db->fetchByAssoc($crows)) {
$exists = findProduct($componentsData, $cr['ecmcomponent_id']);
@@ -221,6 +232,7 @@ function getComponents($ids, $dateFrom, $dateTo)
$row['productGroupKS'] = $cr['group_ks'];
$row['orders'] = $orders;
$row['productStockState'] = (!empty($cr['stockState'])) ? $cr['stockState'] : 0;
$row['scheduled'] = $cr['scheduled'];
$componentsData[] = $row;
}
}
@@ -315,25 +327,6 @@ function getRawMaterials($ids, $cids)
echo json_encode($rawMaterialsData);
}
function saveProductionDate($itemId, $date)
{
$db = $GLOBALS['db'];
$date = date("Y-m-d", strtotime($date));
if ($date == '1970-01-01') {
$db->query("UPDATE ecmsaleitems SET production_date=NULL WHERE id='$itemId'");
} else {
$db->query("UPDATE ecmsaleitems SET production_date='$date' WHERE id='$itemId'");
}
}
function saveProductDescription($itemId, $description)
{
$db = $GLOBALS['db'];
$description = mysql_escape_string($description);
$db->query("UPDATE ecmsaleitems SET description='$description' WHERE id='$itemId'");
}
function getProductRawMaterials($productId, $quantity)
{
$db = $GLOBALS['db'];
@@ -356,3 +349,27 @@ function getProductRawMaterials($productId, $quantity)
return $response;
}
}
function addToProductionScheduler($orderItemId) {
$db = $GLOBALS['db'];
global $current_user;
$res = $db->fetchByAssoc($db->query("SELECT quantity, ecmproduct_id, production_date, description, ecmsale_id FROM ecmsaleitems WHERE id ='$orderItemId'"));
$query = sprintf("INSERT INTO productionScheduler VALUES ('%s', '%s', '%s', '%d', NOW(), NOW(), '%s', '%s', 0, '%s', 0, '%s', '%s');",
generateUuidV4(), $orderItemId, $res['ecmsale_id'], $res['quantity'], $current_user->id, $current_user->id, $res['ecmproduct_id'], $res['production_date'], $res['description']);
$db->query($query);
}
function addComponentToProductionScheduler($productId, $qty) {
$db = $GLOBALS['db'];
global $current_user;
$query = sprintf("INSERT INTO productionScheduler VALUES ('%s', null, null, '%d', NOW(), NOW(), '%s', '%s', 0, '%s', 1, null, null);",
generateUuidV4(), $qty, $current_user->id, $current_user->id, $productId);
$db->query($query);
}
function generateUuidV4() {
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}

View File

@@ -92,7 +92,7 @@
</option>
{/foreach}
</select>
<input class="button" id="submitForm" name="submit" value="Wykonaj" type="submit">
<input class="button" id="submitForm" name="submit" value="Filtruj" type="submit">
<input class="button" id="toogleReadyProducts" value="Ukryj gotowe" type="button">
<input class="button" id="toogleServices" value="Ukryj usługi" type="button" style="display: none">
</td>
@@ -164,8 +164,6 @@
<th>Data rejestracji</th>
<th>Data wysyłki</th>
<th>Data dostawy</th>
<th>Data produkcji</th>
<th>Uwagi</th>
</tr>
</thead>
@@ -179,6 +177,10 @@
{/if}
<td>
<input type="checkbox" value="{$ROW.orderItemId}" class="allCheck"/>
<br><img src="modules/EcmQuotes/images/add_position.gif" style="margin-top: 3px; margin-right: 3px; cursor: pointer" width="12" alt="" onclick="addToProductionScheduler('{$ROW.orderItemId}')">
{if $ROW.scheduled > 0}
<div style="background-color: green; width: 8px; height: 8px; border-radius: 50%; margin-top: 2px; margin-left: 2px;"></div>
{/if}
<input type="hidden" id="productId-{$ROW.orderItemId}" value="{$ROW.productId}"/>
</td>
<td>
@@ -233,34 +235,6 @@
<td>
{$ROW.orderDeliveryDate}
</td>
<td>
<input id="production-date-{$ROW.orderItemId}" name="production-date-{$ROW.orderItemId}" type="text"
maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}" autocomplete="off"
id="production-date-{$ROW.orderItemId}" onchange="saveProductionDate('{$ROW.orderItemId}')">
<img id="production-date-trigger-{$ROW.orderItemId}" src="themes/default/images/jscalendar.gif"
style="width: 13px;">
<script language="JavaScript" type="text/javascript">
Calendar.setup({ldelim}
inputField: "production-date-{$ROW.orderItemId}",
daFormat: "%Y-%m-%d",
button: "production-date-trigger-{$ROW.orderItemId}",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
);
</script>
</td>
<td title="{$ROW.fullDescription}">
<div id="edit-{$ROW.orderItemId}" class="ui-icon ui-icon-pencil"
onclick="editComment('{$ROW.orderItemId}')" style="display: inline-block;"></div>
<div id="save-{$ROW.orderItemId}" class="ui-icon ui-icon-check"
onclick="saveComment('{$ROW.orderItemId}')" style="display: none;"></div>
<div id="description-{$ROW.orderItemId}" style="display: inline; width: 300px;">{$ROW.description}
</div>
<input id="descriptionInput-{$ROW.orderItemId}" type="text" value="{$ROW.fullDescription}"
style="width: 300px; display: none;"/>
</td>
</tr>
{/foreach}
</tbody>
@@ -268,7 +242,7 @@
<tr>
<td colspan=4></td>
<td id="allTableSum">0</td>
<td colspan="13"></td>
<td colspan="11"></td>
</tr>
</tfoot>
</table>

View File

@@ -1,7 +1,8 @@
<?php
if (isset($_GET['reportName']) && $_GET['reportName']=='productsBySales') {
include_once("modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php");
} else if (isset($_GET['reportName']) && $_GET['reportName']=='productionSchedule') {
include_once("modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php");
} else {
include_once("modules/EcmReports/ReportSales.php");
}
?>
}

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,7 @@ set_time_limit(1000000);
$sarr=array();
$parr=array();
// https://crm.e5.pl/index.php?module=EcmStockStates&action=rebuildStates&ids=2096adf3-d888-a84f-c7ec-59f810381701,75d70d0d-8f48-bf2c-3cd7-63a426511e9e,8f0d5583-468a-9c14-83b2-50a25be72052,cbead744-99e9-7d1c-0d7e-58622d8e6d8b,e95ac585-b616-b83f-e5e4-4ae5952dae8f
// https://crm.e5.pl/index.php?module=EcmStockStates&action=rebuildStates&ids=20e88740-56f6-7306-1008-647450c5e4fd,d783e0de-2ea0-f783-d29b-5bffea73981c
if (isset($_GET['ids'])) {
$ids = explode(',', $_GET['ids']);

View File

@@ -157,6 +157,11 @@
<a href="index.php?module=EcmReports&action=index&reportName=productsBySales&parentTab=Produkcja">Planowanie produkcji</a>
</li>
{/if}
{if $group=='Produkcja'}
<li>
<a href="index.php?module=EcmReports&action=index&reportName=productionSchedule&parentTab=Produkcja">Harmonogram produkcji</a>
</li>
{/if}
</ul>
</span>
{/foreach}