Compare commits
18 Commits
cf65b86547
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 578817cf83 | |||
| 5862a89885 | |||
| 2d362277c6 | |||
| 52efb9f850 | |||
| 97274ccde1 | |||
| 7140100a08 | |||
| 34f16df681 | |||
| ff44b45465 | |||
| 0a0d9fa0a6 | |||
| 5920fe9a03 | |||
|
|
36f750e42b | ||
|
|
0fa2cf7423 | ||
| 99cf02c003 | |||
| b60ac8e2c0 | |||
|
|
351e9af67d | ||
| 569a39b153 | |||
|
|
dc48841d9b | ||
|
|
28d637ecc1 |
64
REST/bimai.php
Normal file
64
REST/bimai.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
function bimai_exportEcommerceDate($since)
|
||||
{
|
||||
if (!isset($since)) {
|
||||
echo json_encode(array('ok' => false, 'error' => 'Missing since parameter'));
|
||||
return false;
|
||||
}
|
||||
$sinceDate = date('Y-m-d H:i:s', intval($_GET['since']));
|
||||
$query = "
|
||||
SELECT
|
||||
i.id,
|
||||
i .document_no,
|
||||
i.type,
|
||||
i.register_date,
|
||||
i.sell_date,
|
||||
i.parent_name,
|
||||
i.parent_nip,
|
||||
i.parent_address_street,
|
||||
i.parent_address_postalcode,
|
||||
i.parent_address_city,
|
||||
i.parent_address_country,
|
||||
i.currency,
|
||||
i.total_netto,
|
||||
i.total_brutto,
|
||||
i.total_vat,
|
||||
i.origin
|
||||
FROM ecommerce_invoices i
|
||||
WHERE
|
||||
i.origin = 'allegro'
|
||||
AND YEAR(i.register_date) = 2024
|
||||
AND i.register_date > '$sinceDate'
|
||||
ORDER BY i.register_date
|
||||
LIMIT 0,10000;
|
||||
";
|
||||
|
||||
$db = $GLOBALS['db'];
|
||||
$query = $db->query($query);
|
||||
if ($db->last_error != '') {
|
||||
echo json_encode(array('ok' => false, 'error' => $db->last_error));
|
||||
return false;
|
||||
}
|
||||
$data = array();
|
||||
while ($row = $db->fetchByAssoc($query)) {
|
||||
$d = array();
|
||||
$d['e5Id'] = $row['id'];
|
||||
$d['documentNo'] = $row['document_no'];
|
||||
$d['type'] = $row['type'];
|
||||
$d['registerDate'] = $row['register_date'];
|
||||
$d['sellDate'] = $row['sell_date'];
|
||||
$d['clientName'] = $row['parent_name'];
|
||||
$d['clientId'] = $row['parent_id'] ?: '';
|
||||
$d['clientNip'] = $row['parent_nip'] ?: '';
|
||||
$d['clientAddress'] = $row['parent_address_street'] . ", " . $row['parent_address_postalcode'] . " " . $row['parent_address_city'] . " " . $row['parent_address_country'];;
|
||||
$d['currency'] = $row['currency'];
|
||||
$d['totalNetto'] = $row['total_netto'];
|
||||
$d['totalBrutto'] = $row['total_brutto'];
|
||||
$d['totalVat'] = $row['total_vat'];
|
||||
$d['source'] = $row['origin'];
|
||||
$data[] = $d;
|
||||
}
|
||||
|
||||
echo json_encode(array('ok' => true, 'dataSize' => count($data), 'data' => $data));
|
||||
return true;
|
||||
}
|
||||
@@ -323,81 +323,97 @@ function createCSVReports()
|
||||
$jobs = [
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
SELECT
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
i.parent_name,
|
||||
p.code,
|
||||
p.name,
|
||||
CASE p.group_ks
|
||||
WHEN 1 THEN 'Towar handlowy'
|
||||
WHEN 2 THEN 'Wyrób gotowy'
|
||||
WHEN 3 THEN 'Usługi'
|
||||
WHEN '1' THEN 'Towar handlowy'
|
||||
WHEN '2' THEN 'Wyrób gotowy'
|
||||
WHEN '3' THEN 'Usługi'
|
||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||
ELSE 'Nieznane'
|
||||
END AS group_ks,
|
||||
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
END AS group_ks_name,
|
||||
GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
ii.quantity,
|
||||
ii.price_netto
|
||||
ii.price_netto,
|
||||
COALESCE(cur.name, 'PLN') AS currency_name
|
||||
FROM ecminvoiceouts AS i
|
||||
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id
|
||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
||||
AND cb.bean_name = 'EcmProducts'
|
||||
AND cb.deleted = 0
|
||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
||||
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2024
|
||||
INNER JOIN ecminvoiceoutitems AS ii
|
||||
ON i.id = ii.ecminvoiceout_id
|
||||
AND ii.deleted = 0
|
||||
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.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
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
i.parent_name,
|
||||
p.code,
|
||||
p.name,
|
||||
p.group_ks,
|
||||
ii.quantity,
|
||||
ii.price_netto
|
||||
ORDER BY i.register_date DESC;
|
||||
i.id,
|
||||
ii.id
|
||||
ORDER BY
|
||||
i.register_date DESC;
|
||||
",
|
||||
'filename' => 'invoices_2024.csv',
|
||||
], // invoices 2024
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
SELECT
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
i.parent_name,
|
||||
p.code,
|
||||
p.name,
|
||||
CASE p.group_ks
|
||||
WHEN 1 THEN 'Towar handlowy'
|
||||
WHEN 2 THEN 'Wyrób gotowy'
|
||||
WHEN 3 THEN 'Usługi'
|
||||
WHEN '1' THEN 'Towar handlowy'
|
||||
WHEN '2' THEN 'Wyrób gotowy'
|
||||
WHEN '3' THEN 'Usługi'
|
||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||
ELSE 'Nieznane'
|
||||
END AS group_ks,
|
||||
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
END AS group_ks_name,
|
||||
GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
ii.quantity,
|
||||
ii.price_netto
|
||||
ii.price_netto,
|
||||
COALESCE(cur.name, 'PLN') AS currency_name
|
||||
FROM ecminvoiceouts AS i
|
||||
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id
|
||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
||||
AND cb.bean_name = 'EcmProducts'
|
||||
AND cb.deleted = 0
|
||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
||||
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2025
|
||||
INNER JOIN ecminvoiceoutitems AS ii
|
||||
ON i.id = ii.ecminvoiceout_id
|
||||
AND ii.deleted = 0
|
||||
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.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
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
i.parent_name,
|
||||
p.code,
|
||||
p.name,
|
||||
p.group_ks,
|
||||
ii.quantity,
|
||||
ii.price_netto
|
||||
ORDER BY i.register_date DESC;
|
||||
i.id,
|
||||
ii.id
|
||||
ORDER BY
|
||||
i.register_date DESC;
|
||||
",
|
||||
'filename' => 'invoices_2025.csv',
|
||||
], // invoices 2025
|
||||
@@ -412,39 +428,38 @@ SELECT
|
||||
p.code,
|
||||
p.name,
|
||||
CASE p.group_ks
|
||||
WHEN 1 THEN 'Towar handlowy'
|
||||
WHEN 2 THEN 'Wyrób gotowy'
|
||||
WHEN 3 THEN 'Usługi'
|
||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||
WHEN '1' THEN 'Towar handlowy'
|
||||
WHEN '2' THEN 'Wyrób gotowy'
|
||||
WHEN '3' THEN 'Usługi'
|
||||
ELSE 'Nieznane'
|
||||
END AS group_ks,
|
||||
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
ii.quantity_corrected AS quantity_correced,
|
||||
ii.total_netto_corrected AS total_netto_corrected
|
||||
END AS group_ks_name,
|
||||
GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
ii.quantity_corrected AS quantity_corrected,
|
||||
ii.total_netto_corrected AS total_netto_corrected,
|
||||
COALESCE(cur.name, 'PLN') AS currency_name
|
||||
FROM ecminvoiceouts AS i
|
||||
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id
|
||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
||||
INNER JOIN ecminvoiceouts AS oi ON oi.id = i.ecminvoiceout_id
|
||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
||||
AND cb.bean_name = 'EcmProducts'
|
||||
AND cb.deleted = 0
|
||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
||||
WHERE i.type = 'correct' AND YEAR(i.register_date) = 2024
|
||||
INNER JOIN ecminvoiceoutitems AS ii
|
||||
ON i.id = ii.ecminvoiceout_id AND ii.deleted = 0
|
||||
INNER JOIN ecmproducts AS p
|
||||
ON ii.ecmproduct_id = p.id AND p.deleted = 0
|
||||
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.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
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
oi.document_no,
|
||||
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;
|
||||
i.id,
|
||||
ii.id,
|
||||
oi.id
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'correct_invoices_2024.csv',
|
||||
], // correct invoices 2024
|
||||
@@ -459,38 +474,37 @@ SELECT
|
||||
p.code,
|
||||
p.name,
|
||||
CASE p.group_ks
|
||||
WHEN 1 THEN 'Towar handlowy'
|
||||
WHEN 2 THEN 'Wyrób gotowy'
|
||||
WHEN 3 THEN 'Usługi'
|
||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||
WHEN '1' THEN 'Towar handlowy'
|
||||
WHEN '2' THEN 'Wyrób gotowy'
|
||||
WHEN '3' THEN 'Usługi'
|
||||
ELSE 'Nieznane'
|
||||
END AS group_ks,
|
||||
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
ii.quantity_corrected AS quantity_correced,
|
||||
ii.total_netto_corrected AS total_netto_corrected
|
||||
END AS group_ks_name,
|
||||
GROUP_CONCAT(DISTINCT c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
ii.quantity_corrected AS quantity_corrected,
|
||||
ii.total_netto_corrected AS total_netto_corrected,
|
||||
COALESCE(cur.name, 'PLN') AS currency_name
|
||||
FROM ecminvoiceouts AS i
|
||||
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id
|
||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
||||
INNER JOIN ecminvoiceouts AS oi ON oi.id = i.ecminvoiceout_id
|
||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
||||
AND cb.bean_name = 'EcmProducts'
|
||||
AND cb.deleted = 0
|
||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
||||
WHERE i.type = 'correct' AND YEAR(i.register_date) = 2025
|
||||
INNER JOIN ecminvoiceoutitems AS ii
|
||||
ON i.id = ii.ecminvoiceout_id AND ii.deleted = 0
|
||||
INNER JOIN ecmproducts AS p
|
||||
ON ii.ecmproduct_id = p.id AND p.deleted = 0
|
||||
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.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
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
oi.document_no,
|
||||
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
|
||||
i.id,
|
||||
ii.id,
|
||||
oi.id
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'correct_invoices_2025.csv',
|
||||
@@ -504,33 +518,37 @@ SELECT
|
||||
p.code,
|
||||
p.name,
|
||||
CASE p.group_ks
|
||||
WHEN 1 THEN 'Towar handlowy'
|
||||
WHEN 2 THEN 'Wyrób gotowy'
|
||||
WHEN 3 THEN 'Usługi'
|
||||
WHEN '1' THEN 'Towar handlowy'
|
||||
WHEN '2' THEN 'Wyrób gotowy'
|
||||
WHEN '3' THEN 'Usługi'
|
||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||
ELSE 'Nieznane'
|
||||
END AS group_ks,
|
||||
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
END AS group_ks_name,
|
||||
pc.category,
|
||||
ii.quantity,
|
||||
ii.price_netto
|
||||
FROM ecommerce_invoices AS i
|
||||
INNER JOIN ecommerce_invoices_products AS ii ON i.id = ii.invoice_id
|
||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
||||
AND cb.bean_name = 'EcmProducts'
|
||||
AND cb.deleted = 0
|
||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
||||
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2024
|
||||
GROUP BY
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
i.parent_name,
|
||||
p.code,
|
||||
p.name,
|
||||
p.group_ks,
|
||||
ii.quantity,
|
||||
ii.price_netto
|
||||
INNER JOIN ecommerce_invoices_products AS ii
|
||||
ON i.id = ii.invoice_id
|
||||
INNER JOIN ecmproducts AS p
|
||||
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
|
||||
GROUP BY cb.bean_id
|
||||
) AS pc
|
||||
ON pc.product_id = p.id
|
||||
WHERE i.type = 'normal'
|
||||
AND i.register_date >= '2024-01-01'
|
||||
AND i.register_date < '2025-01-01'
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'ecommerce_invoices_2024.csv',
|
||||
@@ -544,33 +562,37 @@ SELECT
|
||||
p.code,
|
||||
p.name,
|
||||
CASE p.group_ks
|
||||
WHEN 1 THEN 'Towar handlowy'
|
||||
WHEN 2 THEN 'Wyrób gotowy'
|
||||
WHEN 3 THEN 'Usługi'
|
||||
WHEN '1' THEN 'Towar handlowy'
|
||||
WHEN '2' THEN 'Wyrób gotowy'
|
||||
WHEN '3' THEN 'Usługi'
|
||||
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
|
||||
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
|
||||
ELSE 'Nieznane'
|
||||
END AS group_ks,
|
||||
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
END AS group_ks_name,
|
||||
pc.category,
|
||||
ii.quantity,
|
||||
ii.price_netto
|
||||
FROM ecommerce_invoices AS i
|
||||
INNER JOIN ecommerce_invoices_products AS ii ON i.id = ii.invoice_id
|
||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
||||
AND cb.bean_name = 'EcmProducts'
|
||||
AND cb.deleted = 0
|
||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
||||
WHERE i.type = 'normal' AND YEAR(i.register_date) = 2025
|
||||
GROUP BY
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
i.parent_name,
|
||||
p.code,
|
||||
p.name,
|
||||
p.group_ks,
|
||||
ii.quantity,
|
||||
ii.price_netto
|
||||
INNER JOIN ecommerce_invoices_products AS ii
|
||||
ON i.id = ii.invoice_id
|
||||
INNER JOIN ecmproducts AS p
|
||||
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
|
||||
GROUP BY cb.bean_id
|
||||
) AS pc
|
||||
ON pc.product_id = p.id
|
||||
WHERE i.type = 'normal'
|
||||
AND i.register_date >= '2025-01-01'
|
||||
AND i.register_date < '2026-01-01'
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'ecommerce_invoices_2025.csv',
|
||||
@@ -595,32 +617,40 @@ SELECT
|
||||
p.code,
|
||||
p.name,
|
||||
CASE p.group_ks
|
||||
WHEN 1 THEN 'Towar handlowy'
|
||||
WHEN 2 THEN 'Wyrób gotowy'
|
||||
WHEN 3 THEN 'Surowiec'
|
||||
WHEN 4 THEN 'Usługa'
|
||||
WHEN '1' THEN 'Towar handlowy'
|
||||
WHEN '2' THEN 'Wyrób gotowy'
|
||||
WHEN '3' THEN 'Surowiec'
|
||||
WHEN '4' THEN 'Usługa'
|
||||
ELSE 'Nieznane'
|
||||
END AS group_ks,
|
||||
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
END AS group_ks_name,
|
||||
pc.category,
|
||||
s.name AS stock,
|
||||
ii.quantity
|
||||
FROM ecmstockdocinsideouts AS i
|
||||
INNER JOIN ecmstockdocinsideoutitems AS ii ON i.id = ii.ecmstockdocinsideout_id
|
||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
||||
INNER JOIN ecmstocks AS s ON i.stock_id = s.id
|
||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
||||
AND cb.bean_name = 'EcmProducts'
|
||||
AND cb.deleted = 0
|
||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
||||
WHERE YEAR(i.register_date) = 2025
|
||||
GROUP BY
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
p.code,
|
||||
p.name,
|
||||
p.group_ks,
|
||||
s.name,
|
||||
ii.quantity
|
||||
INNER JOIN ecmstockdocinsideoutitems AS ii
|
||||
ON i.id = ii.ecmstockdocinsideout_id
|
||||
AND ii.deleted = 0
|
||||
INNER JOIN ecmproducts AS p
|
||||
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
|
||||
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;
|
||||
",
|
||||
'filename' => 'rw_2025.csv',
|
||||
@@ -633,32 +663,40 @@ SELECT
|
||||
p.code,
|
||||
p.name,
|
||||
CASE p.group_ks
|
||||
WHEN 1 THEN 'Towar handlowy'
|
||||
WHEN 2 THEN 'Wyrób gotowy'
|
||||
WHEN 3 THEN 'Surowiec'
|
||||
WHEN 4 THEN 'Usługa'
|
||||
WHEN '1' THEN 'Towar handlowy'
|
||||
WHEN '2' THEN 'Wyrób gotowy'
|
||||
WHEN '3' THEN 'Surowiec'
|
||||
WHEN '4' THEN 'Usługa'
|
||||
ELSE 'Nieznane'
|
||||
END AS group_ks,
|
||||
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
|
||||
END AS group_ks_name,
|
||||
pc.category,
|
||||
s.name AS stock,
|
||||
ii.quantity
|
||||
FROM ecmstockdocinsideouts AS i
|
||||
INNER JOIN ecmstockdocinsideoutitems AS ii ON i.id = ii.ecmstockdocinsideout_id
|
||||
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
|
||||
INNER JOIN ecmstocks AS s ON i.stock_id = s.id
|
||||
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
|
||||
AND cb.bean_name = 'EcmProducts'
|
||||
AND cb.deleted = 0
|
||||
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
|
||||
WHERE YEAR(i.register_date) = 2024
|
||||
GROUP BY
|
||||
i.document_no,
|
||||
i.register_date,
|
||||
p.code,
|
||||
p.name,
|
||||
p.group_ks,
|
||||
s.name,
|
||||
ii.quantity
|
||||
INNER JOIN ecmstockdocinsideoutitems AS ii
|
||||
ON i.id = ii.ecmstockdocinsideout_id
|
||||
AND ii.deleted = 0
|
||||
INNER JOIN ecmproducts AS p
|
||||
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
|
||||
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;
|
||||
",
|
||||
'filename' => 'rw_2024.csv',
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
}
|
||||
|
||||
require_once('./REST/functions.php');
|
||||
require_once('./REST/bimai.php');
|
||||
// Enable SugarCRM features
|
||||
if(!defined('sugarEntry'))define('sugarEntry', true);
|
||||
require_once('./include/entryPoint.php');
|
||||
@@ -41,6 +42,8 @@
|
||||
case 'createCSVReports':
|
||||
createCSVReports();
|
||||
break;
|
||||
case 'bimai.export.ecommerce':
|
||||
bimai_exportEcommerceDate($_GET['since']);
|
||||
break;
|
||||
}
|
||||
// https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=createCostDocumentFromInvoice&record=c3f6eaa6-0cbd-8c89-1a8c-683ff19a36db
|
||||
?>
|
||||
// https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=createCostDocumentFromInvoice&record=c3f6eaa6-0cbd-8c89-1a8c-683ff19a36db
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
// die('Przerwa techniczna. Michał Zieliński');
|
||||
if(!defined('sugarEntry'))define('sugarEntry', true);
|
||||
|
||||
$SHOW_ERRORS = false; // set to true to show errors, false to hide them
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$searchFields['Documents'] =
|
||||
array (
|
||||
'document_name' => array( 'query_type'=>'default'),
|
||||
'category_id'=> array('query_type'=>'default', 'options' => 'document_category_dom', 'template_var' => 'CATEGORY_OPTIONS'),
|
||||
'subcategory_id'=> array('query_type'=>'default', 'options' => 'document_subcategory_dom', 'template_var' => 'SUBCATEGORY_OPTIONS'),
|
||||
'active_date'=> array('query_type'=>'default'),
|
||||
'exp_date'=> array('query_type'=>'default'),
|
||||
|
||||
|
||||
);
|
||||
?>
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$viewdefs['Documents']['EditView'] = array(
|
||||
'templateMeta' => array('form' => array('enctype'=>'multipart/form-data',
|
||||
'hidden'=>array('<input type="hidden" name="old_id" value="{$fields.document_revision_id.value}">',
|
||||
'<input type="hidden" name="parent_id" value="{$smarty.request.parent_id}">',
|
||||
'<input type="hidden" name="parent_type" value="{$smarty.request.parent_type}">',)),
|
||||
|
||||
'maxColumns' => '2',
|
||||
'widths' => array(
|
||||
array('label' => '10', 'field' => '30'),
|
||||
array('label' => '10', 'field' => '30')
|
||||
),
|
||||
'javascript' => '<script type="text/javascript" src="include/javascript/popup_parent_helper.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>
|
||||
<script type="text/javascript" src="include/jsolait/init.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>
|
||||
<script type="text/javascript" src="include/jsolait/lib/urllib.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>
|
||||
<script type="text/javascript" src="include/javascript/jsclass_base.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jsclass_async.js"></script>
|
||||
<script type="text/javascript" src="modules/Documents/documents.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>',
|
||||
),
|
||||
'panels' =>array (
|
||||
'default' =>
|
||||
array (
|
||||
|
||||
array (
|
||||
'document_name',
|
||||
),
|
||||
|
||||
array (
|
||||
|
||||
array('name'=>'uploadfile',
|
||||
'customCode' => '<input type="hidden" name="escaped_document_name"><input name="uploadfile" type="{$FILE_OR_HIDDEN}" size="30" maxlength="" onchange="setvalue(this);" value="{$fields.filename.value}">{$fields.filename.value}',
|
||||
'displayParams'=>array('required'=>true),
|
||||
),
|
||||
array('name'=>'revision',
|
||||
'customCode' => '<input name="revision" type="text" value="{$fields.revision.value}" {$DISABLED}>'
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
array (
|
||||
array (
|
||||
'name' => 'is_template',
|
||||
'label' => 'LBL_DET_IS_TEMPLATE',
|
||||
),
|
||||
|
||||
array (
|
||||
'name' => 'template_type',
|
||||
'label' => 'LBL_DET_TEMPLATE_TYPE',
|
||||
),
|
||||
),
|
||||
|
||||
array (
|
||||
'category_id',
|
||||
'subcategory_id',
|
||||
),
|
||||
|
||||
array (
|
||||
'status_id',
|
||||
|
||||
|
||||
|
||||
),
|
||||
|
||||
array (
|
||||
array('name'=>'active_date','displayParams'=>array('required'=>true)),
|
||||
'exp_date',
|
||||
),
|
||||
|
||||
array (
|
||||
array('name'=>'related_doc_name',
|
||||
'customCode' => '<input name="related_document_name" type="text" size="30" maxlength="255" value="{$RELATED_DOCUMENT_NAME}" readonly>' .
|
||||
'<input name="related_doc_id" type="hidden" value="{$fields.related_doc_id.value}"/> ' .
|
||||
'<input title="{$APP.LBL_SELECT_BUTTON_TITLE}" accessKey="{$APP.LBL_SELECT_BUTTON_KEY}" type="{$RELATED_DOCUMENT_BUTTON_AVAILABILITY}" class="button" value="{$APP.LBL_SELECT_BUTTON_LABEL}" name="btn2" onclick=\'open_popup("Documents", 600, 400, "", true, false, {$encoded_document_popup_request_data}, "single", true);\'/>'),
|
||||
array('name'=>'related_doc_rev_number',
|
||||
'customCode' => '<select name="related_doc_rev_id" id="related_doc_rev_id" {$RELATED_DOCUMENT_REVISION_DISABLED}>{$RELATED_DOCUMENT_REVISION_OPTIONS}</select>',
|
||||
),
|
||||
),
|
||||
|
||||
array (
|
||||
array('name'=>'description', 'displayParams'=>array('rows'=>10, 'cols'=>120)),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
);
|
||||
?>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
$searchdefs['Documents'] = array(
|
||||
'templateMeta' => array('maxColumns' => '3',
|
||||
'widths' => array('label' => '10', 'field' => '30'),
|
||||
),
|
||||
'layout' => array(
|
||||
'basic_search' => array(
|
||||
'document_name',
|
||||
'category_id',
|
||||
'subcategory_id',
|
||||
),
|
||||
'advanced_search' => array(
|
||||
'document_name',
|
||||
'category_id',
|
||||
'subcategory_id',
|
||||
'active_date',
|
||||
'exp_date',
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
global $mod_strings;
|
||||
$viewdefs['Documents']['SideQuickCreate'] = array(
|
||||
'templateMeta' => array('form'=>array(
|
||||
'enctype'=>'multipart/form-data',
|
||||
'buttons'=>array('SAVE'),
|
||||
'button_location'=>'bottom',
|
||||
'headerTpl'=>'include/EditView/header.tpl',
|
||||
'footerTpl'=>'include/EditView/footer.tpl',
|
||||
),
|
||||
'maxColumns' => '1',
|
||||
'panelClass'=>'none',
|
||||
|
||||
'labelsOnTop'=>true,
|
||||
'widths' => array(
|
||||
array('label' => '10', 'field' => '30'),
|
||||
),
|
||||
),
|
||||
'panels' =>array (
|
||||
'DEFAULT' =>
|
||||
array (
|
||||
array (
|
||||
array('name'=>'document_name', 'displayParams'=>array('size'=>20, 'required'=>true)),
|
||||
),
|
||||
array (
|
||||
array('name'=>'uploadfile', 'displayParams'=>array('size'=>11, 'required'=>true)),
|
||||
),
|
||||
array (
|
||||
array('name'=>'revision', 'displayParams'=>array('size'=>11, 'required'=>true)),
|
||||
),
|
||||
array (
|
||||
array('name'=>'active_date', 'displayParams'=>array('size'=>11, 'required'=>true)),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
)
|
||||
|
||||
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$GLOBALS['studioDefs']['Documents'] = array(
|
||||
'LBL_DETAILVIEW'=>array(
|
||||
'template'=>'xtpl',
|
||||
'template_file'=>'modules/Documents/DetailView.html',
|
||||
'php_file'=>'modules/Documents/DetailView.php',
|
||||
'type'=>'DetailView',
|
||||
),
|
||||
'LBL_EDITVIEW'=>array(
|
||||
'template'=>'xtpl',
|
||||
'template_file'=>'modules/Documents/EditView.html',
|
||||
'php_file'=>'modules/Documents/EditView.php',
|
||||
'type'=>'EditView',
|
||||
),
|
||||
'LBL_LISTVIEW'=>array(
|
||||
'template'=>'listview',
|
||||
'meta_file'=>'modules/Documents/listviewdefs.php',
|
||||
'type'=>'ListView',
|
||||
),
|
||||
'LBL_SEARCHFORM'=>array(
|
||||
'template'=>'xtpl',
|
||||
'template_file'=>'modules/Documents/SearchForm.html',
|
||||
'php_file'=>'modules/Documents/ListView.php',
|
||||
'type'=>'SearchForm',
|
||||
),
|
||||
|
||||
);
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* Layout definition for Quotes
|
||||
*
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$layout_defs['Documents'] = array(
|
||||
// list of what Subpanels to show in the DetailView
|
||||
'subpanel_setup' => array(
|
||||
'therevisions' => array(
|
||||
'order' => 10,
|
||||
'sort_order' => 'desc',
|
||||
'sort_by' => 'revision',
|
||||
'module' => 'DocumentRevisions',
|
||||
'subpanel_name' => 'default',
|
||||
'title_key' => 'LBL_DOC_REV_HEADER',
|
||||
'get_subpanel_data' => 'revisions',
|
||||
'fill_in_additional_fields'=>true,
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
),
|
||||
);
|
||||
?>
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* Subpanel Layout definition for Bugs
|
||||
*
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
$subpanel_layout = array(
|
||||
'top_buttons' => array(
|
||||
array('widget_class' => 'SubPanelTopCreateButton'),
|
||||
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'Documents','field_to_name_array'=>array('document_revision_id'=>'REL_ATTRIBUTE_document_revision_id')),
|
||||
),
|
||||
|
||||
'where' => '',
|
||||
|
||||
|
||||
|
||||
'list_fields'=> array(
|
||||
'document_name'=> array(
|
||||
'name' => 'document_name',
|
||||
'vname' => 'LBL_LIST_DOCUMENT_NAME',
|
||||
'widget_class' => 'SubPanelDetailViewLink',
|
||||
'width' => '30%',
|
||||
),
|
||||
'is_template'=>array(
|
||||
'name' => 'is_template',
|
||||
'vname' => 'LBL_LIST_IS_TEMPLATE',
|
||||
'width' => '5%',
|
||||
'widget_type'=>'checkbox',
|
||||
),
|
||||
'template_type'=>array(
|
||||
'name' => 'template_types',
|
||||
'vname' => 'LBL_LIST_TEMPLATE_TYPE',
|
||||
'width' => '15%',
|
||||
),
|
||||
'latest_revision'=>array(
|
||||
'name' => 'latest_revision',
|
||||
'vname' => 'LBL_LATEST_REVISION',
|
||||
'width' => '10%',
|
||||
'sortable' => false
|
||||
),
|
||||
'edit_button'=>array(
|
||||
'widget_class' => 'SubPanelEditButton',
|
||||
'module' => 'Documents',
|
||||
'width' => '5%',
|
||||
),
|
||||
'remove_button'=>array(
|
||||
'widget_class' => 'SubPanelRemoveButton',
|
||||
'module' => 'Documents',
|
||||
'width' => '5%',
|
||||
),
|
||||
'document_revision_id'=>array(
|
||||
'usage'=>'query_only'
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* Subpanel Layout definition for Bugs
|
||||
*
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
$subpanel_layout = array(
|
||||
'top_buttons' => array(
|
||||
array('widget_class' => 'SubPanelTopCreateButton'),
|
||||
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'Documents','field_to_name_array'=>array('document_revision_id'=>'REL_ATTRIBUTE_document_revision_id')),
|
||||
),
|
||||
|
||||
'where' => '',
|
||||
|
||||
|
||||
|
||||
'list_fields'=> array(
|
||||
'object_image'=>array(
|
||||
'widget_class' => 'SubPanelIcon',
|
||||
'width' => '2%',
|
||||
'image2'=>'attachment',
|
||||
'image2_url_field'=>array('id_field'=>'selected_revision_id','filename_field'=>'selected_revision_filename'),
|
||||
'attachment_image_only'=>true,
|
||||
|
||||
),
|
||||
'document_name'=> array(
|
||||
'name' => 'document_name',
|
||||
'vname' => 'LBL_LIST_DOCUMENT_NAME',
|
||||
'widget_class' => 'SubPanelDetailViewLink',
|
||||
'width' => '30%',
|
||||
),
|
||||
'is_template'=>array(
|
||||
'name' => 'is_template',
|
||||
'vname' => 'LBL_LIST_IS_TEMPLATE',
|
||||
'width' => '5%',
|
||||
'widget_type'=>'checkbox',
|
||||
),
|
||||
'template_type'=>array(
|
||||
'name' => 'template_types',
|
||||
'vname' => 'LBL_LIST_TEMPLATE_TYPE',
|
||||
'width' => '15%',
|
||||
),
|
||||
'selected_revision_name'=>array(
|
||||
'name' => 'selected_revision_name',
|
||||
'vname' => 'LBL_LIST_SELECTED_REVISION',
|
||||
'width' => '10%',
|
||||
),
|
||||
'latest_revision_name'=>array(
|
||||
'name' => 'latest_revision_name',
|
||||
'vname' => 'LBL_LIST_LATEST_REVISION',
|
||||
'width' => '10%',
|
||||
),
|
||||
'get_latest'=>array(
|
||||
'widget_class' => 'SubPanelGetLatestButton',
|
||||
'module' => 'Documents',
|
||||
'width' => '5%',
|
||||
),
|
||||
'load_signed'=>array(
|
||||
'widget_class' => 'SubPanelLoadSignedButton',
|
||||
'module' => 'Documents',
|
||||
'width' => '5%',
|
||||
),
|
||||
'edit_button'=>array(
|
||||
'widget_class' => 'SubPanelEditButton',
|
||||
'module' => 'Documents',
|
||||
'width' => '5%',
|
||||
),
|
||||
'remove_button'=>array(
|
||||
'widget_class' => 'SubPanelRemoveButton',
|
||||
'module' => 'Documents',
|
||||
'width' => '5%',
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/TEMU/files/10-2025.csv';
|
||||
$handle = fopen($filename, 'r');
|
||||
if ($handle === false) {
|
||||
die('Cannot open file: ' . $filename);
|
||||
}
|
||||
|
||||
$invoices = [];
|
||||
$documentsNo = [];
|
||||
$isFirstRow = true;
|
||||
while (($data = fgetcsv($handle, 0, ",")) !== false) {
|
||||
if ($isFirstRow) {
|
||||
$isFirstRow = false;
|
||||
continue;
|
||||
}
|
||||
for ($i = 10; $i <= 20; $i++) {
|
||||
$data[$i] = str_replace(',', '.', $data[$i]);
|
||||
}
|
||||
if ($data[6] != '23%') {
|
||||
die('VAT inny niż 23%! '.$data[6]);
|
||||
}
|
||||
if ($data[21] != 'PLN') {
|
||||
die('Waluta inna niż PLN! '.$data[21]);
|
||||
}
|
||||
if (!isset($invoices[$data[22]])) {
|
||||
$inv = array();
|
||||
$inv['document_no'] = $data[22];
|
||||
$inv['order_no'] = $data[0];
|
||||
$inv['parent_name'] = 'TemuCustomer';
|
||||
$inv['parent_hash'] = substr(md5($inv['parent_name']), 0, 20);
|
||||
$inv['parent_short_name'] = substr($inv['parent_name'], 0, 40);
|
||||
$inv['parent_address_city'] = '';
|
||||
$inv['parent_address_postalcode'] = '';
|
||||
$inv['parent_address_street'] = '';
|
||||
$inv['parent_nip'] = '';
|
||||
$inv['category'] = "Sprzedaż";
|
||||
$inv['register_date'] = $data[3];
|
||||
$inv['sell_date'] = $data[3];
|
||||
|
||||
$inv['total_netto'] = floatval($data[10]) + floatval($data[11]) + floatval($data[12]) + floatval($data[13]);
|
||||
$inv['total_vat'] = floatval($data[20]);
|
||||
$inv['vat_calculated'] = round($inv['total_netto'] * 0.23,2);
|
||||
$inv['total_brutto'] = $inv['total_netto'] + $inv['total_vat'];
|
||||
if (substr($data[22], 0, 2) == 'CN') {
|
||||
$inv['type'] = 'correcting';
|
||||
} else {
|
||||
$inv['type'] = 'normal';
|
||||
}
|
||||
} else {
|
||||
$inv = $invoices[$data[22]];
|
||||
$inv['total_netto'] += floatval($data[10]) + floatval($data[11]) + floatval($data[12]) + floatval($data[13]);
|
||||
$inv['total_vat'] += floatval($data[20]);
|
||||
$inv['vat_calculated'] = round($inv['total_netto'] * 0.23,2);
|
||||
$inv['total_brutto'] = $inv['total_netto'] + $inv['total_vat'];
|
||||
}
|
||||
$invoices[$data[22]] = $inv;
|
||||
}
|
||||
fclose($handle);
|
||||
|
||||
$db = $GLOBALS['db'];
|
||||
$db->query("SET NAMES utf8mb4");
|
||||
foreach ($invoices as $inv) {
|
||||
$query = sprintf("INSERT INTO ecommerce_invoices VALUES ('%s', '%s', '%s', '%s', '%s', 'temu', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%f', '%f', '%f', null, null, null, null, null, null);",
|
||||
getId(), $inv['document_no'], $inv['type'], $inv['register_date'], $inv['sell_date'],
|
||||
$inv['order_no'], 'TemuCustomer', $inv['parent_nip'], null, null, '',
|
||||
'', null, 'PLN', $inv['total_netto'], $inv['total_brutto'], $inv['total_vat']);
|
||||
$res = $db->query($query);
|
||||
if (!$res) {
|
||||
echo "Query error: ".$query.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
function getId() {
|
||||
$db = $GLOBALS['db'];
|
||||
$res = $db->fetchByAssoc($db->query("SELECT UUID() as id;"));
|
||||
return $res['id'];
|
||||
}
|
||||
@@ -5,11 +5,11 @@ ini_set('display_errors', 1);
|
||||
|
||||
/*
|
||||
DELETE FROM ecommerce_invoices_products WHERE invoice_id IN (
|
||||
SELECT id FROM ecommerce_invoices WHERE origin='amazon b2b' AND register_date LIKE '2025-04-%');
|
||||
DELETE FROM ecommerce_invoices WHERE origin='amazon b2b' AND register_date LIKE '2025-04-%';
|
||||
SELECT id FROM ecommerce_invoices WHERE origin='amazon b2b' AND register_date LIKE '2025-09-%');
|
||||
DELETE FROM ecommerce_invoices WHERE origin='amazon b2b' AND register_date LIKE '2025-09-%';
|
||||
*/
|
||||
|
||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/08-2025.csv';
|
||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/10-2025.csv';
|
||||
$handle = fopen($filename, 'r');
|
||||
if ($handle === false) {
|
||||
die('Cannot open file: ' . $filename);
|
||||
@@ -38,7 +38,7 @@ foreach ($b2b as $el) {
|
||||
|
||||
foreach ($groupedB2B as $invoiceNo => $invoice) {
|
||||
if (checkInvoice($invoiceNo)) {
|
||||
echo 'Invoice already exists' . PHP_EOL;
|
||||
echo 'Invoice already exists: '.$invoiceNo.'<br>' ;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
// https://crm.twinpol.com/?module=EcmInvoiceOuts&action=ecommerce&amazon-wz=true
|
||||
|
||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/amazon-wz-08-2025.csv';
|
||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/amazon-wz-10-2025.csv';
|
||||
$handle = fopen($filename, 'r');
|
||||
if ($handle === false) {
|
||||
die('Cannot open file: ' . $filename);
|
||||
|
||||
@@ -9,7 +9,7 @@ DELETE FROM ecommerce_invoices_products WHERE invoice_id IN (
|
||||
DELETE FROM ecommerce_invoices WHERE origin='amazon vat local' AND register_date LIKE '2025-02-%';
|
||||
*/
|
||||
|
||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/08-2025.csv';
|
||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/10-2025.csv';
|
||||
$handle = fopen($filename, 'r');
|
||||
if ($handle === false) {
|
||||
die('Cannot open file: ' . $filename);
|
||||
|
||||
@@ -4,7 +4,7 @@ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
// read csv file tab separated
|
||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/08-2025.csv';
|
||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/10-2025.csv';
|
||||
$handle = fopen($filename, 'r');
|
||||
if ($handle === false) {
|
||||
die('Cannot open file: ' . $filename);
|
||||
@@ -31,12 +31,12 @@ fclose($handle);
|
||||
//if (count($de) == 0) {
|
||||
// die('No data for DE');
|
||||
//}
|
||||
//createInvoice('DE', $de,);
|
||||
//createInvoice('DE', $de, true);
|
||||
|
||||
if (count($cz) == 0) {
|
||||
die('No data for CZ');
|
||||
}
|
||||
createInvoice('CZ', $cz, true);
|
||||
createInvoice('CZ', $cz, true );
|
||||
|
||||
function createInvoice($type, $products, $DO_REAL_SAVE = false)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ function createInvoice($type, $products, $DO_REAL_SAVE = false)
|
||||
$invoice->parent_address_city = 'Obrowo';
|
||||
|
||||
$invoice->type = 'normal';
|
||||
$date = '31.08.2025';
|
||||
$date = '31.10.2025';
|
||||
$invoice->register_date = $date;
|
||||
$invoice->sell_date = $date;
|
||||
$invoice->validtill_date = $date;
|
||||
|
||||
@@ -3,26 +3,28 @@
|
||||
//error_reporting(LC_ALL);
|
||||
//ini_set('display_errors', 1);
|
||||
// ?XDEBUG_SESSION_START=PHPSTORM
|
||||
//importInvoices();
|
||||
//apilo_importInvoices();
|
||||
|
||||
function apilo_importInvoices()
|
||||
{
|
||||
$apilo_config = apilo_loadConfiguration();
|
||||
$db = $GLOBALS['db'];
|
||||
|
||||
|
||||
$dbRes = $db->query("SELECT COUNT(id) as last_id FROM ecommerce_invoices WHERE origin LIKE 'apilo%'");
|
||||
$offset = intval($db->fetchByAssoc($dbRes)['last_id']);
|
||||
|
||||
$invoices = apilo_loadInvoices($apilo_config['token'], $offset);
|
||||
if (isset($invoices->error)) {
|
||||
if (apilo_refreshToken($apilo_config['refreshToken'], $apilo_config['clientId'], $apilo_config['clientSecret']) == true) {
|
||||
//$apilo_config = apilo_loadConfiguration();
|
||||
//$invoices = apilo_loadInvoices($apilo_config['token'], $offset);
|
||||
$apilo_config = apilo_loadConfiguration();
|
||||
$invoices = apilo_loadInvoices($apilo_config['token'], $offset);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
brecho(count($invoices->documents));
|
||||
|
||||
$GLOBALS['log']->bimit('----- Importing invoices from Apilo, documents count', count($invoices->documents));
|
||||
|
||||
$platforms = apilo_loadPlatformsList($apilo_config['token']);
|
||||
@@ -54,7 +56,7 @@ function apilo_loadInvoices($token, $offset)
|
||||
$url = "https://twinpol.apilo.com/rest/api/finance/documents/";
|
||||
$params = [
|
||||
'type' => 1,
|
||||
'limit' => 50,
|
||||
'limit' => 100,
|
||||
'offset' => $offset
|
||||
];
|
||||
$url .= '?' . http_build_query($params);
|
||||
@@ -103,19 +105,19 @@ function apilo_refreshToken($refreshToken, $clientId, $clientSecret)
|
||||
$err = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
brecho($response);
|
||||
brecho($httpCode);
|
||||
if ($httpCode !== 200) {
|
||||
|
||||
if ($httpCode !== 201) {
|
||||
return false;
|
||||
}
|
||||
$tokenData = json_decode($response, true);
|
||||
|
||||
brecho($tokenData);
|
||||
var_dump($tokenData);
|
||||
|
||||
if (isset($tokenData['accessToken'])) {
|
||||
global $db;
|
||||
$db->query("UPDATE config SET value='" . $tokenData['access_token'] . "' WHERE category='apilo' AND name='access_token'");
|
||||
if (isset($tokenData['refresh_token'])) {
|
||||
$db->query("UPDATE config SET value='" . $tokenData['refresh_token'] . "' WHERE category='apilo' AND name='refresh_token'");
|
||||
$db->query("UPDATE config SET value='" . $tokenData['accessToken'] . "' WHERE category='apilo' AND name='token'");
|
||||
if (isset($tokenData['refreshToken'])) {
|
||||
$db->query("UPDATE config SET value='" . $tokenData['refreshToken'] . "' WHERE category='apilo' AND name='refreshToken'");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ FROM ecommerce_invoices_products p
|
||||
LEFT JOIN ecommerce_invoices i ON p.invoice_id = i.id
|
||||
WHERE i.id IS NULL;
|
||||
*/
|
||||
//importFVKOR('7689');
|
||||
function importFV($seriesId)
|
||||
{
|
||||
$baselinker_config = loadConfiguration();
|
||||
@@ -32,6 +33,8 @@ function importFV($seriesId)
|
||||
|
||||
$invoices = $invoicesRes->invoices;
|
||||
|
||||
brecho($invoices);
|
||||
|
||||
usort($invoices, function ($a, $b) {
|
||||
return $a->date_add - $b->date_add;
|
||||
});
|
||||
@@ -54,7 +57,7 @@ function importFVKOR($seriesId)
|
||||
|
||||
$IMPORT_CORRECTION_START_ID = 2106464;
|
||||
|
||||
$dbRes = $db->query("SELECT id FROM ecommerce_invoices WHERE origin = 'Allegro' AND type = 'correcting' AND series_id = '$seriesId' ORDER BY id DESC LIMIT 1");
|
||||
$dbRes = $db->query("SELECT id FROM ecommerce_invoices WHERE type = 'correcting' AND series_id = '$seriesId' ORDER BY CAST(id AS UNSIGNED) DESC LIMIT 1");
|
||||
$lastImportId = $db->fetchByAssoc($dbRes)['id'];
|
||||
if ($lastImportId == null) {
|
||||
$lastImportId = $IMPORT_CORRECTION_START_ID;
|
||||
@@ -62,10 +65,13 @@ function importFVKOR($seriesId)
|
||||
$lastImportId++; //get next
|
||||
}
|
||||
|
||||
brecho($lastImportId);
|
||||
|
||||
$invoicesRes = loadInvoices($baselinker_config['token'], $lastImportId, $seriesId);
|
||||
|
||||
$invoices = $invoicesRes->invoices;
|
||||
|
||||
brecho($invoices);
|
||||
usort($invoices, function ($a, $b) {
|
||||
return $a->date_add - $b->date_add;
|
||||
});
|
||||
@@ -118,6 +124,7 @@ function addInvoice($i)
|
||||
|
||||
|
||||
if ($db->last_error) {
|
||||
brecho($db->last_error);
|
||||
return;
|
||||
}
|
||||
// delete products for this invoice if exists
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
$APP_KEY = '02cbeff8afd35247294810033b036cfe';
|
||||
$APP_SECRET = '8ecfa21b55cddf66c66043cbb80756efc4ba6596';
|
||||
$ACCESS_TOKEN = 'eplugtijmiyppv7ctra6iu7sjbgbvnlixcunsrigd918tl5awdl3ugmxno7';
|
||||
$BASE_URL = 'https://openapi-b-eu.temu.com/openapi/router';
|
||||
|
||||
$dateFromStr = '2025-10-01';
|
||||
$dateToStr = '2025-10-31';
|
||||
$parentOrderStatus = 4;
|
||||
$pageSize = 50;
|
||||
|
||||
function noquote($v){
|
||||
$j = json_encode($v, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
||||
return (is_string($v) && $j[0]==='"' && substr($j,-1)==='"') ? substr($j,1,-1) : $j;
|
||||
}
|
||||
function sign_md5($p, $secret){
|
||||
ksort($p, SORT_STRING);
|
||||
$s = $secret;
|
||||
foreach($p as $k=>$v){ if($v!=='' && $v!==null) $s .= $k . noquote($v); }
|
||||
$s .= $secret;
|
||||
return strtoupper(md5($s));
|
||||
}
|
||||
function parse_date_to_ts_start($s){
|
||||
$s = trim($s);
|
||||
$fmts = array('Y-m-d','d.m.Y','Y/m/d','d-m-Y','d/m/Y');
|
||||
foreach ($fmts as $f){
|
||||
$dt = DateTime::createFromFormat($f, $s);
|
||||
if ($dt && $dt->format($f) === $s){
|
||||
$dt->setTime(0,0,0);
|
||||
return (int)$dt->format('U');
|
||||
}
|
||||
}
|
||||
// fallback
|
||||
$t = strtotime($s);
|
||||
if ($t !== false){ return (int)strtotime(date('Y-m-d 00:00:00', $t)); }
|
||||
return null;
|
||||
}
|
||||
function parse_date_to_ts_end($s){
|
||||
$ts = parse_date_to_ts_start($s);
|
||||
if ($ts === null) return null;
|
||||
return $ts + 86399; // 23:59:59
|
||||
}
|
||||
|
||||
$fromTs = parse_date_to_ts_start($dateFromStr);
|
||||
$toTs = parse_date_to_ts_end($dateToStr);
|
||||
|
||||
if ($fromTs === null || $toTs === null){
|
||||
die('<pre>Błędny format daty od/do</pre>');
|
||||
}
|
||||
|
||||
$totalMatched = 0;
|
||||
$page = 1;
|
||||
$maxPages = 500; // bezpiecznik
|
||||
|
||||
echo '<div style="font-family:monospace; font-size:13px">';
|
||||
|
||||
while ($page <= $maxPages) {
|
||||
// 1) request listy
|
||||
$biz = array(
|
||||
"type" => "bg.order.list.v2.get",
|
||||
//"regionId" => 162,
|
||||
"pageNumber" => $page,
|
||||
"pageSize" => $pageSize,
|
||||
// "parentOrderStatus" => $parentOrderStatus
|
||||
);
|
||||
$common = array(
|
||||
'app_key' => $APP_KEY,
|
||||
'access_token' => $ACCESS_TOKEN,
|
||||
'data_type' => 'JSON',
|
||||
'timestamp' => (int)floor(microtime(true)),
|
||||
);
|
||||
$req = $biz + $common;
|
||||
$req['sign'] = sign_md5($req, $APP_SECRET);
|
||||
$payload = json_encode($req, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, array(
|
||||
CURLOPT_URL => $BASE_URL,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
|
||||
CURLOPT_POSTFIELDS => $payload
|
||||
));
|
||||
$resp = curl_exec($ch);
|
||||
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$cerr = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
var_dump($resp);
|
||||
|
||||
if ($resp === false) {
|
||||
echo "<pre>cURL error: " . htmlspecialchars($cerr, ENT_QUOTES, 'UTF-8') . "</pre>";
|
||||
break;
|
||||
}
|
||||
|
||||
$data = json_decode($resp, true);
|
||||
if (!is_array($data) || !isset($data['result']['pageItems']) || !is_array($data['result']['pageItems'])) {
|
||||
break;
|
||||
}
|
||||
|
||||
$items = $data['result']['pageItems'];
|
||||
if (!count($items)) {
|
||||
break;
|
||||
}
|
||||
|
||||
usort($items, function($a, $b){
|
||||
$ta = isset($a['parentOrderMap']['parentOrderTime']) ? (int)$a['parentOrderMap']['parentOrderTime'] : 0;
|
||||
$tb = isset($b['parentOrderMap']['parentOrderTime']) ? (int)$b['parentOrderMap']['parentOrderTime'] : 0;
|
||||
if ($ta == $tb) return 0;
|
||||
return ($ta > $tb) ? -1 : 1;
|
||||
});
|
||||
|
||||
$minTsOnPage = null;
|
||||
foreach ($items as $row) {
|
||||
if (!isset($row['parentOrderMap']['parentOrderSn'])) continue;
|
||||
$parentOrderSn = $row['parentOrderMap']['parentOrderSn'];
|
||||
$orderTs = isset($row['parentOrderMap']['parentOrderTime']) ? (int)$row['parentOrderMap']['parentOrderTime'] : 0;
|
||||
|
||||
if ($minTsOnPage === null || $orderTs < $minTsOnPage) $minTsOnPage = $orderTs;
|
||||
|
||||
if ($orderTs >= $fromTs && $orderTs <= $toTs) {
|
||||
// trafienie — drukujemy wybrane pola
|
||||
$issueHuman = $orderTs ? date('Y-m-d H:i:s', $orderTs) : '(brak)';
|
||||
|
||||
echo '<hr style="margin:16px 0;border:0;border-top:2px solid #999;">';
|
||||
echo '<div><b>Numer zamówienia:</b> ' . htmlspecialchars($parentOrderSn, ENT_QUOTES, 'UTF-8') . '</div>';
|
||||
echo '<div><b>Status:</b> ' . htmlspecialchars($row['parentOrderMap']['parentOrderStatus'], ENT_QUOTES, 'UTF-8') . '</div>';
|
||||
echo '<div><b>Data wystawienia:</b> ' . htmlspecialchars($issueHuman, ENT_QUOTES, 'UTF-8')
|
||||
. ' <span style="color:#888">(epoch: ' . (int)$orderTs . ')</span></div>';
|
||||
|
||||
echo '<div style="margin-top:6px;"><b>Produkty (extCode, soldFactor):</b></div>';
|
||||
if (isset($row['orderList']) && is_array($row['orderList']) && count($row['orderList'])>0) {
|
||||
echo '<ul style="margin:4px 0 10px 20px; padding:0;">';
|
||||
foreach ($row['orderList'] as $ol) {
|
||||
if (!isset($ol['productList']) || !is_array($ol['productList'])) continue;
|
||||
foreach ($ol['productList'] as $p) {
|
||||
$extCode = isset($p['extCode']) ? $p['extCode'] : '';
|
||||
$soldFactor = isset($p['soldFactor']) ? $p['soldFactor'] : '';
|
||||
echo '<li>extCode: <code>' . htmlspecialchars($extCode, ENT_QUOTES, 'UTF-8') . '</code>'
|
||||
. ', soldFactor: <code>' . htmlspecialchars($soldFactor, ENT_QUOTES, 'UTF-8') . '</code></li>';
|
||||
}
|
||||
}
|
||||
echo '</ul>';
|
||||
} else {
|
||||
echo '<div style="color:#b00">brak productList w orderList</div>';
|
||||
}
|
||||
|
||||
$totalMatched++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($minTsOnPage !== null && $minTsOnPage < $fromTs) {
|
||||
break;
|
||||
}
|
||||
|
||||
$page++;
|
||||
}
|
||||
|
||||
echo '<hr style="margin:16px 0;border:0;border-top:2px solid #999;">';
|
||||
echo '<div><b>Łącznie dopasowanych zamówień:</b> ' . (int)$totalMatched . '</div>';
|
||||
echo '<div><b>Zakres dat:</b> ' . htmlspecialchars(date('Y-m-d H:i:s', $fromTs), ENT_QUOTES, 'UTF-8')
|
||||
. ' — ' . htmlspecialchars(date('Y-m-d H:i:s', $toTs), ENT_QUOTES, 'UTF-8') . '</div>';
|
||||
echo '</div>';
|
||||
@@ -1,108 +1,60 @@
|
||||
<?php
|
||||
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
|
||||
* with the License. You may obtain a copy of the License at
|
||||
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
|
||||
* either express or implied.
|
||||
|
||||
*
|
||||
|
||||
* You may:
|
||||
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
|
||||
* a royalty or other fee.
|
||||
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
|
||||
* publicly available and document your modifications clearly.
|
||||
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
|
||||
* obligations for your customers.
|
||||
|
||||
*
|
||||
|
||||
* You may NOT:
|
||||
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
|
||||
* Provider).
|
||||
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
|
||||
* involves PHYSICAL media.
|
||||
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
|
||||
* or License text in the Licensed Software
|
||||
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
|
||||
* Licensed Software.
|
||||
|
||||
*
|
||||
|
||||
* You must:
|
||||
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
|
||||
*
|
||||
|
||||
* The Original Code is: CommuniCore
|
||||
|
||||
* Olavo Farias
|
||||
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
|
||||
*
|
||||
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
|
||||
* All Rights Reserved.
|
||||
|
||||
********************************************************************************/
|
||||
|
||||
global $mod_strings, $current_user;
|
||||
global $mod_strings, $current_user;
|
||||
|
||||
if(ACLController::checkAccess('EcmInvoiceOuts', "edit", true)) $module_menu [] = Array("index.php?module=".'EcmInvoiceOuts'."&action=EditView&return_module=".'EcmInvoiceOuts'."&return_action=DetailView", translate('LNK_NEW_'.'ECMQUOTE', 'EcmInvoiceOuts'),"CreateEcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
if (ACLController::checkAccess('EcmInvoiceOuts', "edit", true)) $module_menu [] = array("index.php?module=" . 'EcmInvoiceOuts' . "&action=EditView&return_module=" . 'EcmInvoiceOuts' . "&return_action=DetailView", translate('LNK_NEW_' . 'ECMQUOTE', 'EcmInvoiceOuts'), "CreateEcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
|
||||
if(ACLController::checkAccess('EcmInvoiceOuts', "list", true)) $module_menu [] = Array("index.php?module=EcmInvoiceOuts&action=index&return_module=EcmInvoiceOuts&return_action=DetailView", translate('LNK_ECMQUOTES_LIST','EcmInvoiceOuts'),"EcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
if(ACLController::checkAccess('EcmInvoiceOuts', "list", true)) $module_menu [] = Array("index.php?module=EcmInvoiceOuts&action=Report_INTRASTAT", "Raport INTRASTAT","EcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
|
||||
if(ACLController::checkAccess('EcmInvoiceOuts', "list", true)) $module_menu [] = Array("index.php?module=EcmInvoiceOuts&action=ecommerce", "Faktury E-Commerce","EcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
|
||||
if(ACLController::checkAccess('EcmInvoiceOuts', "list", true)) $module_menu [] = Array("index.php?module=EcmInvoiceOuts&action=bimit_invoiceSummary", "Analiza faktur","EcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
if (ACLController::checkAccess('EcmInvoiceOuts', "list", true)) $module_menu [] = array("index.php?module=EcmInvoiceOuts&action=index&return_module=EcmInvoiceOuts&return_action=DetailView", translate('LNK_ECMQUOTES_LIST', 'EcmInvoiceOuts'), "EcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
if (ACLController::checkAccess('EcmInvoiceOuts', "list", true)) $module_menu [] = array("index.php?module=EcmInvoiceOuts&action=Report_INTRASTAT", "Raport INTRASTAT", "EcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
if (ACLController::checkAccess('EcmInvoiceOuts', "list", true)) $module_menu [] = array("index.php?module=EcmInvoiceOuts&action=ecommerce", "Faktury E-Commerce", "EcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
if (ACLController::checkAccess('EcmInvoiceOuts', "list", true)) $module_menu [] = array("index.php?module=EcmInvoiceOuts&action=bimit_invoiceSummary", "Analiza faktur", "EcmInvoiceOuts", 'EcmInvoiceOuts');
|
||||
|
||||
@@ -19,12 +19,16 @@ if (isset($_REQUEST['import_baselinker'])) {
|
||||
include_once(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/amazonWZ.php');
|
||||
} else if (isset($_REQUEST['import_apilo'])) {
|
||||
include_once(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importApiloInvoices.php');
|
||||
} else if (isset($_REQUEST['import_temu'])) {
|
||||
include_once(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importTEMUInvoices.php');
|
||||
} else if (isset($_REQUEST['apilo_details'])) {
|
||||
include_once(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/apiloInvoiceDetails.php');
|
||||
} else if (isset($_REQUEST['baselinker_details'])) {
|
||||
include_once(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/baselinkerInvoiceDetails.php');
|
||||
} else if (isset($_REQUEST['apilo_products'])) {
|
||||
include_once(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/checkApiloProducts.php');
|
||||
} else if (isset($_REQUEST['temu'])) {
|
||||
include_once(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/TEMU/temuInvoicesListView.php');
|
||||
} else {
|
||||
include_once(getcwd().'/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.php');
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ if (isset($_REQUEST['record']) && $_REQUEST['isDuplicate'] == "false") {
|
||||
if (isset($focus->id) && $focus->id != '') {
|
||||
$focus->format_all_fields();
|
||||
}
|
||||
} else if (isset($_REQUEST['ecommerceZS'])) {
|
||||
} else if (isset($_REQUEST['ecommerceZSApilo'])) {
|
||||
$new_number = true;
|
||||
$focus->stock_id = 'cf16804e-f698-5e09-2da3-6553588446ae';
|
||||
$focus->register_date = date("d.m.Y");
|
||||
$focus->parent_id = 'b5612f7f-85e5-f930-293e-62cead14b424';
|
||||
$db = $GLOBALS['db'];
|
||||
$invoiceIds = $_SESSION[$_REQUEST['ecommerceZS']];
|
||||
$invoiceIds = $_SESSION[$_REQUEST['ecommerceZSApilo']];
|
||||
$i = $db->fetchByAssoc($db->query("SELECT register_date FROM ecommerce_invoices WHERE id = '$invoiceIds[0]'"));
|
||||
$focus->delivery_date = date("d.m.Y");
|
||||
$focus->payment_date = date("d.m.Y");
|
||||
@@ -92,6 +92,65 @@ GROUP BY ip.ecmproduct_id, ip.price_netto;
|
||||
$documentNos[] = $row['document_no'];
|
||||
}
|
||||
$focus->pdf_text = "Dotyczy faktur: " . implode(', ', $documentNos);
|
||||
} else if (isset($_REQUEST['ecommerceZSTemu'])) {
|
||||
$orders = json_decode($_SESSION[$_REQUEST['ecommerceZSTemu']]);
|
||||
$new_number = true;
|
||||
$focus->stock_id = 'cf16804e-f698-5e09-2da3-6553588446ae';
|
||||
$focus->register_date = date("d.m.Y");
|
||||
$focus->parent_id = '8b99791c-4e32-4443-fa57-69037059fe3f';
|
||||
$db = $GLOBALS['db'];
|
||||
$invoiceIds = $_SESSION[$_REQUEST['ecommerceZSApilo']];
|
||||
$focus->delivery_date = date("d.m.Y");
|
||||
$focus->payment_date = date("d.m.Y");
|
||||
$focus->send_date = date("d.m.Y");
|
||||
$focus->payment_date_days = 0;
|
||||
$focus->status = 's30';
|
||||
$focus->order_source = 'temu-'.$_REQUEST['temuCountry'];
|
||||
|
||||
$documentNos = array();
|
||||
$products = array();
|
||||
foreach ($orders as $order) {
|
||||
$documentNos[] = $order->orderNumber;
|
||||
foreach($order->products as $product) {
|
||||
$prod = $db->fetchByAssoc($db->query("SELECT id, name, code, unit_id FROM ecmproducts WHERE code = '".$product->extCode."' AND deleted = 0"));
|
||||
if (!isset($prod)) {
|
||||
echo 'Brak produktu, nie wystawiaj dokumentu! '.$product->extCode.' (Zamówienie: '.$order->orderNumber.')<br>';
|
||||
} else {
|
||||
$products[] = array(
|
||||
'product_id' => $prod['id'],
|
||||
'product_code' => $prod['code'],
|
||||
'name' => $prod['name'],
|
||||
'quantity' => $product->soldFactor,
|
||||
'price_start' => 0.01,
|
||||
'price_netto' => 0.01,
|
||||
'unit_id' => $prod['unit_id'],
|
||||
'unit_name' => $app_list_strings['ecmproducts_unit_dom'][$prod['unit_id']],
|
||||
'ecmvat_name' => '0%',
|
||||
'ecmvat_value' => 0,
|
||||
'ecmvat_id' => '9b783d21-5548-6653-e1d6-49610eb3f9dd',
|
||||
);
|
||||
}
|
||||
}
|
||||
$prod = $db->fetchByAssoc($db->query("SELECT id FROM ecmproducts WHERE code = '".$order->productCode."'"));
|
||||
}
|
||||
|
||||
$groupedProducts = array();
|
||||
|
||||
foreach ($products as $p) {
|
||||
$pid = $p['product_id'];
|
||||
if (!isset($groupedProducts[$pid])) {
|
||||
$groupedProducts[$pid] = $p;
|
||||
} else {
|
||||
$groupedProducts[$pid]['quantity'] += $p['quantity'];
|
||||
}
|
||||
}
|
||||
$groupedProducts = array_values($groupedProducts);
|
||||
|
||||
$edit->ss->assign('ECOMMERCE_PRODUCTS', json_encode($groupedProducts));
|
||||
|
||||
$query = "SELECT document_no FROM ecommerce_invoices WHERE id IN ('" . implode('\',\'', $invoiceIds) . "')";
|
||||
$res = $db->query($query);
|
||||
$focus->pdf_text = "Dotyczy zamówień: " . implode(', ', $documentNos);
|
||||
} else if ($_REQUEST['isDuplicate'] == "true") {
|
||||
$new_number = true;
|
||||
$duplicate = true;
|
||||
|
||||
166
modules/EcmSales/bimit_importTemuOrders.php
Normal file
166
modules/EcmSales/bimit_importTemuOrders.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
function noquote($v){
|
||||
$j = json_encode($v, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
||||
return (is_string($v) && $j[0]==='"' && substr($j,-1)==='"') ? substr($j,1,-1) : $j;
|
||||
}
|
||||
function sign_md5($p, $secret){
|
||||
ksort($p, SORT_STRING);
|
||||
$s = $secret;
|
||||
foreach($p as $k=>$v){ if($v!=='' && $v!==null) $s .= $k . noquote($v); }
|
||||
$s .= $secret;
|
||||
return strtoupper(md5($s));
|
||||
}
|
||||
|
||||
function getTemuOrders($from, $to, $country, $pageSize = 50){
|
||||
$APP_KEY = '02cbeff8afd35247294810033b036cfe';
|
||||
$APP_SECRET = '8ecfa21b55cddf66c66043cbb80756efc4ba6596';
|
||||
$ACCESS_TOKEN_DE = 'eploouslfhwjwwzvz5okvmu29stwwdw9l3ullz8pv6y4raips8gouzwcqmv';
|
||||
$ACCESS_TOKEN_PL = 'eplyaf6ogcpewjtzytw8q9ahvx7haqntzk8wsz7vokjusvpry93gy9cvn2c';
|
||||
$ACCESS_TOKEN_FR = 'eplhrdwtdgjpfelzmyelnsifakqjzfza6rpa8neb7nqc8djxj11hlenl3u2';
|
||||
$BASE_URL = 'https://openapi-b-eu.temu.com/openapi/router';
|
||||
$REGION_ID = 162;
|
||||
// --- parse daty ---
|
||||
if (!is_int($from)) $from = strtotime($from);
|
||||
if (!is_int($to)) $to = strtotime($to);
|
||||
|
||||
if (!$from || !$to) return [];
|
||||
if ($from > $to) { $tmp = $from; $from = $to; $to = $tmp; }
|
||||
|
||||
|
||||
$page = 1;
|
||||
$out = [];
|
||||
$seenAnyInRange = false;
|
||||
$guardPages = 500;
|
||||
|
||||
while ($guardPages-- > 0) {
|
||||
$biz = array(
|
||||
"type" => "bg.order.list.v2.get",
|
||||
//"regionId" => $REGION_ID,
|
||||
"pageNumber" => $page,
|
||||
"pageSize" => $pageSize
|
||||
);
|
||||
switch ($country) {
|
||||
case 'pl': $ACCESS_TOKEN = $ACCESS_TOKEN_PL; break;
|
||||
case 'fr': $ACCESS_TOKEN = $ACCESS_TOKEN_FR; break;
|
||||
default: $ACCESS_TOKEN = $ACCESS_TOKEN_DE; break;
|
||||
}
|
||||
$common = array(
|
||||
'app_key' => $APP_KEY,
|
||||
'access_token' => $ACCESS_TOKEN,
|
||||
'data_type' => 'JSON',
|
||||
'timestamp' => (int)floor(microtime(true)),
|
||||
);
|
||||
$req = $biz + $common;
|
||||
$req['sign'] = sign_md5($req, $APP_SECRET);
|
||||
|
||||
$payload = json_encode($req, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, array(
|
||||
CURLOPT_URL => $BASE_URL,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
|
||||
CURLOPT_POSTFIELDS => $payload,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
));
|
||||
$resp = curl_exec($ch);
|
||||
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$cerr = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($resp === false || $http !== 200) {
|
||||
break;
|
||||
}
|
||||
|
||||
$data = json_decode($resp, true);
|
||||
if ($data['success'] == false) {
|
||||
var_dump('Błąd ładowania zamówień TEMU '.$country.': '.$data['errorMsg']);
|
||||
break;
|
||||
}
|
||||
if (!is_array($data)
|
||||
|| !isset($data['result']['pageItems'])
|
||||
|| !is_array($data['result']['pageItems'])
|
||||
|| count($data['result']['pageItems']) === 0) {
|
||||
break;
|
||||
}
|
||||
$items = $data['result']['pageItems'];
|
||||
|
||||
usort($items, function($a, $b){
|
||||
$ta = isset($a['parentOrderMap']['parentOrderTime']) ? (int)$a['parentOrderMap']['parentOrderTime'] : 0;
|
||||
$tb = isset($b['parentOrderMap']['parentOrderTime']) ? (int)$b['parentOrderMap']['parentOrderTime'] : 0;
|
||||
if ($ta == $tb) return 0;
|
||||
return ($ta > $tb) ? -1 : 1;
|
||||
});
|
||||
|
||||
$maxTs = isset($items[0]['parentOrderMap']['parentOrderTime']) ? (int)$items[0]['parentOrderMap']['parentOrderTime'] : 0;
|
||||
$last = $items[count($items)-1];
|
||||
$minTs = isset($last['parentOrderMap']['parentOrderTime']) ? (int)$last['parentOrderMap']['parentOrderTime'] : 0;
|
||||
|
||||
foreach ($items as $row) {
|
||||
if (!isset($row['parentOrderMap']['parentOrderSn'])) continue;
|
||||
|
||||
$ts = isset($row['parentOrderMap']['parentOrderTime']) ? (int)$row['parentOrderMap']['parentOrderTime'] : 0;
|
||||
if ($ts < $from || $ts > $to) continue;
|
||||
|
||||
$pst = isset($row['parentOrderMap']['parentOrderStatus']) ? (int)$row['parentOrderMap']['parentOrderStatus'] : -1;
|
||||
if (!($pst === 4 || $pst === 5)) continue;
|
||||
|
||||
$seenAnyInRange = true;
|
||||
|
||||
$orderSn = $row['parentOrderMap']['parentOrderSn'];
|
||||
|
||||
// check if order exitst
|
||||
$db = $GLOBALS['db'];
|
||||
$exists = $db->fetchByAssoc($db->query("SELECT id FROM ecmsales WHERE pdf_text LIKE '%$orderSn%'"));
|
||||
if (isset($exists['id'])) continue;
|
||||
|
||||
$products = array();
|
||||
|
||||
if (isset($row['orderList']) && is_array($row['orderList'])) {
|
||||
foreach ($row['orderList'] as $ol) {
|
||||
if (!isset($ol['productList']) || !is_array($ol['productList'])) continue;
|
||||
foreach ($ol['productList'] as $p) {
|
||||
// hacks :)
|
||||
if ($p['extCode'] == 'FR00259_52_15g_amz_de-1') {
|
||||
$p['extCode'] = 'FR00259_52_15g_amz_de';
|
||||
}
|
||||
if ($p['extCode'] == 'FR00138_1000_amz_de-1') {
|
||||
$p['extCode'] = 'FR00138_1000_amz_de';
|
||||
}
|
||||
$products[] = array(
|
||||
'extCode' => isset($p['extCode']) ? $p['extCode'] : null,
|
||||
'soldFactor' => isset($p['soldFactor']) ? $p['soldFactor'] : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$out[] = array(
|
||||
'orderNumber' => $orderSn,
|
||||
'issueTime' => $ts,
|
||||
'issueDate' => $ts ? date('Y-m-d H:i:s', $ts) : null,
|
||||
'products' => $products,
|
||||
'raw' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
if ($minTs >= $from) {
|
||||
$page++;
|
||||
continue;
|
||||
}
|
||||
if ($maxTs < $from) {
|
||||
break;
|
||||
}
|
||||
if (!$seenAnyInRange) {
|
||||
$page++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
usort($out, function($a, $b){
|
||||
if ($a['issueTime'] == $b['issueTime']) return 0;
|
||||
return ($a['issueTime'] > $b['issueTime']) ? -1 : 1;
|
||||
});
|
||||
return $out;
|
||||
}
|
||||
@@ -3,6 +3,8 @@ ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
||||
|
||||
require_once ('modules/EcmSales/bimit_importTemuOrders.php');
|
||||
|
||||
$db = $GLOBALS['db'];
|
||||
global $app_list_strings;
|
||||
|
||||
@@ -18,9 +20,9 @@ if (isset($_REQUEST['date_from'])) {
|
||||
foreach ($invoices as $invoice) {
|
||||
$invoiceIds[] = $invoice['id'];
|
||||
}
|
||||
$sessionId = create_guid();
|
||||
$_SESSION[$sessionId] = $invoiceIds;
|
||||
$smarty->assign('sessionId', $sessionId);
|
||||
$sessionIdApilo = create_guid();
|
||||
$_SESSION[$sessionIdApilo] = $invoiceIds;
|
||||
$smarty->assign('sessionIdApilo', $sessionIdApilo);
|
||||
|
||||
$invoiceNo = array();
|
||||
foreach ($invoices as $invoice) {
|
||||
@@ -28,6 +30,39 @@ if (isset($_REQUEST['date_from'])) {
|
||||
}
|
||||
$smarty->assign('invoicesNo', join(", ", $invoiceNo));
|
||||
|
||||
$dateFrom = date('Y-m-d', strtotime($_REQUEST['date_from']));
|
||||
$dateTo = date('Y-m-d', strtotime($_REQUEST['date_to']));
|
||||
|
||||
$ordersPl = getTemuOrders($dateFrom.' 00:00:00', $dateTo.' 23:59:59', 'pl', 50);
|
||||
$orderNoPl = array();
|
||||
foreach ($ordersPl as $order) {
|
||||
$orderNoPl[] = $order['orderNumber'];
|
||||
}
|
||||
$smarty->assign('ordersNoPl', join(", ", $orderNoPl));
|
||||
$sessionIdTemuPl = create_guid();
|
||||
$_SESSION[$sessionIdTemuPl] = json_encode($ordersPl);
|
||||
$smarty->assign('sessionIdTemuPl', $sessionIdTemuPl);
|
||||
|
||||
$ordersDe = getTemuOrders($dateFrom.' 00:00:00', $dateTo.' 23:59:59', 'de', 50);
|
||||
$orderNoDe = array();
|
||||
foreach ($ordersDe as $order) {
|
||||
$orderNoDe[] = $order['orderNumber'];
|
||||
}
|
||||
$smarty->assign('ordersNoDe', join(", ", $orderNoDe));
|
||||
$sessionIdTemuDe = create_guid();
|
||||
$_SESSION[$sessionIdTemuDe] = json_encode($ordersDe);
|
||||
$smarty->assign('sessionIdTemuDe', $sessionIdTemuDe);
|
||||
|
||||
$ordersFr = getTemuOrders($dateFrom.' 00:00:00', $dateTo.' 23:59:59', 'fr', 50);
|
||||
$orderNoFr = array();
|
||||
foreach ($ordersFr as $order) {
|
||||
$orderNoFr[] = $order['orderNumber'];
|
||||
}
|
||||
$smarty->assign('ordersNoFr', join(", ", $orderNoFr));
|
||||
$sessionIdTemuFr = create_guid();
|
||||
$_SESSION[$sessionIdTemuFr] = json_encode($ordersFr);
|
||||
$smarty->assign('sessionIdTemuFr', $sessionIdTemuFr);
|
||||
|
||||
$smarty->assign('date_from', $_REQUEST['date_from']);
|
||||
$smarty->assign('date_to', $_REQUEST['date_to']);
|
||||
echo $smarty->display(getcwd() . '/modules/EcmSales/eCommerceZS/eCommerceZS.tpl');
|
||||
|
||||
@@ -63,7 +63,22 @@
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
ZS zbiorcza dla FV:<br> {$invoicesNo}
|
||||
<b>ZS zbiorcza dla FV (Apilo):</b><br> {$invoicesNo}
|
||||
<br><br>
|
||||
<input title="Wystaw ZS" class="button primary" type="button" name="Edit" id="edit_button" value="Wystaw ZS"
|
||||
onclick="window.open('index.php?module=EcmSales&action=EditView&ecommerceZS={$sessionId}')">
|
||||
<input title="Wystaw ZS" class="button primary" type="button" name="Edit" id="edit_button" value="Wystaw ZS Apilo"
|
||||
onclick="window.open('index.php?module=EcmSales&action=EditView&ecommerceZSApilo={$sessionIdApilo}')">
|
||||
<br><br>
|
||||
<b>ZS zbiorcza dla zamówień TEMU PL:</b><br> {$ordersNoPl}
|
||||
<br><br>
|
||||
<input title="Wystaw ZS" class="button primary" type="button" name="Edit" id="edit_button" value="Wystaw ZS Temu PL"
|
||||
onclick="window.open('index.php?module=EcmSales&action=EditView&temuCountry=PL&ecommerceZSTemu={$sessionIdTemuPl}')">
|
||||
<br><br>
|
||||
<b>ZS zbiorcza dla zamówień TEMU DE:</b><br> {$ordersNoDe}
|
||||
<br><br>
|
||||
<input title="Wystaw ZS" class="button primary" type="button" name="Edit" id="edit_button" value="Wystaw ZS Temu DE"
|
||||
onclick="window.open('index.php?module=EcmSales&action=EditView&temuCountry=DE&ecommerceZSTemu={$sessionIdTemuDe}')">
|
||||
<br><br>
|
||||
<b>ZS zbiorcza dla zamówień TEMU FR:</b><br> {$ordersNoFr}
|
||||
<br><br>
|
||||
<input title="Wystaw ZS" class="button primary" type="button" name="Edit" id="edit_button" value="Wystaw ZS Temu FR"
|
||||
onclick="window.open('index.php?module=EcmSales&action=EditView&temuCountry=FR&ecommerceZSTemu={$sessionIdTemuFr}')">
|
||||
@@ -219,7 +219,6 @@ class Scheduler extends SugarBean {
|
||||
*/
|
||||
function fireQualified() {
|
||||
if(empty($this->id)) { // execute only if we have an instance
|
||||
$GLOBALS['log']->fatal('Scheduler called fireQualified() in a non-instance');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -228,10 +227,8 @@ class Scheduler extends SugarBean {
|
||||
//_pp('now: '.$now); _pp($validTimes);
|
||||
|
||||
if(is_array($validTimes) && in_array($now, $validTimes)) {
|
||||
$GLOBALS['log']->debug('----->Scheduler found valid job ('.$this->name.') for time GMT('.$now.')');
|
||||
return true;
|
||||
} else {
|
||||
$GLOBALS['log']->debug('----->Scheduler did NOT find valid job ('.$this->name.') for time GMT('.$now.')');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -340,7 +337,6 @@ class Scheduler extends SugarBean {
|
||||
|
||||
$this->cleanJobLog();
|
||||
$allSchedulers = $this->get_full_list('', 'schedulers.status=\'Active\'');
|
||||
|
||||
if(!empty($allSchedulers)) {
|
||||
foreach($allSchedulers as $focus) {
|
||||
if($focus->fireQualified()) {
|
||||
|
||||
@@ -77,7 +77,7 @@ function importApiloInvoices() {
|
||||
require_once('modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importApiloInvoices.php');
|
||||
$GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices file loadded');
|
||||
$GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices importInvoices() fired');
|
||||
$res = importInvoices();
|
||||
$res = apilo_importInvoices();
|
||||
$GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices finished', $res);
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user