Commit old changes
This commit is contained in:
1200
modules/EcmReports/BimIT-Reports/lib/xlsxGenerator.php
Normal file
1200
modules/EcmReports/BimIT-Reports/lib/xlsxGenerator.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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
|
||||
|
||||
<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>
|
||||
|
||||
do
|
||||
|
||||
<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>
|
||||
<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">
|
||||
<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> </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>
|
||||
@@ -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.");
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user