Compare commits

...

35 Commits

Author SHA1 Message Date
300aa5381a allow ZS edit for everyone 2025-12-05 09:12:10 +00:00
292748248b Stock Addresses on Stock report 2025-11-30 16:08:08 +00:00
2424bb76a3 Delivery contact on ZS realization list 2025-11-30 15:46:59 +00:00
7312918962 last fix 2025-11-27 21:00:07 +01:00
f2c24967df csv fix 2025-11-27 20:57:49 +01:00
469e254d9c csv fix 2025-11-27 20:45:31 +01:00
a7339e01f4 CSV exports fix 2025-11-27 20:07:59 +01:00
fbc3c112a2 Product.production_description fix 2025-11-27 19:05:26 +00:00
4e4a556e59 Create IO from ProductsSummary 2025-11-20 17:13:40 +01:00
0a4745366b InsideOrder: remove item fix 2025-11-20 16:49:02 +01:00
0caa2351d8 update csv queries 2025-11-10 07:47:51 +00:00
Michał Zieliński
a3bd40889a sort sale products list by stock_address 2025-11-08 12:54:24 +01:00
Michał Zieliński
a39ebfd84c export stock addresses 2025-11-08 12:23:19 +01:00
Michał Zieliński
ef6b3e0f7c currency in csv reports 2025-11-07 10:21:54 +01:00
ec0ada2f7f dropdowns 2025-11-07 09:20:26 +00:00
Michał Zieliński
d5c4261b23 production: filter data fix 2025-10-13 13:34:52 +02:00
Michał Zieliński
07100c8f12 production: update sorting 2025-10-09 15:16:52 +02:00
c02009ad63 cleanup 2025-10-08 06:35:11 +00:00
Michał Zieliński
e52fb4e039 production: filter by date fix 2025-10-08 08:26:37 +02:00
Michał Zieliński
7e0d56c670 production: production_description in product 2025-10-08 07:49:19 +02:00
2fac64346e dropdowns 2025-10-07 15:56:45 +00:00
Michał Zieliński
4374f2cd65 production: time in production date 2025-10-07 17:54:59 +02:00
Michał Zieliński
0e8227fc82 production: time in production date 2025-10-06 20:13:50 +02:00
Michał Zieliński
aae6334793 production: excel export fix 2025-10-02 12:07:33 +02:00
fc4268def0 dropdowns 2025-10-02 08:59:59 +00:00
55f0a2e88d dropdowns 2025-09-24 17:28:26 +00:00
Michał Zieliński
76dd05d591 AI CSV 2025-09-24 19:27:41 +02:00
Michał Zieliński
d5d1d1ac28 AI CSV FIX 2025-09-23 14:08:33 +02:00
Michał Zieliński
5ae9391a70 AI CSV FIX 2025-09-23 14:00:31 +02:00
Michał Zieliński
204edb231f productionScheduler - action time fix 2025-09-22 09:22:07 +02:00
Michał Zieliński
34113a5619 productionScheduler - action time fix 2025-09-22 09:16:59 +02:00
Michał Zieliński
f6e5959027 productionScheduler - action time fix 2025-09-22 09:12:01 +02:00
Michał Zieliński
c447558d2a productionScheduler - action time 2025-09-19 12:53:21 +02:00
21bd1807f3 dropdowns 2025-09-19 10:51:37 +00:00
e759b6eb46 Update google password 2025-09-17 10:11:11 +00:00
26 changed files with 2149 additions and 1266 deletions

View File

