mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2025-01-12 06:41:14 +01:00
cronjob lagerzahlen added information
This commit is contained in:
parent
57a9aa23ff
commit
5b9a04031a
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
if (file_exists(dirname(__DIR__) . '/www/lib/class.erpapi_custom.php') && !class_exists('erpAPICustom')) {
|
||||
include_once dirname(__DIR__) . '/www/lib/class.erpapi_custom.php';
|
||||
}
|
||||
@ -17,8 +18,7 @@ if(empty($app->DB)) {
|
||||
if (empty($app->erp)) {
|
||||
if (class_exists('erpAPICustom')) {
|
||||
$erp = new erpAPICustom($app);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$erp = new erpAPI($app);
|
||||
}
|
||||
$app->erp = $erp;
|
||||
@ -29,8 +29,7 @@ if(empty($app->remote)) {
|
||||
require_once dirname(__DIR__) . '/www/lib/class.remote_custom.php';
|
||||
}
|
||||
$app->remote = new RemoteCustom($app);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$app->remote = new Remote($app);
|
||||
}
|
||||
}
|
||||
@ -48,14 +47,13 @@ $firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
|
||||
if (!$app->DB->Select(
|
||||
"SELECT `id` FROM `prozessstarter` WHERE `mutex` = 0 AND `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
||||
)) {
|
||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Prozessstarter-Mutex nicht bereit");
|
||||
return;
|
||||
}
|
||||
|
||||
$shops = $app->DB->SelectArr('SELECT * FROM `shopexport` WHERE `aktiv` = 1');
|
||||
if (empty($shops)) {
|
||||
|
||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Keine aktiven Shops");
|
||||
|
||||
return;
|
||||
}
|
||||
$shopByIds = [];
|
||||
@ -100,9 +98,7 @@ $firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
|
||||
);
|
||||
|
||||
if (empty($lagerartikel)) {
|
||||
|
||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Keine fälligen Artikel");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -110,14 +106,13 @@ $firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
|
||||
$r = new ReflectionMethod($app->erp, 'LagerSync');
|
||||
$params = $r->getParameters();
|
||||
$anzargs = count($params);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$anzargs = 2;
|
||||
}
|
||||
|
||||
$clagerartikel = $lagerartikel ? count($lagerartikel) : 0;
|
||||
$app->erp->LogFile('Lagerzahlen-Synchronisation, Artikel gesamt: ' . $clagerartikel);
|
||||
foreach($lagerartikel as $ij => $articleId) {
|
||||
foreach ($lagerartikel as $articleCounter => $articleId) {
|
||||
$app->DB->Update(
|
||||
"UPDATE `prozessstarter`
|
||||
SET `mutex` = 1 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
|
||||
@ -129,22 +124,22 @@ $firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
|
||||
} else {
|
||||
$message .= $app->erp->LagerSync($articleId, false);
|
||||
}
|
||||
}
|
||||
catch (Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$message .= '<br>' . $exception->getMessage();
|
||||
}
|
||||
if ($message != '') {
|
||||
$message .= '<br>';
|
||||
}
|
||||
if($ij % 10 === 0 && method_exists($app->erp, 'canRunCronjob')
|
||||
&& !$app->erp->canRunCronjob(['lagerzahlen'])) {
|
||||
if ($articleCounter % 10 === 0 && method_exists($app->erp, 'canRunCronjob') && !$app->erp->canRunCronjob(['lagerzahlen'])) {
|
||||
$app->DB->Update(
|
||||
"UPDATE `prozessstarter`
|
||||
SET `mutex` = 0 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
|
||||
WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
||||
);
|
||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: lagerzahlen-Job kann nicht geladen werden");
|
||||
return;
|
||||
}
|
||||
$app->erp->LogFile("Lagerzahlen-Synchronisation: Warte 10 Sekunden");
|
||||
usleep(10000);
|
||||
}
|
||||
$app->DB->Update(
|
||||
@ -163,7 +158,6 @@ $firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
|
||||
'Systemmeldung: Auto Update Lagerlampen',
|
||||
$message
|
||||
);
|
||||
|
||||
} else {
|
||||
if ($erp->GetFirmaBCC1() != '') {
|
||||
$erp->MailSend(
|
||||
@ -176,8 +170,7 @@ $firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Exception:" . $app->DB->real_escape_string($exception->getMessage()));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user