WIP: ecommerce
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
<?php
|
||||
// enable error reporting
|
||||
error_reporting(LC_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
// ?XDEBUG_SESSION_START=PHPSTORM
|
||||
//importInvoices();
|
||||
importInvoices();
|
||||
function importInvoices()
|
||||
{
|
||||
$apilo_config = loadApiloConfiguration();
|
||||
$db = $GLOBALS['db'];
|
||||
|
||||
$GLOBALS['log']->info('----- Importing invoices from Apilo, config', $apilo_config);
|
||||
|
||||
$dbRes = $db->query("SELECT COUNT(id) as last_id FROM ecommerce_invoices WHERE origin LIKE 'apilo%'");
|
||||
$offset = intval($db->fetchByAssoc($dbRes)['last_id']);
|
||||
|
||||
$GLOBALS['log']->info('----- Importing invoices from Apilo, offset', $offset);
|
||||
|
||||
$invoices = loadApiloInvoices($apilo_config['token'], $offset);
|
||||
if (isset($invoices->error)) {
|
||||
if (refreshApiloToken($apilo_config['refreshToken'], $apilo_config['clientId'], $apilo_config['clientSecret']) == true) {
|
||||
@@ -19,6 +26,10 @@ function importInvoices()
|
||||
}
|
||||
}
|
||||
|
||||
brecho(count($invoices->documents));
|
||||
|
||||
$GLOBALS['log']->info('----- Importing invoices from Apilo, documents count', count($invoices->documents));
|
||||
|
||||
$platforms = loadApiloPlatformsList($apilo_config['token']);
|
||||
|
||||
if (!$platforms) {
|
||||
|
||||
Reference in New Issue
Block a user