example CSV rest action

This commit is contained in:
Michał Zieliński
2025-08-22 17:10:42 +02:00
parent e2fddb327c
commit 3ebc83e7c0
2 changed files with 27 additions and 1 deletions

View File

@@ -313,3 +313,26 @@ function brecho($msg)
var_dump($msg); var_dump($msg);
echo '<br><br>'; echo '<br><br>';
} }
// 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();
}

View File

@@ -38,6 +38,9 @@
case 'createCostDocumentFromInvoice': case 'createCostDocumentFromInvoice':
createCostDocumentFromInvoice($_GET['record']); createCostDocumentFromInvoice($_GET['record']);
break; 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 // https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=createCostDocumentFromInvoice&record=c3f6eaa6-0cbd-8c89-1a8c-683ff19a36db
?> ?>