mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
cronjob lagerzahlen added information
This commit is contained in:
parent
57a9aa23ff
commit
5b9a04031a
@ -1,38 +1,37 @@
|
|||||||
<?php
|
<?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';
|
if (file_exists(dirname(__DIR__) . '/www/lib/class.erpapi_custom.php') && !class_exists('erpAPICustom')) {
|
||||||
|
include_once dirname(__DIR__) . '/www/lib/class.erpapi_custom.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($app) || !class_exists('ApplicationCore') || !($app instanceof ApplicationCore)) {
|
if (empty($app) || !class_exists('ApplicationCore') || !($app instanceof ApplicationCore)) {
|
||||||
$app = new app_t();
|
$app = new app_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($app->Conf)) {
|
if (empty($app->Conf)) {
|
||||||
$conf = new Config();
|
$conf = new Config();
|
||||||
$app->Conf = $conf;
|
$app->Conf = $conf;
|
||||||
}
|
}
|
||||||
if(empty($app->DB)) {
|
if (empty($app->DB)) {
|
||||||
$app->DB = new DB($app->Conf->WFdbhost,$app->Conf->WFdbname,$app->Conf->WFdbuser,$app->Conf->WFdbpass,null,$app->Conf->WFdbport);
|
$app->DB = new DB($app->Conf->WFdbhost, $app->Conf->WFdbname, $app->Conf->WFdbuser, $app->Conf->WFdbpass, null, $app->Conf->WFdbport);
|
||||||
}
|
}
|
||||||
if(empty($app->erp)) {
|
if (empty($app->erp)) {
|
||||||
if(class_exists('erpAPICustom')) {
|
if (class_exists('erpAPICustom')) {
|
||||||
$erp = new erpAPICustom($app);
|
$erp = new erpAPICustom($app);
|
||||||
}
|
} else {
|
||||||
else {
|
$erp = new erpAPI($app);
|
||||||
$erp = new erpAPI($app);
|
}
|
||||||
}
|
$app->erp = $erp;
|
||||||
$app->erp = $erp;
|
}
|
||||||
}
|
if (empty($app->remote)) {
|
||||||
if(empty($app->remote)) {
|
if (is_file(dirname(__DIR__) . '/www/lib/class.remote_custom.php')) {
|
||||||
if(is_file(dirname(__DIR__) . '/www/lib/class.remote_custom.php')){
|
if (!class_exists('RemoteCustom')) {
|
||||||
if(!class_exists('RemoteCustom')) {
|
require_once dirname(__DIR__) . '/www/lib/class.remote_custom.php';
|
||||||
require_once dirname(__DIR__) . '/www/lib/class.remote_custom.php';
|
}
|
||||||
|
$app->remote = new RemoteCustom($app);
|
||||||
|
} else {
|
||||||
|
$app->remote = new Remote($app);
|
||||||
}
|
}
|
||||||
$app->remote = new RemoteCustom($app);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$app->remote = new Remote($app);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Start");
|
$app->erp->LogFile("Lagerzahlen-Synchronisation Start");
|
||||||
|
|
||||||
@ -40,34 +39,33 @@ $app->erp->LogFile("Lagerzahlen-Synchronisation Start");
|
|||||||
|
|
||||||
$firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
|
$firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
|
||||||
|
|
||||||
$app->DB->Update(
|
$app->DB->Update(
|
||||||
"UPDATE `prozessstarter`
|
"UPDATE `prozessstarter`
|
||||||
SET `mutexcounter` = `mutexcounter` + 1
|
SET `mutexcounter` = `mutexcounter` + 1
|
||||||
WHERE `mutex` = 1 AND `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
WHERE `mutex` = 1 AND `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
||||||
);
|
);
|
||||||
if(!$app->DB->Select(
|
if (!$app->DB->Select(
|
||||||
"SELECT `id` FROM `prozessstarter` WHERE `mutex` = 0 AND `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
"SELECT `id` FROM `prozessstarter` WHERE `mutex` = 0 AND `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
||||||
)) {
|
)) {
|
||||||
|
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Prozessstarter-Mutex nicht bereit");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$shops = $app->DB->SelectArr('SELECT * FROM `shopexport` WHERE `aktiv` = 1');
|
|
||||||
if(empty($shops)) {
|
|
||||||
|
|
||||||
|
$shops = $app->DB->SelectArr('SELECT * FROM `shopexport` WHERE `aktiv` = 1');
|
||||||
|
if (empty($shops)) {
|
||||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Keine aktiven Shops");
|
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Keine aktiven Shops");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$shopByIds = [];
|
$shopByIds = [];
|
||||||
foreach($shops as $shop) {
|
foreach ($shops as $shop) {
|
||||||
$shopByIds[$shop['id']] = $shop;
|
$shopByIds[$shop['id']] = $shop;
|
||||||
}
|
}
|
||||||
$shopIds = array_keys($shopByIds);
|
$shopIds = array_keys($shopByIds);
|
||||||
$shopIdsStr = implode(',', $shopIds);
|
$shopIdsStr = implode(',', $shopIds);
|
||||||
$hours = 12;
|
$hours = 12;
|
||||||
$hoursShop = 48;
|
$hoursShop = 48;
|
||||||
$lagerartikel = $app->DB->SelectFirstCols(
|
$lagerartikel = $app->DB->SelectFirstCols(
|
||||||
"SELECT a.id
|
"SELECT a.id
|
||||||
FROM `artikel` AS `a`
|
FROM `artikel` AS `a`
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT ao2.artikel, 1 AS `autolagerlampe`,
|
SELECT ao2.artikel, 1 AS `autolagerlampe`,
|
||||||
@ -97,91 +95,86 @@ $firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
|
|||||||
ORDER BY a.cache_lagerplatzinhaltmenge = -999 DESC,
|
ORDER BY a.cache_lagerplatzinhaltmenge = -999 DESC,
|
||||||
ao.cache_reseted DESC,
|
ao.cache_reseted DESC,
|
||||||
a.laststorage_sync"
|
a.laststorage_sync"
|
||||||
);
|
);
|
||||||
|
|
||||||
if(empty($lagerartikel)) {
|
|
||||||
|
|
||||||
|
if (empty($lagerartikel)) {
|
||||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Keine fälligen Artikel");
|
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Keine fälligen Artikel");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$r = new ReflectionMethod($app->erp, 'LagerSync');
|
$r = new ReflectionMethod($app->erp, 'LagerSync');
|
||||||
$params = $r->getParameters();
|
$params = $r->getParameters();
|
||||||
$anzargs = count($params);
|
$anzargs = count($params);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch(Exception $e) {
|
|
||||||
$anzargs = 2;
|
$anzargs = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$clagerartikel = $lagerartikel?count($lagerartikel):0;
|
$clagerartikel = $lagerartikel ? count($lagerartikel) : 0;
|
||||||
$app->erp->LogFile('Lagerzahlen-Synchronisation, Artikel gesamt: '.$clagerartikel);
|
$app->erp->LogFile('Lagerzahlen-Synchronisation, Artikel gesamt: ' . $clagerartikel);
|
||||||
foreach($lagerartikel as $ij => $articleId) {
|
foreach ($lagerartikel as $articleCounter => $articleId) {
|
||||||
$app->DB->Update(
|
$app->DB->Update(
|
||||||
"UPDATE `prozessstarter`
|
"UPDATE `prozessstarter`
|
||||||
SET `mutex` = 1 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
|
SET `mutex` = 1 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
|
||||||
WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
if($anzargs > 2){
|
if ($anzargs > 2) {
|
||||||
$message .= $app->erp->LagerSync($articleId, false, $shopByIds); // 2nd parameter is print_echo -> prints via echo to logfile (big print_r)
|
$message .= $app->erp->LagerSync($articleId, false, $shopByIds); // 2nd parameter is print_echo -> prints via echo to logfile (big print_r)
|
||||||
}else{
|
} else {
|
||||||
$message .= $app->erp->LagerSync($articleId, false);
|
$message .= $app->erp->LagerSync($articleId, false);
|
||||||
}
|
}
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
$message .= '<br>' . $exception->getMessage();
|
||||||
}
|
}
|
||||||
catch (Exception $exception) {
|
if ($message != '') {
|
||||||
$message .= '<br>' . $exception->getMessage();
|
$message .= '<br>';
|
||||||
}
|
}
|
||||||
if($message!='') {
|
if ($articleCounter % 10 === 0 && method_exists($app->erp, 'canRunCronjob') && !$app->erp->canRunCronjob(['lagerzahlen'])) {
|
||||||
$message .='<br>';
|
$app->DB->Update(
|
||||||
}
|
"UPDATE `prozessstarter`
|
||||||
if($ij % 10 === 0 && method_exists($app->erp, 'canRunCronjob')
|
SET `mutex` = 0 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
|
||||||
&& !$app->erp->canRunCronjob(['lagerzahlen'])) {
|
WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
||||||
$app->DB->Update(
|
);
|
||||||
"UPDATE `prozessstarter`
|
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: lagerzahlen-Job kann nicht geladen werden");
|
||||||
SET `mutex` = 0 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
|
return;
|
||||||
WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
$app->erp->LogFile("Lagerzahlen-Synchronisation: Warte 10 Sekunden");
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
}
|
}
|
||||||
$app->DB->Update(
|
$app->DB->Update(
|
||||||
"UPDATE `prozessstarter`
|
"UPDATE `prozessstarter`
|
||||||
SET `mutex` = 0 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
|
SET `mutex` = 0 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
|
||||||
WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
|
||||||
);
|
);
|
||||||
if($message !='' && $erp->Firmendaten('systemmailsabschalten') == 0 && $erp->GetFirmaMail()!='') {
|
if ($message != '' && $erp->Firmendaten('systemmailsabschalten') == 0 && $erp->GetFirmaMail() != '') {
|
||||||
try {
|
try {
|
||||||
if($erp->Firmendaten('systemmailsempfaenger') != ''){
|
if ($erp->Firmendaten('systemmailsempfaenger') != '') {
|
||||||
$erp->MailSend(
|
$erp->MailSend(
|
||||||
$erp->GetFirmaMail(),
|
$erp->GetFirmaMail(),
|
||||||
$erp->GetFirmaName(),
|
$erp->GetFirmaName(),
|
||||||
$erp->Firmendaten('systemmailsempfaenger'),
|
$erp->Firmendaten('systemmailsempfaenger'),
|
||||||
'Lagerverwaltung',
|
'Lagerverwaltung',
|
||||||
'Systemmeldung: Auto Update Lagerlampen',
|
'Systemmeldung: Auto Update Lagerlampen',
|
||||||
$message
|
$message
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
}else{
|
if ($erp->GetFirmaBCC1() != '') {
|
||||||
if($erp->GetFirmaBCC1() != ''){
|
$erp->MailSend(
|
||||||
$erp->MailSend(
|
$erp->GetFirmaMail(),
|
||||||
$erp->GetFirmaMail(),
|
$erp->GetFirmaName(),
|
||||||
$erp->GetFirmaName(),
|
$erp->GetFirmaBCC1(),
|
||||||
$erp->GetFirmaBCC1(),
|
'Lagerverwaltung',
|
||||||
'Lagerverwaltung',
|
'Systemmeldung: Auto Update Lagerlampen',
|
||||||
'Systemmeldung: Auto Update Lagerlampen',
|
$message
|
||||||
$message
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $exception) {
|
||||||
|
$app->erp->LogFile("Lagerzahlen-Synchronisation Exception:" . $app->DB->real_escape_string($exception->getMessage()));
|
||||||
}
|
}
|
||||||
catch (Exception $exception) {
|
}
|
||||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Exception:".$app->DB->real_escape_string($exception->getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende");
|
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende");
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user