22 lines
733 B
PHP
22 lines
733 B
PHP
|
|
<?php
|
||
|
|
// modules/EcmInvoiceOuts/ai/enqueue.php
|
||
|
|
$from = $_POST['from'] ?? null;
|
||
|
|
$to = $_POST['to'] ?? null;
|
||
|
|
$currency = $_POST['currency'] ?? 'PLN';
|
||
|
|
$axis = $_POST['axis'] ?? 'sku_id';
|
||
|
|
$label = $_POST['label'] ?? 'sku_name';
|
||
|
|
$top_n = (int)($_POST['top_n'] ?? 50);
|
||
|
|
$goal = $_POST['goal'] ?? 'porównanie Q2 vs Q1';
|
||
|
|
|
||
|
|
if (!$from || !$to) { http_response_code(400); exit('Missing from/to'); }
|
||
|
|
|
||
|
|
$base = __DIR__;
|
||
|
|
@mkdir("$base/queue", 0777, true);
|
||
|
|
|
||
|
|
$payload = compact('from','to','currency','axis','label','top_n','goal');
|
||
|
|
$id = bin2hex(random_bytes(8));
|
||
|
|
file_put_contents("$base/queue/$id.json", json_encode($payload, JSON_UNESCAPED_UNICODE));
|
||
|
|
|
||
|
|
header('Content-Type: application/json; charset=utf-8');
|
||
|
|
echo json_encode(['job_id' => $id]);
|