@@ -18,7 +18,6 @@ function sendInvoice($record)
); );
echo json_encode($response); echo json_encode($response);
} }
function sendProduct($record) function sendProduct($record)
{ {
require_once('modules/EcmProducts/EcmProduct.php'); require_once('modules/EcmProducts/EcmProduct.php');
@@ -35,7 +34,6 @@ function sendProduct($record)
); );
echo json_encode($response); echo json_encode($response);
} }
function copySaleFromTwinpol($record) function copySaleFromTwinpol($record)
{ {
$db = $GLOBALS['db']; $db = $GLOBALS['db'];
@@ -118,7 +116,7 @@ function copySaleFromTwinpol($record)
$prod['ecmvat_id'] = $vat_id; $prod['ecmvat_id'] = $vat_id;
$prod['ecmvat_value'] = $vat_value; $prod['ecmvat_value'] = $vat_value;
$prod['ecmvat_name'] = $vat_name; $prod['ecmvat_name'] = $vat_name;
$prod['price_brutto'] = round($prod['price_netto'] + ($prod['price_netto'] * ($prod['ecmvat_value'] / 100)), 2); $prod['price_netto'] = round((float)$price_start - ((float)$price_start * ((float)$product->discount / 100)), 2);
$prod['total_netto'] = round($prod['price_netto'] * $prod['quantity'], 2); $prod['total_netto'] = round($prod['price_netto'] * $prod['quantity'], 2);
$prod['total_brutto'] = round($prod['total_netto'] + ($prod['total_netto'] * ($prod['ecmvat_value'] / 100)), 2); $prod['total_brutto'] = round($prod['total_netto'] + ($prod['total_netto'] * ($prod['ecmvat_value'] / 100)), 2);
@@ -215,7 +213,6 @@ ILN: " . $sale->shipping_iln;
echo '<a target="new" href="https://crm.e5.pl/index.php?module=EcmSales&action=DetailView&record=' . $newId . '">Utworzono ZS.</a>'; echo '<a target="new" href="https://crm.e5.pl/index.php?module=EcmSales&action=DetailView&record=' . $newId . '">Utworzono ZS.</a>';
die(); die();
} }
// local helpers // local helpers
function getProduct($code) function getProduct($code)
{ {
@@ -230,7 +227,6 @@ function getProduct($code)
return $prod; return $prod;
} }
} }
function makeCUrlRequest($url) function makeCUrlRequest($url)
{ {
$curl = curl_init(); $curl = curl_init();
@@ -242,101 +238,114 @@ function makeCUrlRequest($url)
curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_URL, $url);
return curl_exec($curl); return curl_exec($curl);
} }
function brecho($msg) function brecho($msg)
{ {
echo '<br><br>'; echo '<br><br>';
var_dump($msg); var_dump($msg);
echo '<br><br>'; echo '<br><br>';
} }
function createCSVReports() function createCSVReports()
{ {
{ // generateProductComponentsCSV();
$db = $GLOBALS['db'];
$exportDir = __DIR__ . "/export";
$jobs = [ $db = $GLOBALS['db'];
[ $exportDir = __DIR__ . "/export";
'sql' => "
SELECT $jobs = [
[
'sql' => "
SELECT
i.document_no, i.document_no,
i.register_date, i.register_date,
i.parent_name, i.parent_name,
p.code, p.code,
p.name, p.name,
CASE p.group_ks CASE p.group_ks
WHEN 1 THEN 'Towar handlowy' WHEN '1' THEN 'Towar handlowy'
WHEN 2 THEN 'Wyrób gotowy' WHEN '2' THEN 'Wyrób gotowy'
WHEN 3 THEN 'Surowiec' WHEN '3' THEN 'Surowiec'
WHEN 4 THEN 'Usługa' WHEN '4' THEN 'Usługa'
ELSE 'Nieznane' ELSE 'Nieznane'
END AS group_ks, END AS group_ks_name,
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category, GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
ii.quantity, ii.quantity,
ii.price_netto ii.price_netto,
cur.name AS currency_name
FROM ecminvoiceouts AS i FROM ecminvoiceouts AS i
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id INNER JOIN ecminvoiceoutitems AS ii
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id ON i.id = ii.ecminvoiceout_id
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci AND ii.deleted = 0
AND cb.bean_name = 'EcmProducts' INNER JOIN ecmproducts AS p
AND cb.deleted = 0 ON ii.ecmproduct_id = p.id
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id AND p.deleted = 0
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2024 LEFT JOIN currencies AS cur
ON cur.id = i.currency_id
AND cur.deleted = 0
LEFT JOIN ecmproductcategories_bean AS cb
ON cb.bean_id = p.id
AND cb.bean_name = 'EcmProducts'
AND cb.deleted = 0
LEFT JOIN ecmproductcategories AS c
ON c.id = cb.ecmproductcategory_id
AND c.deleted = 0
WHERE i.type = 'normal'
AND i.register_date BETWEEN '2024-01-01' AND '2024-12-31'
AND i.deleted = 0
GROUP BY GROUP BY
i.document_no, i.id,
i.register_date, ii.id
i.parent_name,
p.code,
p.name,
p.group_ks,
ii.quantity,
ii.price_netto
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'invoices_2024.csv', 'filename' => 'invoices_2024.csv',
], // invoices 2024 ], // invoices 2024
[ [
'sql' => " 'sql' => "
SELECT SELECT
i.document_no, i.document_no,
i.register_date, i.register_date,
i.parent_name, i.parent_name,
p.code, p.code,
p.name, p.name,
CASE p.group_ks CASE p.group_ks
WHEN 1 THEN 'Towar handlowy' WHEN '1' THEN 'Towar handlowy'
WHEN 2 THEN 'Wyrób gotowy' WHEN '2' THEN 'Wyrób gotowy'
WHEN 3 THEN 'Surowiec' WHEN '3' THEN 'Surowiec'
WHEN 4 THEN 'Usługa' WHEN '4' THEN 'Usługa'
ELSE 'Nieznane' ELSE 'Nieznane'
END AS group_ks, END AS group_ks_name,
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category, GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
ii.quantity, ii.quantity,
ii.price_netto ii.price_netto,
cur.name AS currency_name
FROM ecminvoiceouts AS i FROM ecminvoiceouts AS i
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id INNER JOIN ecminvoiceoutitems AS ii
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id ON i.id = ii.ecminvoiceout_id
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci AND ii.deleted = 0
AND cb.bean_name = 'EcmProducts' INNER JOIN ecmproducts AS p
AND cb.deleted = 0 ON ii.ecmproduct_id = p.id
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id AND p.deleted = 0
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2025 LEFT JOIN currencies AS cur
ON cur.id = i.currency_id
AND cur.deleted = 0
LEFT JOIN ecmproductcategories_bean AS cb
ON cb.bean_id = p.id
AND cb.bean_name = 'EcmProducts'
AND cb.deleted = 0
LEFT JOIN ecmproductcategories AS c
ON c.id = cb.ecmproductcategory_id
AND c.deleted = 0
WHERE i.type = 'normal'
AND i.register_date BETWEEN '2025-01-01' AND '2025-12-31'
AND i.deleted = 0
GROUP BY GROUP BY
i.document_no, i.id,
i.register_date, ii.id
i.parent_name,
p.code,
p.name,
p.group_ks,
ii.quantity,
ii.price_netto
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'invoices_2025.csv', 'filename' => 'invoices_2025.csv',
], // invoices 2025 ], // invoices 2025
[ [
'sql' => " 'sql' => "
SELECT SELECT
i.document_no, i.document_no,
i.register_date, i.register_date,
@@ -346,43 +355,49 @@ SELECT
p.code, p.code,
p.name, p.name,
CASE p.group_ks CASE p.group_ks
WHEN 1 THEN 'Towar handlowy' WHEN '1' THEN 'Towar handlowy'
WHEN 2 THEN 'Wyrób gotowy' WHEN '2' THEN 'Wyrób gotowy'
WHEN 3 THEN 'Surowiec' WHEN '3' THEN 'Surowiec'
WHEN 4 THEN 'Usługa' WHEN '4' THEN 'Usługa'
ELSE 'Nieznane' ELSE 'Nieznane'
END AS group_ks, END AS group_ks_name,
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category, GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
ii.quantity_corrected AS quantity_correced, ii.quantity_corrected AS quantity_corrected,
ii.total_netto_corrected AS total_netto_corrected ii.total_netto_corrected AS total_netto_corrected,
cur.name AS currency_name
FROM ecminvoiceouts AS i FROM ecminvoiceouts AS i
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id INNER JOIN ecminvoiceoutitems AS ii
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id ON i.id = ii.ecminvoiceout_id
INNER JOIN ecminvoiceouts AS oi ON oi.id = i.ecminvoiceout_id AND ii.deleted = 0
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci INNER JOIN ecmproducts AS p
AND cb.bean_name = 'EcmProducts' ON ii.ecmproduct_id = p.id
AND cb.deleted = 0 AND p.deleted = 0
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id LEFT JOIN ecminvoiceouts AS oi
WHERE i.type = 'correct' AND YEAR(i.register_date) = 2024 ON oi.id = i.ecminvoiceout_id
AND oi.deleted = 0
LEFT JOIN currencies AS cur
ON cur.id = i.currency_id
AND cur.deleted = 0
LEFT JOIN ecmproductcategories_bean AS cb
ON cb.bean_id = p.id
AND cb.bean_name = 'EcmProducts'
AND cb.deleted = 0
LEFT JOIN ecmproductcategories AS c
ON c.id = cb.ecmproductcategory_id
AND c.deleted = 0
WHERE i.type = 'correct'
AND i.register_date BETWEEN '2024-01-01' AND '2024-12-31'
AND i.deleted = 0
GROUP BY GROUP BY
i.document_no, i.id,
i.register_date, ii.id,
oi.document_no, oi.id
oi.register_date, ORDER BY i.register_date DESC;
i.parent_name,
p.code,
p.name,
p.group_ks,
ii.quantity,
ii.price_netto,
ii.quantity_corrected,
ii.total_netto_corrected
ORDER BY i.register_date DESC;
", ",
'filename' => 'correct_invoices_2024.csv', 'filename' => 'correct_invoices_2024.csv',
], // correct invoices 2024 ], // correct invoices 2024
[ [
'sql' => " 'sql' => "
SELECT SELECT
i.document_no, i.document_no,
i.register_date, i.register_date,
@@ -392,191 +407,266 @@ SELECT
p.code, p.code,
p.name, p.name,
CASE p.group_ks CASE p.group_ks
WHEN 1 THEN 'Towar handlowy' WHEN '1' THEN 'Towar handlowy'
WHEN 2 THEN 'Wyrób gotowy' WHEN '2' THEN 'Wyrób gotowy'
WHEN 3 THEN 'Surowiec' WHEN '3' THEN 'Surowiec'
WHEN 4 THEN 'Usługa' WHEN '4' THEN 'Usługa'
ELSE 'Nieznane' ELSE 'Nieznane'
END AS group_ks, END AS group_ks_name,
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category, GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
ii.quantity_corrected AS quantity_correced, ii.quantity_corrected AS quantity_corrected,
ii.total_netto_corrected AS total_netto_corrected ii.total_netto_corrected AS total_netto_corrected,
cur.name AS currency_name
FROM ecminvoiceouts AS i FROM ecminvoiceouts AS i
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id INNER JOIN ecminvoiceoutitems AS ii
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id ON i.id = ii.ecminvoiceout_id
INNER JOIN ecminvoiceouts AS oi ON oi.id = i.ecminvoiceout_id AND ii.deleted = 0
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci INNER JOIN ecmproducts AS p
AND cb.bean_name = 'EcmProducts' ON ii.ecmproduct_id = p.id
AND cb.deleted = 0 AND p.deleted = 0
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id LEFT JOIN ecminvoiceouts AS oi
WHERE i.type = 'correct' AND YEAR(i.register_date) = 2025 ON oi.id = i.ecminvoiceout_id
AND oi.deleted = 0
LEFT JOIN currencies AS cur
ON cur.id = i.currency_id
AND cur.deleted = 0
LEFT JOIN ecmproductcategories_bean AS cb
ON cb.bean_id = p.id
AND cb.bean_name = 'EcmProducts'
AND cb.deleted = 0
LEFT JOIN ecmproductcategories AS c
ON c.id = cb.ecmproductcategory_id
AND c.deleted = 0
WHERE i.type = 'correct'
AND i.register_date BETWEEN '2025-01-01' AND '2025-12-31'
AND i.deleted = 0
GROUP BY GROUP BY
i.document_no, i.id,
i.register_date, ii.id,
oi.document_no, oi.id
oi.register_date,
i.parent_name,
p.code,
p.name,
p.group_ks,
ii.quantity,
ii.price_netto,
ii.quantity_corrected,
ii.total_netto_corrected
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'correct_invoices_2025.csv', 'filename' => 'correct_invoices_2025.csv',
], // correct invoices 2025 ], // correct invoices 2025
[ [
'sql' => " 'sql' => "
SELECT SELECT
i.document_no, i.document_no,
i.register_date, i.register_date,
p.code, p.code,
p.name, p.name,
CASE p.group_ks CASE p.group_ks
WHEN 1 THEN 'Towar handlowy' WHEN '1' THEN 'Towar handlowy'
WHEN 2 THEN 'Wyrób gotowy' WHEN '2' THEN 'Wyrób gotowy'
WHEN 3 THEN 'Surowiec' WHEN '3' THEN 'Surowiec'
WHEN 4 THEN 'Usługa' WHEN '4' THEN 'Usługa'
ELSE 'Nieznane' ELSE 'Nieznane'
END AS group_ks, END AS group_ks_name,
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category, pc.category,
s.name AS stock, s.name AS stock,
ii.quantity ii.quantity
FROM ecmstockdocinsideouts AS i FROM ecmstockdocinsideouts AS i
INNER JOIN ecmstockdocinsideoutitems AS ii ON i.id = ii.ecmstockdocinsideout_id INNER JOIN ecmstockdocinsideoutitems AS ii
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id ON i.id = ii.ecmstockdocinsideout_id
INNER JOIN ecmstocks AS s ON i.stock_id = s.id AND ii.deleted = 0
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci INNER JOIN ecmproducts AS p
AND cb.bean_name = 'EcmProducts' ON ii.ecmproduct_id = p.id
AND cb.deleted = 0 AND p.deleted = 0
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id INNER JOIN ecmstocks AS s
WHERE YEAR(i.register_date) = 2025 ON i.stock_id = s.id
GROUP BY AND s.deleted = 0
i.document_no, LEFT JOIN (
i.register_date, SELECT
p.code, cb.bean_id AS product_id,
p.name, GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category
p.group_ks, FROM ecmproductcategories_bean AS cb
s.name, INNER JOIN ecmproductcategories AS c
ii.quantity ON c.id = cb.ecmproductcategory_id
AND c.deleted = 0
WHERE cb.bean_name = 'EcmProducts'
AND cb.deleted = 0
GROUP BY cb.bean_id
) AS pc
ON pc.product_id = p.id
WHERE i.deleted = 0
AND i.register_date BETWEEN '2025-01-01' AND '2025-12-31'
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'rw_2025.csv', 'filename' => 'rw_2025.csv',
], // rw 2025 ], // rw 2025
[ [
'sql' => " 'sql' => "
SELECT SELECT
i.document_no, i.document_no,
i.register_date, i.register_date,
p.code, p.code,
p.name, p.name,
CASE p.group_ks CASE p.group_ks
WHEN 1 THEN 'Towar handlowy' WHEN '1' THEN 'Towar handlowy'
WHEN 2 THEN 'Wyrób gotowy' WHEN '2' THEN 'Wyrób gotowy'
WHEN 3 THEN 'Surowiec' WHEN '3' THEN 'Surowiec'
WHEN 4 THEN 'Usługa' WHEN '4' THEN 'Usługa'
ELSE 'Nieznane' ELSE 'Nieznane'
END AS group_ks, END AS group_ks_name,
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category, pc.category,
s.name AS stock, s.name AS stock,
ii.quantity ii.quantity
FROM ecmstockdocinsideouts AS i FROM ecmstockdocinsideouts AS i
INNER JOIN ecmstockdocinsideoutitems AS ii ON i.id = ii.ecmstockdocinsideout_id INNER JOIN ecmstockdocinsideoutitems AS ii
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id ON i.id = ii.ecmstockdocinsideout_id
INNER JOIN ecmstocks AS s ON i.stock_id = s.id AND ii.deleted = 0
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci INNER JOIN ecmproducts AS p
AND cb.bean_name = 'EcmProducts' ON ii.ecmproduct_id = p.id
AND cb.deleted = 0 AND p.deleted = 0
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id INNER JOIN ecmstocks AS s
WHERE YEAR(i.register_date) = 2024 ON i.stock_id = s.id
GROUP BY AND s.deleted = 0
i.document_no, LEFT JOIN (
i.register_date, SELECT
p.code, cb.bean_id AS product_id,
p.name, GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category
p.group_ks, FROM ecmproductcategories_bean AS cb
s.name, INNER JOIN ecmproductcategories AS c
ii.quantity ON c.id = cb.ecmproductcategory_id
AND c.deleted = 0
WHERE cb.bean_name = 'EcmProducts'
AND cb.deleted = 0
GROUP BY cb.bean_id
) AS pc
ON pc.product_id = p.id
WHERE i.deleted = 0
AND i.register_date BETWEEN '2024-01-01' AND '2024-12-31'
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'rw_2024.csv', 'filename' => 'rw_2024.csv',
], // rw 2024 ], // rw 2024
[ [
'sql' => " 'sql' => "
SELECT SELECT
ss.product_code, ss.product_code,
ss.product_name, ss.product_name,
ss.product_id, ss.product_id,
COALESCE(NULLIF(ss.quantity, ''), 0) AS quantity, COALESCE(NULLIF(ss.quantity, ''), 0) AS quantity,
s.name, s.name,
COALESCE(si.ordered_quantity, 0) AS ordered_quantity CASE
WHEN s.id = 'c7afd71a-4c3a-bde4-138d-4acaee1644e4' THEN COALESCE(si.ordered_quantity, 0)
WHEN s.id = '368479db-22c5-0220-3a14-4bc426b1c709' THEN COALESCE(poi.ordered_quantity, 0)
ELSE 0
END AS ordered_quantity
FROM ecmstockstates AS ss FROM ecmstockstates AS ss
JOIN ecmstocks AS s ON ss.stock_id = s.id JOIN ecmstocks AS s
ON ss.stock_id = s.id
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
i.ecmproduct_id, i.ecmproduct_id,
SUM(i.quantity) AS ordered_quantity SUM(i.quantity) AS ordered_quantity
FROM ecmsaleitems AS i FROM ecmsaleitems AS i
JOIN ecmsales AS es ON es.id = i.ecmsale_id JOIN ecmsales AS es
WHERE es.status IN ('s10','s20','s30') ON es.id = i.ecmsale_id
WHERE es.status IN ('s20', 's30')
AND es.deleted = 0
AND i.deleted = 0
AND es.register_date >= '2025-06-01'
GROUP BY i.ecmproduct_id GROUP BY i.ecmproduct_id
) AS si ON si.ecmproduct_id = ss.product_id ) AS si
ORDER BY quantity + 0 DESC;", ON si.ecmproduct_id = ss.product_id
'filename' => 'stocks.csv', LEFT JOIN (
],// stocks SELECT
[ poi.ecmproduct_id,
'sql' => " SUM(poi.quantity) AS ordered_quantity
SELECT FROM ecmpurchaseorderitems AS poi
JOIN ecmpurchaseorders AS po
ON po.id = poi.ecmpurchaseorder_id
WHERE po.status IN ('accepted', 'registered')
AND po.deleted = 0
AND poi.deleted = 0
AND po.register_date >= '2025-06-01'
GROUP BY poi.ecmproduct_id
) AS poi
ON poi.ecmproduct_id = ss.product_id
WHERE ss.stock_id IN ('c7afd71a-4c3a-bde4-138d-4acaee1644e4', '368479db-22c5-0220-3a14-4bc426b1c709')
ORDER BY quantity + 0 DESC;
",
'filename' => 'stocks.csv',
],// stocks
[
'sql' => "
SELECT
i.code AS product_code, i.code AS product_code,
i.name AS product_name, i.name AS product_name,
i.quantity, i.quantity,
i.price_netto, i.price_netto,
es.document_no, es.document_no,
es.parent_name,
CASE es.status CASE es.status
WHEN 's10' THEN 'Planowany'
WHEN 's20' THEN 'Oczekujący' WHEN 's20' THEN 'Oczekujący'
WHEN 's30' THEN 'Zaakceptowany' WHEN 's30' THEN 'Zaakceptowany'
ELSE 'Nieznane' ELSE 'Nieznane'
END AS status, END AS status,
es.register_date, es.register_date,
es.delivery_date, es.delivery_date,
es.send_date es.send_date
FROM ecmsaleitems AS i FROM ecmsaleitems AS i
JOIN ecmsales AS es ON es.id = i.ecmsale_id INNER JOIN ecmsales AS es
WHERE es.status IN ('s10','s20','s30') ON es.id = i.ecmsale_id
AND es.deleted = '0' WHERE es.status IN ('s20','s30')
AND i.deleted = '0' AND es.deleted = 0
ORDER BY es.register_date DESC, i.position; AND i.deleted = 0
AND es.register_date >= '2025-06-01'
ORDER BY es.register_date DESC, es.document_no DESC, i.position;
", ",
'filename' => 'sales.csv', 'filename' => 'zs.csv',
], //sales ], //sales
]; [
'sql' => "
SELECT
i.code AS product_code,
i.name AS product_name,
i.quantity,
i.price_start,
es.document_no,
es.parent_name,
CASE es.status
WHEN 'accepted' THEN 'Zaakceptowany'
WHEN 'registered' THEN 'Zarejestrowany'
ELSE 'Nieznane'
END AS status,
es.register_date,
es.delivery_date
FROM ecmpurchaseorderitems AS i
JOIN ecmpurchaseorders AS es
ON es.id = i.ecmpurchaseorder_id
WHERE es.status IN ('accepted','registered')
AND es.deleted = 0
AND i.deleted = 0
AND es.register_date >= '2025-06-01'
ORDER BY es.register_date DESC, es.document_no DESC, i.position;
",
'filename' => 'zz.csv',
], //orders
];
$report = []; $report = [];
foreach ($jobs as $job) { foreach ($jobs as $job) {
$sql = $job['sql']; $sql = $job['sql'];
$filename = $job['filename']; $filename = $job['filename'];
$headers = isset($job['headers']) ? $job['headers'] : null; $headers = isset($job['headers']) ? $job['headers'] : null;
$res = $db->query($sql); $res = $db->query($sql);
$fullpath = rtrim($exportDir, "/") . "/" . $filename; $fullpath = rtrim($exportDir, "/") . "/" . $filename;
$result = exportToCSVFile($res, $fullpath, $headers, ';', true); $result = exportToCSVFile($res, $fullpath, $headers, ';', true);
if ($result['ok']) { if ($result['ok']) {
$report[] = "OK → {$result['path']} (wiersze: {$result['rows']})" . PHP_EOL; $report[] = "OK → {$result['path']} (wiersze: {$result['rows']})" . PHP_EOL;
} else { } else {
$report[] = "ERR → {$result['path']} ({$result['error']})" . PHP_EOL;; $report[] = "ERR → {$result['path']} ({$result['error']})" . PHP_EOL;
}
} }
echo implode("\n", $report);
exit;
} }
}
echo implode("\n", $report);
exit;
}
function exportToCSVFile($res, $fullpath, array $headers = null, $delimiter = ';', $withBom = true) function exportToCSVFile($res, $fullpath, array $headers = null, $delimiter = ';', $withBom = true)
{ {
$db = $GLOBALS['db']; $db = $GLOBALS['db'];
@@ -642,4 +732,160 @@ function exportToCSVFile($res, $fullpath, array $headers = null, $delimiter = ';
fclose($fp); fclose($fp);
$chmod_ok = @chmod($fullpath, 0664); $chmod_ok = @chmod($fullpath, 0664);
return ['ok' => true, 'path' => $fullpath, 'rows' => $count, 'chmod' => $chmod_ok, 'error' => null]; return ['ok' => true, 'path' => $fullpath, 'rows' => $count, 'chmod' => $chmod_ok, 'error' => null];
} }
function generateProductComponentsCSV()
{
$db = $GLOBALS['db'];
$exportDir = __DIR__ . "/export";
$filename = 'product_components.csv';
$fullpath = rtrim($exportDir, "/") . "/" . $filename;
if (!is_dir($exportDir)) {
if (!@mkdir($exportDir, 0775, true)) {
echo "Błąd: Nie mogę utworzyć katalogu: $exportDir";
return;
}
}
$productsWithComponents = $db->query("
SELECT DISTINCT p.id, p.code, p.name
FROM ecmproducts p
INNER JOIN ecmproductcomponents c ON p.id = c.ecmproduct_id
WHERE p.deleted = '0' AND c.deleted = '0' AND p.active = '1'
ORDER BY p.code
");
$fp = @fopen($fullpath, 'w');
if ($fp === false) {
echo "Błąd: Nie mogę otworzyć pliku do zapisu: $fullpath";
return;
}
fwrite($fp, "\xEF\xBB\xBF");
$headers = [
'Poziom_1_Kod', 'Poziom_1_Nazwa', 'Poziom_1_Ilosc',
'Poziom_2_Kod', 'Poziom_2_Nazwa', 'Poziom_2_Ilosc',
'Poziom_3_Kod', 'Poziom_3_Nazwa', 'Poziom_3_Ilosc',
'Poziom_4_Kod', 'Poziom_4_Nazwa', 'Poziom_4_Ilosc',
'Poziom_5_Kod', 'Poziom_5_Nazwa', 'Poziom_5_Ilosc',
'Poziom_6_Kod', 'Poziom_6_Nazwa', 'Poziom_6_Ilosc',
'Poziom_7_Kod', 'Poziom_7_Nazwa', 'Poziom_7_Ilosc',
'Poziom_8_Kod', 'Poziom_8_Nazwa', 'Poziom_8_Ilosc',
'Poziom_9_Kod', 'Poziom_9_Nazwa', 'Poziom_9_Ilosc',
'Poziom_10_Kod', 'Poziom_10_Nazwa', 'Poziom_10_Ilosc'
];
fputcsv($fp, $headers, ';');
$totalRows = 0;
while ($product = $db->fetchByAssoc($productsWithComponents)) {
$rows = generateComponentRows($product['id'], $product['code'], $product['name'], 1.0, [], $db);
foreach ($rows as $row) {
fputcsv($fp, $row, ';');
$totalRows++;
}
}
fclose($fp);
echo "Wygenerowano plik CSV: $fullpath (wiersze: $totalRows)";
}
function generateComponentRows($productId, $productCode, $productName, $quantity, $path, $db, $level = 1)
{
if (in_array($productId, array_column($path, 'id'))) {
return [];
}
if ($level > 10) {
return [];
}
$rows = [];
$currentPath = $path;
$currentPath[] = [
'id' => $productId,
'code' => $productCode,
'name' => $productName,
'quantity' => $quantity
];
$componentsQuery = $db->query("
SELECT
c.ecmcomponent_id,
c.quantity,
p.code,
p.name
FROM ecmproductcomponents c
INNER JOIN ecmproducts p ON c.ecmcomponent_id = p.id
WHERE c.ecmproduct_id = '$productId'
AND c.deleted = '0'
AND p.deleted = '0'
ORDER BY c.position, p.code
");
$hasComponents = false;
while ($component = $db->fetchByAssoc($componentsQuery)) {
$hasComponents = true;
// Oblicz rzeczywistą ilość komponentu (ilość z hierarchii wyżej * ilość komponentu)
$totalQuantity = bcmul($quantity, $component['quantity'], 6);
// Sprawdź czy komponent ma swoje komponenty (rekurencja)
$subRows = generateComponentRows(
$component['ecmcomponent_id'],
$component['code'],
$component['name'],
$totalQuantity,
$currentPath,
$db,
$level + 1
);
if (empty($subRows)) {
// Komponent nie ma pod-komponentów, dodaj wiersz z kompletną ścieżką
$row = createCSVRow($currentPath, $component['ecmcomponent_id'], $component['code'], $component['name'], $totalQuantity);
$rows[] = $row;
} else {
// Komponent ma pod-komponenty, dodaj wszystkie zwrócone wiersze
$rows = array_merge($rows, $subRows);
}
}
// Jeśli produkt nie ma komponentów i jesteśmy na poziomie > 1, zwróć pusty array
// (główny produkt zawsze musi być pokazany)
if (!$hasComponents && $level > 1) {
$row = createCSVRow($currentPath);
$rows[] = $row;
}
return $rows;
}
function createCSVRow($path, $lastComponentId = null, $lastComponentCode = null, $lastComponentName = null, $lastQuantity = null)
{
// Utwórz tablicę z 30 elementami (10 poziomów * 3 kolumny: kod, nazwa, ilość)
$row = array_fill(0, 30, '');
// Wypełnij ścieżkę
foreach ($path as $index => $item) {
if ($index < 10) { // Maksymalnie 10 poziomów
$row[$index * 3] = $item['code']; // Kod
$row[$index * 3 + 1] = $item['name']; // Nazwa
$row[$index * 3 + 2] = $item['quantity']; // Ilość
}
}
// Dodaj ostatni komponent jeśli został przekazany
if ($lastComponentId !== null && count($path) < 10) {
$lastIndex = count($path);
$row[$lastIndex * 3] = $lastComponentCode;
$row[$lastIndex * 3 + 1] = $lastComponentName;
$row[$lastIndex * 3 + 2] = $lastQuantity;
}
return $row;
}

View File

@@ -655,8 +655,9 @@ $viewdefs['EcmProducts']['DetailView'] = array(
'name' => 'production_panel', 'name' => 'production_panel',
'allCols' => true, 'allCols' => true,
'hideLabel' => true, 'hideLabel' => true,
'customCode' => '{$MOD.LBL_COMPONENTS}<br><div id="componentsTable"></div><br><br>{$MOD.LBL_ACTIONS}<div id="actionsTable"></div> 'customCode' => '{$MOD.LBL_COMPONENTS}<br><div id="componentsTable"></div><br><br>{$MOD.LBL_ACTIONS}<div id="actionsTable"></div>
<br><br><div id="summaryTable" style="width: 50%; padding-right: 0px;">Podsumowanie</div>' <br><br><div id="summaryTable" style="width: 50%; padding-right: 0px;">Podsumowanie</div>
<br><b>Receptura:</b> {$PRODUCTION_DESCRIPTION}'
) )
) )
), ),

View File

@@ -1,5 +1,5 @@
<?php <?php
// created: 2025-09-14 08:35:03 // created: 2025-11-06 11:08:29
$customDoms = array ( $customDoms = array (
'ecmproducts_attribute_dom' => 'ecmproducts_attribute_dom' =>
array ( array (
@@ -47,6 +47,7 @@ $customDoms = array (
'75980ea5-d89e-3923-2662-66bb55202244' => 'Butelka ULA 1000 ml', '75980ea5-d89e-3923-2662-66bb55202244' => 'Butelka ULA 1000 ml',
'ab74cd2c-7720-5875-7ca5-66bb55a3e075' => 'Butelka ULA 500 ml', 'ab74cd2c-7720-5875-7ca5-66bb55a3e075' => 'Butelka ULA 500 ml',
'e3a77ebf-9ba1-3776-3d80-67a9e325c268' => 'Butelka ULA 250 ml ', 'e3a77ebf-9ba1-3776-3d80-67a9e325c268' => 'Butelka ULA 250 ml ',
'881d099d-36ee-3b45-b1ab-68dd2becfe84' => 'Butelka Irys 150 ml',
'ba4f06a8-f6fb-4969-d4b9-6683e6b6b372' => 'Butelka PDP_2000 ml ', 'ba4f06a8-f6fb-4969-d4b9-6683e6b6b372' => 'Butelka PDP_2000 ml ',
'a2ba9b76-8e2e-32c4-e9c8-689c6ac2dbb9' => 'Bottle 30 ml N-34B plastan', 'a2ba9b76-8e2e-32c4-e9c8-689c6ac2dbb9' => 'Bottle 30 ml N-34B plastan',
'cb8f5e45-43e1-b62d-05d7-669646b4eb10' => 'Kanister 5000 ml', 'cb8f5e45-43e1-b62d-05d7-669646b4eb10' => 'Kanister 5000 ml',
@@ -83,6 +84,7 @@ $customDoms = array (
'47fbe61c-20f4-5d48-118c-6851105ddc97' => 'Tablet', '47fbe61c-20f4-5d48-118c-6851105ddc97' => 'Tablet',
'27c00505-f6cf-3ef1-3c1d-6880847a5893' => 'Powder', '27c00505-f6cf-3ef1-3c1d-6880847a5893' => 'Powder',
'1b7d6313-d7d4-4529-73d4-684a6d5ddde3' => 'Cellophane Bag', '1b7d6313-d7d4-4529-73d4-684a6d5ddde3' => 'Cellophane Bag',
'40eb0d63-517e-345c-532d-68d37d215372' => 'Sachet',
), ),
'ecmproducts_brand_dom' => 'ecmproducts_brand_dom' =>
array ( array (
@@ -179,6 +181,10 @@ $customDoms = array (
'c709e4cf-9ca7-c946-f5e3-688202ec4c24' => 'Aspico', 'c709e4cf-9ca7-c946-f5e3-688202ec4c24' => 'Aspico',
'8bf5f833-51a9-3913-aa0a-68b6d539a1b5' => 'MediaShop', '8bf5f833-51a9-3913-aa0a-68b6d539a1b5' => 'MediaShop',
'973ff617-4696-1a21-1ba3-68c2c008e079' => 'Severno', '973ff617-4696-1a21-1ba3-68c2c008e079' => 'Severno',
'd6f1a2c9-58ea-707f-112f-68cba0dcf990' => 'Safelt',
'2f1cc2a6-7fe7-4848-b7e9-68cd307ec67f' => 'CleanFix',
'261451a0-d1fb-546b-28e4-68e3bb7fdde9' => 'Alarsa',
'd3f20145-cd52-0c92-bb81-690c81cba13e' => 'Hisense',
), ),
'ecmproducts_category_dom' => 'ecmproducts_category_dom' =>
array ( array (
@@ -231,28 +237,32 @@ $customDoms = array (
'ecmactions_category_dom' => 'ecmactions_category_dom' =>
array ( array (
'dd4ddbad-c949-0ee5-fb73-54cb9b6c86ef' => 'None', 'dd4ddbad-c949-0ee5-fb73-54cb9b6c86ef' => 'None',
'8519dfc8-5eec-0233-7f84-54d1fe00e9fc' => 'PK1', '5d843f39-893f-51f8-3df5-68c86f1d41c3' => 'HP1',
'55020d96-73d5-7b29-3bab-654f4818e0cd' => 'HP1', '31174829-986e-4d7f-4262-68b2e73742e9' => 'HP2',
'8519dfc8-5eec-0233-7f84-54d1fe00e9fc' => 'Pakowalnia 1 Hala 1',
'2bdf9315-5c31-778d-4922-68c86f4af827' => 'Pakowalnia 2 Hala 1',
'55020d96-73d5-7b29-3bab-654f4818e0cd' => 'Mieszalnia Hala 1',
'de2448f8-45ac-6b2a-f2b1-68b2e7e40a6f' => 'Mieszalnik1 Hala 2',
'9bc2bafc-0608-7bc7-468b-686a94772424' => 'BL1', '9bc2bafc-0608-7bc7-468b-686a94772424' => 'BL1',
'347509e3-fff6-4db9-761e-68b2e36436c6' => 'Opis', '347509e3-fff6-4db9-761e-68b2e36436c6' => 'LNE1',
'26c3b7fa-e1ac-66d9-517b-68b2e4c6cae8' => 'LNE2', '26c3b7fa-e1ac-66d9-517b-68b2e4c6cae8' => 'LNE2',
'5664a1b1-42dc-2bb8-ad24-68b2e52df143' => 'LNE3', '5664a1b1-42dc-2bb8-ad24-68b2e52df143' => 'LNE3',
'307b8935-5235-628f-aac1-68b2e56d3f4d' => 'LNE4', '307b8935-5235-628f-aac1-68b2e56d3f4d' => 'LNE4',
'8d68df07-0779-5a23-aaf3-68b2e5d72a46' => 'LNE5', '8d68df07-0779-5a23-aaf3-68b2e5d72a46' => 'LNE5',
'31174829-986e-4d7f-4262-68b2e73742e9' => 'Mieszalnik 100L',
'53d9cae1-1ec5-71e4-5a3c-68b2e77b6d92' => 'MDC5', '53d9cae1-1ec5-71e4-5a3c-68b2e77b6d92' => 'MDC5',
'de2448f8-45ac-6b2a-f2b1-68b2e7e40a6f' => 'HP2',
'3fea0360-a9d8-93fc-1984-68b2e89e4ec8' => 'FPH9', '3fea0360-a9d8-93fc-1984-68b2e89e4ec8' => 'FPH9',
'6159a89b-219c-bb4e-1505-68b2e9da1b7c' => 'LNEZ7', '6159a89b-219c-bb4e-1505-68b2e9da1b7c' => 'LNEZ7',
'9bc005d7-5222-3d65-b754-68b2e9854af7' => 'LE10', '9bc005d7-5222-3d65-b754-68b2e9854af7' => 'LE10',
'b1176c04-4fe3-d347-9e3a-68b2e945b5c3' => 'FPH1', 'b1176c04-4fe3-d347-9e3a-68b2e945b5c3' => 'FPH1',
'bc4422dc-8f80-4f54-26a6-68b2ea0cd2c0' => 'LNEZ8', 'bc4422dc-8f80-4f54-26a6-68b2ea0cd2c0' => 'LNEZ8',
'd8208a7e-b810-91e5-ccfa-68b2eaa73abb' => 'LNAS1', 'd8208a7e-b810-91e5-ccfa-68b2eaa73abb' => 'LNAS1',
'a87e1b10-771d-2f24-e795-68d385f0cd35' => 'LNAS2',
'f2364990-b244-064d-b5d1-68b2ebcd0ded' => 'MDC6', 'f2364990-b244-064d-b5d1-68b2ebcd0ded' => 'MDC6',
'cc4905b6-a791-5c57-4721-68b2eb29e0fe' => 'TAB1', 'cc4905b6-a791-5c57-4721-68b2eb29e0fe' => 'TAB1',
'40e8149a-40ec-aeb0-4cdd-68b2eb52634b' => 'TAB2', '40e8149a-40ec-aeb0-4cdd-68b2eb52634b' => 'TAB2',
'b64ca8db-ff88-082c-887c-68b2ec98c15d' => 'TAB3', 'b64ca8db-ff88-082c-887c-68b2ec98c15d' => 'TAB3',
'dab10a8b-295a-8eeb-be7c-68c67ec66ff7' => 'TAB4', 'dab10a8b-295a-8eeb-be7c-68c67ec66ff7' => 'TAB4',
'640aea22-b0c0-fd36-1ed4-68cac4262fe8' => 'LT1',
), ),
'payment_method_dom' => 'payment_method_dom' =>
array ( array (

View File

@@ -1,5 +1,5 @@
<?php <?php
// created: 2025-09-14 08:35:03 // created: 2025-11-06 11:08:29
$customDoms = array ( $customDoms = array (
'ecmproducts_attribute_dom' => 'ecmproducts_attribute_dom' =>
array ( array (
@@ -47,6 +47,7 @@ $customDoms = array (
'75980ea5-d89e-3923-2662-66bb55202244' => 'BT_ULA_1000', '75980ea5-d89e-3923-2662-66bb55202244' => 'BT_ULA_1000',
'ab74cd2c-7720-5875-7ca5-66bb55a3e075' => 'BT_ULA_500', 'ab74cd2c-7720-5875-7ca5-66bb55a3e075' => 'BT_ULA_500',
'e3a77ebf-9ba1-3776-3d80-67a9e325c268' => 'BT_ULA_250', 'e3a77ebf-9ba1-3776-3d80-67a9e325c268' => 'BT_ULA_250',
'881d099d-36ee-3b45-b1ab-68dd2becfe84' => 'BT_IRYS_150',
'ba4f06a8-f6fb-4969-d4b9-6683e6b6b372' => 'BT_PDP_2000ml (płyn do prania)', 'ba4f06a8-f6fb-4969-d4b9-6683e6b6b372' => 'BT_PDP_2000ml (płyn do prania)',
'a2ba9b76-8e2e-32c4-e9c8-689c6ac2dbb9' => 'Butelka 30 ml N-34B plastan', 'a2ba9b76-8e2e-32c4-e9c8-689c6ac2dbb9' => 'Butelka 30 ml N-34B plastan',
'cb8f5e45-43e1-b62d-05d7-669646b4eb10' => 'KAN_5000 (kanister)', 'cb8f5e45-43e1-b62d-05d7-669646b4eb10' => 'KAN_5000 (kanister)',
@@ -83,6 +84,7 @@ $customDoms = array (
'47fbe61c-20f4-5d48-118c-6851105ddc97' => 'Tabletka', '47fbe61c-20f4-5d48-118c-6851105ddc97' => 'Tabletka',
'27c00505-f6cf-3ef1-3c1d-6880847a5893' => 'Proszek', '27c00505-f6cf-3ef1-3c1d-6880847a5893' => 'Proszek',
'1b7d6313-d7d4-4529-73d4-684a6d5ddde3' => 'Woreczek celofanowy', '1b7d6313-d7d4-4529-73d4-684a6d5ddde3' => 'Woreczek celofanowy',
'40eb0d63-517e-345c-532d-68d37d215372' => 'Sachet',
), ),
'ecmproducts_brand_dom' => 'ecmproducts_brand_dom' =>
array ( array (
@@ -179,6 +181,10 @@ $customDoms = array (
'c709e4cf-9ca7-c946-f5e3-688202ec4c24' => 'Aspico', 'c709e4cf-9ca7-c946-f5e3-688202ec4c24' => 'Aspico',
'8bf5f833-51a9-3913-aa0a-68b6d539a1b5' => 'MediaShop', '8bf5f833-51a9-3913-aa0a-68b6d539a1b5' => 'MediaShop',
'973ff617-4696-1a21-1ba3-68c2c008e079' => 'Severno', '973ff617-4696-1a21-1ba3-68c2c008e079' => 'Severno',
'd6f1a2c9-58ea-707f-112f-68cba0dcf990' => 'Safelt',
'2f1cc2a6-7fe7-4848-b7e9-68cd307ec67f' => 'CleanFix',
'261451a0-d1fb-546b-28e4-68e3bb7fdde9' => 'Alarsa',
'd3f20145-cd52-0c92-bb81-690c81cba13e' => 'Hisense',
), ),
'ecmproducts_category_dom' => 'ecmproducts_category_dom' =>
array ( array (
@@ -231,28 +237,32 @@ $customDoms = array (
'ecmactions_category_dom' => 'ecmactions_category_dom' =>
array ( array (
'dd4ddbad-c949-0ee5-fb73-54cb9b6c86ef' => 'None', 'dd4ddbad-c949-0ee5-fb73-54cb9b6c86ef' => 'None',
'8519dfc8-5eec-0233-7f84-54d1fe00e9fc' => 'PK1', '5d843f39-893f-51f8-3df5-68c86f1d41c3' => 'HP1',
'55020d96-73d5-7b29-3bab-654f4818e0cd' => 'HP1', '31174829-986e-4d7f-4262-68b2e73742e9' => 'HP2',
'8519dfc8-5eec-0233-7f84-54d1fe00e9fc' => 'PAK1',
'2bdf9315-5c31-778d-4922-68c86f4af827' => 'PAK2',
'55020d96-73d5-7b29-3bab-654f4818e0cd' => 'MIE_HP1',
'de2448f8-45ac-6b2a-f2b1-68b2e7e40a6f' => 'M1_HP2',
'9bc2bafc-0608-7bc7-468b-686a94772424' => 'BL1', '9bc2bafc-0608-7bc7-468b-686a94772424' => 'BL1',
'347509e3-fff6-4db9-761e-68b2e36436c6' => 'LNE1', '347509e3-fff6-4db9-761e-68b2e36436c6' => 'LNE1',
'26c3b7fa-e1ac-66d9-517b-68b2e4c6cae8' => 'LNE2', '26c3b7fa-e1ac-66d9-517b-68b2e4c6cae8' => 'LNE2',
'5664a1b1-42dc-2bb8-ad24-68b2e52df143' => 'LNE3', '5664a1b1-42dc-2bb8-ad24-68b2e52df143' => 'LNE3',
'307b8935-5235-628f-aac1-68b2e56d3f4d' => 'LNE4', '307b8935-5235-628f-aac1-68b2e56d3f4d' => 'LNE4',
'8d68df07-0779-5a23-aaf3-68b2e5d72a46' => 'LNE5', '8d68df07-0779-5a23-aaf3-68b2e5d72a46' => 'LNE5',
'31174829-986e-4d7f-4262-68b2e73742e9' => 'M1',
'53d9cae1-1ec5-71e4-5a3c-68b2e77b6d92' => 'MDC5', '53d9cae1-1ec5-71e4-5a3c-68b2e77b6d92' => 'MDC5',
'de2448f8-45ac-6b2a-f2b1-68b2e7e40a6f' => 'HP2',
'3fea0360-a9d8-93fc-1984-68b2e89e4ec8' => 'FPH9', '3fea0360-a9d8-93fc-1984-68b2e89e4ec8' => 'FPH9',
'6159a89b-219c-bb4e-1505-68b2e9da1b7c' => 'LNEZ7', '6159a89b-219c-bb4e-1505-68b2e9da1b7c' => 'LNEZ7',
'9bc005d7-5222-3d65-b754-68b2e9854af7' => 'LE10', '9bc005d7-5222-3d65-b754-68b2e9854af7' => 'LE10',
'b1176c04-4fe3-d347-9e3a-68b2e945b5c3' => 'FPH1', 'b1176c04-4fe3-d347-9e3a-68b2e945b5c3' => 'FPH1',
'bc4422dc-8f80-4f54-26a6-68b2ea0cd2c0' => 'LNEZ8', 'bc4422dc-8f80-4f54-26a6-68b2ea0cd2c0' => 'LNEZ8',
'd8208a7e-b810-91e5-ccfa-68b2eaa73abb' => 'LNAS1', 'd8208a7e-b810-91e5-ccfa-68b2eaa73abb' => 'LNAS1',
'a87e1b10-771d-2f24-e795-68d385f0cd35' => 'LNAS2',
'f2364990-b244-064d-b5d1-68b2ebcd0ded' => 'MDC6', 'f2364990-b244-064d-b5d1-68b2ebcd0ded' => 'MDC6',
'cc4905b6-a791-5c57-4721-68b2eb29e0fe' => 'TAB1', 'cc4905b6-a791-5c57-4721-68b2eb29e0fe' => 'TAB1',
'40e8149a-40ec-aeb0-4cdd-68b2eb52634b' => 'TAB2', '40e8149a-40ec-aeb0-4cdd-68b2eb52634b' => 'TAB2',
'b64ca8db-ff88-082c-887c-68b2ec98c15d' => 'TAB3', 'b64ca8db-ff88-082c-887c-68b2ec98c15d' => 'TAB3',
'dab10a8b-295a-8eeb-be7c-68c67ec66ff7' => 'TAB4', 'dab10a8b-295a-8eeb-be7c-68c67ec66ff7' => 'TAB4',
'640aea22-b0c0-fd36-1ed4-68cac4262fe8' => 'LT1',
), ),
'payment_method_dom' => 'payment_method_dom' =>
array ( array (

View File

@@ -73,7 +73,7 @@ else if ($_REQUEST['isDuplicate']=="true") {
$row = []; $row = [];
$row['id'] = create_guid(); $row['id'] = create_guid();
$row['product_component'] = 1; $row['product_component'] = 1;
$tmp = explode('|',$p); $row['product_product_id'] = $tmp[0];
$row['product_id'] = $c['ecmcomponent_id']; $row['product_id'] = $c['ecmcomponent_id'];
$row['position'] = $position; $row['position'] = $position;
$position++; $position++;

View File

@@ -196,7 +196,7 @@ function deleteRow(index) {
var error = false; // hope :) var error = false; // hope :)
var id = $("#product_id_" + index).val(); var id = $("#product_id_" + index).val();
var howmany = 1; var howmany = 1;
for (var row = 0; row != count; row++) { for (var row = index+1; row != count; row++) {
comp_id = $("#product_product_id_" + row).val(); comp_id = $("#product_product_id_" + row).val();
if (comp_id == id) howmany++; if (comp_id == id) howmany++;
} }

View File

@@ -56,7 +56,9 @@ $detail->preDisplay();
$uunit.='>'.$row['name'].'</option>'; $uunit.='>'.$row['name'].'</option>';
$uunit_array[$row['id']] = $row['name']; $uunit_array[$row['id']] = $row['name'];
} }
$detail->ss->assign("USAGE_UNIT_ID",$uunit); $detail->ss->assign("USAGE_UNIT_ID",$uunit);
$detail->ss->assign("PRODUCTION_DESCRIPTION",$focus->production_description);
$tax=''; $tax='';
$result = $db->query("select id,name from ecmvats where deleted='0' order by name asc"); $result = $db->query("select id,name from ecmvats where deleted='0' order by name asc");

View File

@@ -175,6 +175,7 @@ class EcmProduct extends SugarBean
var $url8; var $url8;
var $url9; var $url9;
var $ean; var $ean;
var $production_description;
// RELATED FIELDS // RELATED FIELDS
var $created_by; var $created_by;

View File

@@ -134,6 +134,23 @@ function isProductValid(id) {
return false; return false;
} }
} }
function exportFile() {
$("#loader").show();
$.ajax({
url: "index.php?module=EcmProducts&action=&action=stockAddress&ajax=export&to_pdf=1",
}).done(function (data) {
$("#loader").hide();
if (data.status === 'Error') {
alert('Błąd: ' + data.msg);
} else {
console.log(data);
downloadFile(data.fileContent, data.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
}
}).fail(() => {
$("#loader").hide();
alert('Błąd serwera.');
});
}
$(document).ready(function () { $(document).ready(function () {
$("#address").mask("AB.CD.E.F", { $("#address").mask("AB.CD.E.F", {
placeholder: "__.__._._", placeholder: "__.__._._",
@@ -189,12 +206,49 @@ $(document).ready(function () {
$("#searchByIndexForm").submit(); $("#searchByIndexForm").submit();
} }
}); });
$("#exportTrigger").click(() => {
exportFile();
});
$('[name^="showAddress').click((event) => { $('[name^="showAddress').click((event) => {
$("#address").val(event.target.name.split('-')[1]); $("#address").val(event.target.name.split('-')[1]);
if (isAddressValid()) { if (isAddressValid()) {
$("#searchByAddressForm").submit(); $("#searchByAddressForm").submit();
} }
}); });
//bind buttons //bind buttons
}); });
function downloadFile(base64Data, fileName, mimeType) {
// Stwórz blob z danych base64
const byteCharacters = atob(base64Data);
const byteArrays = [];
for (let offset = 0; offset < byteCharacters.length; offset += 512) {
const slice = byteCharacters.slice(offset, offset + 512);
const byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
const blob = new Blob(byteArrays, {type: mimeType});
// Stwórz link do pobrania
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = fileName;
// Dodaj link do dokumentu i kliknij go
document.body.appendChild(link);
link.click();
// Usuń link z dokumentu
setTimeout(function () {
document.body.removeChild(link);
window.URL.revokeObjectURL(link.href);
}, 100);
}

View File

@@ -531,8 +531,6 @@ $viewdefs['EcmProducts']['DetailView'] = array(
) )
) )
), ),
'LBL_PANEL_CATEGORIES' => array( 'LBL_PANEL_CATEGORIES' => array(
0 => array( 0 => array(
0 => array( 0 => array(
@@ -569,7 +567,8 @@ $viewdefs['EcmProducts']['DetailView'] = array(
'allCols' => true, 'allCols' => true,
'hideLabel' => true, 'hideLabel' => true,
'customCode' => '{$MOD.LBL_COMPONENTS}<br><div id="componentsTable"></div><br><br>{$MOD.LBL_ACTIONS}<div id="actionsTable"></div> 'customCode' => '{$MOD.LBL_COMPONENTS}<br><div id="componentsTable"></div><br><br>{$MOD.LBL_ACTIONS}<div id="actionsTable"></div>
<br><br><div id="summaryTable" style="width: 50%; padding-right: 0px;">Podsumowanie</div>' <br><br><div id="summaryTable" style="width: 50%; padding-right: 0px;">Podsumowanie</div>
<br>Receptura: {$PRODUCTION_DESCRIPTION}'
) )
) )
), ),

View File

@@ -566,7 +566,8 @@ $viewdefs['EcmProducts']['EditView'] = array(
'allCols' => true, 'allCols' => true,
'hideLabel' => true, 'hideLabel' => true,
'customCode' => '{$MOD.LBL_COMPONENTS}<br><div id="componentsTable"></div><br><br>{$MOD.LBL_ACTIONS}<div id="actionsTable"></div> 'customCode' => '{$MOD.LBL_COMPONENTS}<br><div id="componentsTable"></div><br><br>{$MOD.LBL_ACTIONS}<div id="actionsTable"></div>
<br><br><div style="width: 17%;" id="copyProduct"></div><div style="width: 17%" id="copyButtons"></div>' <br><br><div style="width: 17%;" id="copyProduct"></div><div style="width: 17%" id="copyButtons"></div><br>
Receptura:<br><textarea name="production_description" id="production_description" cols="80" rows="10">{$fields.production_description.value}</textarea>'
) )
) )
), ),

View File

@@ -1,151 +1,203 @@
<?php <?php
//error_reporting(E_ALL); //error_reporting(E_ALL);
//ini_set('display_errors', 1); //ini_set('display_errors', 1);
$db = $GLOBALS['db']; $db = $GLOBALS['db'];
if ($_GET['ajax']) { if ($_GET['ajax']) {
switch ($_GET['ajax']) { switch ($_GET['ajax']) {
case 'addAddress': case 'addAddress':
$productId = $_GET['productId']; $productId = $_GET['productId'];
$address = $_GET['address'];
$isNotFull = $_GET['isNotFull'];
// 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 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'"));
if ($location != null) {
echo json_encode(array('status' => 'Error', 'msg' => 'Wskazana lokalizacja jest zajęta: '.$address ));
return;
}
$db->query("INSERT INTO ecmproducts_stock_addresses (ecmproduct_id, stock_address, is_not_full) VALUES ('$productId','$address', $isNotFull)");
echo json_encode(array('status' => 'Success', 'msg' => 'addAddress' ));
break;
case 'removeAddress':
$address = $_GET['address'];
$db->query("DELETE FROM ecmproducts_stock_addresses WHERE stock_address='$address'");
echo json_encode(array('status' => 'Success', 'msg' => 'removeAddress' ));
break;
case 'setIsNotFull':
$address = $_GET['address'];
$isNotFull = $_GET['isNotFull'] == 'true' ? 1 : 0;
$db->query("UPDATE ecmproducts_stock_addresses SET is_not_full=$isNotFull WHERE stock_address='$address'");
echo json_encode(array('status' => 'Success', 'msg' => 'setIsNotFull'));
break;
}
} else {
$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']);
array_push($codes, ['id' => $p['id'], 'code' => $index]);
}
$smarty = new Sugar_Smarty ();
if (strlen($_GET['searchType']) > 0 && $_GET['searchType'] == 'address')
{
$address = $_GET['address']; $address = $_GET['address'];
$product = $db->fetchByAssoc($db->query(" $isNotFull = $_GET['isNotFull'];
// 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 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'"));
if ($location != null) {
echo json_encode(array('status' => 'Error', 'msg' => 'Wskazana lokalizacja jest zajęta: ' . $address));
return;
}
$db->query("INSERT INTO ecmproducts_stock_addresses (ecmproduct_id, stock_address, is_not_full) VALUES ('$productId','$address', $isNotFull)");
echo json_encode(array('status' => 'Success', 'msg' => 'addAddress'));
break;
case 'removeAddress':
$address = $_GET['address'];
$db->query("DELETE FROM ecmproducts_stock_addresses WHERE stock_address='$address'");
echo json_encode(array('status' => 'Success', 'msg' => 'removeAddress'));
break;
case 'setIsNotFull':
$address = $_GET['address'];
$isNotFull = $_GET['isNotFull'] == 'true' ? 1 : 0;
$db->query("UPDATE ecmproducts_stock_addresses SET is_not_full=$isNotFull WHERE stock_address='$address'");
echo json_encode(array('status' => 'Success', 'msg' => 'setIsNotFull'));
break;
case 'export':
exportExcel();
break;
}
} else {
$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']);
array_push($codes, ['id' => $p['id'], 'code' => $index]);
}
$smarty = new Sugar_Smarty();
if (strlen($_GET['searchType']) > 0 && $_GET['searchType'] == 'address') {
$address = $_GET['address'];
$product = $db->fetchByAssoc($db->query("
SELECT a.ecmproduct_id, p.name, p.code, p.ems_qty_in_stock AS stock_state, a.is_not_full FROM ecmproducts_stock_addresses AS a SELECT a.ecmproduct_id, p.name, p.code, p.ems_qty_in_stock AS stock_state, a.is_not_full FROM ecmproducts_stock_addresses AS a
INNER JOIN ecmproducts as p ON p.id=a.ecmproduct_id INNER JOIN ecmproducts as p ON p.id=a.ecmproduct_id
WHERE stock_address='$address';")); WHERE stock_address='$address';"));
$state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='".$product['ecmproduct_id']."'")); if ($product) {
$state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='" . $product['ecmproduct_id'] . "'"));
$product['stock_state'] = $state['qty']; $product['stock_state'] = $state['qty'];
$smarty->assign("PROCESS", "ADDRESS");
$smarty->assign("PRODUCT", $product);
} }
$smarty->assign("PROCESS", "ADDRESS");
if (strlen($_GET['searchType']) > 0 && $_GET['searchType'] == 'index') $smarty->assign("PRODUCT", $product);
{ }
$id = $_GET['productId'];
$res = $db->query(" if (strlen($_GET['searchType']) > 0 && $_GET['searchType'] == 'address') {
$address = $_GET['address'];
$product = $db->fetchByAssoc($db->query("
SELECT a.ecmproduct_id, p.name, p.code, p.ems_qty_in_stock AS stock_state, a.is_not_full FROM ecmproducts_stock_addresses AS a
INNER JOIN ecmproducts as p ON p.id=a.ecmproduct_id
WHERE stock_address='$address';"));
if ($product) {
$state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='" . $product['ecmproduct_id'] . "'"));
$product['stock_state'] = $state['qty'];
}
$smarty->assign("PROCESS", "ADDRESS");
$smarty->assign("PRODUCT", $product);
}
if (strlen($_GET['searchType']) > 0 && $_GET['searchType'] == 'index') {
$id = $_GET['productId'];
$res = $db->query("
SELECT a.ecmproduct_id, a.stock_address, a.is_not_full, p.name, p.code FROM ecmproducts_stock_addresses AS a 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 INNER JOIN ecmproducts as p ON p.id=a.ecmproduct_id
WHERE p.id='$id' AND p.deleted=0;"); WHERE p.id='$id' AND p.deleted=0;");
$addresses = array(); $addresses = array();
while ($r = $db -> fetchByAssoc($res)) { while ($r = $db->fetchByAssoc($res)) {
array_push($addresses, $r); array_push($addresses, $r);
}
$product = $db->fetchByAssoc($db->query("SELECT id, name, code, ems_qty_in_stock FROM ecmproducts WHERE id = '$id';"));
$state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='$id'"));
$product['ems_qty_in_stock'] = $state['qty'];
$smarty->assign("PROCESS", "PRODUCT");
$smarty->assign("PRODUCT", $product);
$smarty->assign("ADDRESSES", $addresses);
} }
$product = $db->fetchByAssoc($db->query("SELECT id, name, code, ems_qty_in_stock FROM ecmproducts WHERE id = '$id';"));
if (strlen($_GET['searchType']) > 0 && $_GET['searchType'] == 'allAddresses') $state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='$id'"));
{ $product['ems_qty_in_stock'] = $state['qty'];
if ($_GET['onlyFull'] == "on") { $smarty->assign("PROCESS", "PRODUCT");
$allAddresses = getAllAddresses(true); $smarty->assign("PRODUCT", $product);
} else { $smarty->assign("ADDRESSES", $addresses);
$allAddresses = getAllAddresses(false);
}
$res = $db->query("
SELECT a.ecmproduct_id, a.stock_address, a.is_not_full, p.name, p.code, p.ems_qty_in_stock FROM ecmproducts_stock_addresses AS a
INNER JOIN ecmproducts as p ON p.id=a.ecmproduct_id");
$used = array();
while ($r = $db -> fetchByAssoc($res)) {
array_push($used, $r);
}
$addresses = array();
$sum = 0;
foreach ($allAddresses as $a ) {
$i = array_search($a, array_column($used, 'stock_address'));
$element = ($i !== false ? $used[$i] : null);
$row = array();
$row['stock_address'] = $a;
$row['is_not_full'] = $element['is_not_full'];
if ($element) {
$row['name'] = $element['name'];
$row['code'] = $element['code'];
$row['ecmproduct_id'] = $element['ecmproduct_id'];
$state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='".$element['ecmproduct_id']."'"));
$row['stock_state'] = $state['qty'];
}
if ($_GET['allType'] == 'used' && $element) {
array_push($addresses, $row);
$sum++;
} else if ($_GET['allType'] == 'empty' && !$element) {
array_push($addresses, $row);
$sum++;
} else if ($_GET['allType'] == 'all') {
array_push($addresses, $row);
$sum++;
}
}
$smarty->assign("SUM", $sum);
$smarty->assign("ALL_TYPE", $_GET['allType']);
$smarty->assign("ONLY_FULL", $_GET['onlyFull']);
$smarty->assign("PROCESS", "ALL_ADDRESSES");
$smarty->assign("ADDRESSES", $addresses);
}
$smarty->assign("CODES", json_encode($codes));
$smarty->assign("CURRENT_ADDRESS", $_GET['address']);
$smarty->assign("CURRENT_INDEX", $_GET['index']);
echo $smarty->display ( 'modules/EcmProducts/tpls/stockAddress.tpl' );
} }
function getAllAddresses($onlyFull) { if (strlen($_GET['searchType']) > 0 && $_GET['searchType'] == 'allAddresses') {
if ($_GET['onlyFull'] == "on") {
$allAddresses = getAllAddresses(true);
} else {
$allAddresses = getAllAddresses(false);
}
$res = $db->query("
SELECT a.ecmproduct_id, a.stock_address, a.is_not_full, p.name, p.code, p.ems_qty_in_stock FROM ecmproducts_stock_addresses AS a
INNER JOIN ecmproducts as p ON p.id=a.ecmproduct_id");
$used = array();
while ($r = $db->fetchByAssoc($res)) {
array_push($used, $r);
}
$addresses = array(); $addresses = array();
for ($i = 1; $i <= 17; $i++) { $sum = 0;
$s1 = (strlen($i) == 1) ? '0'.$i : $i; foreach ($allAddresses as $a) {
for ($j = 1; $j <= 15; $j++) { $i = array_search($a, array_column($used, 'stock_address'));
$s2 = (strlen($j) == 1) ? '0'.$j : $j; $element = ($i !== false ? $used[$i] : null);
for ($k = 1; $k <=3; $k++) { $row = array();
if ($onlyFull) { $row['stock_address'] = $a;
array_push($addresses, $s1.'.'.$s2.'.'.$k.'.0'); $row['is_not_full'] = $element['is_not_full'];
} else { if ($element) {
for ($l = 0; $l <=2; $l++) { $row['name'] = $element['name'];
array_push($addresses, $s1.'.'.$s2.'.'.$k.'.'.$l); $row['code'] = $element['code'];
} $row['ecmproduct_id'] = $element['ecmproduct_id'];
} $state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='" . $element['ecmproduct_id'] . "'"));
$row['stock_state'] = $state['qty'];
}
if ($_GET['allType'] == 'used' && $element) {
array_push($addresses, $row);
$sum++;
} else if ($_GET['allType'] == 'empty' && !$element) {
array_push($addresses, $row);
$sum++;
} else if ($_GET['allType'] == 'all') {
array_push($addresses, $row);
$sum++;
}
}
$smarty->assign("SUM", $sum);
$smarty->assign("ALL_TYPE", $_GET['allType']);
$smarty->assign("ONLY_FULL", $_GET['onlyFull']);
$smarty->assign("PROCESS", "ALL_ADDRESSES");
$smarty->assign("ADDRESSES", $addresses);
}
$smarty->assign("CODES", json_encode($codes));
$smarty->assign("CURRENT_ADDRESS", $_GET['address']);
$smarty->assign("CURRENT_INDEX", $_GET['index']);
echo $smarty->display('modules/EcmProducts/tpls/stockAddress.tpl');
}
function getAllAddresses($onlyFull)
{
$addresses = array();
for ($i = 1; $i <= 17; $i++) {
$s1 = (strlen($i) == 1) ? '0' . $i : $i;
for ($j = 1; $j <= 15; $j++) {
$s2 = (strlen($j) == 1) ? '0' . $j : $j;
for ($k = 1; $k <= 3; $k++) {
if ($onlyFull) {
array_push($addresses, $s1 . '.' . $s2 . '.' . $k . '.0');
} else {
for ($l = 0; $l <= 2; $l++) {
array_push($addresses, $s1 . '.' . $s2 . '.' . $k . '.' . $l);
}
} }
} }
} }
return $addresses; }
} return $addresses;
}
function exportExcel()
{
$db = $GLOBALS['db'];
$address = $_GET['address'];
$res = $db->query("SELECT p.code, s.stock_address
FROM ecmproducts_stock_addresses AS s
INNER JOIN ecmproducts AS p
ON p.id = s.ecmproduct_id
ORDER BY s.stock_address;");
$result = array();
while ($row = $db->fetchByAssoc($res)) {
array_push($result, $row);
}
$headers = [
'Indeks',
'Adres'
];
$sheetData = array_merge([$headers], $result);
require_once 'modules/EcmReports/BimIT-Reports/lib/xlsxGenerator.php';
$xlsx = Shuchkin\SimpleXLSXGen::fromArray($sheetData);
$xlsx_content = (string)$xlsx;
header('Content-Type: application/json');
echo json_encode([
'success' => true,
'fileContent' => base64_encode($xlsx_content),
'fileName' => 'adresy_magazynowe.xlsx'
]);
}

View File

@@ -1,5 +1,5 @@
<div class="loader" id="loader"> <div class="loader" id="loader">
<img src="themes/default/images/loading.gif" /> <img src="themes/default/images/loading.gif"/>
</div> </div>
<script> <script>
var CODES = {$CODES}; var CODES = {$CODES};
@@ -17,10 +17,10 @@
<input type="text" name="address" id="address" size="30" value="{$CURRENT_ADDRESS}"> <input type="text" name="address" id="address" size="30" value="{$CURRENT_ADDRESS}">
</td> </td>
<td> <td>
<input type="hidden" name="module" value="EcmProducts" /> <input type="hidden" name="module" value="EcmProducts"/>
<input type="hidden" name="action" value="stockAddress" /> <input type="hidden" name="action" value="stockAddress"/>
<input type="hidden" name="searchType" value="address" /> <input type="hidden" name="searchType" value="address"/>
<input type="button" id="searchByAddressTrigger" value="Szukaj adresu&nbsp;" class="button" /> <input type="button" id="searchByAddressTrigger" value="Szukaj adresu&nbsp;" class="button"/>
<span style="color: red;" id="addressError"></span> <span style="color: red;" id="addressError"></span>
</td> </td>
</tr> </tr>
@@ -34,11 +34,11 @@
<input type='text' name="index" id="index" size="30" value="{$CURRENT_INDEX}"> <input type='text' name="index" id="index" size="30" value="{$CURRENT_INDEX}">
</td> </td>
<td> <td>
<input type="hidden" name="module" value="EcmProducts" /> <input type="hidden" name="module" value="EcmProducts"/>
<input type="hidden" name="action" value="stockAddress" /> <input type="hidden" name="action" value="stockAddress"/>
<input type="hidden" name="searchType" value="index" /> <input type="hidden" name="searchType" value="index"/>
<input type="hidden" name="productId" id="productId" value="" /> <input type="hidden" name="productId" id="productId" value=""/>
<input type="button" id="searchByIndexTrigger" value="Szukaj indeksu" class="button" /> <input type="button" id="searchByIndexTrigger" value="Szukaj indeksu" class="button"/>
<span style="color: red;" id="indexError"></span> <span style="color: red;" id="indexError"></span>
</td> </td>
</tr> </tr>
@@ -57,13 +57,23 @@
</select> </select>
</td> </td>
<td> <td>
<input type="hidden" name="module" value="EcmProducts" /> <input type="hidden" name="module" value="EcmProducts"/>
<input type="hidden" name="action" value="stockAddress" /> <input type="hidden" name="action" value="stockAddress"/>
<input type="hidden" name="searchType" value="allAddresses" /> <input type="hidden" name="searchType" value="allAddresses"/>
<input type="submit" id="searchByIndexTrigger" value="Pokaż adresy" class="button" /> <input type="submit" id="searchByIndexTrigger" value="Pokaż adresy" class="button"/>
</td> </td>
</tr> </tr>
</form> </form>
<tr>
<td scope="row" nowrap="nowrap" width="1%">
<input type="hidden" name="module" value="EcmProducts"/>
<input type="hidden" name="action" value="stockAddress"/>
<input type="hidden" name="searchType" value="export"/>
<input type="button" id="exportTrigger" value="Eksport Excel" class="button"/>
</td>
<td nowrap="nowrap" width="1%">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table> </table>
</div> </div>
{if $PROCESS && $PROCESS=='ADDRESS'} {if $PROCESS && $PROCESS=='ADDRESS'}
@@ -92,10 +102,11 @@
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
<input type="button" value="Karta produktu" class="button" <input type="button" value="Karta produktu" class="button"
onclick="openProductCard('{$PRODUCT.ecmproduct_id}');" />&nbsp;&nbsp; onclick="openProductCard('{$PRODUCT.ecmproduct_id}');"/>&nbsp;&nbsp;
<input type="button" value="Wyszukaj wszystkie adresy" class="button" <input type="button" value="Wyszukaj wszystkie adresy" class="button"
onclick="searchByIndex('{$PRODUCT.code}')" />&nbsp;&nbsp; onclick="searchByIndex('{$PRODUCT.code}')"/>&nbsp;&nbsp;
<input type="button" value="Usuń produkt z adresu" class="button" onclick="removeProductFromAddress()" /> <input type="button" value="Usuń produkt z adresu" class="button"
onclick="removeProductFromAddress()"/>
</td> </td>
</tr> </tr>
</table> </table>
@@ -118,7 +129,7 @@
</td> </td>
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
<input type="button" value="Dodaj produkt" class="button" onclick="addProductToAddress()" /> <input type="button" value="Dodaj produkt" class="button" onclick="addProductToAddress()"/>
</td> </td>
</tr> </tr>
</table> </table>
@@ -126,7 +137,10 @@
{/if} {/if}
{if $PROCESS && $PROCESS=='PRODUCT'} {if $PROCESS && $PROCESS=='PRODUCT'}
<h2>{$PRODUCT.code} {$PRODUCT.name} ( Stan: {$PRODUCT.ems_qty_in_stock} )&nbsp;<input type="button" <h2>{$PRODUCT.code} {$PRODUCT.name} ( Stan: {$PRODUCT.ems_qty_in_stock} )&nbsp;<input type="button"
value="Karta produktu" class="button" onclick="openProductCard('{$PRODUCT.id}');" /></h2> value="Karta produktu"
class="button"
onclick="openProductCard('{$PRODUCT.id}');"/>
</h2>
<table cellpadding="0" cellspacing="0" class="list view"> <table cellpadding="0" cellspacing="0" class="list view">
<tr class="oddListRowS1"> <tr class="oddListRowS1">
<th style="width: 15%;"><b>Adres</b></td> <th style="width: 15%;"><b>Adres</b></td>
@@ -141,29 +155,29 @@
</td> </td>
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
<input type="checkbox" {if $item.is_not_full}checked{/if} <input type="checkbox" {if $item.is_not_full}checked{/if}
onclick="setAddressIsNotFull('{$item.stock_address}', this)" /> onclick="setAddressIsNotFull('{$item.stock_address}', this)"/>
</td> </td>
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
<input type="button" value="Usuń lokalizację" class="button" <input type="button" value="Usuń lokalizację" class="button"
onclick="removeAddressFromProduct('{$item.stock_address}')" /> onclick="removeAddressFromProduct('{$item.stock_address}')"/>
</td> </td>
</tr> </tr>
{/foreach} {/foreach}
<tr class="oddListRowS1"> <tr class="oddListRowS1">
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
<input type="text" size="10" id="newAddress" /> <input type="text" size="10" id="newAddress"/>
<span style="color: red;" id="newAddressError"></span> <span style="color: red;" id="newAddressError"></span>
</td> </td>
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
<input type="checkbox" id="isNotFull" /> <input type="checkbox" id="isNotFull"/>
</td> </td>
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
<input type="button" value="Dodaj lokalizację" class="button" onclick="addAddressToProduct();" /> <input type="button" value="Dodaj lokalizację" class="button" onclick="addAddressToProduct();"/>
</td> </td>
</tr> </tr>
</table> </table>
@@ -186,11 +200,11 @@
</td> </td>
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
<input type="checkbox" {if $item.is_not_full}checked{/if} disabled /> <input type="checkbox" {if $item.is_not_full}checked{/if} disabled/>
</td> </td>
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
<input type="button" value="Pokaż adres" class="button" name="showAddress-{$item.stock_address}" /> <input type="button" value="Pokaż adres" class="button" name="showAddress-{$item.stock_address}"/>
</td> </td>
<td valign="top" class="oddListRowS1" <td valign="top" class="oddListRowS1"
style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"> style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">
@@ -212,31 +226,32 @@
{/if} {/if}
<style> <style>
{literal} {literal}
.ui-autocomplete { .ui-autocomplete {
max-height: 200px; max-height: 200px;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
padding-right: 20px; padding-right: 20px;
border-radius: 0; border-radius: 0;
} }
.ui-corner-all { .ui-corner-all {
border-radius: 0; border-radius: 0;
} }
.loader { .loader {
display: none; display: none;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
padding-top: 50vh; padding-top: 50vh;
text-align: center; text-align: center;
background-color: rgba(16, 16, 16, 0.5); background-color: rgba(16, 16, 16, 0.5);
} }
.loader>img {} .loader > img {
}
{/literal} {/literal}
</style> </style>

View File

@@ -1459,6 +1459,11 @@ $dictionary['EcmProduct'] = array(
'vname' => 'LBL_DESCRIPTION', 'vname' => 'LBL_DESCRIPTION',
'type' => 'text' 'type' => 'text'
), ),
'production_description' => array(
'name' => 'description',
'vname' => 'LBL_DESCRIPTION',
'type' => 'text'
),
'models' => array( 'models' => array(
'name' => 'models', 'name' => 'models',
'vname' => 'LBL_MODELS', 'vname' => 'LBL_MODELS',

View File

@@ -8,7 +8,10 @@ $(document).ready(function () {
return false; return false;
}, },
format: function (s, table, cell) { format: function (s, table, cell) {
return $(cell).find("input[id^=production-date]").val() || "2222-01-01"; if ($(cell).find("input[id^=production-date]").val() === '') {
return "2222-01-01";
}
return $(cell).find("input[id^=production-date]").val() + " " + $(cell).find("input[id^=production-time]").val();
}, },
parsed: false, parsed: false,
type: "text" type: "text"
@@ -60,19 +63,22 @@ $(document).ready(function () {
} }
}, },
headers: { headers: {
3: { sorter: "production_date" }, 3: {sorter: "production_date"},
}, },
}); });
$("#allTable").bind('filterEnd', function () { $("#allTable").bind('filterEnd', function () {
$("#selectAll").attr('checked', false); $("#selectAll").attr('checked', false);
$(".allCheck").prop('checked', false); $(".allCheck").prop('checked', false);
localStorage.setItem("productionSchedule_filter", $.tablesorter.getFilters($("#allTable"))); localStorage.setItem("productionSchedule_filter", $.tablesorter.getFilters($("#allTable")));
updateTimeSummary();
}); });
$("#allTable").bind("sortEnd", function () { $("#allTable").bind("sortEnd", function () {
try { try {
localStorage.setItem('productionSchedule_sort', localStorage.setItem('productionSchedule_sort',
$("#allTable")[0].config.sortList[0][0] + "|" + $("#allTable")[0].config.sortList[0][1]); $("#allTable")[0].config.sortList[0][0] + "|" + $("#allTable")[0].config.sortList[0][1]);
} catch (e) {} } catch (e) {
}
updateTimeSummary();
}); });
setTimeout(() => { setTimeout(() => {
const filters = localStorage.getItem("productionSchedule_filter"); const filters = localStorage.getItem("productionSchedule_filter");
@@ -85,12 +91,13 @@ $(document).ready(function () {
var tmp = sort.split("|"); var tmp = sort.split("|");
$("#allTable")[0].config.sortList = [[parseInt(tmp[0]), parseInt(tmp[1])]]; $("#allTable")[0].config.sortList = [[parseInt(tmp[0]), parseInt(tmp[1])]];
$.tablesorter.sortOn($("#allTable")[0].config, [[parseInt(tmp[0]), parseInt(tmp[1])]]); $.tablesorter.sortOn($("#allTable")[0].config, [[parseInt(tmp[0]), parseInt(tmp[1])]]);
} catch (e) { } } catch (e) {
}
} }
}, 500); }, 500);
$("#selectAll").click(function () { $("#selectAll").click(function () {
if (this.checked) { if (this.checked) {
$(".allCheck").each(function() { $(".allCheck").each(function () {
if ($(this).closest('tr').is(':visible')) { if ($(this).closest('tr').is(':visible')) {
$(this).prop('checked', true); $(this).prop('checked', true);
} }
@@ -98,17 +105,38 @@ $(document).ready(function () {
} else { } else {
$(".allCheck").prop("checked", false); $(".allCheck").prop("checked", false);
} }
updateTimeSummary();
}); });
$("#duplicateBtn").click(() => duplicatePositions()); $("#duplicateBtn").click(() => duplicatePositions());
$("#deleteBtn").click(() => { removePositions(); }); $("#deleteBtn").click(() => {
$("#excelBtn").click(() => { exportExcel(); }); removePositions();
$("#pdfBtn").click(() => { exportPDF(); }); });
$("#productionBtn").click(() => { window.alert("In progress."); }); $("#excelBtn").click(() => {
exportExcel();
});
$("#pdfBtn").click(() => {
exportPDF();
});
$("#changeDateBtn").click(() => {
changeDate();
});
$("#rawMaterialsExcelBtn").click(() => {
exportRawMaterialsExcel();
});
$("#productionBtn").click(() => {
window.alert("In progress.");
});
$("#createInsideOrder").click(createInsideOrder); $("#createInsideOrder").click(createInsideOrder);
$(document).on('change', '.allCheck', function () {
updateTimeSummary();
});
}); });
function SetTab(tab_name) { function SetTab(tab_name) {
if (TabsMainBlock) { return; } if (TabsMainBlock) {
return;
}
var TabMenu = document.getElementById("groupTabsPanels"); var TabMenu = document.getElementById("groupTabsPanels");
var tabs = TabMenu.getElementsByTagName("li"); var tabs = TabMenu.getElementsByTagName("li");
for (var i = 0; i < tabs.length; i++) { for (var i = 0; i < tabs.length; i++) {
@@ -134,6 +162,7 @@ function SetTab(tab_name) {
if (SelectedTab === "1") { if (SelectedTab === "1") {
} }
} }
function getRawMaterials() { function getRawMaterials() {
var ids = []; var ids = [];
$("input.allCheck:checkbox:checked").each(function () { $("input.allCheck:checkbox:checked").each(function () {
@@ -169,6 +198,7 @@ function getRawMaterials() {
} }
}); });
} }
function drawRawMaterials(data) { function drawRawMaterials(data) {
$("#rawMaterialsTableContainer").html(rawMaterialsTablePrototype()); $("#rawMaterialsTableContainer").html(rawMaterialsTablePrototype());
// TODO: tutraj czasami się wiesza // TODO: tutraj czasami się wiesza
@@ -182,7 +212,7 @@ function drawRawMaterials(data) {
} }
code += "><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.id + "\">" + el.code + "</a></td>"; code += "><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.id + "\">" + el.code + "</a></td>";
tr.append(code); tr.append(code);
tr.append("<td title=\""+ el.fullName +"\">" + el.name + "</td>"); tr.append("<td title=\"" + el.fullName + "\">" + el.name + "</td>");
tr.append("<td id=\"qty-" + el.id + "\">" + el.quantity + "</td>"); tr.append("<td id=\"qty-" + el.id + "\">" + el.quantity + "</td>");
tr.append("<td>" + el.unit + "</td>"); tr.append("<td>" + el.unit + "</td>");
tr.append("<td id=\"state-" + el.id + "\">" + el.stockState + "</td>"); tr.append("<td id=\"state-" + el.id + "\">" + el.stockState + "</td>");
@@ -210,7 +240,7 @@ function drawRawMaterials(data) {
$("#selectAllRawMaterials").attr('checked', false); $("#selectAllRawMaterials").attr('checked', false);
$("#selectAllRawMaterials").click(function () { $("#selectAllRawMaterials").click(function () {
if (this.checked) { if (this.checked) {
$(".rawMaterialCheck").each(function() { $(".rawMaterialCheck").each(function () {
if ($(this).closest('tr').is(':visible')) { if ($(this).closest('tr').is(':visible')) {
$(this).prop('checked', true); $(this).prop('checked', true);
} }
@@ -221,9 +251,11 @@ function drawRawMaterials(data) {
}); });
updateRawMaterialsPositions(); updateRawMaterialsPositions();
} }
function rawMaterialsTablePrototype() { 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>Adres magazynowy</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody></table>'; 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>Adres magazynowy</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody></table>';
} }
function updateRawMaterialsPositions() { function updateRawMaterialsPositions() {
var i = 0; var i = 0;
$("#rawMaterialsTable").find("tr").each(function (index) { $("#rawMaterialsTable").find("tr").each(function (index) {
@@ -233,6 +265,7 @@ function updateRawMaterialsPositions() {
} }
}); });
} }
function editQty(id) { function editQty(id) {
$("#edit-" + id).css("display", "none"); $("#edit-" + id).css("display", "none");
$("#qty-" + id).css("display", "none"); $("#qty-" + id).css("display", "none");
@@ -240,6 +273,7 @@ function editQty(id) {
$("#qtyInput-" + id).select(); $("#qtyInput-" + id).select();
$("#save-" + id).css("display", "inline-block"); $("#save-" + id).css("display", "inline-block");
} }
function saveQty(id) { function saveQty(id) {
showLoader("Trwa aktualizacja..."); showLoader("Trwa aktualizacja...");
$("#edit-" + id).css("display", "inline-block"); $("#edit-" + id).css("display", "inline-block");
@@ -255,6 +289,7 @@ function saveQty(id) {
}, },
}); });
} }
function duplicatePositions() { function duplicatePositions() {
var ids = []; var ids = [];
$("input.allCheck:checkbox:checked").each(function () { $("input.allCheck:checkbox:checked").each(function () {
@@ -265,7 +300,9 @@ function duplicatePositions() {
return; return;
} }
var userResponse = window.confirm("Zduplikować pozycje?"); var userResponse = window.confirm("Zduplikować pozycje?");
if (!userResponse) { return; } if (!userResponse) {
return;
}
showLoader("Duplikowanie..."); showLoader("Duplikowanie...");
$.ajax({ $.ajax({
method: "get", method: "get",
@@ -275,6 +312,7 @@ function duplicatePositions() {
}, },
}); });
} }
function removePositions() { function removePositions() {
var ids = []; var ids = [];
$("input.allCheck:checkbox:checked").each(function () { $("input.allCheck:checkbox:checked").each(function () {
@@ -285,23 +323,68 @@ function removePositions() {
return; return;
} }
var userResponse = window.confirm("Usunąć pozycje?"); var userResponse = window.confirm("Usunąć pozycje?");
if (!userResponse) { return; } if (!userResponse) {
return;
}
showLoader("Usuwanie..."); showLoader("Usuwanie...");
$.ajax({ $.ajax({
method: "get", method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=removePositions&ids=" + ids.join("|"), url: $(location).attr("href") + "&to_pdf=1&ajaxAction=removePositions&ids=" + ids.join("|"),
success: function () success: function () {
{
window.location.reload(); window.location.reload();
}, },
}); });
} }
function saveProductionDate(id) { function saveProductionDate(id) {
let date = $("#production-date-" + id).val();
let time = $("#production-time-" + id).val();
if (date.length !== 10) {
$("#production-date-" + id).val('');
$("#production-time-" + id).val('');
date = '';
time = '';
} else {
if (time.length === 5) {
const timeRegex = /^([0-5]?[0-9]|1[0-3]):[0-5][0-9]$|^14:[0-2][0-9]$|^14:30$/;
if (!timeRegex.test(time)) {
time = "06:00";
} else {
const timeParts = time.split(':');
const hours = parseInt(timeParts[0], 10);
const minutes = parseInt(timeParts[1], 10);
if (hours < 6 || (hours === 14 && minutes > 30) || hours > 14) {
time = "06:00";
}
}
} else if (time.length === 4) {
time = time.substring(0, 2) + ":" + time.substring(2);
const timeRegex = /^([0-5]?[0-9]|1[0-3]):[0-5][0-9]$|^14:[0-2][0-9]$|^14:30$/;
if (!timeRegex.test(time)) {
time = "06:00";
} else {
const timeParts = time.split(':');
const hours = parseInt(timeParts[0], 10);
const minutes = parseInt(timeParts[1], 10);
if (hours < 6 || (hours === 14 && minutes > 30) || hours > 14) {
time = "06:00";
}
}
} else {
time = "06:00";
}
}
$("#production-time-" + id).val(time);
$.ajax({ $.ajax({
method: "get", method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductionDate&id=" + id + "&date=" + $("#production-date-" + id).val(), url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductionDate&id=" + id + "&date=" + encodeURIComponent(date) + "&time=" + encodeURIComponent(time),
}); });
} }
function editDescription(id) { function editDescription(id) {
$("#edit-description-" + id).css("display", "none"); $("#edit-description-" + id).css("display", "none");
$("#description-" + id).css("display", "none"); $("#description-" + id).css("display", "none");
@@ -309,6 +392,7 @@ function editDescription(id) {
$("#descriptionInput-" + id).select(); $("#descriptionInput-" + id).select();
$("#save-description-" + id).css("display", "inline-block"); $("#save-description-" + id).css("display", "inline-block");
} }
function saveDescription(id) { function saveDescription(id) {
$("#edit-description-" + id).css("display", "inline-block"); $("#edit-description-" + id).css("display", "inline-block");
$("#description-" + id).css("display", "inline"); $("#description-" + id).css("display", "inline");
@@ -322,6 +406,7 @@ function saveDescription(id) {
}, },
}); });
} }
function showLoader(msg = "Pobieranie danych") { function showLoader(msg = "Pobieranie danych") {
$.blockUI({ $.blockUI({
css: { css: {
@@ -338,30 +423,83 @@ function showLoader(msg = "Pobieranie danych") {
message: msg message: msg
}); });
} }
function hideLoader() { function hideLoader() {
$.unblockUI(); $.unblockUI();
} }
function exportExcel() { function exportExcel() {
var ids = []; // Check if any rows are selected
$("input.allCheck:checkbox:checked").each(function () { var checkedRows = $("input.allCheck:checkbox:checked").closest('tr:visible');
ids.push($(this).val()); if (checkedRows.length === 0) {
}); window.alert("Wybierz pozycje do eksportu");
if (ids.length === 0) { return;
$("input.allCheck:checkbox").each(function () {
ids.push($(this).val());
});
} }
// Get table data from selected rows only
var tableData = [];
// Get headers (skip first checkbox column)
var headers = [];
$("#allTable thead tr th").each(function (index) {
if (index > 0) {
headers.push($(this).text().trim());
}
});
tableData.push(headers);
// Get data from checked and visible rows
checkedRows.each(function () {
var rowData = [];
var $row = $(this);
$row.find('td').each(function (index) {
if (index > 0) { // Skip first checkbox column
var $cell = $(this);
var cellValue = '';
// Check for input fields (like production date)
var $input = $cell.find('input[type="text"], input[type="number"]');
if ($input.length > 0) {
cellValue = $input.val() || '';
} else {
// Check for editable divs (like qty, description)
var $editableDiv = $cell.find('div[id^="qty-"], div[id^="description-"]');
if ($editableDiv.length > 0) {
cellValue = $editableDiv.text().trim();
} else {
// Regular cell text
cellValue = $cell.text().trim();
}
}
rowData.push(cellValue);
}
});
if (rowData.length > 0) {
tableData.push(rowData);
}
});
showLoader("Generowanie pliku..."); showLoader("Generowanie pliku...");
$.ajax({ $.ajax({
method: "get", method: "post",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportExcel&ids=" + ids.join("|"), url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportExcelWYSIWYG",
success: function (response) data: {
{ tableData: JSON.stringify(tableData)
downloadFile(response.fileContent, response.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); },
success: function (result) {
downloadFile(result.fileContent, result.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
hideLoader(); hideLoader();
}, },
error: function () {
window.alert("Błąd podczas generowania pliku");
hideLoader();
}
}); });
} }
function exportPDF() { function exportPDF() {
var ids = []; var ids = [];
$("input.allCheck:checkbox:checked").each(function () { $("input.allCheck:checkbox:checked").each(function () {
@@ -376,31 +514,107 @@ function exportPDF() {
$.ajax({ $.ajax({
method: "get", method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportPDF&ids=" + ids.join("|"), url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportPDF&ids=" + ids.join("|"),
success: function (response) success: function (response) {
{
downloadFile(response.fileContent, response.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); downloadFile(response.fileContent, response.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
hideLoader(); hideLoader();
}, },
}); });
} }
function exportRawMaterialsExcel() {
// Check if raw materials table exists
if ($("#rawMaterialsTable").length === 0) {
window.alert("Brak tabeli surowców do eksportu");
return;
}
// Check if any rows are selected
var checkedRows = $("input.rawMaterialCheck:checkbox:checked").closest('tr:visible');
if (checkedRows.length === 0) {
// If no rows selected, export all visible rows
checkedRows = $("#rawMaterialsTable tbody tr:visible");
if (checkedRows.length === 0) {
window.alert("Brak danych do eksportu");
return;
}
}
// Get table data from selected rows
var tableData = [];
// Get headers (skip first checkbox column)
var headers = [];
$("#rawMaterialsTable thead tr th").each(function (index) {
if (index > 0) {
headers.push($(this).text().trim());
}
});
tableData.push(headers);
// Get data from selected/visible rows
checkedRows.each(function () {
var rowData = [];
var $row = $(this);
$row.find('td').each(function (index) {
if (index > 0) { // Skip first checkbox column
var $cell = $(this);
var cellValue = '';
// Check for links (product codes)
var $link = $cell.find('a');
if ($link.length > 0) {
cellValue = $link.text().trim();
} else {
// Regular cell text
cellValue = $cell.text().trim();
}
rowData.push(cellValue);
}
});
if (rowData.length > 0) {
tableData.push(rowData);
}
});
showLoader("Generowanie pliku...");
$.ajax({
method: "post",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportExcelWYSIWYG",
data: {
tableData: JSON.stringify(tableData)
},
success: function (result) {
downloadFile(result.fileContent, result.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
hideLoader();
},
error: function () {
window.alert("Błąd podczas generowania pliku");
hideLoader();
}
});
}
function createInsideOrder() { function createInsideOrder() {
var ids = []; var ids = [];
$('input.allCheck:checkbox:checked').each(function () { $('input.allCheck:checkbox:checked').each(function () {
ids.push($(this).val()); ids.push($(this).val());
}); });
if (ids.length === 0) { if (ids.length === 0) {
alert('Wybierz pozycje.'); alert('Wybierz pozycje.');
return; return;
} }
var products = []; var products = [];
ids.forEach(el => { ids.forEach(el => {
const qty = parseFloat($("#qtyInput-" + el).val().trim()); const qty = parseFloat($("#qtyInput-" + el).val().trim());
const id = $("#productId-" + el).val(); const id = $("#productId-" + el).val();
products.push(id + "|" + qty); products.push(id + "|" + qty);
}); });
$("#insideOrderProducts").val(products.join('*')); $("#insideOrderProducts").val(products.join('*'));
$("#createInsideOrderForm").submit(); $("#createInsideOrderForm").submit();
} }
function downloadFile(base64Data, fileName, mimeType) { function downloadFile(base64Data, fileName, mimeType) {
// Stwórz blob z danych base64 // Stwórz blob z danych base64
@@ -431,8 +645,84 @@ function downloadFile(base64Data, fileName, mimeType) {
link.click(); link.click();
// Usuń link z dokumentu // Usuń link z dokumentu
setTimeout(function() { setTimeout(function () {
document.body.removeChild(link); document.body.removeChild(link);
window.URL.revokeObjectURL(link.href); window.URL.revokeObjectURL(link.href);
}, 100); }, 100);
} }
function updateTimeSummary() {
var totalMinutes = 0;
var rows;
var checkedBoxes = $('.allCheck:checked');
if (checkedBoxes.length > 0) {
rows = checkedBoxes.closest('tr');
} else {
rows = $('#allTable tbody tr:visible');
}
rows.each(function () {
var actionTimeCell = $(this).find('td').eq(17);
var timeText = actionTimeCell.text().trim();
if (timeText && timeText.includes(':')) {
var timeParts = timeText.split(':');
if (timeParts.length === 2) {
var hours = parseInt(timeParts[0], 10) || 0;
var minutes = parseInt(timeParts[1], 10) || 0;
totalMinutes += (hours * 60) + minutes;
}
}
});
var totalHours = Math.floor(totalMinutes / 60);
var remainingMinutes = totalMinutes % 60;
var formattedTime = String(totalHours).padStart(2, '0') + ':' +
String(remainingMinutes).padStart(2, '0');
$('#timeSummary').html(formattedTime);
return formattedTime;
}
function changeDate() {
var ids = [];
$('input.allCheck:checkbox:checked').each(function () {
ids.push($(this).val());
});
if (ids.length === 0) {
alert('Wybierz pozycje.');
return;
}
let hours = prompt("Podaj ilość godzin:");
if (hours === null) {
return null; // no response
}
hours = parseFloat(hours);
if (hours === "") {
window.alert("Niepoprawna wartość (-100 : 100)");
return null;
}
const hoursNum = parseFloat(hours);
if (isNaN(hoursNum)) {
window.alert("Niepoprawna wartość (-100 : 100)");
return null;
}
if (hoursNum < -100 || hoursNum > 100) {
window.alert("Niepoprawna wartość (-100 : 100)");
return null;
}
$.ajax({
method: "get",
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=updateProductionDate&ids=" + ids.join("|") + "&hours=" + hoursNum,
success: function () {
window.location.reload();
},
error: function () {
window.alert("Aktualizacja nie powiodła się.");
window.location.reload();
}
});
}

View File

@@ -1,7 +1,7 @@
<?php <?php
ini_set('display_errors', 1); //ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); //ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); //error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
if (!isset($_GET['ajaxAction'])) { if (!isset($_GET['ajaxAction'])) {
@@ -36,7 +36,7 @@ if (!isset($_GET['ajaxAction'])) {
removePositions($_GET['ids']); removePositions($_GET['ids']);
break; break;
case 'saveProductionDate': case 'saveProductionDate':
saveProductionDate($_GET['id'], $_GET['date']); saveProductionDate($_GET['id'], $_GET['date'], $_GET['time']);
break; break;
case 'saveProductDescription': case 'saveProductDescription':
saveProductDescription($_GET['id'], $_GET['description']); saveProductDescription($_GET['id'], $_GET['description']);
@@ -44,12 +44,18 @@ if (!isset($_GET['ajaxAction'])) {
case 'exportExcel': case 'exportExcel':
exportExcel($_GET['ids']); exportExcel($_GET['ids']);
break; break;
case 'exportExcelWYSIWYG':
exportExcelWYSIWYG($_POST['tableData']);
break;
case 'exportPDF': case 'exportPDF':
exportPDF($_GET['ids']); exportPDF($_GET['ids']);
break; break;
case 'getRawMaterials': case 'getRawMaterials':
getRawMaterials($_POST['ids']); getRawMaterials($_POST['ids']);
break; break;
case 'updateProductionDate':
updateProductionDate($_GET['ids'], $_GET['hours']);
break;
} }
} }
function loadSchedulers($dateFrom = null, $dateTo = null, $ids = null) function loadSchedulers($dateFrom = null, $dateTo = null, $ids = null)
@@ -68,7 +74,8 @@ SELECT s.id as orderId, s.document_no, s.status, s.parent_name, s.parent_id, s.s
p_main.code as main_product_code, p_main.code as main_product_code,
a.id AS action_id, a.id AS action_id,
a.indeks AS action_index, a.indeks AS action_index,
a.category AS action_category a.category AS action_category,
a.performance AS action_performance
FROM productionScheduler AS ps FROM productionScheduler AS ps
LEFT JOIN ecmsaleitems AS si LEFT JOIN ecmsaleitems AS si
ON ps.ecmsaleitem_id = si.id ON ps.ecmsaleitem_id = si.id
@@ -98,8 +105,8 @@ WHERE ps.deleted = 0 ";
if ($dateFrom != null && $dateTo != null) { if ($dateFrom != null && $dateTo != null) {
$query .= " AND ( $query .= " AND (
(ps.production_date >= '$dateFrom' AND ps.production_date <= '$dateTo') (DATE(ps.production_date) >= '$dateFrom' AND DATE(ps.production_date) <= '$dateTo')
OR ps.production_date IS NULL OR ps.production_date = '0000-00-00')"; OR ps.production_date IS NULL OR DATE(ps.production_date) = '0000-00-00 00:00:00')";
} }
if ($ids != null) { if ($ids != null) {
@@ -107,7 +114,6 @@ WHERE ps.deleted = 0 ";
} }
$query .= "GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.id "; $query .= "GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.id ";
$query .= "ORDER BY s.delivery_date, s.register_date, s.document_no;";
$rows = $db->query($query); $rows = $db->query($query);
$data = array(); $data = array();
@@ -139,7 +145,8 @@ WHERE ps.deleted = 0 ";
$row['description'] = strlen($r['description']) > 0 ? substr($r['description'], 0, 30) : ''; $row['description'] = strlen($r['description']) > 0 ? substr($r['description'], 0, 30) : '';
$row['fullDescription'] = $r['description']; $row['fullDescription'] = $r['description'];
$row['shippingTo'] = ($r['shipping_address_name'] == 'Adres korespondencyjny' ? '' : $r['shipping_address_name']); $row['shippingTo'] = ($r['shipping_address_name'] == 'Adres korespondencyjny' ? '' : $r['shipping_address_name']);
$row['productionDate'] = $r['production_date'] == '0000-00-00' ? '' : $r['production_date']; $row['productionDate'] = $r['production_date'] == '0000-00-00 00:00:00' ? '' : substr($r['production_date'], 0, 10);
$row['productionTime'] = $r['production_date'] == '0000-00-00 00:00:00' ? '' : substr($r['production_date'], 11, 5);
$row['productStockState'] = $r['stockState'] | 0; $row['productStockState'] = $r['stockState'] | 0;
$row['mainProductId'] = $r['main_product_id']; $row['mainProductId'] = $r['main_product_id'];
$row['mainProductCode'] = strlen($r['main_product_code']) > 20 ? substr($r['main_product_code'], 0, 20) . "..." : $r['main_product_code']; $row['mainProductCode'] = strlen($r['main_product_code']) > 20 ? substr($r['main_product_code'], 0, 20) . "..." : $r['main_product_code'];
@@ -147,6 +154,17 @@ WHERE ps.deleted = 0 ";
$row['action_id'] = $r['action_id']; $row['action_id'] = $r['action_id'];
$row['action_index'] = $r['action_index']; $row['action_index'] = $r['action_index'];
$row['action_category'] = $app_list_strings['ecmactions_category_dom'][$r['action_category']]; $row['action_category'] = $app_list_strings['ecmactions_category_dom'][$r['action_category']];
// check if action_performance is number and is not 0
if (is_numeric($r['action_performance']) && $r['action_performance'] != 0) {
$timeInHours = $r['scheduledQuantity'] / $r['action_performance'];
$hours = floor($timeInHours);
$minutes = round(($timeInHours - $hours) * 60);
$row['action_time'] = sprintf('%02d:%02d', $hours, $minutes);
} else {
$row['action_time'] = '---';
}
$data[] = $row; $data[] = $row;
} }
return $data; return $data;
@@ -253,8 +271,8 @@ function duplicatePositions($ids)
$ids = explode("|", $ids); $ids = explode("|", $ids);
foreach ($ids as $id) { foreach ($ids as $id) {
$res = $db->fetchByAssoc($db->query("SELECT * FROM productionScheduler WHERE id ='$id'")); $res = $db->fetchByAssoc($db->query("SELECT * FROM productionScheduler WHERE id ='$id'"));
$query = sprintf("INSERT INTO productionScheduler VALUES ('%s', null, '%s', '%s', '%d', NOW(), NOW(), '%s', '%s', 0, '%s', '%d', '%s', '%s');", $query = sprintf("INSERT INTO productionScheduler VALUES ('%s', '%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'], generateUuidV4(), $res['main_id'], $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']); $res['is_component'], $res['production_date'], $res['description']);
$db->query($query); $db->query($query);
} }
@@ -270,14 +288,15 @@ function removePositions($ids)
$db->query($query); $db->query($query);
} }
function saveProductionDate($id, $date) function saveProductionDate($id, $date, $time)
{ {
$db = $GLOBALS['db']; $db = $GLOBALS['db'];
$date = date("Y-m-d", strtotime($date)); $parsedDate = date("Y-m-d", strtotime($date));
if ($date == '1970-01-01') { if ($parsedDate == '1970-01-01') {
$db->query("UPDATE productionScheduler SET production_date=NULL WHERE id='$id'"); $db->query("UPDATE productionScheduler SET production_date=NULL WHERE id='$id'");
} else { } else {
$db->query("UPDATE productionScheduler SET production_date='$date' WHERE id='$id'"); $parsetDateTime = date("Y-m-d H:i", strtotime($date . ' ' . $time));
$db->query("UPDATE productionScheduler SET production_date='$parsetDateTime' WHERE id='$id'");
} }
} }
@@ -454,4 +473,151 @@ function generateUuidV4()
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); $data[6] = chr(ord($data[6]) & 0x0f | 0x40);
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); $data[8] = chr(ord($data[8]) & 0x3f | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
} }
function exportExcelWYSIWYG($tableDataJson)
{
if (function_exists('from_html')) {
$tableDataJson = from_html($tableDataJson);
}
$json = getJSONobj();
$rawData = $json->decode($tableDataJson);
if (isset($rawData['jsonObject']) && is_array($rawData['jsonObject'])) {
$tableData = $rawData['jsonObject'];
} else {
$tableData = $rawData;
}
if (empty($tableData) || !is_array($tableData)) {
header('Content-Type: application/json');
echo json_encode(array(
'success' => false,
'error' => 'Failed to decode table data. Type: ' . gettype($tableData)
));
return;
}
require_once 'modules/EcmReports/BimIT-Reports/lib/xlsxGenerator.php';
$xlsx = Shuchkin\SimpleXLSXGen::fromArray($tableData);
$xlsx_content = (string)$xlsx;
header('Content-Type: application/json');
echo json_encode(array(
'success' => true,
'fileContent' => base64_encode($xlsx_content),
'fileName' => 'harmonogram_produkcji.xlsx'
));
}
function updateProductionDate($ids, $hours) {
$db = $GLOBALS['db'];
$ids = explode("|", $ids);
foreach ($ids as $id) {
$res = $db->fetchByAssoc($db->query("SELECT production_date FROM productionScheduler WHERE id ='$id'"));
if ($res['production_date'] && $res['production_date'] != '0000-00-00 00:00:00') {
$newDate = calculateProductionDate($res['production_date'], $hours);
$db->query("UPDATE productionScheduler SET production_date='$newDate:00' WHERE id='$id'");
}
}
}
function calculateProductionDate($currentDateTime, $hoursToAdd) {
$WORK_START = 6 * 60;
$WORK_END = 14 * 60 + 30;
$date = new DateTime($currentDateTime);
$totalMinutesToAdd = $hoursToAdd * 60;
if ($totalMinutesToAdd > 0) {
while ($totalMinutesToAdd > 0) {
$dayOfWeek = $date->format('w');
if ($dayOfWeek == 0 || $dayOfWeek == 6) {
$date = getNextWorkDay($date);
continue;
}
$currentMinutes = $date->format('H') * 60 + $date->format('i');
if ($currentMinutes < $WORK_START) {
$date->setTime(6, 0, 0);
continue;
}
if ($currentMinutes >= $WORK_END) {
$date = getNextWorkDay($date);
continue;
}
$remainingMinutesToday = $WORK_END - $currentMinutes;
if ($totalMinutesToAdd <= $remainingMinutesToday) {
$date->modify('+' . $totalMinutesToAdd . ' minutes');
$totalMinutesToAdd = 0;
} else {
$totalMinutesToAdd -= $remainingMinutesToday;
$date = getNextWorkDay($date);
}
}
}
else if ($totalMinutesToAdd < 0) {
$totalMinutesToAdd = abs($totalMinutesToAdd);
while ($totalMinutesToAdd > 0) {
$dayOfWeek = $date->format('w');
if ($dayOfWeek == 0 || $dayOfWeek == 6) {
$date = getPreviousWorkDay($date);
continue;
}
$currentMinutes = $date->format('H') * 60 + $date->format('i');
if ($currentMinutes > $WORK_END) {
$date->setTime(14, 30, 0);
continue;
}
if ($currentMinutes <= $WORK_START) {
$date = getPreviousWorkDay($date);
continue;
}
$minutesFromStart = $currentMinutes - $WORK_START;
if ($totalMinutesToAdd <= $minutesFromStart) {
$date->modify('-' . $totalMinutesToAdd . ' minutes');
$totalMinutesToAdd = 0;
} else {
$totalMinutesToAdd -= $minutesFromStart;
$date = getPreviousWorkDay($date);
}
}
}
return $date->format('Y-m-d H:i');
}
function getNextWorkDay($date) {
$nextDay = clone $date;
$nextDay->modify('+1 day');
$nextDay->setTime(6, 0, 0);
while ($nextDay->format('w') == 0 || $nextDay->format('w') == 6) {
$nextDay->modify('+1 day');
}
return $nextDay;
}
function getPreviousWorkDay($date) {
$prevDay = clone $date;
$prevDay->modify('-1 day');
$prevDay->setTime(14, 30, 0);
while ($prevDay->format('w') == 0 || $prevDay->format('w') == 6) {
$prevDay->modify('-1 day');
}
return $prevDay;
}

View File

@@ -133,6 +133,7 @@
<input class="button" id="excelBtn" value="Excel" type="button"> <input class="button" id="excelBtn" value="Excel" type="button">
<input class="button" id="pdfBtn" value="PDF" type="button"> <input class="button" id="pdfBtn" value="PDF" type="button">
<input class="button" value="Utwórz przyjęcie produkcyjne" type="button" id="createInsideOrder"/> <input class="button" value="Utwórz przyjęcie produkcyjne" type="button" id="createInsideOrder"/>
<input class="button" id="changeDateBtn" value="Aktualizuj datę produkcji" type="button">
<table id="allTable"> <table id="allTable">
<thead> <thead>
<tr> <tr>
@@ -153,6 +154,7 @@
<th>Data wysyłki</th> <th>Data wysyłki</th>
<th>Czynność</th> <th>Czynność</th>
<th>Linia</th> <th>Linia</th>
<th>Czas</th>
<th>Uwagi</th> <th>Uwagi</th>
</tr> </tr>
</thead> </thead>
@@ -178,23 +180,28 @@
{$ROW.productName} {$ROW.productName}
</td> </td>
<td> <td>
<input id="production-date-{$ROW.id}" name="production-date-{$ROW.id}" type="text" <div style="white-space: nowrap">
maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}" <input id="production-date-{$ROW.id}" name="production-date-{$ROW.id}" type="text"
autocomplete="off" maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}"
id="production-date-{$ROW.id}" onchange="saveProductionDate('{$ROW.id}')"> autocomplete="off"
<img id="production-date-trigger-{$ROW.id}" src="themes/default/images/jscalendar.gif" id="production-date-{$ROW.id}" onchange="saveProductionDate('{$ROW.id}')">
style="width: 13px;"> <img id="production-date-trigger-{$ROW.id}" src="themes/default/images/jscalendar.gif"
<script language="JavaScript" type="text/javascript"> style="width: 13px;">
Calendar.setup({ldelim} <script language="JavaScript" type="text/javascript">
inputField: "production-date-{$ROW.id}", Calendar.setup({ldelim}
daFormat: "%Y-%m-%d", inputField: "production-date-{$ROW.id}",
button: "production-date-trigger-{$ROW.id}", daFormat: "%Y-%m-%d",
singleClick: true, button: "production-date-trigger-{$ROW.id}",
dateStr: "", singleClick: true,
step: 1 dateStr: "",
{rdelim} step: 1
); {rdelim}
</script> );
</script>
</div>
<input type="text"
maxlength="10" size="11" tabindex="" title="" id="production-time-{$ROW.id}" name="production-time-{$ROW.id}"
autocomplete="off" value="{$ROW.productionTime}" onchange="saveProductionDate('{$ROW.id}')">
</td> </td>
<td style="white-space: nowrap;"> <td style="white-space: nowrap;">
<div id="edit-{$ROW.id}" class="ui-icon ui-icon-pencil" <div id="edit-{$ROW.id}" class="ui-icon ui-icon-pencil"
@@ -249,6 +256,9 @@
<td> <td>
{$ROW.action_category} {$ROW.action_category}
</td> </td>
<td>
{$ROW.action_time}
</td>
<td> <td>
<div id="edit-description-{$ROW.id}" class="ui-icon ui-icon-pencil" <div id="edit-description-{$ROW.id}" class="ui-icon ui-icon-pencil"
onclick="editDescription('{$ROW.id}')" style="display: inline-block;"></div> onclick="editDescription('{$ROW.id}')" style="display: inline-block;"></div>
@@ -262,10 +272,19 @@
</tr> </tr>
{/foreach} {/foreach}
</tbody> </tbody>
<tfoot>
<tr>
<td colspan="17" style="text-align: right;"></td>
<td id="timeSummary"></td>
<td></td>
</tr>
</tfoot>
</table> </table>
</div> </div>
<div id="2" style="display: none"> <div id="2" style="display: none">
<br>
<input class="button" id="rawMaterialsExcelBtn" value="Excel" type="button">
<div id="rawMaterialsTableContainer"> <div id="rawMaterialsTableContainer">
</div> </div>
</div> </div>

View File

@@ -1,6 +1,6 @@
<?php <?php
if (! defined ( 'sugarEntry' ) || ! sugarEntry) if (! defined('sugarEntry') || ! sugarEntry)
die ( 'Not A Valid Entry Point' ); die('Not A Valid Entry Point');
/** /**
* ************************************************** * **************************************************
@@ -11,64 +11,64 @@ if (! defined ( 'sugarEntry' ) || ! sugarEntry)
/** /**
* ************************************************** * **************************************************
*/ */
$db = $GLOBALS ['db']; $db = $GLOBALS['db'];
$data = array (); $data = array();
$categoryArray = array (); $categoryArray = array();
$sum = array (); $sum = array();
$sumSub = array (); $sumSub = array();
$sumSub2 = array (); $sumSub2 = array();
$KSGROUPS=array(); $KSGROUPS = array();
$group['id']='1'; $group['id'] = '1';
$group['name']='Towar handlowy'; $group['name'] = 'Towar handlowy';
$KSGROUPS[]=$group; $KSGROUPS[] = $group;
$group['id']='2'; $group['id'] = '2';
$group['name']='Wyrób gotowy'; $group['name'] = 'Wyrób gotowy';
$KSGROUPS[]=$group; $KSGROUPS[] = $group;
$group['id']='3'; $group['id'] = '3';
$group['name']='Surowiec'; $group['name'] = 'Surowiec';
$KSGROUPS[]=$group; $KSGROUPS[] = $group;
$group['id']='4'; $group['id'] = '4';
$group['name']='Transport'; $group['name'] = 'Transport';
$KSGROUPS[]=$group; $KSGROUPS[] = $group;
if ($_GET ['selectProductActive'] != "") { if ($_GET['selectProductActive'] != "") {
$selectProductActive = $_GET ['selectProductActive']; $selectProductActive = $_GET['selectProductActive'];
} else { } else {
$selectProductActive = ""; $selectProductActive = "";
} }
if ($_GET ['selectProductEol'] != "") { if ($_GET['selectProductEol'] != "") {
$selectProductEol = $_GET ['selectProductEol']; $selectProductEol = $_GET['selectProductEol'];
} else { } else {
$selectProductEol = ""; $selectProductEol = "";
} }
if ($_GET ['selectStock'] != "") { if ($_GET['selectStock'] != "") {
$selectStock = $_GET ['selectStock']; $selectStock = $_GET['selectStock'];
} else { } else {
$selectStock = ""; $selectStock = "";
} }
$datastocks = array (); $datastocks = array();
$users = array (); $users = array();
$queryStocks = "SELECT $queryStocks = "SELECT
name, name,
id id
FROM ecmstocks FROM ecmstocks
where deleted= 0"; where deleted= 0";
$rowsStocks = $db->query ( $queryStocks ); $rowsStocks = $db->query($queryStocks);
while ( $rowStocks = $db->fetchByAssoc ( $rowsStocks ) ) { while ($rowStocks = $db->fetchByAssoc($rowsStocks)) {
$stocks ["name"] = $rowStocks ["name"]; $stocks["name"] = $rowStocks["name"];
$stocks ["id"] = $rowStocks ["id"]; $stocks["id"] = $rowStocks["id"];
$datastocks [] = $stocks; $datastocks[] = $stocks;
} }
$query = "SELECT $query = "SELECT
@@ -80,20 +80,20 @@ ON ss.product_id = p.id
WHERE WHERE
p.deleted = '0' AND ss.quantity IS NOT NULL"; p.deleted = '0' AND ss.quantity IS NOT NULL";
if ($_GET ['selectStock'] != "") if ($_GET['selectStock'] != "")
$query .= " AND ss.stock_id = '" . $_GET ["selectStock"] . "' "; $query .= " AND ss.stock_id = '" . $_GET["selectStock"] . "' ";
if ($_GET ['selectProductActive'] != "") if ($_GET['selectProductActive'] != "")
$query .= " AND p.product_active = '" . $_GET ["selectProductActive"] . "' "; $query .= " AND p.product_active = '" . $_GET["selectProductActive"] . "' ";
if ($_GET ['selectProductEol'] != "") { if ($_GET['selectProductEol'] != "") {
if ($_GET ['selectProductEol'] == "1") if ($_GET['selectProductEol'] == "1")
$query .= " AND p.status='end_of_line' "; $query .= " AND p.status='end_of_line' ";
if ($_GET ['selectProductEol'] == "0") if ($_GET['selectProductEol'] == "0")
$query .= " AND p.status!='end_of_line' "; $query .= " AND p.status!='end_of_line' ";
} }
if($_GET['productKS']!=''){ if ($_GET['productKS'] != '') {
$query .= " AND p.group_ks = '" . $_GET ["productKS"] . "' "; $query .= " AND p.group_ks = '" . $_GET["productKS"] . "' ";
} }
$query .= " GROUP BY p.id"; $query .= " GROUP BY p.id";
@@ -106,86 +106,96 @@ $query .= " GROUP BY p.id";
/** /**
* ************************************************** * **************************************************
*/ */
$rows = $db->query ( $query ); $rows = $db->query($query);
// prepare data for Smarty // prepare data for Smarty
while ( $r = $db->fetchByAssoc ( $rows ) ) { while ($r = $db->fetchByAssoc($rows)) {
$row = array (); $row = array();
$row ["id"] = $r ["id"]; $row["id"] = $r["id"];
$row ["name"] = $r ["name"]; $row["name"] = $r["name"];
$row ["code"] = $r ["code"]; $row["code"] = $r["code"];
$row ["quantity"] = $r ["quantity"]; $row["quantity"] = $r["quantity"];
$row ["price"] = $r ["price"] ; $row["price"] = $r["price"];
// stock addresses
$a = $db->query("SELECT stock_address FROM ecmproducts_stock_addresses WHERE ecmproduct_id='" . $r['id'] . "' ORDER BY stock_address");
$addresses = array();
while ($addr = $db->fetchByAssoc($a)) {
$addresses[] = $addr['stock_address'];
}
$row['stock_address'] = implode(", ", $addresses);
$querySubCategory = "SELECT category.name as 'podkategoria' $querySubCategory = "SELECT category.name as 'podkategoria'
FROM FROM
ecmproductcategories_bean bean ecmproductcategories_bean bean
JOIN JOIN
ecmproductcategories category ON bean.ecmproductcategory_id = category.id ecmproductcategories category ON bean.ecmproductcategory_id = category.id
WHERE bean.bean_id='" . $row ["id"] . "' WHERE bean.bean_id='" . $row["id"] . "'
and bean.position = '1' and bean.position = '1'
and bean.deleted = '0' and bean.deleted = '0'
and category.deleted = '0';"; and category.deleted = '0';";
$rowsSubCategory = $db->query ( $querySubCategory ); $rowsSubCategory = $db->query($querySubCategory);
$row["podkategoria"] =""; $row["podkategoria"] = "";
while ( $rowSubCategory = $db->fetchByAssoc ( $rowsSubCategory ) ) { while ($rowSubCategory = $db->fetchByAssoc($rowsSubCategory)) {
$row ["podkategoria"] = $rowSubCategory ["podkategoria"]; $row["podkategoria"] = $rowSubCategory["podkategoria"];
} }
$queryCategory = "SELECT category.name as 'kategoria' $queryCategory = "SELECT category.name as 'kategoria'
FROM FROM
ecmproductcategories_bean bean ecmproductcategories_bean bean
JOIN JOIN
ecmproductcategories category ON bean.ecmproductcategory_id = category.id ecmproductcategories category ON bean.ecmproductcategory_id = category.id
WHERE bean.bean_id='" . $row ["id"] . "' WHERE bean.bean_id='" . $row["id"] . "'
and bean.position = '0' and bean.position = '0'
and bean.deleted = '0' and bean.deleted = '0'
and category.deleted = '0';"; and category.deleted = '0';";
$rowscategory = $db->query ( $queryCategory ); $rowscategory = $db->query($queryCategory);
$row["kategoria"] = ""; $row["kategoria"] = "";
while ( $rowcategory = $db->fetchByAssoc ( $rowscategory ) ) { while ($rowcategory = $db->fetchByAssoc($rowscategory)) {
$row ["kategoria"] = $rowcategory ["kategoria"]; $row["kategoria"] = $rowcategory["kategoria"];
} }
$data [] = $row; $data[] = $row;
} }
// //////////////// SUM ///////////////////////////////// // //////////////// SUM /////////////////////////////////
foreach ( $data as $key => &$element ) { foreach ($data as $key => &$element) {
$categoryArray1 [$element ["kategoria"] == "" ? "Inne" : $element ["kategoria"]] [$element ["podkategoria"] == "" ? "Reszta" : $element ["podkategoria"]] [$key] = $element; $categoryArray1[$element["kategoria"] == "" ? "Inne" : $element["kategoria"]][$element["podkategoria"] == "" ? "Reszta" : $element["podkategoria"]][$key] = $element;
} }
function cmp($a, $b) { function cmp($a, $b)
if ($a ["name"] == $b ["name"]) { {
if ($a["name"] == $b["name"]) {
return 0; return 0;
} }
return ($a ["name"] < $b ["name"]) ? - 1 : 1; return ($a["name"] < $b["name"]) ? -1 : 1;
} }
// grupowanie po kategoriach // grupowanie po kategoriach
foreach ( $categoryArray1 as $key1 => &$element1 ) { foreach ($categoryArray1 as $key1 => &$element1) {
foreach ( $element1 as $key2 => &$element2 ) { foreach ($element1 as $key2 => &$element2) {
usort ( $element2, "cmp" ); usort($element2, "cmp");
$i = 0; $i = 0;
$tmp2 [$key1] [$key2] [0] = array ( $tmp2[$key1][$key2][0] = array(
'name' => null 'name' => null
); );
$counter = 0; $counter = 0;
foreach ( $element2 as $count => &$element3 ) { foreach ($element2 as $count => &$element3) {
if ($element3 ["id"] != $tmp2 [$key1] [$key2] [$i] ["id"]) { if ($element3["id"] != $tmp2[$key1][$key2][$i]["id"]) {
if ($tmp2 [$key1] [$key2] [$i] ["id"] != null) { if ($tmp2[$key1][$key2][$i]["id"] != null) {
$i ++; $i++;
} }
$tmp2 [$key1] [$key2] [$i] ["id"] = $element3 ["id"]; $tmp2[$key1][$key2][$i]["id"] = $element3["id"];
$tmp2 [$key1] [$key2] [$i] ["name"] = $element3 ["name"]; $tmp2[$key1][$key2][$i]["name"] = $element3["name"];
$tmp2 [$key1] [$key2] [$i] ["code"] = $element3 ["code"]; $tmp2[$key1][$key2][$i]["code"] = $element3["code"];
$tmp2 [$key1] [$key2] [$i] ["quantity"] = $element3 ["quantity"]; $tmp2[$key1][$key2][$i]["stock_address"] = $element3["stock_address"];
$tmp2 [$key1] [$key2] [$i] ["price"] = $element3 ["price"]; $tmp2[$key1][$key2][$i]["quantity"] = $element3["quantity"];
$tmp2[$key1][$key2][$i]["price"] = $element3["price"];
} }
$counter += 1; $counter += 1;
/* /*
if ($element2 [$count] ["name"] != $element2 [$count + 1] ["name"]) { if ($element2 [$count] ["name"] != $element2 [$count + 1] ["name"]) {
$tmp2 [$key1] [$key2] [$i] ["marza"] = $tmp2 [$key1] [$key2] [$i] ["marza"] / $counter; $tmp2 [$key1] [$key2] [$i] ["marza"] = $tmp2 [$key1] [$key2] [$i] ["marza"] / $counter;
@@ -197,67 +207,67 @@ foreach ( $categoryArray1 as $key1 => &$element1 ) {
$categoryArray = $tmp2; $categoryArray = $tmp2;
} }
} }
foreach ( $categoryArray as $key => &$element ) { foreach ($categoryArray as $key => &$element) {
$count = 0; $count = 0;
foreach ( $element as $keyy => &$elementt ) { foreach ($element as $keyy => &$elementt) {
foreach ( $elementt as $keyyy => &$elementtt ) { foreach ($elementt as $keyyy => &$elementtt) {
$sumSub ["QuantitySum"] [$key] += $elementtt ["quantity"]; $sumSub["QuantitySum"][$key] += $elementtt["quantity"];
$sumSub ["PriceSum"] [$key] += $elementtt ["price"]; $sumSub["PriceSum"][$key] += $elementtt["price"];
$sumSub2 ["QuantitySum"] [$key] [$keyy] += $elementtt ["quantity"]; $sumSub2["QuantitySum"][$key][$keyy] += $elementtt["quantity"];
$sumSub2 ["PriceSum"] [$key] [$keyy] += $elementtt ["price"]; $sumSub2["PriceSum"][$key][$keyy] += $elementtt["price"];
} }
$count += sizeof ( $elementt ); $count += sizeof($elementt);
$categoryArray [$key] [$keyy] ["QuantitySum2"] = $sumSub2 ["QuantitySum"] [$key] [$keyy]; $categoryArray[$key][$keyy]["QuantitySum2"] = $sumSub2["QuantitySum"][$key][$keyy];
$categoryArray [$key] [$keyy] ["PriceSum2"] = $sumSub2 ["PriceSum"] [$key] [$keyy]; $categoryArray[$key][$keyy]["PriceSum2"] = $sumSub2["PriceSum"][$key][$keyy];
} }
$categoryArray [$key] ["QuantitySum"] = $sumSub ["QuantitySum"] [$key]; $categoryArray[$key]["QuantitySum"] = $sumSub["QuantitySum"][$key];
$categoryArray [$key] ["PriceSum"] = $sumSub ["PriceSum"] [$key]; $categoryArray[$key]["PriceSum"] = $sumSub["PriceSum"][$key];
} }
foreach ( $categoryArray as $key => &$element ) { foreach ($categoryArray as $key => &$element) {
$sum ["QuantitySumSum"] += $sumSub ["QuantitySum"] [$key]; $sum["QuantitySumSum"] += $sumSub["QuantitySum"][$key];
$sum ["PriceSumSum"] += $sumSub ["PriceSum"] [$key]; $sum["PriceSumSum"] += $sumSub["PriceSum"][$key];
} }
foreach ( $categoryArray as $key1 => &$element ) { foreach ($categoryArray as $key1 => &$element) {
foreach ( $element as $key2 => &$elements ) { foreach ($element as $key2 => &$elements) {
foreach ( $element as $key3 => &$element2 ) { foreach ($element as $key3 => &$element2) {
if ($sumSub2 ["PriceSum"] [$key1] [$key2] > $sumSub2 ["PriceSum"] [$key1] [$key3]) { if ($sumSub2["PriceSum"][$key1][$key2] > $sumSub2["PriceSum"][$key1][$key3]) {
$tmp = $sumSub2 ["PriceSum"] [$key1] [$key2]; $tmp = $sumSub2["PriceSum"][$key1][$key2];
$sumSub2 ["PriceSum"] [$key1] [$key2] = $sumSub2 ["PriceSum"] [$key1] [$key3]; $sumSub2["PriceSum"][$key1][$key2] = $sumSub2["PriceSum"][$key1][$key3];
$sumSub2 ["PriceSum"] [$key1] [$key3] = $tmp; $sumSub2["PriceSum"][$key1][$key3] = $tmp;
} }
} }
} }
} }
foreach ( $sumSub ["PriceSum"] as $key1 => &$element ) { foreach ($sumSub["PriceSum"] as $key1 => &$element) {
foreach ( $sumSub ["PriceSum"] as $key2 => &$element2 ) { foreach ($sumSub["PriceSum"] as $key2 => &$element2) {
if ($sumSub ["PriceSum"] [$key1] > $sumSub ["PriceSum"] [$key2]) { if ($sumSub["PriceSum"][$key1] > $sumSub["PriceSum"][$key2]) {
$tmp = $sumSub ["PriceSum"] [$key1]; $tmp = $sumSub["PriceSum"][$key1];
$sumSub ["PriceSum"] [$key1] = $sumSub ["PriceSum"] [$key2]; $sumSub["PriceSum"][$key1] = $sumSub["PriceSum"][$key2];
$sumSub ["PriceSum"] [$key2] = $tmp; $sumSub["PriceSum"][$key2] = $tmp;
} }
} }
} }
// //////////////// SORT array ///////////////////////////////// // //////////////// SORT array /////////////////////////////////
$newArray2; $newArray2;
foreach ( $sumSub ["PriceSum"] as $key1 => &$element1 ) { foreach ($sumSub["PriceSum"] as $key1 => &$element1) {
foreach ( $categoryArray as $key2 => &$element2 ) { foreach ($categoryArray as $key2 => &$element2) {
if ($sumSub ["PriceSum"] [$key1] == $categoryArray [$key2] ["PriceSum"]) { if ($sumSub["PriceSum"][$key1] == $categoryArray[$key2]["PriceSum"]) {
$newArray2 [$key2] = $categoryArray [$key2]; $newArray2[$key2] = $categoryArray[$key2];
} }
} }
} }
$newArray1; $newArray1;
foreach ( $newArray2 as $key1 => &$element1 ) { foreach ($newArray2 as $key1 => &$element1) {
foreach ( $element1 as $key2 => &$element2 ) { foreach ($element1 as $key2 => &$element2) {
foreach ( $element1 as $key3 => &$element3 ) { foreach ($element1 as $key3 => &$element3) {
if ($sumSub2 ["PriceSum"] [$key1] [$key2] == $newArray2 [$key1] [$key3] ["PriceSum2"]) { if ($sumSub2["PriceSum"][$key1][$key2] == $newArray2[$key1][$key3]["PriceSum2"]) {
$newArray1 [$key1] [$key3] = $newArray2 [$key1] [$key3]; $newArray1[$key1][$key3] = $newArray2[$key1][$key3];
} }
} }
} }
@@ -274,17 +284,15 @@ foreach ( $newArray2 as $key1 => &$element1 ) {
* ************************************************** * **************************************************
*/ */
// create & execute smarty // create & execute smarty
$smarty = new Sugar_Smarty (); $smarty = new Sugar_Smarty();
global $mod_strings; global $mod_strings;
$smarty->assign ( "MOD", $mod_strings ); $smarty->assign("MOD", $mod_strings);
$smarty->assign ( "DATA", $newArray1 ); $smarty->assign("DATA", $newArray1);
$smarty->assign ( "SUM", $sum ); $smarty->assign("SUM", $sum);
$smarty->assign ('KSGROUPS',$KSGROUPS); $smarty->assign('KSGROUPS', $KSGROUPS);
$smarty->assign ( "STOCKS", $datastocks ); $smarty->assign("STOCKS", $datastocks);
$smarty->assign ( "selectStock", $selectStock ); $smarty->assign("selectStock", $selectStock);
$smarty->assign ('selectKS',$_GET['productKS']); $smarty->assign('selectKS', $_GET['productKS']);
$smarty->assign ( "selectProductActive", $selectProductActive ); $smarty->assign("selectProductActive", $selectProductActive);
$smarty->assign ( "selectProductEol", $selectProductEol ); $smarty->assign("selectProductEol", $selectProductEol);
echo $smarty->display ( 'modules/EcmReports/tpls/ReportStocks.tpl' ); echo $smarty->display('modules/EcmReports/tpls/ReportStocks.tpl');
?>

View File

@@ -1,7 +1,7 @@
<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.css"/> <link rel="stylesheet" type="text/css" href="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.css" />
<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-ui/themes/base/jquery-ui.css"/> <link rel="stylesheet" type="text/css" href="include/jQuery/jquery-ui/themes/base/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="modules/EcmReports/TableSorter/css/theme.blue.css"/> <link rel="stylesheet" type="text/css" href="modules/EcmReports/TableSorter/css/theme.blue.css" />
<link rel="stylesheet" type="text/css" href="modules/EcmReports/TableSorter/css/theme.blue2.css"/> <link rel="stylesheet" type="text/css" href="modules/EcmReports/TableSorter/css/theme.blue2.css" />
<!-- Tablesorter --> <!-- Tablesorter -->
<script type="text/javascript" src="modules/EcmReports/TableSorter/js/jquery.min.js"></script> <script type="text/javascript" src="modules/EcmReports/TableSorter/js/jquery.min.js"></script>
<script type="text/javascript" src="modules/EcmReports/TableSorter/js/jquery.tablesorter.min.js"></script> <script type="text/javascript" src="modules/EcmReports/TableSorter/js/jquery.tablesorter.min.js"></script>
@@ -14,7 +14,7 @@
<style type="text/css"> <style type="text/css">
{literal} {literal}
thead, tfoot {font-weight: bold;} thead, tfoot {font-weight: bold;}
@@ -34,45 +34,50 @@
background-color: #BDC7B5; background-color: #BDC7B5;
} }
.sumAll td{ .sumAll td {
background-color: #BDC7B5; background-color: #BDC7B5;
} }
table.tablesorter tbody tr:hover td { table.tablesorter tbody tr:hover td {
background: #E8E8E8; background: #E8E8E8;
color: #343432; color: #343432;
} }
/* Extra selectors needed to override the default styling */ /* Extra selectors needed to override the default styling */
table.tablesorter tbody tr.normal-row td { table.tablesorter tbody tr.normal-row td {
background: #EFEFF1; background: #EFEFF1;
color: #343432; color: #343432;
} }
table.tablesorter tbody tr.alt-row td { table.tablesorter tbody tr.alt-row td {
background: #FFF; background: #FFF;
color: #343432; color: #343432;
} }
/* Extra selectors needed to override the default styling */ /* Extra selectors needed to override the default styling */
table.tablesorter tbody tr.normal-row:hover td { table.tablesorter tbody tr.normal-row:hover td {
background: #E8E8E8; background: #E8E8E8;
color: #343432; color: #343432;
}
table.tablesorter tbody tr.alt-row:hover td {
background: #E8E8E8;
color: #343432;
}
table.tablesorter tbody tr.sumAll td {
background: #EBEBED;
color: black;
}
table.tablesorter tbody tr.sumAll:hover td {
background: #E0E0E2;
color: black;
font-weight: bold;
} }
table.tablesorter .sumRow, .oddListRowS1 { table.tablesorter tbody tr.alt-row:hover td {
background: #E8E8E8;
color: #343432;
}
table.tablesorter tbody tr.sumAll td {
background: #EBEBED;
color: black;
}
table.tablesorter tbody tr.sumAll:hover td {
background: #E0E0E2;
color: black;
font-weight: bold;
}
table.tablesorter .sumRow,
.oddListRowS1 {
text-align: right; text-align: right;
} }
@@ -99,15 +104,16 @@
<table id="tableMenu" cellspacing="0" cellpadding="0" border="0"> <table id="tableMenu" cellspacing="0" cellpadding="0" border="0">
<tbody> <tbody>
<tr> <tr>
<td> <td>
<img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"> <img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;"
</td> alt="EcmProducts" width="16" border="0" height="16">
<td> </td>
<h2>{$MOD.LBL_REPORT_STOCKS} </h2> <td>
</td> <h2>{$MOD.LBL_REPORT_STOCKS} </h2>
</tr> </td>
</tr>
</table> </table>
<br /> <br />
@@ -120,143 +126,177 @@
<form action="index.php" method="get" name="searchReportStocks"> <form action="index.php" method="get" name="searchReportStocks">
<input type="hidden" name="module" value="EcmReports" /> <input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="ReportStocks" /> <input type="hidden" name="action" value="ReportStocks" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0"> <table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0"
cellspacing="0">
<tr> <tr>
<td class="dataLabel" width="5%" nowrap="nowrap">{$MOD.LBL_STOCK}</td> <td class="dataLabel" width="5%" nowrap="nowrap">{$MOD.LBL_STOCK}</td>
<td class="dataField" width="10%" nowrap="nowrap"> <td class="dataField" width="10%" nowrap="nowrap">
<select id="stock" name="selectStock"> <select id="stock" name="selectStock">
<option value="" { if $selectStock==""} selected="true" {/if} >{$MOD.LBL_ALL_STOCKS}</option> <option value="" { if $selectStock=="" } selected="true" {/if}>{$MOD.LBL_ALL_STOCKS}</option>
{foreach from=$STOCKS item=STOCK key=count name=loop} {foreach from=$STOCKS item=STOCK key=count name=loop}
<option value="{$STOCK.id}" { if $selectStock==$STOCK.id} selected="true" {/if} >{$STOCK.name}</option> <option value="{$STOCK.id}" { if $selectStock==$STOCK.id} selected="true" {/if}>{$STOCK.name}
{/foreach} </option>
</select> {/foreach}
</td> </select>
<td class="dataLabel" width="25%" nowrap="nowrap"></td> </td>
<td class="dataLabel" width="25%" nowrap="nowrap"></td>
<td class="dataLabel" width="5%" nowrap="nowrap">{$MOD.LBL_PRODUCT_ACTIVE}</td> <td class="dataLabel" width="5%" nowrap="nowrap">{$MOD.LBL_PRODUCT_ACTIVE}</td>
<td class="dataField" width="10%" nowrap="nowrap"> <td class="dataField" width="10%" nowrap="nowrap">
<select id="productActive" name="selectProductActive"> <select id="productActive" name="selectProductActive">
<option value="" { if $selectProductActive==""} selected="true" {/if} >{$MOD.LBL_YES}/{$MOD.LBL_NO}</option> <option value="" { if $selectProductActive=="" } selected="true" {/if}>{$MOD.LBL_YES}/{$MOD.LBL_NO}
<option value="1" { if $selectProductActive=="1"} selected="true" {/if} >{$MOD.LBL_YES}</option> </option>
<option value="0" { if $selectProductActive=="0"} selected="true" {/if} >{$MOD.LBL_NO}</option> <option value="1" { if $selectProductActive=="1" } selected="true" {/if}>{$MOD.LBL_YES}</option>
</select> <option value="0" { if $selectProductActive=="0" } selected="true" {/if}>{$MOD.LBL_NO}</option>
</td> </select>
<td class="dataLabel" width="25%" nowrap="nowrap"></td> </td>
<td class="dataLabel" width="5%" nowrap="nowrap">End of line</td> <td class="dataLabel" width="25%" nowrap="nowrap"></td>
<td class="dataField" width="10%" nowrap="nowrap"> <td class="dataLabel" width="5%" nowrap="nowrap">End of line</td>
<select id="productEol" name="selectProductEol"> <td class="dataField" width="10%" nowrap="nowrap">
<option value="" { if $selectProductEol==""} selected="true" {/if} >{$MOD.LBL_YES}/{$MOD.LBL_NO}</option> <select id="productEol" name="selectProductEol">
<option value="1" { if $selectProductEol=="1"} selected="true" {/if} >{$MOD.LBL_YES}</option> <option value="" { if $selectProductEol=="" } selected="true" {/if}>{$MOD.LBL_YES}/{$MOD.LBL_NO}
<option value="0" { if $selectProductEol=="0"} selected="true" {/if} >{$MOD.LBL_NO}</option> </option>
</select> <option value="1" { if $selectProductEol=="1" } selected="true" {/if}>{$MOD.LBL_YES}</option>
</td> <option value="0" { if $selectProductEol=="0" } selected="true" {/if}>{$MOD.LBL_NO}</option>
<td class="dataLabel" width="25%" nowrap="nowrap"></td> </select>
<td class="dataLabel" width="5%" nowrap="nowrap">Grupa księgowa</td> </td>
<td class="dataField" width="10%" nowrap="nowrap"> <td class="dataLabel" width="25%" nowrap="nowrap"></td>
<select id="productKS" name="productKS"> <td class="dataLabel" width="5%" nowrap="nowrap">Grupa księgowa</td>
<option value="" { if $selectKS==""} selected="true" {/if} >Wszystkie</option> <td class="dataField" width="10%" nowrap="nowrap">
{foreach from=$KSGROUPS item=GROUP key=count name=loop} <select id="productKS" name="productKS">
<option value="{$GROUP.id}" { if $selectKS==$GROUP.id} selected="true" {/if} >{$GROUP.name}</option> <option value="" { if $selectKS=="" } selected="true" {/if}>Wszystkie</option>
{/foreach} {foreach from=$KSGROUPS item=GROUP key=count name=loop}
</select> <option value="{$GROUP.id}" { if $selectKS==$GROUP.id} selected="true" {/if}>{$GROUP.name}</option>
</td> {/foreach}
<td class="dataLabel" width="25%" nowrap="nowrap"></td> </select>
</td>
<td class="dataLabel" width="25%" nowrap="nowrap"></td>
<td class="dataLabel" width="5%" nowrap="nowrap"></td> <td class="dataLabel" width="5%" nowrap="nowrap"></td>
<td class="dataField" width="10%" nowrap="nowrap"> <td class="dataField" width="10%" nowrap="nowrap">
</td>
<td class="dataLabel" width="25%" nowrap="nowrap"></td>
<td class="dataLabel" width="5%" nowrap="nowrap"></td>
<td class="dataField" width="10%" nowrap="nowrap">
</td>
<td class="dataLabel" width="25%" nowrap="nowrap"></td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="{$MOD.LBL_EXECUTE}" type="submit"> </td>
<input class="button" name="clear" value="{$MOD.LBL_CLEAR}" type="button" onclick="location.href='index.php?module=EcmReports&action=ReportSales';"> <td class="dataLabel" width="25%" nowrap="nowrap"></td>
<input id="excelEksport" class="button" name="importToExcel" value="{$MOD.BTN_EXCEL_EXPORT}" type="button"> <td class="dataLabel" width="5%" nowrap="nowrap"></td>
<td class="dataField" width="10%" nowrap="nowrap">
</td>
<td class="dataLabel" width="25%" nowrap="nowrap"></td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="{$MOD.LBL_EXECUTE}" type="submit">
<input class="button" name="clear" value="{$MOD.LBL_CLEAR}" type="button"
onclick="location.href='index.php?module=EcmReports&action=ReportSales';">
<input id="excelEksport" class="button" name="importToExcel" value="{$MOD.BTN_EXCEL_EXPORT}" type="button">
<br> <br>
<br> <br>
<table id="myTable" class="tablesorter tablesorter-blue" role="grid"> <table id="myTable" class="tablesorter tablesorter-blue" role="grid">
<thead> <thead>
<tr class="tablesorter-headerRow" role="row"> <tr class="tablesorter-headerRow" role="row">
<th width="30%" class="sorter-text tablesorter-header tablesorter-headerUnSorted" data-column="0" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" style="-moz-user-select: none;" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort">{$MOD.LBL_PRODUCTS}</th> <th width="30%" class="sorter-text tablesorter-header tablesorter-headerUnSorted" data-column="0"
<th width="10%" class="sorter-text tablesorter-header tablesorter-headerUnSorted" data-column="1" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" style="-moz-user-select: none;" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort">{$MOD.LBL_INDEX}</th> tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on"
<th width="8%" class="sorter-saas tablesorter-header tablesorter-headerUnSorted" data-column="5" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" style="-moz-user-select: none;" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort">{$MOD.LBL_QUANTITY}</th> style="-moz-user-select: none;" aria-sort="none"
<th width="8%" class="sorter-saas tablesorter-header tablesorter-headerUnSorted" data-column="6" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" style="-moz-user-select: none;" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort">{$MOD.LBL_VALUE}</th> aria-label="Name: No sort applied, activate to apply an ascending sort">{$MOD.LBL_PRODUCTS}</th>
<th width="8%" class="sorter-saas tablesorter-header tablesorter-headerUnSorted" data-column="6" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" style="-moz-user-select: none;" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort">Średnia Cena</th> <th width="4%" class="sorter-text tablesorter-header tablesorter-headerUnSorted" data-column="1"
tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on"
style="-moz-user-select: none;" aria-sort="none"
aria-label="Name: No sort applied, activate to apply an ascending sort">{$MOD.LBL_INDEX}</th>
<th width="6%" class="sorter-text tablesorter-header tablesorter-headerUnSorted" data-column="1"
tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on"
style="-moz-user-select: none;" aria-sort="none"
aria-label="Name: No sort applied, activate to apply an ascending sort">Adres magazynowy</th>
<th width="8%" class="sorter-saas tablesorter-header tablesorter-headerUnSorted" data-column="5"
tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on"
style="-moz-user-select: none;" aria-sort="none"
aria-label="Name: No sort applied, activate to apply an ascending sort">{$MOD.LBL_QUANTITY}</th>
<th width="8%" class="sorter-saas tablesorter-header tablesorter-headerUnSorted" data-column="6"
tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on"
style="-moz-user-select: none;" aria-sort="none"
aria-label="Name: No sort applied, activate to apply an ascending sort">{$MOD.LBL_VALUE}</th>
<th width="8%" class="sorter-saas tablesorter-header tablesorter-headerUnSorted" data-column="6"
tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on"
style="-moz-user-select: none;" aria-sort="none"
aria-label="Name: No sort applied, activate to apply an ascending sort">Średnia Cena</th>
</tr> </tr>
</thead> </thead>
{foreach from=$DATA item=CAT key=CATNAME name=loop} {foreach from=$DATA item=CAT key=CATNAME name=loop}
{* Table headers *} {* Table headers *}
<tbody id="functions-core" class="tablesorter-infoOnly"> <tbody id="functions-core" class="tablesorter-infoOnly">
<tr class="static category"> <tr class="static category">
{if $CATNAME != ""} {if $CATNAME != ""}
<td class="oddListRowS1 alignLeft"><a class="plusStyle showTables">[+]</a><b> {$CATNAME}</b></td> <td class="oddListRowS1 alignLeft"><a class="plusStyle showTables">[+]</a><b> {$CATNAME}</b></td>
{/if} {/if}
<td class="oddListRowS1" ></td> <td class="oddListRowS1"></td>
<td class="oddListRowS1 sumRow" ><b>{$DATA.$CATNAME.QuantitySum|number_format:4:",":"." }</b></td> <td class="oddListRowS1"></td>
<td class="oddListRowS1 sumRow" ><b>{$DATA.$CATNAME.PriceSum|number_format:2:",":"." }</b></td> <td class="oddListRowS1 sumRow"><b>{$DATA.$CATNAME.QuantitySum|number_format:4:",":"." }</b></td>
<td class="oddListRowS1 sumRow" ><b>{$DATA.$CATNAME.PriceSum/$DATA.$CATNAME.QuantitySum|number_format:2:",":"." }</b></td> <td class="oddListRowS1 sumRow"><b>{$DATA.$CATNAME.PriceSum|number_format:2:",":"." }</b></td>
</tr> <td class="oddListRowS1 sumRow">
</tbody> <b>{$DATA.$CATNAME.PriceSum/$DATA.$CATNAME.QuantitySum|number_format:2:",":"." }</b></td>
{foreach from=$CAT item=CAT2 key=CAT2NAME name=loop} </tr>
{if $CAT2NAME!="QuantitySum" && $CAT2NAME!="PriceSum"} </tbody>
<tbody id="functions-core" class="tablesorter-infoOnly tablesShowHide"> {foreach from=$CAT item=CAT2 key=CAT2NAME name=loop}
<tr class="subcategory"> {if $CAT2NAME!="QuantitySum" && $CAT2NAME!="PriceSum"}
<td class="oddListRowS1 alignLeft"><a class="showRows" style="color: cadetblue; text-decoration: none; cursor: pointer;">[+]</a><b> {$CAT2NAME}</b></td> <tbody id="functions-core" class="tablesorter-infoOnly tablesShowHide">
<td class="oddListRowS1" ></td> <tr class="subcategory">
<td class="oddListRowS1 sumRow" ><b>{$CAT.$CAT2NAME.QuantitySum2|number_format:4:",":"." }</b></td> <td class="oddListRowS1 alignLeft"><a class="showRows"
<td class="oddListRowS1 sumRow" ><b>{$CAT.$CAT2NAME.PriceSum2|number_format:2:",":"." }</b></td> style="color: cadetblue; text-decoration: none; cursor: pointer;">[+]</a><b> {$CAT2NAME}</b>
<td class="oddListRowS1 sumRow" ><b>{$CAT.$CAT2NAME.PriceSum2/$CAT.$CAT2NAME.QuantitySum2|number_format:2:",":"." }</b></td> </td>
</tr> <td class="oddListRowS1"></td>
</tbody> <td class="oddListRowS1"></td>
<td class="oddListRowS1 sumRow"><b>{$CAT.$CAT2NAME.QuantitySum2|number_format:4:",":"." }</b></td>
<td class="oddListRowS1 sumRow"><b>{$CAT.$CAT2NAME.PriceSum2|number_format:2:",":"." }</b></td>
<td class="oddListRowS1 sumRow">
<b>{$CAT.$CAT2NAME.PriceSum2/$CAT.$CAT2NAME.QuantitySum2|number_format:2:",":"." }</b></td>
</tr>
</tbody>
<tbody aria-live="polite" aria-relevant="all" class="rowShowHide"> <tbody aria-live="polite" aria-relevant="all" class="rowShowHide">
{foreach from=$CAT2 item=ROW name=loop} {foreach from=$CAT2 item=ROW name=loop}
{if $CAT2NAME!="AvgPriceSum" && $CAT2NAME!="QuantitySum" && $ROW.name!=""} {if $CAT2NAME!="AvgPriceSum" && $CAT2NAME!="QuantitySum" && $ROW.name!=""}
{if $smarty.foreach.loop.index % 2 == 1} {if $smarty.foreach.loop.index % 2 == 1}
<tr role="row" class="contractor"> <tr role="row" class="contractor">
{else} {else}
<tr class="contractor" role="row"> <tr class="contractor" role="row">
{/if} {/if}
<td class="oddListRowS1 alignLeft" style="text-align:left;"> <td class="oddListRowS1 alignLeft" style="text-align:left;">
<a target="new" href="index.php?module=EcmProducts&action=index&return_module=EcmProducts&action=DetailView&record={$ROW.id}"> <a target="new"
{$ROW.name} href="index.php?module=EcmProducts&action=index&return_module=EcmProducts&action=DetailView&record={$ROW.id}">
</a> {$ROW.name}
</td> </a>
<td class="oddListRowS1 alignLeft" >{$ROW.code}</td> </td>
<td class="oddListRowS1" >{$ROW.quantity|number_format:4:",":"."}</td> <td class="oddListRowS1 alignLeft">{$ROW.code}</td>
<td class="oddListRowS1" >{$ROW.price|number_format:2:",":"."}</td> <td class="oddListRowS1">{$ROW.stock_address}</td>
<td class="oddListRowS1" >{$ROW.price/$ROW.quantity|number_format:2:",":"."}</td> <td class="oddListRowS1">{$ROW.quantity|number_format:4:",":"."}</td>
</tr> <td class="oddListRowS1">{$ROW.price|number_format:2:",":"."}</td>
{/if} <td class="oddListRowS1">{$ROW.price/$ROW.quantity|number_format:2:",":"."}</td>
{/foreach} </tr>
</tbody> {/if}
<tbody id="stopRows"></tbody> {/foreach}
{/if} </tbody>
{/foreach} <tbody id="stopRows"></tbody>
<tbody id="stopTables"></tbody> {/if}
{/foreach} {/foreach}
<tbody id="functions-core" class="tablesorter-infoOnly"> <tbody id="stopTables"></tbody>
<tr class="static category sumAll"> {/foreach}
<td class="oddListRowS1 alignLeft"><b>{$MOD.LBL_SUM}:</b></td> <tbody id="functions-core" class="tablesorter-infoOnly">
<td class="oddListRowS1" ></td> <tr class="static category sumAll">
<td class="oddListRowS1 sumRow" ><b>{$SUM.QuantitySumSum|number_format:4:",":"." }</b></td> <td class="oddListRowS1 alignLeft"><b>{$MOD.LBL_SUM}:</b></td>
<td class="oddListRowS1 sumRow" ><b>{$SUM.PriceSumSum|number_format:2:",":"." }</b></td> <td class="oddListRowS1"></td>
<td class="oddListRowS1 sumRow" ><b>{$SUM.PriceSumSum/$SUM.QuantitySumSum|number_format:2:",":"." }</b></td> <td class="oddListRowS1"></td>
</tr> <td class="oddListRowS1 sumRow"><b>{$SUM.QuantitySumSum|number_format:4:",":"." }</b></td>
</tbody> <td class="oddListRowS1 sumRow"><b>{$SUM.PriceSumSum|number_format:2:",":"." }</b></td>
</table> <td class="oddListRowS1 sumRow"><b>{$SUM.PriceSumSum/$SUM.QuantitySumSum|number_format:2:",":"." }</b>
<br/> </td>
</tr>
</tbody>
</table>
<br />

View File

@@ -76,7 +76,7 @@ if (
$r = $db->fetchByAssoc ( $rows ); $r = $db->fetchByAssoc ( $rows );
if($r['id']!='')$can_edit=false; if($r['id']!='')$can_edit=false;
$edit->ss->assign("CAN_EDIT", $can_edit); $edit->ss->assign("CAN_EDIT", true);
$edit->ss->assign("CREATED_BY_NAME", $focus->created_by_name); $edit->ss->assign("CREATED_BY_NAME", $focus->created_by_name);
$edit->ss->assign("MODIFIED_BY_NAME", $focus->modified_by_name); $edit->ss->assign("MODIFIED_BY_NAME", $focus->modified_by_name);

View File

@@ -864,7 +864,7 @@ class EcmSale extends SugarBean
$where = " and " . implode(" and ", $field_array); $where = " and " . implode(" and ", $field_array);
else else
$where = ""; $where = "";
$z = "select * from ecmsales where deleted='0' and status!='s10' " . $where . " ORDER BY send_date DESC"; $z = "select * from ecmsales where deleted='0' and status!='s10' " . $where . " ORDER BY send_date";
return $z; return $z;
} }
@@ -1059,6 +1059,16 @@ class EcmSale extends SugarBean
$result_array[$i]['total_invoice'] = $total_invoice; $result_array[$i]['total_invoice'] = $total_invoice;
$result_array[$i]['percent'] = $percent; $result_array[$i]['percent'] = $percent;
$result_array[$i]['currency'] = $r['currency_id']; $result_array[$i]['currency'] = $r['currency_id'];
$result_array[$i]['delivery_name'] = null;
if (strlen($r['shipping_address_name']) > 0) {
$result_array[$i]['delivery_name'] = $r['shipping_address_name'];
$d = $db->fetchByAssoc($db->query(sprintf("SELECT id, TRIM(name) FROM accounts WHERE name LIKE '%s' AND deleted=0", strtolower(trim($r['shipping_address_name'])))));
if ($d && $d['id']) {
$result_array[$i]['delivery_id'] = $d['id'];
}
}
$i++; $i++;
$sum_total_qty += $total_qty; $sum_total_qty += $total_qty;

View File

@@ -1,120 +1,150 @@
<?php <?php
if (! defined ( 'sugarEntry' ) || ! sugarEntry) if (!defined('sugarEntry') || !sugarEntry)
die ( 'Not A Valid Entry Point' ); die ('Not A Valid Entry Point');
// require_once('modules/EcmGroupSales/HeaderMenu.php');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings; global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
require_once ('modules/EcmInsideOrders/EcmInsideOrder.php'); require_once('modules/EcmInsideOrders/EcmInsideOrder.php');
require_once ('include/time.php'); require_once('include/time.php');
require_once ('include/json_config.php'); require_once('include/json_config.php');
// add jquery // add jquery
echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/css/style.css"/>'; echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/css/style.css"/>';
echo '<script type="text/javascript" echo '<script type="text/javascript" src="include/jQuery/jquery-lastes.js"></script>';
src="include/jQuery/jquery-lastes.js"></script>'; echo '<script type="text/javascript" src="include/jQuery/jquery.tablesorter.pager.js"></script>';
echo '<script type="text/javascript" echo '<script type="text/javascript" src="modules/EcmSales/javascript/ProductSummary.js"></script>';
src="include/jQuery/jquery.tablesorter.pager.js"></script>';
echo '<script type="text/javascript"
src="modules/EcmSales/javascript/ProductSummary.js"></script>';
$json_config = new json_config (); $json_config = new json_config ();
$focus = new EcmSale (); $focus = new EcmSale ();
$db = $GLOBALS ['db']; $db = $GLOBALS['db'];
$data = array();
$categoryArray=array();
$id_array= explode(",", $_GET['ids']) ;
//var_dump($id_array);
$where="and doc.id IN ('".implode("','",$id_array)."')";
if($_GET['product_group']=='1')$where.=" and pr.group_ks=1";
if($_GET['product_group']=='2')$where.=" and pr.group_ks=2";
if($_GET['product_group']=='3')$where.=" and pr.group_ks=3";
$query= "SELECT
pr.id,
item.code,
item.name,
ROUND(sum(item.quantity),0) AS quantity,
ROUND(ifnull(x.stock, 0),0) AS stock,
pr.group_ks,
pr.product_category_name,
pr.product_category_id
FROM
ecmsaleitems as item
INNER JOIN
ecmsales as doc ON doc.id=item.ecmsale_id
INNER JOIN
ecmproducts as pr ON pr.id=item.ecmproduct_id
LEFT JOIN
(SELECT sum(quantity) as stock ,product_id
FROM
ecmstockstates
GROUP BY product_id) x ON x.product_id=item.ecmproduct_id
WHERE doc.deleted='0' and doc.status!='s10' " . $where;
$query.=" AND NOT EXISTS
(
SELECT NULL
FROM ecmstockdocouts t1
WHERE t1.ecmsale_id = doc.id
) GROUP by item.ecmproduct_id
ORDER BY pr.group_ks DESC";
$rows = $db->query ($query);
while($r = $db->fetchByAssoc ( $rows )) $positions = array();
{ $total = 0;
$row = array(); $stock = 0;
$row["id"] = $r["id"];
$row["code"] = $r["code"];
$row["name"] = $r["name"];
$row["quantity"] = $r["quantity"];
$row["stock"] = $r["stock"];
$row["product_category_name"]=$r["product_category_name"];
$row["group_ks"] = $r["group_ks"];
if($r["group_ks"]=='1')$daj='TH';
if($r["group_ks"]=='2')$daj='WG';
if($r["group_ks"]=='3')$daj='S';
$row["group_ks_name"] = $daj;
$id_array = isset($_GET['ids']) ? explode(",", $_GET['ids']) : array();
$where = "and doc.id IN ('" . implode("','", $id_array) . "')";
if (isset($_GET['product_group']) && $_GET['product_group'] == '1') $where .= " and pr.group_ks=1";
if (isset($_GET['product_group']) && $_GET['product_group'] == '2') $where .= " and pr.group_ks=2";
if (isset($_GET['product_group']) && $_GET['product_group'] == '3') $where .= " and pr.group_ks=3";
// get stock addresses $query = "SELECT
$result = $db->query("SELECT stock_address, is_not_full FROM ecmproducts_stock_addresses WHERE ecmproduct_id='".$r['id']."';"); pr.id,
$stock_addresses = ""; item.code,
while($addr=$db->fetchByAssoc($result)) { item.name,
if ($addr['is_not_full'] == '1') { ROUND(SUM(item.quantity),0) AS quantity,
$stock_addresses .= " <span style='color: red;'>".$addr['stock_address']."</span>"; ROUND(IFNULL(x.stock, 0),0) AS stock,
} else { pr.group_ks,
$stock_addresses .= " ".$addr['stock_address']; pr.product_category_name,
} pr.product_category_id
} FROM ecmsaleitems AS item
$row['stock_addresses'] = $stock_addresses; INNER JOIN ecmsales AS doc ON doc.id=item.ecmsale_id
INNER JOIN ecmproducts AS pr ON pr.id=item.ecmproduct_id
array_push($row, $r); LEFT JOIN (
$data [] = $row; SELECT SUM(quantity) AS stock, product_id
$total+=$r['quantity']; FROM ecmstockstates
$stock+=$r['stock']; GROUP BY product_id
} ) x ON x.product_id=item.ecmproduct_id
$data['quantity']=$total; WHERE doc.deleted='0' AND doc.status!='s10' " . $where . "
$data['stock']=$stock; AND NOT EXISTS (
SELECT NULL
FROM ecmstockdocouts t1
WHERE t1.ecmsale_id = doc.id
)
GROUP BY item.ecmproduct_id
ORDER BY pr.group_ks DESC";
$rows = $db->query($query);
$edit->ss = new Sugar_Smarty (); while ($r = $db->fetchByAssoc($rows)) {
$edit->module = 'EcmSales'; $row = array();
$row['id'] = $r['id'];
$row['code'] = $r['code'];
$row['name'] = $r['name'];
$row['quantity'] = $r['quantity'];
$row['stock'] = $r['stock'];
$row['product_category_name'] = $r['product_category_name'];
$row['group_ks'] = $r['group_ks'];
$edit->ss->assign ( "CREATED_BY_NAME", $focus->created_by_name ); $daj = '';
$edit->ss->assign ( "MODIFIED_BY_NAME", $focus->modified_by_name ); if ($r['group_ks'] == '1') $daj = 'TH';
$edit->ss->assign ( 'FOCUS', $focus); if ($r['group_ks'] == '2') $daj = 'WG';
$edit->ss->assign ( 'POST', $_POST); if ($r['group_ks'] == '3') $daj = 'S';
$edit->ss->assign ( 'LINK', $link); $row['group_ks_name'] = $daj;
$edit->ss->assign ( 'IDS', $_GET['ids']);
$edit->ss->assign('POSITION_LIST',$data);
$edit->ss->assign ( 'MOD', $mod_strings);
$edit->ss-> display('modules/EcmSales/tpls/ProductSummary.tpl'); //4
$result = $db->query("SELECT stock_address, is_not_full FROM ecmproducts_stock_addresses WHERE ecmproduct_id='" . $r['id'] . "' ORDER BY stock_address");
$addresses_raw = array();
while ($addr = $db->fetchByAssoc($result)) {
$addresses_raw[] = array(
'addr' => trim($addr['stock_address']),
'not_full' => ($addr['is_not_full'] == '1')
);
}
// loading view if (!empty($addresses_raw)) {
//echo '<link rel="stylesheet" type="text/css" href="modules/EcmInsideOrders/javascript/helper.css" media="screen" /><div class="loading_panel"></div>'; usort($addresses_raw, function ($a, $b) {
?> return strcmp($a['addr'], $b['addr']);
});
}
$only_addrs = array();
$has_not_full = 0;
foreach ($addresses_raw as $ar) {
$only_addrs[] = $ar['addr'];
if ($ar['not_full']) $has_not_full = 1;
}
$row['stock_addresses_sort_key'] = implode(' ', $only_addrs);
$row['has_not_full'] = $has_not_full;
$stock_addresses_html = '';
foreach ($addresses_raw as $ar) {
if ($ar['not_full']) {
$stock_addresses_html .= " <span style='color: red;'>" . $ar['addr'] . "</span>";
} else {
$stock_addresses_html .= " " . $ar['addr'];
}
}
$row['stock_addresses'] = $stock_addresses_html;
$positions[] = $row;
$total += (float)$r['quantity'];
$stock += (float)$r['stock'];
}
usort($positions, function ($a, $b) {
$ka = isset($a['stock_addresses_sort_key']) ? $a['stock_addresses_sort_key'] : '';
$kb = isset($b['stock_addresses_sort_key']) ? $b['stock_addresses_sort_key'] : '';
return strcmp($ka, $kb);
});
$data = $positions;
$data['quantity'] = $total;
$data['stock'] = $stock;
if (!isset($_REQUEST['to_pdf'])) {
$edit->ss = new Sugar_Smarty();
$edit->module = 'EcmSales';
$edit->ss->assign("CREATED_BY_NAME", $focus->created_by_name);
$edit->ss->assign("MODIFIED_BY_NAME", $focus->modified_by_name);
$edit->ss->assign('FOCUS', $focus);
$edit->ss->assign('POST', $_POST);
$edit->ss->assign('LINK', isset($link) ? $link : '');
$edit->ss->assign('IDS', isset($_GET['ids']) ? $_GET['ids'] : '');
$edit->ss->assign('POSITION_LIST', $data);
$edit->ss->assign('MOD', $mod_strings);
$edit->ss->display('modules/EcmSales/tpls/ProductSummary.tpl');
} else {
$t = '<table style="border: 1px solid black; border-collapse: collapse;"><tr><td><b>Kod</b></td><td><b>Nazwa</b></td><td><b>Ilość</b></td><td><b>Adres magazynowy</b></td></tr>';
foreach ($data as $r) {
if (isset($r['code'])) {
$t .= '<tr><td style="border: 1px solid black;">' . $r['code'] . '</td><td style="border: 1px solid black;">' . $r['name'] . '</td><td style="border: 1px solid black;">' . $r['quantity'] . '</td><td style="border: 1px solid black;">' . $r['stock_addresses'] . '</td></tr>';
}
}
$t .= '</table>';
echo $t;
}

View File

@@ -48,8 +48,8 @@ function getList() {
} }
function getList2() { function getList2() {
if($('#idss').val()!=""){ if($('#idss').val()!=""){
window.open('index.php?module=EcmSales&action=productsSummaryList&to_pdf=1&ids='+$('#idss').val()); window.open('index.php?module=EcmSales&action=ProductSummary&to_pdf=1&ids='+$('#idss').val());
} else { } else {
alert("Proszę zaznaczyć chociaż jedną pozycje!"); alert("Proszę zaznaczyć chociaż jedną pozycje!");
} }

View File

@@ -15,100 +15,15 @@ function getList() {
$(document).ready(function() $(document).ready(function()
{ {
$("#createInsideOrder").click(createInsideOrder);
// by document no
$.tablesorter.addParser({
// set a unique id
id: 'rangesort',
is: function (s) {
// return false so this parser is not auto detected
return false;
},
format: function (s, table, cell, cellIndex) {
// get data attributes from $(cell).attr('data-something');
// check specific column using cellIndex
return $(cell).attr('data-price');
},
// set type, either numeric or text
type: 'numeric'
});
// by total netto
$.tablesorter.addParser({
// set a unique id
id: 'rangesorttota',
is: function (s) {
// return false so this parser is not auto detected
return false;
},
format: function (s, table, cell, cellIndex) {
// get data attributes from $(cell).attr('data-something');
// check specific column using cellIndex
return $(cell).attr('data-total');
},
// set type, either numeric or text
type: 'numeric'
});
// by vat
$.tablesorter.addParser({
// set a unique id
id: 'rangesorttotav',
is: function (s) {
// return false so this parser is not auto detected
return false;
},
format: function (s, table, cell, cellIndex) {
// get data attributes from $(cell).attr('data-something');
// check specific column using cellIndex
return $(cell).attr('data-total');
},
// set type, either numeric or text
type: 'numeric'
});
// by total brutto
$.tablesorter.addParser({
// set a unique id
id: 'rangesorttotan',
is: function (s) {
// return false so this parser is not auto detected
return false;
},
format: function (s, table, cell, cellIndex) {
// get data attributes from $(cell).attr('data-something');
// check specific column using cellIndex
return $(cell).attr('data-total');
},
// set type, either numeric or text
type: 'numeric'
});
// by total invoice
$.tablesorter.addParser({
// set a unique id
id: 'rangesorttotai',
is: function (s) {
// return false so this parser is not auto detected
return false;
},
format: function (s, table, cell, cellIndex) {
// get data attributes from $(cell).attr('data-something');
// check specific column using cellIndex
return $(cell).attr('data-total');
},
// set type, either numeric or text
type: 'numeric'
});
$('#selectall').click(function(event) { //on click $('#selectall').click(function(event) { //on click
if(this.checked) { // check select status if(this.checked) { // check select status
$('.make_pdf').each(function() { //loop through each checkbox $('.allCheck').each(function() { //loop through each checkbox
this.checked = true; //select all checkboxes with class "checkbox1" this.checked = true; //select all checkboxes with class "checkbox1"
}); });
}else{ }else{
$('.make_pdf').each(function() { //loop through each checkbox $('.allCheck').each(function() { //loop through each checkbox
this.checked = false; //deselect all checkboxes with class "checkbox1" this.checked = false; //deselect all checkboxes with class "checkbox1"
}); });
} }
@@ -140,32 +55,24 @@ $(document).ready(function()
$('#myTable tr').removeClass('highlighted'); $('#myTable tr').removeClass('highlighted');
$(this).addClass('highlighted'); $(this).addClass('highlighted');
}); });
$("#myTable").tablesorter({ });
headers: {
0: {
// disable it by setting the property sorter to false
sorter: false
},
} function createInsideOrder() {
console.log('createInsideOrder');
var ids = [];
$('input.allCheck:checkbox:checked').each(function () {
ids.push($(this).val());
}); });
if (ids.length === 0) {
$("#myTable2").tablesorter({ alert('Wybierz pozycje.');
headers: { return;
0: { }
// disable it by setting the property sorter to false var products = [];
sorter: false ids.forEach(el => {
}, const qty = parseFloat($("#qtyInput-" + el).val().trim());
console.log(qty);
} products.push(el + "|" + qty);
}); });
$("#myTable3").tablesorter({ $("#insideOrderProducts").val(products.join('*'));
headers: { $("#createInsideOrderForm").submit();
0: { }
// disable it by setting the property sorter to false
sorter: false
},
}
});
});

View File

@@ -1,16 +1,15 @@
<script type="text/javascript" <script type="text/javascript" src="include/ECM/EcmMultiPdf/EcmMultiPdf.js"></script>
src="include/ECM/EcmMultiPdf/EcmMultiPdf.js"></script> <script type="text/javascript" src="include/jQuery/jquery.blockUI.js"></script>
<script type="text/javascript"
src="include/jQuery/jquery.blockUI.js"></script>
<table cellspacing="0" cellpadding="0" border="0"> <table cellspacing="0" cellpadding="0" border="0">
<tr> <tr>
<td><img src="themes/Sugar/images/EcmProducts.gif" <td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts"
style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td>
width="16" border="0" height="16"></td> <td>
<td><h2>{$MOD.LBL_LISTNEWSALES_NAME}</h2></td> <h2>{$MOD.LBL_LISTNEWSALES_NAME}</h2>
</td>
</tr> </tr>
</table> </table>
<br/> <br />
<form action="index.php?module=EcmSales&action=ListNewSales" method="get" name="SearchFormListNewSales"> <form action="index.php?module=EcmSales&action=ListNewSales" method="get" name="SearchFormListNewSales">
<ul class="tablist" style="width:100%;"> <ul class="tablist" style="width:100%;">
<input type="hidden" name="module" value="EcmSales"> <input type="hidden" name="module" value="EcmSales">
@@ -20,21 +19,21 @@
</li> </li>
</ul> </ul>
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" <table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0"
cellspacing="0"> cellspacing="0">
<tr> <tr>
<td nowrap=""> <td nowrap="">
Data wysyłki od Data wysyłki od
</td> </td>
<td nowrap=""> <td nowrap="">
<input type="text" maxlength="10" size="11" tabindex="" title="" <input type="text" maxlength="10" size="11" tabindex="" title=""
value="{if $POST.date_send_from!=''}{$POST.date_send_from}{else}{$smarty.now|date_format:"%d.%m.%Y"}{/if}" id="date_send_from" value="{if $POST.date_send_from!=''}{$POST.date_send_from}{else}{$smarty.now|date_format:"%d.%m.%Y"}{/if}"
name="date_send_from" autocomplete="off"> id="date_send_from" name="date_send_from" autocomplete="off">
<img align="absmiddle" border="0" id="date_send_from_trigger" name="date_send_from_trigger" <img align="absmiddle" border="0" id="date_send_from_trigger" name="date_send_from_trigger"
alt="Enter Date" src="themes/default/images/jscalendar.gif"> alt="Enter Date" src="themes/default/images/jscalendar.gif">
<script type="text/javascript"> <script type="text/javascript">
{literal} {literal}
// musi być tu w pliku js nie chce działać // musi być tu w pliku js nie chce działać
Calendar.setup({ Calendar.setup({
inputField: "date_send_from", inputField: "date_send_from",
daFormat: "%d.%m.%Y", daFormat: "%d.%m.%Y",
button: "date_send_from_trigger", button: "date_send_from_trigger",
@@ -42,22 +41,21 @@
dateStr: "", dateStr: "",
step: 1, step: 1,
weekNumbers: false weekNumbers: false
} });
);
{/literal} {/literal}
</script> </script>
{$MOD.LBL_LISTNEWSALES_DATE_END}: {$MOD.LBL_LISTNEWSALES_DATE_END}:
<input type="text" maxlength="10" size="11" tabindex="" title="" <input type="text" maxlength="10" size="11" tabindex="" title=""
value="{if $POST.date_send_to!=''}{$POST.date_send_to}{else}{$smarty.now|date_format:"%d.%m.%Y"}{/if}" id="date_send_to" value="{if $POST.date_send_to!=''}{$POST.date_send_to}{else}{$smarty.now|date_format:"%d.%m.%Y"}{/if}"
name="date_send_to" autocomplete="off"> id="date_send_to" name="date_send_to" autocomplete="off">
<img align="absmiddle" border="0" id="date_send_to_trigger" name="date_send_to_trigger" alt="Enter Date" <img align="absmiddle" border="0" id="date_send_to_trigger" name="date_send_to_trigger" alt="Enter Date"
src="themes/default/images/jscalendar.gif"> src="themes/default/images/jscalendar.gif">
<script type="text/javascript"> <script type="text/javascript">
{literal} {literal}
// musi być tu w pliku js nie chce działać // musi być tu w pliku js nie chce działać
Calendar.setup({ Calendar.setup({
inputField: "date_send_to", inputField: "date_send_to",
daFormat: "%d.%m.%Y", daFormat: "%d.%m.%Y",
button: "date_send_to_trigger", button: "date_send_to_trigger",
@@ -65,8 +63,7 @@
dateStr: "", dateStr: "",
step: 1, step: 1,
weekNumbers: false weekNumbers: false
} });
);
{/literal} {/literal}
</script> </script>
</td> </td>
@@ -74,7 +71,8 @@
<td rowspan="2"> <td rowspan="2">
<select id="sale_type" name="sale_type[]" multiple="true"> <select id="sale_type" name="sale_type[]" multiple="true">
{foreach from=$SALE_TYPES key="key" item="value" name="sale_types"} {foreach from=$SALE_TYPES key="key" item="value" name="sale_types"}
<option {if in_array($key, $SELECTED_TYPES)}selected="selected" {/if} value="{$key}">{$value}</option> <option {if in_array($key, $SELECTED_TYPES)}selected="selected" {/if} value="{$key}">{$value}
</option>
{/foreach} {/foreach}
</select> </select>
</td> </td>
@@ -82,7 +80,8 @@
<td rowspan="2"> <td rowspan="2">
<select id="sale_status" name="sale_status[]" multiple="true"> <select id="sale_status" name="sale_status[]" multiple="true">
{foreach from=$SALE_STATUSES key="key" item="value" name="sale_statuses"} {foreach from=$SALE_STATUSES key="key" item="value" name="sale_statuses"}
<option {if in_array($key, $SELECTED_STATUSES)}selected="selected" {/if} value="{$key}">{$value}</option> <option {if in_array($key, $SELECTED_STATUSES)}selected="selected" {/if} value="{$key}">{$value}
</option>
{/foreach} {/foreach}
</select> </select>
</td> </td>
@@ -91,17 +90,17 @@
</td> </td>
<td nowrap=""> <td nowrap="">
<input type="text" title="" value="{if $POST.account_name!=''}{$POST.account_name}{/if}" size="" <input type="text" title="" value="{if $POST.account_name!=''}{$POST.account_name}{/if}" size=""
id="account_name" tabindex="" name="account_name"> id="account_name" tabindex="" name="account_name">
<input type="hidden" value="{if $POST.account_id!=''}{$POST.account_id}{/if}" id="account_id" <input type="hidden" value="{if $POST.account_id!=''}{$POST.account_id}{/if}" id="account_id"
name="account_id"> name="account_id">
<input type="button" <input type="button"
onclick="{literal}open_popup(&quot;Accounts&quot;, 600, 400, &quot;&quot;, true, false, {&quot;call_back_function&quot;:&quot;set_return&quot;,&quot;form_name&quot;:&quot;SearchFormListNewSales&quot;,&quot;field_to_name_array&quot;:{&quot;id&quot;:&quot;account_id&quot;,&quot;name&quot;:&quot;account_name&quot;}}, &quot;single&quot;, true);{/literal}" onclick="{literal}open_popup(&quot;Accounts&quot;, 600, 400, &quot;&quot;, true, false, {&quot;call_back_function&quot;:&quot;set_return&quot;,&quot;form_name&quot;:&quot;SearchFormListNewSales&quot;,&quot;field_to_name_array&quot;:{&quot;id&quot;:&quot;account_id&quot;,&quot;name&quot;:&quot;account_name&quot;}}, &quot;single&quot;, true);{/literal}"
value="Wybierz" class="button" accesskey="T" title="Select [Alt+T]" tabindex="" value="Wybierz" class="button" accesskey="T" title="Select [Alt+T]" tabindex=""
name="btn_account_name"> name="btn_account_name">
<button value="Wyczyść" onclick="this.form.account_name.value = ''; this.form.account_id.value = '';" <button value="Wyczyść" onclick="this.form.account_name.value = ''; this.form.account_id.value = '';"
class="button lastChild" accesskey="C" title="Wyczyść[Alt+C]" tabindex="" class="button lastChild" accesskey="C" title="Wyczyść[Alt+C]" tabindex=""
name="btn_clr_parent_name_basic" type="button"><img name="btn_clr_parent_name_basic" type="button"><img
src="themes/default/images/id-ff-clear.png?s=bed8cd35065048ceebdc639ebe305e2c&amp;c=1"> src="themes/default/images/id-ff-clear.png?s=bed8cd35065048ceebdc639ebe305e2c&amp;c=1">
</button> </button>
</td> </td>
@@ -118,14 +117,14 @@
</td> </td>
<td nowrap=""> <td nowrap="">
<input type="text" maxlength="10" size="11" tabindex="" title="" <input type="text" maxlength="10" size="11" tabindex="" title=""
value="{if $POST.date_from!=''}{$POST.date_from}{/if}" value="{if $POST.date_from!=''}{$POST.date_from}{/if}" id="date_from" name="date_from"
id="date_from" name="date_from" autocomplete="off"> autocomplete="off">
<img align="absmiddle" border="0" id="date_from_trigger" name="date_from_trigger" alt="Enter Date" <img align="absmiddle" border="0" id="date_from_trigger" name="date_from_trigger" alt="Enter Date"
src="themes/default/images/jscalendar.gif"> src="themes/default/images/jscalendar.gif">
<script type="text/javascript"> <script type="text/javascript">
{literal} {literal}
// musi być tu w pliku js nie chce działać // musi być tu w pliku js nie chce działać
Calendar.setup({ Calendar.setup({
inputField: "date_from", inputField: "date_from",
daFormat: "%d.%m.%Y", daFormat: "%d.%m.%Y",
button: "date_from_trigger", button: "date_from_trigger",
@@ -133,20 +132,18 @@
dateStr: "", dateStr: "",
step: 1, step: 1,
weekNumbers: false weekNumbers: false
} });
);
{/literal} {/literal}
</script> </script>
do: do:
<input type="text" maxlength="10" size="11" tabindex="" title="" <input type="text" maxlength="10" size="11" tabindex="" title=""
value="{if $POST.date_to!=''}{$POST.date_to}{/if}" value="{if $POST.date_to!=''}{$POST.date_to}{/if}" id="date_to" name="date_to" autocomplete="off">
id="date_to" name="date_to" autocomplete="off">
<img align="absmiddle" border="0" id="date_to_trigger" name="date_to_trigger" alt="Enter Date" <img align="absmiddle" border="0" id="date_to_trigger" name="date_to_trigger" alt="Enter Date"
src="themes/default/images/jscalendar.gif"> src="themes/default/images/jscalendar.gif">
<script type="text/javascript"> <script type="text/javascript">
{literal} {literal}
// musi być tu w pliku js nie chce działać // musi być tu w pliku js nie chce działać
Calendar.setup({ Calendar.setup({
inputField: "date_to", inputField: "date_to",
daFormat: "%d.%m.%Y", daFormat: "%d.%m.%Y",
button: "date_to_trigger", button: "date_to_trigger",
@@ -154,8 +151,7 @@
dateStr: "", dateStr: "",
step: 1, step: 1,
weekNumbers: false weekNumbers: false
} });
);
{/literal} {/literal}
</script> </script>
</td> </td>
@@ -164,169 +160,180 @@
</td> </td>
<td nowrap=""> <td nowrap="">
<input type="text" value="{if $POST.parent_order_no!=''}{$POST.parent_order_no}{/if}" <input type="text" value="{if $POST.parent_order_no!=''}{$POST.parent_order_no}{/if}"
name="parent_order_no"> name="parent_order_no">
</td> </td>
</tr> </tr>
</table> </table>
<h3 style="color:red">{if $POST.date_send_from!='' && $POST.date_from!=''}Proszę wybrać date dostawy lub datę wysyłki{/if}</h3> <h3 style="color:red">{if $POST.date_send_from!='' && $POST.date_from!=''}Proszę wybrać date dostawy lub datę
wysyłki{/if}</h3>
<input type="hidden" id="idss" value=""> <input type="hidden" id="idss" value="">
<input type="submit" value="{$MOD.LBL_LISTNEWSALES_POST}" name="submit" class="button"> <input type="submit" value="{$MOD.LBL_LISTNEWSALES_POST}" name="submit" class="button">
<input type="button" onclick="location.href='index.php?module=EcmSales&amp;action=ListNewSales';" <input type="button" onclick="location.href='index.php?module=EcmSales&amp;action=ListNewSales';"
value="{$MOD.LBL_LISTNEWSALES_CLEAR}" name="clear" class="button"> value="{$MOD.LBL_LISTNEWSALES_CLEAR}" name="clear" class="button">
<input type="button" id="gets" class="button" name="gets" value="{$MOD.LBL_LISTNEWSALES_CREATE_PDFS}" <input type="button" id="gets" class="button" name="gets" value="{$MOD.LBL_LISTNEWSALES_CREATE_PDFS}"
onclick="createMultiPdf()"> onclick="createMultiPdf()">
<input type="button" id="products_list" class="button" name="products_list" <input type="button" id="products_list" class="button" name="products_list"
value="{$MOD.LBL_LISTNEWSALES_PRODUCT_SUMMARY}" onclick="getSelected(); getList();"> value="{$MOD.LBL_LISTNEWSALES_PRODUCT_SUMMARY}" onclick="getSelected(); getList();">
<input type="button" id="products_list" class="button" name="products_list" <input type="button" id="products_list" class="button" name="products_list"
value="{$MOD.LBL_LISTNEWSALES_PRODUCT_SUMMARY} 2" onclick="getSelected(); getList2();"> value="{$MOD.LBL_LISTNEWSALES_PRODUCT_SUMMARY} 2" onclick="getSelected(); getList2();">
<input type="button" id="products_list" class="button" name="products_list" value="Lista komponentów" <input type="button" id="products_list" class="button" name="products_list" value="Lista komponentów"
onclick="getSelected(); getList3();"> onclick="getSelected(); getList3();">
<br>{if $LINK!=''}<a href="https://95.50.148.50/crm/pdftmp/{$LINK}">{$LINK}</a>{/if} <br>{if $LINK!=''}<a href="https://95.50.148.50/crm/pdftmp/{$LINK}">{$LINK}</a>{/if}
<table cellspacing="0" cellpadding="0" border="0" style="width:100%;" id="myTable" class="tablesorter"> <table cellspacing="0" cellpadding="0" border="0" style="width:100%;" id="myTable" class="tablesorter">
<thead> <thead>
<tr> <tr>
<th><input type="checkbox" name="selectall" id="selectall"></th> <th><input type="checkbox" name="selectall" id="selectall"></th>
<th>{$MOD.LBL_LISTNEWSALES_POS}</th> <th>{$MOD.LBL_LISTNEWSALES_POS}</th>
<th>{$MOD.LBL_LISTNEWSALES_NUMBER}</th> <th>{$MOD.LBL_LISTNEWSALES_NUMBER}</th>
<th>{$MOD.LBL_LISTNEWSALES_DESCRIPTION}</th> <th>{$MOD.LBL_LISTNEWSALES_DESCRIPTION}</th>
<th>{$MOD.LBL_LISTNEWSALES_PARENT_NAME}</th> <th>{$MOD.LBL_LISTNEWSALES_PARENT_NAME}</th>
<th>{$MOD.LBL_LISTNEWSALES_DELIVERY_DATE}</th> <th>{$MOD.LBL_LISTNEWSALES_DELIVERY_DATE}</th>
<th></th> <th></th>
<th>Termin wysyłki</th> <th>Termin wysyłki</th>
<th>{$MOD.LBL_LISTNEWSALES_QUANTITY}</th> <th>{$MOD.LBL_LISTNEWSALES_QUANTITY}</th>
<th>{$MOD.LBL_LISTNEWSALES_TOTAL_NETTO}</th> <th>{$MOD.LBL_LISTNEWSALES_TOTAL_NETTO}</th>
<th>{$MOD.LBL_LISTNEWSALES_TOTAL_VAT}</th> <th>{$MOD.LBL_LISTNEWSALES_TOTAL_VAT}</th>
<th>{$MOD.LBL_LISTNEWSALES_TOTAL_BRUTTO}</th> <th>{$MOD.LBL_LISTNEWSALES_TOTAL_BRUTTO}</th>
<th>{$MOD.LBL_LISTNEWSALES_TOTAL_INVOICE}</th> <th>{$MOD.LBL_LISTNEWSALES_TOTAL_INVOICE}</th>
<th>{$MOD.LBL_LISTNEWSALES_PERCENT}</th> <th>{$MOD.LBL_LISTNEWSALES_PERCENT}</th>
<th>{$MOD.LBL_LISTNEWSALES_CURRENCY}</th> <th>{$MOD.LBL_LISTNEWSALES_CURRENCY}</th>
<th>{$MOD.LBL_LISTNEWSALES_PRINTED}</th> <th>{$MOD.LBL_LISTNEWSALES_PRINTED}</th>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{foreach from=$POSITION_LIST key="key" item="item" name="components"} {foreach from=$POSITION_LIST key="key" item="item" name="components"}
{if $item.id!=''} {if $item.id!=''}
<tr style="vertical-align:top;"> <tr style="vertical-align:top;">
<td><input type="checkbox" value="{$item.id}" class="make_pdf" id="make_pdf_{$item.position}" <td><input type="checkbox" value="{$item.id}" class="make_pdf" id="make_pdf_{$item.position}"
name="selectedid[]"></td> name="selectedid[]"></td>
<td>{$item.position}</td> <td>{$item.position}</td>
<td data-price="{$item.number}"><a <td data-price="{$item.number}"><a
href="index.php?module=EcmSales&action=DetailView&record={$item.id}">{$item.document_no}</a> href="index.php?module=EcmSales&action=DetailView&record={$item.id}">{$item.document_no}</a>
</td> </td>
<td></td> <td></td>
<td> <td>
<a href="index.php?module=Accounts&action=DetailView&record={$item.parent_id}">{$item.parent_name}</a> <a
</td> href="index.php?module=Accounts&action=DetailView&record={$item.parent_id}">{$item.parent_name}</a>
<td>{$item.delivery_date}</td> {if $item.delivery_name}
<td><input type="checkbox" {if $item.send_accepted==true}checked="checked" {/if} {if $item.delivery_id}
disabled="disabled"></td> &nbsp;(<a
<td>{$item.send_date} </td> href="index.php?module=Accounts&action=DetailView&record={$item.delivery_id}">{$item.delivery_name}</a>)
<td style="text-align: right">{$item.quantity}</td> {else}
<td data-total="{$item.total_netto}" &nbsp;({$item.delivery_name})
style="text-align: right">{$item.total_netto|number_format:2:".":","}</td> {/if}
<td data-total="{$item.total_vat}" {/if}
style="text-align: right">{$item.total_vat|number_format:2:".":","}</td> </td>
<td data-total="{$item.total_brutto}" <td>{$item.delivery_date}</td>
style="text-align: right">{$item.total_brutto|number_format:2:".":","}</td> <td><input type="checkbox" {if $item.send_accepted==true}checked="checked" {/if} disabled="disabled">
<td data-total="{$item.total_invoice}" </td>
style="text-align: right">{$item.total_invoice|number_format:2:".":","}</td> <td>{$item.send_date} </td>
<td style="text-align: right">{$item.percent}<a style="cursor:pointer;" <td style="text-align: right">{$item.quantity}</td>
onclick="{literal}if(document.getElementById('div{/literal}{$item.id}{literal}').style.display=='none'){document.getElementById('div{/literal}{$item.id}{literal}').style.display='block';}else{document.getElementById('{/literal}div{$item.id}{literal}').style.display='none';}{/literal} "><img <td data-total="{$item.total_netto}" style="text-align: right">
{$item.total_netto|number_format:2:".":","}</td>
<td data-total="{$item.total_vat}" style="text-align: right">{$item.total_vat|number_format:2:".":","}
</td>
<td data-total="{$item.total_brutto}" style="text-align: right">
{$item.total_brutto|number_format:2:".":","}</td>
<td data-total="{$item.total_invoice}" style="text-align: right">
{$item.total_invoice|number_format:2:".":","}</td>
<td style="text-align: right">{$item.percent}<a style="cursor:pointer;"
onclick="{literal}if(document.getElementById('div{/literal}{$item.id}{literal}').style.display=='none'){document.getElementById('div{/literal}{$item.id}{literal}').style.display='block';}else{document.getElementById('{/literal}div{$item.id}{literal}').style.display='none';}{/literal} "><img
border="0" src="modules/EcmQuotes/images/search.gif"></a> border="0" src="modules/EcmQuotes/images/search.gif"></a>
<div style="display:none; border: 1px solid #cccccc;background-color:#e6e6e6;padding:3px;" <div style="display:none; border: 1px solid #cccccc;background-color:#e6e6e6;padding:3px;"
id="div{$item.id}"> id="div{$item.id}">
<table cellspacing="0" cellpadding="3" border="0"> <table cellspacing="0" cellpadding="3" border="0">
<tbody> <tbody>
<tr> <tr>
<td width="40%"><strong>Index</strong></td> <td width="40%"><strong>Index</strong></td>
<td><strong>Order</strong></td> <td><strong>Order</strong></td>
<td><strong>WZ</strong></td> <td><strong>WZ</strong></td>
<td><strong>ETA</strong></td> <td><strong>ETA</strong></td>
</tr>
{foreach from=$item.products key="ki" item="va" name="products"}
{if $va.code!=''}
<tr style="color:black;">
<td style="color:black;"><a
href="index.php?module=EcmProducts&amp;action=DetailView&amp;record={$va.id}">{$va.code}</a>
</td>
{if $va.order>$va.wz}
<td style="color:red;">{$va.order|number_format:2:".":","}</td>
<td style="color:red;">{$va.wz|number_format:2:".":","}</td>
{else}
<td style="color:black;">{$va.order|number_format:2:".":","}</td>
<td style="color:black;">{$va.wz|number_format:2:".":","}</td>
{/if}
<td style="color:black;"></td>
</tr> </tr>
{/if} {foreach from=$item.products key="ki" item="va" name="products"}
{/foreach} {if $va.code!=''}
<tr style="color:black;">
<td style="color:black;"><a
href="index.php?module=EcmProducts&amp;action=DetailView&amp;record={$va.id}">{$va.code}</a>
</td>
{if $va.order>$va.wz}
<td style="color:red;">{$va.order|number_format:2:".":","}</td>
<td style="color:red;">{$va.wz|number_format:2:".":","}</td>
{else}
<td style="color:black;">{$va.order|number_format:2:".":","}</td>
<td style="color:black;">{$va.wz|number_format:2:".":","}</td>
{/if}
<td style="color:black;"></td>
</tr>
{/if}
{/foreach}
<tr style="color:black;font-weight:bold"> <tr style="color:black;font-weight:bold">
<td>Total</td> <td>Total</td>
<td>{$item.products.order_total|number_format:2:".":","}</td> <td>{$item.products.order_total|number_format:2:".":","}</td>
<td>{$item.products.wz_total|number_format:2:".":","}</td> <td>{$item.products.wz_total|number_format:2:".":","}</td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td></td> <td></td>
<td> <td>
<span style="color:red;font-weight:bold">{$item.products.minus|number_format:2:".":","}</span> <span
</td> style="color:red;font-weight:bold">{$item.products.minus|number_format:2:".":","}</span>
</tr> </td>
<tr> </tr>
<td></td> <tr>
<td></td> <td></td>
<td> <td></td>
<span style="color:green;font-weight:bold">{$item.products.plus|number_format:2:".":","}</span> <td>
</td> <span
</tr> style="color:green;font-weight:bold">{$item.products.plus|number_format:2:".":","}</span>
</tbody> </td>
</table> </tr>
</div> </tbody>
</td> </table>
<td style="text-align: right">{$CURRENCIES[$item.currency]}</td> </div>
<td></td> </td>
<td> <td style="text-align: right">{$CURRENCIES[$item.currency]}</td>
{if $item.type!='gratis'} <td></td>
{if $item.fv_switch=='yes'}<img border="0" id="convert_to_invoice_{$item.id}" <td>
src="modules/EcmSales/images/convert_disabled.gif" {if $item.type!='gratis'}
title="{$item.fv_name}" style="cursor:pointer;" {if $item.fv_switch=='yes'}<img border="0" id="convert_to_invoice_{$item.id}"
onClick="{literal}javascript:window.open('index.php?module=EcmInvoiceOuts&action=DetailView&record={/literal}{$item.fv_id}{literal}','_newtab');{/literal} " />'{/if} src="modules/EcmSales/images/convert_disabled.gif" title="{$item.fv_name}"
{if $item.fv_switch=='no'}<img border="0" id="convert_to_invoice_{$item.id}" style="cursor:pointer;"
src="modules/EcmSales/images/convert_enabled.gif" onClick="{literal}javascript:window.open('index.php?module=EcmInvoiceOuts&action=DetailView&record={/literal}{$item.fv_id}{literal}','_newtab');{/literal} " />'{/if}
title="Create Invoice" {if $item.fv_switch=='no'}<img border="0" id="convert_to_invoice_{$item.id}"
onClick="{literal}javascript:window.open('index.php?module=EcmInvoiceOuts&action=EditView&isWZ=true&wz_record={/literal}{$item.fv_id}{literal}','_newtab');{/literal}" src="modules/EcmSales/images/convert_enabled.gif" title="Create Invoice"
style="cursor:pointer;" />{/if} onClick="{literal}javascript:window.open('index.php?module=EcmInvoiceOuts&action=EditView&isWZ=true&wz_record={/literal}{$item.fv_id}{literal}','_newtab');{/literal}"
{if $item.wz_switch=='disabled'}<img src="modules/EcmSales/images/create_wz_disabled.gif" style="cursor:pointer;" />{/if}
title="{$item.wz_name}" {if $item.wz_switch=='disabled'}<img src="modules/EcmSales/images/create_wz_disabled.gif"
onclick="{literal}window.open('index.php?module=EcmStockDocOuts&action=DetailView&record={/literal}{$item.wz_id}{literal}','_newtab');{/literal}" title="{$item.wz_name}"
style="cursor: pointer;" border="0">&nbsp;{/if} onclick="{literal}window.open('index.php?module=EcmStockDocOuts&action=DetailView&record={/literal}{$item.wz_id}{literal}','_newtab');{/literal}"
{if $item.wz_switch=='enabled'}<img src="modules/EcmSales/images/create_wz_enabled.gif" style="cursor: pointer;" border="0">&nbsp;{/if}
title="{$MOD.LBL_LISTNEWSALES_CREATEWZ}" {if $item.wz_switch=='enabled'}<img src="modules/EcmSales/images/create_wz_enabled.gif"
onclick="{literal}javascript:window.open('index.php?module=EcmStockDocOuts&amp;action=EditView&parent_doc_type=EcmSales&parent_doc_id={/literal}{$item.id}{literal}','_newtab');{/literal}" title="{$MOD.LBL_LISTNEWSALES_CREATEWZ}"
style="cursor: pointer;" border="0">{/if} onclick="{literal}javascript:window.open('index.php?module=EcmStockDocOuts&amp;action=EditView&parent_doc_type=EcmSales&parent_doc_id={/literal}{$item.id}{literal}','_newtab');{/literal}"
{else} style="cursor: pointer;" border="0">{/if}
{if $item.rw_switch=='disabled'}<img src="modules/EcmSales/images/create_wz_disabled.gif" {else}
title="{$item.rw_name}" {if $item.rw_switch=='disabled'}<img src="modules/EcmSales/images/create_wz_disabled.gif"
onclick="{literal}window.open('index.php?module=EcmStockDocInsideOuts&action=DetailView&record={/literal}{$item.rw_id}{literal}','_newtab');{/literal}" title="{$item.rw_name}"
style="cursor: pointer;" border="0">&nbsp;{/if} onclick="{literal}window.open('index.php?module=EcmStockDocInsideOuts&action=DetailView&record={/literal}{$item.rw_id}{literal}','_newtab');{/literal}"
{if $item.rw_switch=='enabled'}<img src="modules/EcmSales/images/create_wz_enabled.gif" style="cursor: pointer;" border="0">&nbsp;{/if}
title="{$MOD.LBL_LISTNEWSALES_CREATERW}" {if $item.rw_switch=='enabled'}<img src="modules/EcmSales/images/create_wz_enabled.gif"
onclick="{literal}javascript:window.open('index.php?module=EcmStockDocInsideOuts&amp;action=EditView&parent_doc_type=EcmSales&parent_doc_id={/literal}{$item.id}{literal}','_newtab');{/literal}" title="{$MOD.LBL_LISTNEWSALES_CREATERW}"
style="cursor: pointer;" border="0">{/if} onclick="{literal}javascript:window.open('index.php?module=EcmStockDocInsideOuts&amp;action=EditView&parent_doc_type=EcmSales&parent_doc_id={/literal}{$item.id}{literal}','_newtab');{/literal}"
{/if} style="cursor: pointer;" border="0">{/if}
<img src="modules/EcmSales/images/pdf.gif" title="Preview Sale" {/if}
onclick="{literal}EcmPreviewPDF('index.php?module=EcmSales&action=previewPDF&method=I&record={$item.id}&to_pdf=1',{zoom:75,toolbar:1});{/literal}" <img src="modules/EcmSales/images/pdf.gif" title="Preview Sale"
style="cursor: pointer;" border="0"> onclick="{literal}EcmPreviewPDF('index.php?module=EcmSales&action=previewPDF&method=I&record={$item.id}&to_pdf=1',{zoom:75,toolbar:1});{/literal}"
</td> style="cursor: pointer;" border="0">
</tr> </td>
</tr>
{/if} {/if}
{/foreach} {/foreach}
</tbody> </tbody>
<tr style="vertical-align:top;"> <tr style="vertical-align:top;">
<td></td> <td></td>
@@ -343,56 +350,58 @@
<td style="text-align: right">{$POSITION_LIST.total_brutto|number_format:2:".":","}</td> <td style="text-align: right">{$POSITION_LIST.total_brutto|number_format:2:".":","}</td>
<td style="text-align: right">{$POSITION_LIST.total_invoice|number_format:2:".":","}</td> <td style="text-align: right">{$POSITION_LIST.total_invoice|number_format:2:".":","}</td>
<td style="text-align: right">{$POSITION_LIST.total_percent|string_format:"%.2f"}%<a style="cursor:pointer;" <td style="text-align: right">{$POSITION_LIST.total_percent|string_format:"%.2f"}%<a style="cursor:pointer;"
onclick="{literal}if(document.getElementById('div_all').style.display=='none'){document.getElementById('div_all').style.display='block';}else{document.getElementById('div_all').style.display='none';}{/literal}"><img onclick="{literal}if(document.getElementById('div_all').style.display=='none'){document.getElementById('div_all').style.display='block';}else{document.getElementById('div_all').style.display='none';}{/literal}"><img
border="0" src="modules/EcmQuotes/images/search.gif"></a> border="0" src="modules/EcmQuotes/images/search.gif"></a>
<div style="display:none; border: 1px solid #cccccc;background-color:#e6e6e6;padding:3px;" id="div_all"> <div style="display:none; border: 1px solid #cccccc;background-color:#e6e6e6;padding:3px;" id="div_all">
<table cellspacing="0" cellpadding="3" border="0"> <table cellspacing="0" cellpadding="3" border="0">
<tbody> <tbody>
<tr> <tr>
<td width="40%"><strong>Index</strong></td> <td width="40%"><strong>Index</strong></td>
<td><strong>Order</strong></td> <td><strong>Order</strong></td>
<td><strong>WZ</strong></td> <td><strong>WZ</strong></td>
<td><strong>ETA</strong></td> <td><strong>ETA</strong></td>
{foreach from=$POSITION_LIST.total_product key="ki" item="va" name="products"} {foreach from=$POSITION_LIST.total_product key="ki" item="va" name="products"}
{if $va.code!=''} {if $va.code!=''}
<tr style="color:black;"> <tr style="color:black;">
<td style="color:black;"><a <td style="color:black;"><a
href="index.php?module=EcmProducts&amp;action=DetailView&amp;record={$va.id}">{$va.code}</a> href="index.php?module=EcmProducts&amp;action=DetailView&amp;record={$va.id}">{$va.code}</a>
</td> </td>
{if $va.order>$va.wz} {if $va.order>$va.wz}
<td style="color:red;">{$va.order|number_format:2:".":","}</td> <td style="color:red;">{$va.order|number_format:2:".":","}</td>
<td style="color:red;">{$va.wz|number_format:2:".":","}</td> <td style="color:red;">{$va.wz|number_format:2:".":","}</td>
{else} {else}
<td style="color:black;">{$va.order|number_format:2:".":","}</td> <td style="color:black;">{$va.order|number_format:2:".":","}</td>
<td style="color:black;">{$va.wz|number_format:2:".":","}</td> <td style="color:black;">{$va.wz|number_format:2:".":","}</td>
{/if} {/if}
<td style="color:black;"></td> <td style="color:black;"></td>
</tr> </tr>
{/if} {/if}
{/foreach} {/foreach}
<tr style="color:black;font-weight:bold"> <tr style="color:black;font-weight:bold">
<td>Total</td> <td>Total</td>
<td>{$POSITION_LIST.total_product.order_total|number_format:2:".":","}</td> <td>{$POSITION_LIST.total_product.order_total|number_format:2:".":","}</td>
<td>{$POSITION_LIST.total_product.wz_total|number_format:2:".":","}</td> <td>{$POSITION_LIST.total_product.wz_total|number_format:2:".":","}</td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td></td> <td></td>
<td> <td>
<span style="color:red;font-weight:bold">{$POSITION_LIST.total_product.minus|number_format:2:".":","}</span> <span
</td> style="color:red;font-weight:bold">{$POSITION_LIST.total_product.minus|number_format:2:".":","}</span>
</tr> </td>
<tr> </tr>
<td></td> <tr>
<td></td> <td></td>
<td> <td></td>
<span style="color:green;font-weight:bold">{$POSITION_LIST.total_product.plus|number_format:2:".":","}</span> <td>
</td> <span
</tr> style="color:green;font-weight:bold">{$POSITION_LIST.total_product.plus|number_format:2:".":","}</span>
</tbody> </td>
</table> </tr>
</div> </tbody>
</table>
</div>
</table> </table>

View File

@@ -8,6 +8,7 @@
</tr> </tr>
</table> </table>
<br /> <br />
<form style="display:none;" action="index.php?module=EcmSales&action=ProductSummary" method="post" <form style="display:none;" action="index.php?module=EcmSales&action=ProductSummary" method="post"
name="SearchFormListNewSales"> name="SearchFormListNewSales">
<ul class="tablist" style="width:100%;"> <ul class="tablist" style="width:100%;">
@@ -166,7 +167,11 @@
<input type="hidden" value="{$IDS}" name='ids' id='ids'> <input type="hidden" value="{$IDS}" name='ids' id='ids'>
</form> </form>
<form action="index.php?module=EcmInsideOrders&action=EditView&fromProductionScheduler=true" method="post"
target="_blank" id="createInsideOrderForm">
<input id="insideOrderProducts" name="insideOrderProducts" type="hidden" value=""/>
</form>
<input class="button" value="Utwórz przyjęcie produkcyjne" type="button" id="createInsideOrder"/>
<table cellspacing="0" cellpadding="0" style="width:100%;" id="myTable" class="tablesorter"> <table cellspacing="0" cellpadding="0" style="width:100%;" id="myTable" class="tablesorter">
<thead> <thead>
<tr> <tr>
@@ -184,8 +189,11 @@
{foreach from=$POSITION_LIST key="key" item="item" name="components"} {foreach from=$POSITION_LIST key="key" item="item" name="components"}
{if $item.id!=''} {if $item.id!=''}
<tr style="vertical-align:top;"> <tr style="vertical-align:top;">
<td style="text-align:center;"><input type="checkbox" value="{$item.id}" class="make_pdf" <td style="text-align:center;"><input type="checkbox" value="{$item.id}"
id="make_pdf_{$item.position}" name="selectedid[]"></td> id="make_pdf_{$item.position}" name="selectedid[]" class="allCheck">
<input id="qtyInput-{$item.id}" value="{$item.quantity-$item.stock}" style="width: 50px; display: none;"
type="number"/>
</td>
<td>{$item.code}</td> <td>{$item.code}</td>
<td>{$item.name}</td> <td>{$item.name}</td>
<td>{$item.product_category_name}</td> <td>{$item.product_category_name}</td>