116 lines
4.4 KiB
PHP
116 lines
4.4 KiB
PHP
<?php
|
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
|
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
|
$_SERVER['SERVER_PORT'] = 80;
|
|
|
|
include(dirname(__FILE__) . '/../../../config/config.inc.php');
|
|
include( dirname(__FILE__) . '/../philea_magistor.php');
|
|
|
|
global $regex_file_in;
|
|
$regex_file_in = '@^RPTEDI(.*)\.(XML)@';
|
|
|
|
require_once('connection_ftp.php');
|
|
@set_time_limit(0);
|
|
|
|
$inFolder = dirname(__FILE__).'/IN/';
|
|
|
|
$iterator = new DirectoryIterator($inFolder);
|
|
if(is_object($iterator) && count($iterator)) {
|
|
foreach($iterator as $fileinfo) {
|
|
if(!$fileinfo->isFile() || $fileinfo->getFilename() == '..' || $fileinfo->getFilename() == '.') {
|
|
continue;
|
|
}
|
|
if(!preg_match($regex_file_in, $fileinfo->getFilename())) {
|
|
continue;
|
|
}
|
|
|
|
$content = file_get_contents($fileinfo->getPath().'/'.$fileinfo->getFilename());
|
|
|
|
if(empty($content)) {
|
|
continue;
|
|
}
|
|
|
|
$xml = new SimpleXMLElement($content);
|
|
|
|
if((string) $xml->TypeMessage == 'REFART') {
|
|
$file = explode('.', str_replace((string) $xml->TypeMessage.'_', '', (string) $xml->NomFichier));
|
|
$file = $file[0].'.DAT';
|
|
$result = array();
|
|
|
|
foreach($xml->Listing->Message as $message) {
|
|
//$result[] = ((string) $message['bloquant'] == 'False'? '<span>[W]': '<span style="color:red;">[E]').' '.(string) $message['codeArticle'].' : </span>'.(string) $message;
|
|
if((string) $message['bloquant'] != 'False') {
|
|
$result[] = '<span style="color:red;">[E] '.(string) $message['codeArticle'].' : </span>'.(string) $message;
|
|
}
|
|
}
|
|
|
|
$result = nl2br(implode("\n", $result));
|
|
|
|
if($result == '') {
|
|
$result = "RAS";
|
|
}
|
|
Db::getInstance()->Execute('
|
|
UPDATE `'._DB_PREFIX_.'philea_syncreport`
|
|
SET `report_date` = NOW(),
|
|
`report_data` = "'.pSQL($result, TRUE).'"
|
|
WHERE `filename` = "'.pSQL($file).'"
|
|
LIMIT 1
|
|
');
|
|
} elseif($xml->TypeMessage == 'CMDCLI') {
|
|
$file = explode('.', str_replace((string) $xml->TypeMessage.'_', '', (string) $xml->NomFichier));
|
|
$file = $file[0].'.DAT';
|
|
$result = array();
|
|
|
|
foreach($xml->Listing->Message as $message) {
|
|
$result[] = ((string) $message['bloquant'] == 'False'? '<span>[W]': '<span style="color:red;">[E]').' '.(string) $message['ordrePreparation'].' : </span>'.(string) $message;
|
|
}
|
|
|
|
$result = nl2br(implode("\n", $result));
|
|
|
|
if($result == '') {
|
|
$result = "RAS";
|
|
}
|
|
Db::getInstance()->Execute('
|
|
UPDATE `'._DB_PREFIX_.'philea_syncreport`
|
|
SET `report_date` = NOW(),
|
|
`report_data` = "'.pSQL($result, TRUE).'"
|
|
WHERE `filename` = "'.pSQL($file).'"
|
|
LIMIT 1
|
|
');
|
|
} elseif($xml->TypeMessage == 'ANAPRO') {
|
|
$file = explode('.', str_replace((string) $xml->TypeMessage.'_', '', (string) $xml->NomFichier));
|
|
$file = $file[0].'.DAT';
|
|
$result = array();
|
|
|
|
foreach($xml->Listing->Message as $message) {
|
|
$result[] = ((string) $message['bloquant'] == 'False'? '[W]': '[E]').' '.(string) $message['reference'].' / '.(string) $message['referenceLigne'].' : '.(string) $message;
|
|
}
|
|
|
|
$result = nl2br(implode("\n", $result));
|
|
|
|
// if($result != '') {
|
|
// Db::getInstance()->Execute('
|
|
// UPDATE `'._DB_PREFIX_.'logship_sync`
|
|
// SET `report_date` = NOW(),
|
|
// `report_data` = "'.pSQL($result, TRUE).'"
|
|
// WHERE `sync` = "philea"
|
|
// AND `filename` = "'.pSQL($file).'"
|
|
// LIMIT 1
|
|
// ');
|
|
// }
|
|
}
|
|
|
|
$repo_archive = dirname(__FILE__).'/archives/IN/REPORTS/';
|
|
$repo_paths = array(date('Y'), date('m'));
|
|
foreach($repo_paths as $repo_path) {
|
|
$repo_archive .= $repo_path.'/';
|
|
if(!file_exists($repo_archive)) {
|
|
mkdir($repo_archive);
|
|
}
|
|
}
|
|
|
|
copy($inFolder.$fileinfo->getFilename(), $repo_archive.$fileinfo->getFilename());
|
|
unlink($inFolder.$fileinfo->getFilename());
|
|
}
|
|
}
|