scheduler fixes
This commit is contained in:
@@ -5,11 +5,11 @@ ini_set('display_errors', 1);
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
DELETE FROM ecommerce_invoices_products WHERE invoice_id IN (
|
DELETE FROM ecommerce_invoices_products WHERE invoice_id IN (
|
||||||
SELECT id 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-04-%';
|
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/09-2025.csv';
|
||||||
$handle = fopen($filename, 'r');
|
$handle = fopen($filename, 'r');
|
||||||
if ($handle === false) {
|
if ($handle === false) {
|
||||||
die('Cannot open file: ' . $filename);
|
die('Cannot open file: ' . $filename);
|
||||||
@@ -38,7 +38,7 @@ foreach ($b2b as $el) {
|
|||||||
|
|
||||||
foreach ($groupedB2B as $invoiceNo => $invoice) {
|
foreach ($groupedB2B as $invoiceNo => $invoice) {
|
||||||
if (checkInvoice($invoiceNo)) {
|
if (checkInvoice($invoiceNo)) {
|
||||||
echo 'Invoice already exists' . PHP_EOL;
|
echo 'Invoice already exists: '.$invoiceNo.'<br>' ;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
// https://crm.twinpol.com/?module=EcmInvoiceOuts&action=ecommerce&amazon-wz=true
|
// 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-09-2025.csv';
|
||||||
$handle = fopen($filename, 'r');
|
$handle = fopen($filename, 'r');
|
||||||
if ($handle === false) {
|
if ($handle === false) {
|
||||||
die('Cannot open file: ' . $filename);
|
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-%';
|
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/09-2025.csv';
|
||||||
$handle = fopen($filename, 'r');
|
$handle = fopen($filename, 'r');
|
||||||
if ($handle === false) {
|
if ($handle === false) {
|
||||||
die('Cannot open file: ' . $filename);
|
die('Cannot open file: ' . $filename);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
|||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
// read csv file tab separated
|
// read csv file tab separated
|
||||||
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/08-2025.csv';
|
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/09-2025.csv';
|
||||||
$handle = fopen($filename, 'r');
|
$handle = fopen($filename, 'r');
|
||||||
if ($handle === false) {
|
if ($handle === false) {
|
||||||
die('Cannot open file: ' . $filename);
|
die('Cannot open file: ' . $filename);
|
||||||
@@ -31,7 +31,7 @@ fclose($handle);
|
|||||||
//if (count($de) == 0) {
|
//if (count($de) == 0) {
|
||||||
// die('No data for DE');
|
// die('No data for DE');
|
||||||
//}
|
//}
|
||||||
//createInvoice('DE', $de,);
|
//createInvoice('DE', $de);
|
||||||
|
|
||||||
if (count($cz) == 0) {
|
if (count($cz) == 0) {
|
||||||
die('No data for CZ');
|
die('No data for CZ');
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ FROM ecommerce_invoices_products p
|
|||||||
LEFT JOIN ecommerce_invoices i ON p.invoice_id = i.id
|
LEFT JOIN ecommerce_invoices i ON p.invoice_id = i.id
|
||||||
WHERE i.id IS NULL;
|
WHERE i.id IS NULL;
|
||||||
*/
|
*/
|
||||||
|
//importFVKOR('7689');
|
||||||
function importFV($seriesId)
|
function importFV($seriesId)
|
||||||
{
|
{
|
||||||
$baselinker_config = loadConfiguration();
|
$baselinker_config = loadConfiguration();
|
||||||
@@ -32,6 +33,8 @@ function importFV($seriesId)
|
|||||||
|
|
||||||
$invoices = $invoicesRes->invoices;
|
$invoices = $invoicesRes->invoices;
|
||||||
|
|
||||||
|
brecho($invoices);
|
||||||
|
|
||||||
usort($invoices, function ($a, $b) {
|
usort($invoices, function ($a, $b) {
|
||||||
return $a->date_add - $b->date_add;
|
return $a->date_add - $b->date_add;
|
||||||
});
|
});
|
||||||
@@ -54,7 +57,7 @@ function importFVKOR($seriesId)
|
|||||||
|
|
||||||
$IMPORT_CORRECTION_START_ID = 2106464;
|
$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'];
|
$lastImportId = $db->fetchByAssoc($dbRes)['id'];
|
||||||
if ($lastImportId == null) {
|
if ($lastImportId == null) {
|
||||||
$lastImportId = $IMPORT_CORRECTION_START_ID;
|
$lastImportId = $IMPORT_CORRECTION_START_ID;
|
||||||
@@ -62,10 +65,13 @@ function importFVKOR($seriesId)
|
|||||||
$lastImportId++; //get next
|
$lastImportId++; //get next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
brecho($lastImportId);
|
||||||
|
|
||||||
$invoicesRes = loadInvoices($baselinker_config['token'], $lastImportId, $seriesId);
|
$invoicesRes = loadInvoices($baselinker_config['token'], $lastImportId, $seriesId);
|
||||||
|
|
||||||
$invoices = $invoicesRes->invoices;
|
$invoices = $invoicesRes->invoices;
|
||||||
|
|
||||||
|
brecho($invoices);
|
||||||
usort($invoices, function ($a, $b) {
|
usort($invoices, function ($a, $b) {
|
||||||
return $a->date_add - $b->date_add;
|
return $a->date_add - $b->date_add;
|
||||||
});
|
});
|
||||||
@@ -118,6 +124,7 @@ function addInvoice($i)
|
|||||||
|
|
||||||
|
|
||||||
if ($db->last_error) {
|
if ($db->last_error) {
|
||||||
|
brecho($db->last_error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// delete products for this invoice if exists
|
// delete products for this invoice if exists
|
||||||
|
|||||||
@@ -219,7 +219,6 @@ class Scheduler extends SugarBean {
|
|||||||
*/
|
*/
|
||||||
function fireQualified() {
|
function fireQualified() {
|
||||||
if(empty($this->id)) { // execute only if we have an instance
|
if(empty($this->id)) { // execute only if we have an instance
|
||||||
$GLOBALS['log']->fatal('Scheduler called fireQualified() in a non-instance');
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,10 +227,8 @@ class Scheduler extends SugarBean {
|
|||||||
//_pp('now: '.$now); _pp($validTimes);
|
//_pp('now: '.$now); _pp($validTimes);
|
||||||
|
|
||||||
if(is_array($validTimes) && in_array($now, $validTimes)) {
|
if(is_array($validTimes) && in_array($now, $validTimes)) {
|
||||||
$GLOBALS['log']->debug('----->Scheduler found valid job ('.$this->name.') for time GMT('.$now.')');
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$GLOBALS['log']->debug('----->Scheduler did NOT find valid job ('.$this->name.') for time GMT('.$now.')');
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -340,7 +337,6 @@ class Scheduler extends SugarBean {
|
|||||||
|
|
||||||
$this->cleanJobLog();
|
$this->cleanJobLog();
|
||||||
$allSchedulers = $this->get_full_list('', 'schedulers.status=\'Active\'');
|
$allSchedulers = $this->get_full_list('', 'schedulers.status=\'Active\'');
|
||||||
|
|
||||||
if(!empty($allSchedulers)) {
|
if(!empty($allSchedulers)) {
|
||||||
foreach($allSchedulers as $focus) {
|
foreach($allSchedulers as $focus) {
|
||||||
if($focus->fireQualified()) {
|
if($focus->fireQualified()) {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ function importApiloInvoices() {
|
|||||||
require_once('modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importApiloInvoices.php');
|
require_once('modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importApiloInvoices.php');
|
||||||
$GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices file loadded');
|
$GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices file loadded');
|
||||||
$GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices importInvoices() fired');
|
$GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices importInvoices() fired');
|
||||||
$res = importInvoices();
|
$res = apilo_importInvoices();
|
||||||
$GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices finished', $res);
|
$GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices finished', $res);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user