mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2025-03-30 18:10:23 +02:00
cronjobs/shop_rueckmeldungen.php format
This commit is contained in:
parent
4ed783a7ca
commit
ea515b0727
@ -1,89 +1,86 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
||||||
if(!class_exists('ApplicationCore') && is_file(dirname(__DIR__).'/xentral_autoloader.php')) {
|
if (!class_exists('ApplicationCore') && is_file(dirname(__DIR__) . '/xentral_autoloader.php')) {
|
||||||
include_once dirname(__DIR__).'/xentral_autoloader.php';
|
include_once dirname(__DIR__) . '/xentral_autoloader.php';
|
||||||
}
|
}
|
||||||
include_once dirname(__DIR__).'/conf/main.conf.php';
|
include_once dirname(__DIR__) . '/conf/main.conf.php';
|
||||||
include_once dirname(__DIR__).'/phpwf/plugins/class.mysql.php';
|
include_once dirname(__DIR__) . '/phpwf/plugins/class.mysql.php';
|
||||||
include_once dirname(__DIR__).'/phpwf/plugins/class.secure.php';
|
include_once dirname(__DIR__) . '/phpwf/plugins/class.secure.php';
|
||||||
include_once dirname(__DIR__).'/phpwf/plugins/class.user.php';
|
include_once dirname(__DIR__) . '/phpwf/plugins/class.user.php';
|
||||||
if(file_exists(dirname(__DIR__).'/conf/user_defined.php')) {
|
if (file_exists(dirname(__DIR__) . '/conf/user_defined.php')) {
|
||||||
include_once dirname(__DIR__).'/conf/user_defined.php';
|
include_once dirname(__DIR__) . '/conf/user_defined.php';
|
||||||
}
|
}
|
||||||
if(!class_exists('FPDFWAWISION')){
|
if (!class_exists('FPDFWAWISION')) {
|
||||||
if(file_exists(dirname(__DIR__).'/conf/user_defined.php')){
|
if (file_exists(dirname(__DIR__) . '/conf/user_defined.php')) {
|
||||||
include_once dirname(__DIR__) . '/conf/user_defined.php';
|
include_once dirname(__DIR__) . '/conf/user_defined.php';
|
||||||
}
|
}
|
||||||
if(defined('USEFPDF3') && USEFPDF3 && file_exists(dirname(__DIR__) . '/www/lib/pdf/fpdf_3.php')){
|
if (defined('USEFPDF3') && USEFPDF3 && file_exists(dirname(__DIR__) . '/www/lib/pdf/fpdf_3.php')) {
|
||||||
require_once dirname(__DIR__) . '/www/lib/pdf/fpdf_3.php';
|
require_once dirname(__DIR__) . '/www/lib/pdf/fpdf_3.php';
|
||||||
}else if(defined('USEFPDF2') && USEFPDF2 && file_exists(dirname(__DIR__) . '/www/lib/pdf/fpdf_2.php')){
|
} else if (defined('USEFPDF2') && USEFPDF2 && file_exists(dirname(__DIR__) . '/www/lib/pdf/fpdf_2.php')) {
|
||||||
require_once dirname(__DIR__) . '/www/lib/pdf/fpdf_2.php';
|
require_once dirname(__DIR__) . '/www/lib/pdf/fpdf_2.php';
|
||||||
}else{
|
} else {
|
||||||
require_once dirname(__DIR__) . '/www/lib/pdf/fpdf.php';
|
require_once dirname(__DIR__) . '/www/lib/pdf/fpdf.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
include_once dirname(__DIR__).'/www/lib/pdf/fpdf_final.php';
|
include_once dirname(__DIR__) . '/www/lib/pdf/fpdf_final.php';
|
||||||
include_once dirname(__DIR__).'/www/lib/imap.inc.php';
|
include_once dirname(__DIR__) . '/www/lib/imap.inc.php';
|
||||||
include_once dirname(__DIR__).'/www/lib/class.erpapi.php';
|
include_once dirname(__DIR__) . '/www/lib/class.erpapi.php';
|
||||||
include_once dirname(__DIR__).'/www/lib/class.remote.php';
|
include_once dirname(__DIR__) . '/www/lib/class.remote.php';
|
||||||
include_once dirname(__DIR__).'/www/lib/class.httpclient.php';
|
include_once dirname(__DIR__) . '/www/lib/class.httpclient.php';
|
||||||
$aes = '';
|
$aes = '';
|
||||||
$phpversion = (String)phpversion();
|
$phpversion = (String) phpversion();
|
||||||
if($phpversion[0] == '7' && (int)$phpversion[2] > 0) {
|
if ($phpversion[0] == '7' && (int) $phpversion[2] > 0) {
|
||||||
$aes = '2';
|
$aes = '2';
|
||||||
}
|
}
|
||||||
if($aes == 2 && is_file(dirname(__DIR__).'/www/lib/class.aes2.php')) {
|
if ($aes == 2 && is_file(dirname(__DIR__) . '/www/lib/class.aes2.php')) {
|
||||||
include_once dirname(__DIR__).'/www/lib/class.aes2.php';
|
include_once dirname(__DIR__) . '/www/lib/class.aes2.php';
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
include_once dirname(__DIR__) . '/www/lib/class.aes.php';
|
include_once dirname(__DIR__) . '/www/lib/class.aes.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
$classes = array('briefpapier','lieferschein','auftrag','anfrage','gutschrift','bestellung','rechnung','mahnwesen');
|
$classes = array('briefpapier', 'lieferschein', 'auftrag', 'anfrage', 'gutschrift', 'bestellung', 'rechnung', 'mahnwesen');
|
||||||
foreach($classes as $class)
|
foreach ($classes as $class) {
|
||||||
{
|
if (file_exists(dirname(__DIR__) . '/www/lib/dokumente/class.' . $class . '_custom.php')) {
|
||||||
if(file_exists(dirname(__DIR__).'/www/lib/dokumente/class.'.$class.'_custom.php'))
|
include_once dirname(__DIR__) . '/www/lib/dokumente/class.' . $class . '_custom.php';
|
||||||
{
|
} elseif (file_exists(dirname(__DIR__) . '/www/lib/dokumente/class.' . $class . '.php')) {
|
||||||
include_once dirname(__DIR__).'/www/lib/dokumente/class.'.$class.'_custom.php';
|
include_once dirname(__DIR__) . '/www/lib/dokumente/class.' . $class . '.php';
|
||||||
}
|
|
||||||
elseif(file_exists(dirname(__DIR__).'/www/lib/dokumente/class.'.$class.'.php')) {
|
|
||||||
include_once dirname(__DIR__).'/www/lib/dokumente/class.'.$class.'.php';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.briefpapier.php");
|
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.briefpapier.php");
|
||||||
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.lieferschein.php");
|
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.lieferschein.php");
|
||||||
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.auftrag.php");
|
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.auftrag.php");
|
||||||
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.angebot.php");
|
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.angebot.php");
|
||||||
if(file_exists(dirname(__FILE__)."/../www/lib/dokumente/class.anfrage.php"))include_once(dirname(__FILE__)."/../www/lib/dokumente/class.anfrage.php");
|
if(file_exists(dirname(__FILE__)."/../www/lib/dokumente/class.anfrage.php"))include_once(dirname(__FILE__)."/../www/lib/dokumente/class.anfrage.php");
|
||||||
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.gutschrift.php");
|
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.gutschrift.php");
|
||||||
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.bestellung.php");
|
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.bestellung.php");
|
||||||
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.rechnung.php");
|
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.rechnung.php");
|
||||||
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.mahnwesen.php");*/
|
include_once(dirname(__FILE__)."/../www/lib/dokumente/class.mahnwesen.php"); */
|
||||||
include_once dirname(__DIR__).'/phpwf/plugins/class.string.php';
|
include_once dirname(__DIR__) . '/phpwf/plugins/class.string.php';
|
||||||
if(!class_exists('app_t2'))
|
if (!class_exists('app_t2')) {
|
||||||
{
|
|
||||||
class app_t2 extends ApplicationCore {
|
class app_t2 extends ApplicationCore {
|
||||||
|
|
||||||
var $DB;
|
var $DB;
|
||||||
var $erp;
|
var $erp;
|
||||||
var $User;
|
var $User;
|
||||||
var $mail;
|
var $mail;
|
||||||
var $remote;
|
var $remote;
|
||||||
var $Secure;
|
var $Secure;
|
||||||
function GetLandLang($isocode)
|
|
||||||
{
|
function GetLandLang($isocode) {
|
||||||
$flipped = array_flip($this->GetLaender());
|
$flipped = array_flip($this->GetLaender());
|
||||||
if(isset($flipped[$isocode]))
|
if (isset($flipped[$isocode]))
|
||||||
$land = $flipped[$isocode];
|
$land = $flipped[$isocode];
|
||||||
else {
|
else {
|
||||||
$land = 'unkown';
|
$land = 'unkown';
|
||||||
}
|
}
|
||||||
return $land;
|
return $land;
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetLaender()
|
function GetLaender() {
|
||||||
{
|
|
||||||
$laender = array(
|
$laender = array(
|
||||||
'Afghanistan' => 'AF',
|
'Afghanistan' => 'AF',
|
||||||
'Ägypten' => 'EG',
|
'Ägypten' => 'EG',
|
||||||
@ -329,65 +326,64 @@ function GetLaender()
|
|||||||
'Zypern' => 'CY'
|
'Zypern' => 'CY'
|
||||||
);
|
);
|
||||||
return $laender;
|
return $laender;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//ENDE
|
//ENDE
|
||||||
|
|
||||||
|
|
||||||
if(empty($app) || !class_exists('ApplicationCore') || !($app instanceof ApplicationCore)) {
|
if (empty($app) || !class_exists('ApplicationCore') || !($app instanceof ApplicationCore)) {
|
||||||
$app = new app_t2();
|
$app = new app_t2();
|
||||||
}
|
}
|
||||||
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)) {
|
||||||
$erp = new erpAPI($app);
|
$erp = new erpAPI($app);
|
||||||
$app->erp = $erp;
|
$app->erp = $erp;
|
||||||
}
|
}
|
||||||
$app->String = new WawiString();
|
$app->String = new WawiString();
|
||||||
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')) {
|
||||||
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);
|
$app->remote = new RemoteCustom($app);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$app->remote = new Remote($app);
|
$app->remote = new Remote($app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//$app->remote = new Remote($app);
|
//$app->remote = new Remote($app);
|
||||||
$app->Secure = new Secure($app);
|
$app->Secure = new Secure($app);
|
||||||
$app->User = new User($app);
|
$app->User = new User($app);
|
||||||
if(!defined('FPDF_FONTPATH')) {
|
if (!defined('FPDF_FONTPATH')) {
|
||||||
define('FPDF_FONTPATH',dirname(__DIR__).'/www/lib/pdf/font/');
|
define('FPDF_FONTPATH', dirname(__DIR__) . '/www/lib/pdf/font/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//ENDE
|
//ENDE
|
||||||
|
|
||||||
const MAXIMUM_NUMBER_OF_TRIES = 10;
|
const MAXIMUM_NUMBER_OF_TRIES = 10;
|
||||||
|
|
||||||
$shops = $app->DB->SelectFirstCols(
|
$shops = $app->DB->SelectFirstCols(
|
||||||
'SELECT id FROM shopexport WHERE auftragabgleich = 1 AND aktiv = 1 AND demomodus <> 1 AND sendonlywithtracking = 0'
|
'SELECT id FROM shopexport WHERE auftragabgleich = 1 AND aktiv = 1 AND demomodus <> 1 AND sendonlywithtracking = 0'
|
||||||
);
|
);
|
||||||
if(empty($shops)) {
|
if (empty($shops)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$app->DB->Update("UPDATE prozessstarter SET mutexcounter = mutexcounter + 1 WHERE mutex = 1 AND (parameter = 'shop_rueckmeldungen' ) AND aktiv = 1");
|
$app->DB->Update("UPDATE prozessstarter SET mutexcounter = mutexcounter + 1 WHERE mutex = 1 AND (parameter = 'shop_rueckmeldungen' ) AND aktiv = 1");
|
||||||
if(!$app->DB->Select("SELECT id FROM prozessstarter WHERE mutex = 0 AND (parameter = 'shop_rueckmeldungen') AND aktiv = 1")) {
|
if (!$app->DB->Select("SELECT id FROM prozessstarter WHERE mutex = 0 AND (parameter = 'shop_rueckmeldungen') AND aktiv = 1")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$app->DB->Update("UPDATE prozessstarter SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now() WHERE (parameter = 'shop_rueckmeldungen' ) AND aktiv = 1");
|
$app->DB->Update("UPDATE prozessstarter SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now() WHERE (parameter = 'shop_rueckmeldungen' ) AND aktiv = 1");
|
||||||
|
|
||||||
$subwhere = sprintf(' a.shop IN (%s) ', implode(',', $shops));
|
$subwhere = sprintf(' a.shop IN (%s) ', implode(',', $shops));
|
||||||
$join = '';
|
$join = '';
|
||||||
$where = '';
|
$where = '';
|
||||||
$app->erp->RunHook('shop_rueckmeldung', 2, $join, $where);
|
$app->erp->RunHook('shop_rueckmeldung', 2, $join, $where);
|
||||||
$sql = "SELECT a.id,apro.zeit, a.shop, l.id as lieferschein, v.id as versandid, l.projekt
|
$sql = "SELECT a.id,apro.zeit, a.shop, l.id as lieferschein, v.id as versandid, l.projekt
|
||||||
FROM auftrag AS a
|
FROM auftrag AS a
|
||||||
LEFT JOIN lieferschein AS l on l.auftragid = a.id
|
LEFT JOIN lieferschein AS l on l.auftragid = a.id
|
||||||
LEFT JOIN auftrag_protokoll AS apro ON a.id = apro.auftrag AND apro.grund LIKE 'Auftrag importiert vom Shop'
|
LEFT JOIN auftrag_protokoll AS apro ON a.id = apro.auftrag AND apro.grund LIKE 'Auftrag importiert vom Shop'
|
||||||
@ -403,13 +399,13 @@ function GetLaender()
|
|||||||
((pr.kommissionierverfahren = 'lieferschein' OR pr.kommissionierverfahren = 'rechnungsmail') AND isnull(v.id))
|
((pr.kommissionierverfahren = 'lieferschein' OR pr.kommissionierverfahren = 'rechnungsmail') AND isnull(v.id))
|
||||||
)
|
)
|
||||||
AND (ISNULL(a.shop_status_update_last_attempt_at) OR a.shop_status_update_last_attempt_at < DATE_SUB(NOW(), INTERVAL 4 HOUR))
|
AND (ISNULL(a.shop_status_update_last_attempt_at) OR a.shop_status_update_last_attempt_at < DATE_SUB(NOW(), INTERVAL 4 HOUR))
|
||||||
AND a.shop_status_update_attempt <= ".MAXIMUM_NUMBER_OF_TRIES."
|
AND a.shop_status_update_attempt <= " . MAXIMUM_NUMBER_OF_TRIES . "
|
||||||
$where
|
$where
|
||||||
ORDER BY a.id, l.id DESC, v.id DESC
|
ORDER BY a.id, l.id DESC, v.id DESC
|
||||||
";
|
";
|
||||||
|
|
||||||
$auftraege = $app->DB->SelectArr($sql);
|
$auftraege = $app->DB->SelectArr($sql);
|
||||||
if(!empty($auftraege)) {
|
if (!empty($auftraege)) {
|
||||||
$app->DB->Update(
|
$app->DB->Update(
|
||||||
"UPDATE prozessstarter
|
"UPDATE prozessstarter
|
||||||
SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now()
|
SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now()
|
||||||
@ -417,12 +413,12 @@ function GetLaender()
|
|||||||
);
|
);
|
||||||
$auftragid = null;
|
$auftragid = null;
|
||||||
$countRequests = 0;
|
$countRequests = 0;
|
||||||
foreach($auftraege as $auftrag) {
|
foreach ($auftraege as $auftrag) {
|
||||||
if($auftrag['id'] != $auftragid) {
|
if ($auftrag['id'] != $auftragid) {
|
||||||
$countRequests++;
|
$countRequests++;
|
||||||
$auftragid = $auftrag['id'];
|
$auftragid = $auftrag['id'];
|
||||||
$app->remote->RemoteUpdateAuftrag($auftrag['shop'], $auftrag['id']);
|
$app->remote->RemoteUpdateAuftrag($auftrag['shop'], $auftrag['id']);
|
||||||
if($countRequests % 10 === 0) {
|
if ($countRequests % 10 === 0) {
|
||||||
$app->DB->Update(
|
$app->DB->Update(
|
||||||
"UPDATE prozessstarter
|
"UPDATE prozessstarter
|
||||||
SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now()
|
SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now()
|
||||||
@ -432,11 +428,11 @@ function GetLaender()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($auftraege);
|
unset($auftraege);
|
||||||
}
|
}
|
||||||
$app->DB->Update("UPDATE prozessstarter SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now() WHERE (parameter = 'shop_rueckmeldungen' ) AND aktiv = 1");
|
$app->DB->Update("UPDATE prozessstarter SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now() WHERE (parameter = 'shop_rueckmeldungen' ) AND aktiv = 1");
|
||||||
|
|
||||||
//Zahlungsstatus
|
//Zahlungsstatus
|
||||||
$query = $app->DB->Query(
|
$query = $app->DB->Query(
|
||||||
"SELECT a.id
|
"SELECT a.id
|
||||||
FROM `auftrag` AS `a`
|
FROM `auftrag` AS `a`
|
||||||
LEFT JOIN `rechnung` AS `r1` ON r1.id = a.rechnungid
|
LEFT JOIN `rechnung` AS `r1` ON r1.id = a.rechnungid
|
||||||
@ -448,13 +444,13 @@ function GetLaender()
|
|||||||
AND (r1.zahlungsstatus = 'bezahlt' OR r2.zahlungsstatus = 'bezahlt') AND DATEDIFF(NOW(), a.datum) <= 28
|
AND (r1.zahlungsstatus = 'bezahlt' OR r2.zahlungsstatus = 'bezahlt') AND DATEDIFF(NOW(), a.datum) <= 28
|
||||||
GROUP BY a.id
|
GROUP BY a.id
|
||||||
LIMIT 1000"
|
LIMIT 1000"
|
||||||
);
|
);
|
||||||
if($query) {
|
if ($query) {
|
||||||
$countRequests = 0;
|
$countRequests = 0;
|
||||||
while($row = $app->DB->Fetch_Assoc($query)) {
|
while ($row = $app->DB->Fetch_Assoc($query)) {
|
||||||
$app->erp->ImportUpdateZahlungsstatus($row['id']);
|
$app->erp->ImportUpdateZahlungsstatus($row['id']);
|
||||||
$countRequests++;
|
$countRequests++;
|
||||||
if($countRequests % 10 === 0) {
|
if ($countRequests % 10 === 0) {
|
||||||
$app->DB->Update(
|
$app->DB->Update(
|
||||||
"UPDATE prozessstarter
|
"UPDATE prozessstarter
|
||||||
SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now()
|
SET mutex = 1 , mutexcounter = 0, letzteausfuerhung = now()
|
||||||
@ -463,6 +459,7 @@ function GetLaender()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$app->DB->free($query);
|
$app->DB->free($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$app->DB->Update("UPDATE prozessstarter SET mutex = 0, mutexcounter = 0, letzteausfuerhung = now() WHERE (parameter = 'shop_rueckmeldungen' ) AND aktiv = 1");
|
||||||
|
|
||||||
$app->DB->Update("UPDATE prozessstarter SET mutex = 0, mutexcounter = 0, letzteausfuerhung = now() WHERE (parameter = 'shop_rueckmeldungen' ) AND aktiv = 1");
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user