diff --git a/config.php b/config.php
index df3bfb0c..2af40869 100755
--- a/config.php
+++ b/config.php
@@ -236,7 +236,7 @@ $sugar_config = array (
'log_memory_usage' => false,
'logger' =>
array (
- 'level' => 'debug',
+ 'level' => 'bimit',
'file' =>
array (
'ext' => '.log',
diff --git a/cron.php b/cron.php
index fb7f0aa7..352fe98d 100644
--- a/cron.php
+++ b/cron.php
@@ -68,7 +68,6 @@ $current_user->getSystemUser();
///////////////////////////////////////////////////////////////////////////////
//// PREP FOR SCHEDULER PID
-$GLOBALS['log']->debug('--------------------------------------------> at cron.php <--------------------------------------------');
$cachePath = $GLOBALS['sugar_config']['cache_dir'].'modules/Schedulers';
$pid = 'pid.php';
@@ -79,14 +78,10 @@ if(!is_file($cachePath.'/'.$pid)) {
if(is_writable($cachePath)) { // the "file" does not yet exist
write_array_to_file('timestamp', array(strtotime(date('H:i'))) , $cachePath.'/'.$pid);
require_once($cachePath.'/'.$pid);
- } else {
- $GLOBALS['log']->fatal('Scheduler cannot write PID file. Please check permissions on '.$cachePath);
}
} else {
if(is_writable($cachePath.'/'.$pid)) {
require_once($cachePath.'/'.$pid);
- } else {
- $GLOBALS['log']->fatal('Scheduler cannot read the PID file. Please check permissions on '.$cachePath);
}
}
//// END PREP FOR SCHEDULER PID
@@ -102,11 +97,7 @@ if($timestamp[0] < strtotime(date('H:i'))) {
$s = new Scheduler();
$s->flushDeadJobs();
$s->checkPendingJobs();
- } else {
- $GLOBALS['log']->fatal('Scheduler cannot write PID file. Please check permissions on '.$cachePath);
}
-} else {
- $GLOBALS['log']->fatal('If you see a whole string of these, there is a chance someone is attacking your system.');
}
$exit_on_cleanup = true;
sugar_cleanup($exit_on_cleanup);
diff --git a/include/SugarLogger/LoggerManager.php b/include/SugarLogger/LoggerManager.php
index 5cde36f7..ceb7711a 100755
--- a/include/SugarLogger/LoggerManager.php
+++ b/include/SugarLogger/LoggerManager.php
@@ -65,6 +65,7 @@ class LoggerManager {
'error' => 25,
'fatal' => 10,
'security' => 5,
+ 'bimit' => 2,
'off' => 0,
);
diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/apiloInvoiceDetails.php b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/apiloInvoiceDetails.php
index 0b29f551..3ad02852 100644
--- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/apiloInvoiceDetails.php
+++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/apiloInvoiceDetails.php
@@ -2,8 +2,10 @@
$id = $_REQUEST['apilo_details'];
$apilo_config = loadApiloConfiguration();
+brecho('halo');
brecho(loadApiloOrder($apilo_config['token'], $id));
function loadApiloOrder($token, $orderId) {
+ brecho($token);
$url = "https://twinpol.apilo.com/rest/api/orders/".$orderId."/";
$headers = [
'Authorization: Bearer ' . $token,
@@ -17,6 +19,7 @@ function loadApiloOrder($token, $orderId) {
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
+ brecho($response);
if ($httpCode !== 200) {
return false;
}
diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/baselinkerInvoiceDetails.php b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/baselinkerInvoiceDetails.php
index e972a4d3..f4de654b 100644
--- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/baselinkerInvoiceDetails.php
+++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/baselinkerInvoiceDetails.php
@@ -39,7 +39,7 @@ function getOrder($token, $orderId)
function brecho($msg)
{
echo '
';
- var_dump($msg);
+ print_r($msg);
echo PHP_EOL;
echo '
';
}
\ No newline at end of file
diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.js b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.js
index e71363c5..4dd52b96 100644
--- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.js
+++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.js
@@ -111,7 +111,7 @@ function copyToClipboard(text) {
}
function openDetails(id, origin) {
window.console.log(origin);
- if (origin.startsWith('apilo')) {
+ if (origin.startsWith('Apilo')) {
window.open("index.php?module=EcmInvoiceOuts&action=ecommerce&apilo_details="+id, "_blank");
} else {
window.open("index.php?module=EcmInvoiceOuts&action=ecommerce&baselinker_details="+id, "_blank");
diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.tpl b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.tpl
index faaef86a..3675eabb 100644
--- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.tpl
+++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.tpl
@@ -109,12 +109,17 @@
{$ROW.document_no}
{if $ROW.origin == 'amazon'}
+ style="cursor:pointer;"/>
{/if}
{if $ROW.origin == 'allegro'}
+ style="cursor:pointer;"/>
+ {/if}
+
+
{$ROW.wz_document_no}
diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importApiloInvoices.php b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importApiloInvoices.php
index 0e26894f..31795caf 100644
--- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importApiloInvoices.php
+++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importApiloInvoices.php
@@ -1,36 +1,31 @@
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);
+ $invoices = apilo_loadInvoices($apilo_config['token'], $offset);
if (isset($invoices->error)) {
- if (refreshApiloToken($apilo_config['refreshToken'], $apilo_config['clientId'], $apilo_config['clientSecret']) == true) {
- $apilo_config = loadApiloConfiguration();
- $invoices = loadApiloInvoices($apilo_config['token'], $offset);
+ if (apilo_refreshToken($apilo_config['refreshToken'], $apilo_config['clientId'], $apilo_config['clientSecret']) == true) {
+ //$apilo_config = apilo_loadConfiguration();
+ //$invoices = apilo_loadInvoices($apilo_config['token'], $offset);
} else {
return false;
}
}
- brecho(count($invoices->documents));
+ $GLOBALS['log']->bimit('----- Importing invoices from Apilo, documents count', count($invoices->documents));
- $GLOBALS['log']->info('----- Importing invoices from Apilo, documents count', count($invoices->documents));
-
- $platforms = loadApiloPlatformsList($apilo_config['token']);
+ $platforms = apilo_loadPlatformsList($apilo_config['token']);
if (!$platforms) {
return false;
@@ -38,15 +33,15 @@ function importInvoices()
if (isset($invoices->documents) && count($invoices->documents) > 0) {
foreach ($invoices->documents as $invoice) {
- addapiloInvoice($invoice, $platforms, $apilo_config['token']);
+ apilo_addInvoice($invoice, $platforms, $apilo_config['token']);
}
}
- $GLOBALS['log']->info('----- Importing invoices from Apilo, all processed, return TRUE');
+ $GLOBALS['log']->bimit('----- Importing invoices from Apilo, all processed, return TRUE');
return true;
}
-function loadApiloConfiguration()
+function apilo_loadConfiguration()
{
- global $db;
+ $db = $GLOBALS['db'];
$dbRes = $db->query("SELECT * FROM config WHERE category='apilo'");
$config = [];
while ($row = $db->fetchByAssoc($dbRes)) {
@@ -54,7 +49,7 @@ function loadApiloConfiguration()
}
return $config;
}
-function loadApiloInvoices($token, $offset)
+function apilo_loadInvoices($token, $offset)
{
$url = "https://twinpol.apilo.com/rest/api/finance/documents/";
$params = [
@@ -81,7 +76,7 @@ function loadApiloInvoices($token, $offset)
}
return json_decode($response);
}
-function refreshApiloToken($refreshToken, $clientId, $clientSecret)
+function apilo_refreshToken($refreshToken, $clientId, $clientSecret)
{
$url = "https://twinpol.apilo.com/rest/auth/token/";
@@ -126,11 +121,11 @@ function refreshApiloToken($refreshToken, $clientId, $clientSecret)
}
return false;
}
-function addApiloInvoice($invoice, $platforms, $token)
+function apilo_addInvoice($invoice, $platforms, $token)
{
$db = $GLOBALS['db'];
- $platformId = loadApiloOrderPlatformId($token, $invoice->orderId);
+ $platformId = apilo_loadOrderPlatformId($token, $invoice->orderId);
if (!$platformId) {
return false;
}
@@ -231,12 +226,12 @@ function addApiloInvoice($invoice, $platforms, $token)
if (isset($invoice->documentItems) && is_array($invoice->documentItems)) {
$db->query(sprintf("DELETE FROM ecommerce_invoices_products WHERE invoice_id='%s'", $db->quote($invoice->id)));
foreach ($invoice->documentItems as $item) {
- addApiloInvoiceProduct($invoice->id, $item);
+ apilo_addInvoiceProduct($invoice->id, $item);
}
}
return true;
}
-function addApiloInvoiceProduct($invoiceId, $item)
+function apilo_addInvoiceProduct($invoiceId, $item)
{
$db = $GLOBALS['db'];
@@ -290,7 +285,7 @@ function addApiloInvoiceProduct($invoiceId, $item)
return false;
}
}
-function loadApiloPlatformsList($token) {
+function apilo_loadPlatformsList($token) {
$url = "https://twinpol.apilo.com/rest/api/orders/platform/map/";
$headers = [
'Authorization: Bearer ' . $token,
@@ -309,7 +304,7 @@ function loadApiloPlatformsList($token) {
}
return json_decode($response);
}
-function loadApiloOrderPlatformId($token, $orderId) {
+function apilo_loadOrderPlatformId($token, $orderId) {
$url = "https://twinpol.apilo.com/rest/api/orders/".$orderId."/";
$headers = [
'Authorization: Bearer ' . $token,
diff --git a/modules/Schedulers/Scheduler.php b/modules/Schedulers/Scheduler.php
index 83170614..6663062a 100755
--- a/modules/Schedulers/Scheduler.php
+++ b/modules/Schedulers/Scheduler.php
@@ -106,7 +106,6 @@ class Scheduler extends SugarBean {
*/
function fire() {
if(empty($this->job)) { // only execute when valid
- $GLOBALS['log']->fatal('Scheduler tried to fire an empty job!!');
return false;
}
@@ -126,16 +125,18 @@ class Scheduler extends SugarBean {
$job->retrieve($jobId);
if($exJob[0] == 'function') {
- $GLOBALS['log']->debug('----->Scheduler found a job of type FUNCTION');
+
require_once('modules/Schedulers/_AddJobsHere.php');
$job->setJobFlag(1);
$func = $exJob[1];
- $GLOBALS['log']->debug('----->SchedulersJob firing '.$func);
+
+ $GLOBALS['log']->bimit('Starting function', $job->scheduler->id, $job->scheduler->name, $func);
$res = call_user_func($func);
if($res) {
+ $GLOBALS['log']->bimit('Setting JOB as finished', $job->scheduler->id, $job->scheduler->name, $res);
$job->setJobFlag(2);
$job->finishJob();
return true;
@@ -340,21 +341,14 @@ class Scheduler extends SugarBean {
$this->cleanJobLog();
$allSchedulers = $this->get_full_list('', 'schedulers.status=\'Active\'');
-
- $GLOBALS['log']->info('-----> Scheduler found [ '.count($allSchedulers).' ] ACTIVE jobs');
-
if(!empty($allSchedulers)) {
foreach($allSchedulers as $focus) {
if($focus->fireQualified()) {
- if($focus->fire()) {
- $GLOBALS['log']->debug('----->Scheduler Job completed successfully');
- } else {
- $GLOBALS['log']->fatal('----->Scheduler Job FAILED');
- }
+ $GLOBALS['log']->bimit('Starting job', $focus->id, $focus->name);
+ $res = $focus->fire();
+ $GLOBALS['log']->bimit('Finished job', $focus->id, $focus->name, $res);
}
}
- } else {
- $GLOBALS['log']->debug('----->No Schedulers found');
}
}
diff --git a/modules/Schedulers/_AddJobsHere.php b/modules/Schedulers/_AddJobsHere.php
index 81eae73a..a9faa8cf 100644
--- a/modules/Schedulers/_AddJobsHere.php
+++ b/modules/Schedulers/_AddJobsHere.php
@@ -71,27 +71,33 @@ $job_strings = array(
function importApiloInvoices() {
try {
- $GLOBALS['log']->info('----- Importing invoices from Apilo, _addJobsHereReturn, starting');
+ $GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices started');
$GLOBALS['db']->query("USE preDb_0dcc87940d3655fa574b253df04ca1c3;");
+ $GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices db query done');
require_once('modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importApiloInvoices.php');
+ $GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices file loadded');
+ $GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices importInvoices() fired');
$res = importInvoices();
- $GLOBALS['log']->info('----- Importing invoices from Apilo, _addJobsHereReturn', $res);
+ $GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices finished', $res);
return true;
} catch (Exception $e) {
- $GLOBALS['log']->info('----- Importing invoices from Apilo, _addJobsHereReturn, error catched', $e);
+ $GLOBALS['log']->bimit('_addJobsHere, importApiloInvoices error', $e);
return false;
}
}
function importBaselinkerInvoices()
{
try {
+ $GLOBALS['log']->bimit('_addJobsHere, importBaselinkerInvoices started');
$GLOBALS['db']->query("USE preDb_0dcc87940d3655fa574b253df04ca1c3;");
require_once('modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importBaselinkerInvoices.php');
importFV('7688'); // FV Polska
//importFV('15356'); // FV Polska (stare)
importFV('53096'); // FV Temu
+ $GLOBALS['log']->bimit('_addJobsHere, importBaselinkerInvoices finished');
return true;
} catch (Exception $e) {
+ $GLOBALS['log']->bimit('_addJobsHere, importBaselinkerInvoices error', $e);
return false;
}
}
diff --git a/modules/Schedulers/test.php b/modules/Schedulers/test.php
index 83ac87fe..9d1b9b5c 100755
--- a/modules/Schedulers/test.php
+++ b/modules/Schedulers/test.php
@@ -1,4 +1,4 @@
debug('test');
+$logger->bimit('test');
echo 'test';
\ No newline at end of file
|