Merge branch 'main' of ssh://code.bim-it.pl:2222/mz/crm.twinpol.com
This commit is contained in:
@@ -323,85 +323,97 @@ function createCSVReports()
|
|||||||
$jobs = [
|
$jobs = [
|
||||||
[
|
[
|
||||||
'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 'Usługi'
|
WHEN '3' THEN 'Usługi'
|
||||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||||
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
|
COALESCE(cur.name, 'PLN') 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 currencies AS cur ON cur.id = i.currency_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
|
||||||
|
ON ii.ecmproduct_id = p.id
|
||||||
|
AND p.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.bean_name = 'EcmProducts'
|
||||||
AND cb.deleted = 0
|
AND cb.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
LEFT JOIN ecmproductcategories AS c
|
||||||
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2024
|
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,
|
ORDER BY
|
||||||
p.code,
|
i.register_date DESC;
|
||||||
p.name,
|
|
||||||
p.group_ks,
|
|
||||||
ii.quantity,
|
|
||||||
ii.price_netto
|
|
||||||
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 'Usługi'
|
WHEN '3' THEN 'Usługi'
|
||||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||||
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
|
COALESCE(cur.name, 'PLN') 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 currencies AS cur ON cur.id = i.currency_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
|
||||||
|
ON ii.ecmproduct_id = p.id
|
||||||
|
AND p.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.bean_name = 'EcmProducts'
|
||||||
AND cb.deleted = 0
|
AND cb.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
LEFT JOIN ecmproductcategories AS c
|
||||||
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2025
|
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,
|
ORDER BY
|
||||||
p.code,
|
i.register_date DESC;
|
||||||
p.name,
|
|
||||||
p.group_ks,
|
|
||||||
ii.quantity,
|
|
||||||
ii.price_netto
|
|
||||||
ORDER BY i.register_date DESC;
|
|
||||||
",
|
",
|
||||||
'filename' => 'invoices_2025.csv',
|
'filename' => 'invoices_2025.csv',
|
||||||
], // invoices 2025
|
], // invoices 2025
|
||||||
@@ -416,40 +428,37 @@ 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 'Usługi'
|
WHEN '3' THEN 'Usługi'
|
||||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
|
||||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
|
||||||
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
|
COALESCE(cur.name, 'PLN') 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 AND ii.deleted = 0
|
||||||
INNER JOIN ecminvoiceouts AS oi ON oi.id = i.ecminvoiceout_id
|
INNER JOIN ecmproducts AS p
|
||||||
INNER JOIN currencies AS cur ON cur.id = i.currency_id
|
ON ii.ecmproduct_id = p.id AND p.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
LEFT JOIN ecminvoiceouts AS oi
|
||||||
|
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.bean_name = 'EcmProducts'
|
||||||
AND cb.deleted = 0
|
AND cb.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
LEFT JOIN ecmproductcategories AS c
|
||||||
WHERE i.type = 'correct' AND YEAR(i.register_date) = 2024
|
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,
|
|
||||||
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_2024.csv',
|
'filename' => 'correct_invoices_2024.csv',
|
||||||
@@ -465,40 +474,37 @@ 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 'Usługi'
|
WHEN '3' THEN 'Usługi'
|
||||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
|
||||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
|
||||||
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
|
COALESCE(cur.name, 'PLN') 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 AND ii.deleted = 0
|
||||||
INNER JOIN ecminvoiceouts AS oi ON oi.id = i.ecminvoiceout_id
|
INNER JOIN ecmproducts AS p
|
||||||
INNER JOIN currencies AS cur ON cur.id = i.currency_id
|
ON ii.ecmproduct_id = p.id AND p.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
LEFT JOIN ecminvoiceouts AS oi
|
||||||
|
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.bean_name = 'EcmProducts'
|
||||||
AND cb.deleted = 0
|
AND cb.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
LEFT JOIN ecmproductcategories AS c
|
||||||
WHERE i.type = 'correct' AND YEAR(i.register_date) = 2025
|
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',
|
||||||
@@ -512,33 +518,37 @@ 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 'Usługi'
|
WHEN '3' THEN 'Usługi'
|
||||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||||
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,
|
||||||
ii.quantity,
|
ii.quantity,
|
||||||
ii.price_netto
|
ii.price_netto
|
||||||
FROM ecommerce_invoices AS i
|
FROM ecommerce_invoices AS i
|
||||||
INNER JOIN ecommerce_invoices_products AS ii ON i.id = ii.invoice_id
|
INNER JOIN ecommerce_invoices_products AS ii
|
||||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
ON i.id = ii.invoice_id
|
||||||
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
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
cb.bean_id AS product_id,
|
||||||
|
GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category
|
||||||
|
FROM ecmproductcategories_bean AS cb
|
||||||
|
INNER JOIN ecmproductcategories AS c
|
||||||
|
ON c.id = cb.ecmproductcategory_id
|
||||||
|
AND c.deleted = 0
|
||||||
|
WHERE cb.bean_name = 'EcmProducts'
|
||||||
AND cb.deleted = 0
|
AND cb.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
GROUP BY cb.bean_id
|
||||||
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2024
|
) AS pc
|
||||||
GROUP BY
|
ON pc.product_id = p.id
|
||||||
i.document_no,
|
WHERE i.type = 'normal'
|
||||||
i.register_date,
|
AND i.register_date >= '2024-01-01'
|
||||||
i.parent_name,
|
AND i.register_date < '2025-01-01'
|
||||||
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' => 'ecommerce_invoices_2024.csv',
|
'filename' => 'ecommerce_invoices_2024.csv',
|
||||||
@@ -552,33 +562,37 @@ 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 'Usługi'
|
WHEN '3' THEN 'Usługi'
|
||||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||||
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,
|
||||||
ii.quantity,
|
ii.quantity,
|
||||||
ii.price_netto
|
ii.price_netto
|
||||||
FROM ecommerce_invoices AS i
|
FROM ecommerce_invoices AS i
|
||||||
INNER JOIN ecommerce_invoices_products AS ii ON i.id = ii.invoice_id
|
INNER JOIN ecommerce_invoices_products AS ii
|
||||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
ON i.id = ii.invoice_id
|
||||||
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
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
cb.bean_id AS product_id,
|
||||||
|
GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category
|
||||||
|
FROM ecmproductcategories_bean AS cb
|
||||||
|
INNER JOIN ecmproductcategories AS c
|
||||||
|
ON c.id = cb.ecmproductcategory_id
|
||||||
|
AND c.deleted = 0
|
||||||
|
WHERE cb.bean_name = 'EcmProducts'
|
||||||
AND cb.deleted = 0
|
AND cb.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
GROUP BY cb.bean_id
|
||||||
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2025
|
) AS pc
|
||||||
GROUP BY
|
ON pc.product_id = p.id
|
||||||
i.document_no,
|
WHERE i.type = 'normal'
|
||||||
i.register_date,
|
AND i.register_date >= '2025-01-01'
|
||||||
i.parent_name,
|
AND i.register_date < '2026-01-01'
|
||||||
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' => 'ecommerce_invoices_2025.csv',
|
'filename' => 'ecommerce_invoices_2025.csv',
|
||||||
@@ -603,32 +617,40 @@ 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,
|
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 p.deleted = 0
|
||||||
|
INNER JOIN ecmstocks AS s
|
||||||
|
ON i.stock_id = s.id
|
||||||
|
AND s.deleted = 0
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
cb.bean_id AS product_id,
|
||||||
|
GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category
|
||||||
|
FROM ecmproductcategories_bean AS cb
|
||||||
|
INNER JOIN ecmproductcategories AS c
|
||||||
|
ON c.id = cb.ecmproductcategory_id
|
||||||
|
AND c.deleted = 0
|
||||||
|
WHERE cb.bean_name = 'EcmProducts'
|
||||||
AND cb.deleted = 0
|
AND cb.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
GROUP BY cb.bean_id
|
||||||
WHERE YEAR(i.register_date) = 2025
|
) AS pc
|
||||||
GROUP BY
|
ON pc.product_id = p.id
|
||||||
i.document_no,
|
WHERE i.deleted = 0
|
||||||
i.register_date,
|
AND i.register_date BETWEEN '2025-01-01' AND '2025-12-31'
|
||||||
p.code,
|
|
||||||
p.name,
|
|
||||||
p.group_ks,
|
|
||||||
s.name,
|
|
||||||
ii.quantity
|
|
||||||
ORDER BY i.register_date DESC;
|
ORDER BY i.register_date DESC;
|
||||||
",
|
",
|
||||||
'filename' => 'rw_2025.csv',
|
'filename' => 'rw_2025.csv',
|
||||||
@@ -641,32 +663,40 @@ 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,
|
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 p.deleted = 0
|
||||||
|
INNER JOIN ecmstocks AS s
|
||||||
|
ON i.stock_id = s.id
|
||||||
|
AND s.deleted = 0
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
cb.bean_id AS product_id,
|
||||||
|
GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category
|
||||||
|
FROM ecmproductcategories_bean AS cb
|
||||||
|
INNER JOIN ecmproductcategories AS c
|
||||||
|
ON c.id = cb.ecmproductcategory_id
|
||||||
|
AND c.deleted = 0
|
||||||
|
WHERE cb.bean_name = 'EcmProducts'
|
||||||
AND cb.deleted = 0
|
AND cb.deleted = 0
|
||||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
GROUP BY cb.bean_id
|
||||||
WHERE YEAR(i.register_date) = 2024
|
) AS pc
|
||||||
GROUP BY
|
ON pc.product_id = p.id
|
||||||
i.document_no,
|
WHERE i.deleted = 0
|
||||||
i.register_date,
|
AND i.register_date BETWEEN '2024-01-01' AND '2024-12-31'
|
||||||
p.code,
|
|
||||||
p.name,
|
|
||||||
p.group_ks,
|
|
||||||
s.name,
|
|
||||||
ii.quantity
|
|
||||||
ORDER BY i.register_date DESC;
|
ORDER BY i.register_date DESC;
|
||||||
",
|
",
|
||||||
'filename' => 'rw_2024.csv',
|
'filename' => 'rw_2024.csv',
|
||||||
|
|||||||
Reference in New Issue
Block a user