diff --git a/REST/functions.php b/REST/functions.php
index 8389ea98..30d234e7 100644
--- a/REST/functions.php
+++ b/REST/functions.php
@@ -74,7 +74,7 @@ function createPzFromInvoice($record, $stockId)
$pz->position_list = array();
$pz->fromREST = true;
- $gotAllProducts = true; // hope :)
+ $gotAllProducts = true; // hope :)
foreach ($inv->position_list as $product) {
echo 'Produkt: ' . $product->product_code . '
';
$p = getProduct($product->product_code);
@@ -313,3 +313,26 @@ function brecho($msg)
var_dump($msg);
echo '
';
}
+// AI analysis
+ function createCSVReports() {
+ // Zestawienie faktur
+ $db = $GLOBALS['db'];
+ $query = "SELECT ";
+ $res = $db->query("
+ SELECT i.document_no, i.register_date, i.parent_name, p.code, p.name, p.group_ks, ii.quantity, ii.price_netto
+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
+WHERE i.type = 'normal' AND YEAR(i.register_date) = 2024
+ORDER BY i.register_date DESC;");
+ while ($row = $db->fetchByAssoc($res)) {
+ var_dump($row);
+ }
+ // TODO: zapisaś wynik do pliku CSV
+ // zetawienie faktur korygujących
+
+ // zestawienie RW
+
+ // zestawienie aktualnych stanów magazynowych
+ die();
+ }
\ No newline at end of file
diff --git a/REST/index.php b/REST/index.php
index 60b4af4d..16931b6d 100644
--- a/REST/index.php
+++ b/REST/index.php
@@ -38,6 +38,9 @@
case 'createCostDocumentFromInvoice':
createCostDocumentFromInvoice($_GET['record']);
break;
+ case 'createCSVReports':
+ createCSVReports();
+ break;
}
// https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=createCostDocumentFromInvoice&record=c3f6eaa6-0cbd-8c89-1a8c-683ff19a36db
?>
\ No newline at end of file