scheduler fixes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user