Merge branch 'ticket-philea' into develop
This commit is contained in:
commit
415b4b0999
@ -203,21 +203,110 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
public function display() {
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
$form = '<h2>'.$this->l('Philea').'</h2>';
|
||||
$form = '<style type="text/css">
|
||||
.path_bar {
|
||||
background-color: #F1F1F1;
|
||||
border: 1px solid #565485;
|
||||
}
|
||||
h2 {
|
||||
color: #565485;
|
||||
}
|
||||
fieldset {
|
||||
background: #F1F1F1;
|
||||
border: 1px solid #565485;
|
||||
}
|
||||
legend {
|
||||
background: #565485;
|
||||
background: rgba(86,84,133,0.6);
|
||||
border: 1px solid #565485;
|
||||
color: #fff;
|
||||
}
|
||||
.table {
|
||||
border: 1px solid #565485;
|
||||
}
|
||||
.table tr th {
|
||||
background: #565485;
|
||||
background: rgba(86,84,133,0.6);
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
}
|
||||
.table tr{
|
||||
background:#fff;
|
||||
}
|
||||
.table tr:nth-child(even){
|
||||
background:#F1F1F1;
|
||||
}
|
||||
.table tr:nth-child(even) td {
|
||||
border-left:1px solid #FFF;
|
||||
border-right:1px solid #FFF;
|
||||
}
|
||||
.table tr td {
|
||||
border-bottom: 1px solid #DEDEDE;
|
||||
color: #000;
|
||||
}
|
||||
.table tr td[id*=ART] p,
|
||||
.table tr td[id*=CDC] p{
|
||||
font-size:11px;
|
||||
}
|
||||
.table tr td label {
|
||||
font-size:13px;
|
||||
}
|
||||
input[type="text"], input[type="password"],
|
||||
input[type="file"], textarea, select {
|
||||
border: 1px solid #565485;
|
||||
}
|
||||
.button {
|
||||
background-color: rgba(86,84,133,0.6);
|
||||
border: 1px solid #565485;
|
||||
border-left: 1px solid rgba(86,84,133,0.6);
|
||||
border-top: 1px solid rgba(86,84,133,0.6);
|
||||
color: rgba(255,255,255,0.9);
|
||||
padding: 3px;
|
||||
}
|
||||
.button:hover {
|
||||
background-color: #565485;
|
||||
border: 1px solid rgba(86,84,133,0.6);
|
||||
border-left: 1px solid #565485;
|
||||
border-top: 1px solid #565485;
|
||||
color: #fff;
|
||||
padding: 3px;
|
||||
}
|
||||
.button:focus{
|
||||
background-color: rgba(86,84,133,0.6);
|
||||
}
|
||||
|
||||
.div_report {
|
||||
position: absolute;
|
||||
z-index: 999;
|
||||
padding: 15px;
|
||||
padding-top: 20px;
|
||||
background: #fff;
|
||||
border: 1px solid;
|
||||
line-height: 20px;
|
||||
text-align: left;
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
color:#000;
|
||||
}
|
||||
.div_report h3 {text-align:center;}
|
||||
</style>';
|
||||
|
||||
$form .= '<h2>'.$this->l('Philea').'</h2>';
|
||||
|
||||
$base_link = $currentIndex . '&token='.Tools::getAdminTokenLite('AdminPhileaMagistor');
|
||||
|
||||
$id_sale_options = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT p.`id_sale`, c.`name`
|
||||
SELECT p.`id_sale`, c.`name`, c.`id_category`
|
||||
FROM `'._DB_PREFIX_.'privatesale` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` c ON (c.`id_category` = p.`id_category`)
|
||||
WHERE c.`id_lang` = '.$cookie->id_lang.'
|
||||
AND p.`date_start` > "2015-01-01 00:00:00"
|
||||
ORDER BY p.`id_sale` DESC
|
||||
') as $row) {
|
||||
$extrafields = Category::getSalesInfos(array((int) $row['id_category']));
|
||||
$id_sale_options[] = array(
|
||||
'label' => (int) $row['id_sale'].' - '.$row['name'],
|
||||
'label' => (int) $row['id_sale'].' - '.$row['name'].(empty($extrafields[(int) $row['id_category']]['sales'][1])?'':' - '.$extrafields[(int) $row['id_category']]['sales'][1]) ,
|
||||
'value' => (int) $row['id_sale']
|
||||
);
|
||||
}
|
||||
@ -268,10 +357,9 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">' . $this->l('ID sale') . '</th>
|
||||
<th width="250">' . $this->l('Name') . '</th>
|
||||
<th width="325">' . $this->l('Name') . '</th>
|
||||
<th>' . $this->l('Date envoi (ART)') . '</th>
|
||||
<th>' . $this->l('Télécharger le CRR') . '</th>
|
||||
<th>' . $this->l('Date Reçu CRR') . '</th>
|
||||
<th>' . $this->l('Envoyer la commande') . '</th>
|
||||
<th>' . $this->l('Date envoi (CMD)') . '</th>
|
||||
<th>' . $this->l('Envoi auto') . '</th>
|
||||
@ -294,7 +382,7 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
}
|
||||
else{
|
||||
$CRR['recep_date'] = '--';
|
||||
$dl_link = '--';
|
||||
$dl_link = '';
|
||||
}
|
||||
$auto_sync = (isset($CRR['auto_sync_active']) && $CRR['auto_sync_active']) ? true : false;
|
||||
$title = ($auto_sync ? $this->l('Désactiver l\'envoi automatique pour la vente') : $this->l('Activer l\'envoi automatique pour la vente') );
|
||||
@ -308,12 +396,20 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
$form .= '<tr>
|
||||
<td><input type="checkbox" id="check_sale_'.(int) $CRR['id_sale'].'" name="id_sales[]" value="'.(int) $CRR['id_sale'].'" /></td>
|
||||
<td><label style="float:none; width:auto; padding: 0; text-align: left; font-weight: normal;" for="check_sale_'.(int) $CRR['id_sale'].'">'.(int) $CRR['id_sale'].'</label></td>
|
||||
<td><label style="float:none; width:auto; padding: 0; text-align: left; font-weight: normal;" for="check_sale_'.(int) $CRR['id_sale'].'">'.$CRR['name'].'</label></td>
|
||||
<td style="text-align: center;">'.$CRR['sync_date'].'</td>
|
||||
<td style="text-align: center;">' . $dl_link . '</td>
|
||||
<td style="text-align: center;">'.$CRR['recep_date'].'</td>
|
||||
<td><label style="float:none; width:auto; padding: 0; text-align: left; font-weight: normal;" for="check_sale_'.(int) $CRR['id_sale'].'"><strong>'.$CRR['name'].'</strong> - '.$CRR['subtitle'].'</label></td>
|
||||
<td style="text-align: center;" id="ART_'. (int) $CRR['id_sale'] .'">
|
||||
<p>'.(!empty($CRR['sync_date'])?date('d-m-Y H:i',strtotime($CRR['sync_date'])):'--').'</p>
|
||||
'.((isset($CRR['sync_date']) && !empty($CRR['sync_date']))?'<p><a class="button see_report" data-id="'. (int) $CRR['id_sale'] .'" data-type="ART" href="#" title="'.$this->l('See ATR report').'">'.$this->l('Rapport').'</a></p>':'').'
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<p>'.($CRR['recep_date']!= "--"?date('d-m-Y H:i',strtotime($CRR['recep_date'])):'--').'</p>
|
||||
' . $dl_link . '
|
||||
</td>
|
||||
<td style="text-align: center;"><a title="'.$this->l('Envoi du fichier CDC').'" class="button upload_link" data-id="' . (int) $CRR['id_sale'] . '" href="'.$submit_link.'" title="'.$this->l('Upload CDC file').'"><img src="../img/admin/export.gif"/>'.$this->l('Envoyer à Philea').'</a></td>
|
||||
<td style="text-align: center;">'.$CRR['sent_date'].'</td>
|
||||
<td style="text-align: center;" id="CDC_'. (int) $CRR['id_sale'] .'">
|
||||
<p>'.(!empty($CRR['sent_date'])?date('d-m-Y H:i',strtotime($CRR['sent_date'])):'--').'</p>
|
||||
'.((isset($CRR['sent_date']) && !empty($CRR['sent_date']))?'<p><a class="button see_report" data-id="'. (int) $CRR['id_sale'] .'" data-type="CDC" href="#" title="'.$this->l('See CDC report').'">'.$this->l('Rapport').'</a></p>':'').'
|
||||
</td>
|
||||
<td style="text-align: center;">'.$auto_sync_btn.'</td>
|
||||
</tr>';
|
||||
}
|
||||
@ -330,6 +426,46 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
$("#id_sale_hidden").val($(this).data("id"));
|
||||
$("#upload_form").submit();
|
||||
});
|
||||
|
||||
$(".see_report").click(function(e){
|
||||
e.preventDefault();
|
||||
$(".report_error").remove();
|
||||
id_sale = $(this).data("id");
|
||||
type = $(this).data("type");
|
||||
data = {
|
||||
action : "getReport",
|
||||
id_sale: id_sale,
|
||||
type : type
|
||||
};
|
||||
$.ajax({
|
||||
type: \'POST\',
|
||||
url: \''._MODULE_DIR_.'philea_magistor/ajax.php'.'\',
|
||||
dataType: \'json\',
|
||||
data: data,
|
||||
success: function(response) {
|
||||
if (response.error == \'true\') {
|
||||
$("#"+type+"_"+id_sale).append("<p class=\'report_error\'>"+response.message+"</p>");
|
||||
} else if (response.report.report_data != "" && response.report.report_data != "null") {
|
||||
$("#"+type+"_"+id_sale).append("<div class=\'report_error div_report\'><h3>Rapport "+type+" vente "+id_sale+"</h3>"+response.report.report_data+"</div>");
|
||||
$(".div_report").css(\'top\',$("#"+type+"_"+id_sale+" .see_report").position().top);
|
||||
|
||||
if (type == \'ART\') {
|
||||
$(".div_report").css(\'left\',$("#"+type+"_"+id_sale+" .see_report").position().left+50);
|
||||
} else if (type == \'CDC\') {
|
||||
pos = $(window).width() - ($("#"+type+"_"+id_sale+" .see_report").offset().left + $("#"+type+"_"+id_sale+" .see_report").outerWidth());
|
||||
$(".div_report").css(\'right\',pos+50);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
console.log(JSON.parse(xhr.responseText));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).click(function(e){
|
||||
$(".div_report").remove();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
';
|
||||
@ -384,6 +520,7 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
SELECT
|
||||
p.`id_sale`,
|
||||
c.`name`,
|
||||
c.`id_category`,
|
||||
p.`date_start`,
|
||||
p.`date_end`
|
||||
FROM `'._DB_PREFIX_.'privatesale` p
|
||||
@ -418,11 +555,12 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
|
||||
$CRR_list = array();
|
||||
foreach ($id_sales as $id_sale) {
|
||||
$sync_date = (isset($pm_sync[(int) $id_sale]) ? $pm_sync[(int) $id_sale] : '');
|
||||
$recep = (isset($receptions[(int) $id_sale]) ? $receptions[(int) $id_sale] : array('filename' => '', 'recep_date' => ''));
|
||||
$sale = (isset($sales[(int) $id_sale]) ? $sales[(int) $id_sale] : array('name' => '', 'date_start' => '', 'date_end' => ''));
|
||||
$sent_date = (isset($pm_sent[(int) $id_sale]) ? $pm_sent[(int) $id_sale] : '');
|
||||
$as_active = (isset($pm_active[(int) $id_sale])) ? 1 : 0;
|
||||
$sync_date = (isset($pm_sync[(int) $id_sale]) ? $pm_sync[(int) $id_sale] : '');
|
||||
$recep = (isset($receptions[(int) $id_sale]) ? $receptions[(int) $id_sale] : array('filename' => '', 'recep_date' => ''));
|
||||
$sale = (isset($sales[(int) $id_sale]) ? $sales[(int) $id_sale] : array('name' => '', 'date_start' => '', 'date_end' => ''));
|
||||
$sent_date = (isset($pm_sent[(int) $id_sale]) ? $pm_sent[(int) $id_sale] : '');
|
||||
$as_active = (isset($pm_active[(int) $id_sale])) ? 1 : 0;
|
||||
$extrafields = Category::getSalesInfos(array((int) $sales[(int) $id_sale]['id_category']));
|
||||
|
||||
$CRR_list[$id_sale] = array(
|
||||
'id_sale' => $id_sale,
|
||||
@ -433,7 +571,8 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
'sent_date' => $sent_date,
|
||||
'auto_sync_active' => $as_active,
|
||||
'date_start' => $sale['date_start'],
|
||||
'date_end' => $sale['date_end']
|
||||
'date_end' => $sale['date_end'],
|
||||
'subtitle' => $extrafields[(int) $sales[(int) $id_sale]['id_category']]['sales'][1]
|
||||
);
|
||||
}
|
||||
self::$_crrlist_cache = $CRR_list;
|
||||
|
57
modules/philea_magistor/ajax.php
Normal file
57
modules/philea_magistor/ajax.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__).'../../../config/config.inc.php');
|
||||
require_once(dirname(__FILE__).'../../../init.php');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
if(Tools::getValue('action') != 'getReport') {
|
||||
http_response_code(418);
|
||||
die('I\'m a teapot');
|
||||
}
|
||||
|
||||
switch (Tools::getValue('type')) {
|
||||
case 'ART':
|
||||
die(getReport('ART'));
|
||||
break;
|
||||
case 'CDC':
|
||||
die(getReport('CDC'));
|
||||
break;
|
||||
default:
|
||||
http_response_code(418);
|
||||
die(json_encode('I\'m a teapot'));
|
||||
break;
|
||||
}
|
||||
|
||||
function getReport($type) {
|
||||
//global $cookie;
|
||||
$id_sale = (int)Tools::getValue('id_sale', false);
|
||||
|
||||
if (!$id_sale) {
|
||||
http_response_code(500);
|
||||
return json_encode(array(
|
||||
'error'=> 'true',
|
||||
'message'=> Tools::displayError('Vente non trouvée')
|
||||
));
|
||||
}
|
||||
|
||||
$report = Db::getInstance()->getRow('
|
||||
SELECT `report_data`, `report_date`, `id_sale`
|
||||
FROM `'._DB_PREFIX_.'philea_syncreport`
|
||||
WHERE `id_sale` = '.$id_sale.'
|
||||
AND `filename` LIKE "'.$type.'%"
|
||||
');
|
||||
if(empty($report['report_data'])){
|
||||
$report['report_data'] = Tools::displayError('Pas encore de rapport '.$type.' disponible');
|
||||
}
|
||||
if(isset($report) && $report != false) {
|
||||
return json_encode(array(
|
||||
'error' => 'false',
|
||||
'report' => $report
|
||||
));
|
||||
} else {
|
||||
return json_encode(array(
|
||||
'error'=> 'true',
|
||||
'message' => Tools::displayError('Pas encore de rapport '.$type.' disponible')
|
||||
));
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ if(isset($regex_file_in))
|
||||
print('erreur lors de l\'ouverture du fichier : '.$file.chr(10));
|
||||
else
|
||||
{
|
||||
// ftp_fput($id_ftp,'archives/'.$name_file,$handle,FTP_BINARY);
|
||||
ftp_fput($id_ftp,'archives/'.$name_file,$handle,FTP_BINARY);
|
||||
ftp_delete($id_ftp,$file);
|
||||
}
|
||||
fclose($handle);
|
||||
|
110
modules/philea_magistor/script/receive_report.php
Normal file
110
modules/philea_magistor/script/receive_report.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?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'? '[W]': '[E]').' '.(string) $message['codeArticle'].' : '.(string) $message;
|
||||
}
|
||||
|
||||
$result = nl2br(implode("\n", $result));
|
||||
|
||||
if($result != '') {
|
||||
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'? '[W]': '[E]').' '.(string) $message['ordrePreparation'].' : '.(string) $message;
|
||||
}
|
||||
|
||||
$result = nl2br(implode("\n", $result));
|
||||
|
||||
if($result != '') {
|
||||
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());
|
||||
}
|
||||
}
|
@ -287,11 +287,12 @@ if($magistorModule->active) {
|
||||
$nb_ligne++;
|
||||
|
||||
$ean = !empty($product['product_ean13'])? $product['product_ean13']: $product['product_supplier_reference'];
|
||||
$ref = ($product['product_attribute_id']?$product['product_id'].'_'.$product['product_attribute_id']:$product['product_id']);
|
||||
|
||||
$data .= str_pad('L01', 10, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad('OP'.(int) $id_sale.'-'.$order->id, 50, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad($nb_ligne, 4, '0', STR_PAD_LEFT);
|
||||
$data .= str_pad(str_replace(array("\r", "\n"), '', $ean), 50, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad(str_replace(array("\r", "\n"), '', $ref), 50, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad(max($product['product_quantity'] - max($product['product_quantity_return'], $product['product_quantity_refunded']), 0), 8, '0', STR_PAD_LEFT);
|
||||
$data .= str_pad(substr(utf8_decode(cleanChar($product['product_name'])), 0, 50), 50, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad(str_replace(array("\r", "\n"), '', $ean), 14, ' ', STR_PAD_LEFT);
|
||||
|
Loading…
Reference in New Issue
Block a user