modif css and fix alert missing quantity in orders
This commit is contained in:
parent
d9fd7547d1
commit
c0110a6618
@ -274,10 +274,31 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
.button:focus{
|
||||
background-color: rgba(86,84,133,0.6);
|
||||
}
|
||||
|
||||
.div_report_overlay{
|
||||
background: rgb(181,189,200); /* Old browsers */
|
||||
background: -moz-linear-gradient(top, rgba(181,189,200,0.4) 0%, rgba(130,140,149,0.4) 36%, rgba(40,52,59,0.4) 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,189,200,0.4)), color-stop(36%,rgba(130,140,149,0.4)), color-stop(100%,rgba(40,52,59,0.4))); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, rgba(181,189,200,0.4) 0%,rgba(130,140,149,0.4) 36%,rgba(40,52,59,0.4) 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, rgba(181,189,200,0.4) 0%,rgba(130,140,149,0.4) 36%,rgba(40,52,59,0.4) 100%); /* Opera 11.10+ */
|
||||
background: -ms-linear-gradient(top, rgba(181,189,200,0.4) 0%,rgba(130,140,149,0.4) 36%,rgba(40,52,59,0.4) 100%); /* IE10+ */
|
||||
background: linear-gradient(to bottom, rgba(181,189,200,0.4) 0%,rgba(130,140,149,0.4) 36%,rgba(40,52,59,0.4) 100%); /* W3C */
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 998;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
display: none;
|
||||
}
|
||||
.div_report {
|
||||
position: absolute;
|
||||
display:none;
|
||||
position: fixed;
|
||||
z-index: 999;
|
||||
left: 50%;
|
||||
margin-left: -287.5px;
|
||||
position: fixed;
|
||||
top: 15%;
|
||||
padding: 15px;
|
||||
padding-top: 20px;
|
||||
background: #fff;
|
||||
@ -285,6 +306,7 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
line-height: 20px;
|
||||
text-align: left;
|
||||
max-height: 300px;
|
||||
width: 575px;
|
||||
overflow: auto;
|
||||
color:#000;
|
||||
}
|
||||
@ -359,9 +381,9 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
<th colspan="2">' . $this->l('ID sale') . '</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('Envoyer la commande') . '</th>
|
||||
<th>' . $this->l('Date envoi (CMD)') . '</th>
|
||||
<th>' . $this->l('Préparation (CRP)') . '</th>
|
||||
<th>' . $this->l('Envoi auto') . '</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -401,23 +423,25 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
<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;" id="CRP_'. (int) $CRR['id_sale'] .'">
|
||||
<p><a class="button see_report" data-id="'. (int) $CRR['id_sale'] .'" data-type="CRP" href="#" title="'.$this->l('See CRP report').'">'.$this->l('Rapport').'</a></p>
|
||||
</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;" 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;" id="CRP_'. (int) $CRR['id_sale'] .'">
|
||||
'.((isset($CRR['sent_date']) && !empty($CRR['sent_date']))?'<p><a class="button see_report" data-id="'. (int) $CRR['id_sale'] .'" data-type="CRP" href="#" title="'.$this->l('See CRP report').'">'.$this->l('Rapport').'</a></p>':'').'
|
||||
</td>
|
||||
<td style="text-align: center;">'.$auto_sync_btn.'</td>
|
||||
</tr>';
|
||||
}
|
||||
$form .= '
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="report_error div_report"></div>
|
||||
<p><input type="submit" class="btn button" name="philea_archive_submit" value="' . $this->l('Archiver la sélection') . '"/></p>
|
||||
</fieldset>
|
||||
</form>
|
||||
<div class="div_report_overlay"></div>
|
||||
<script type="text/javascript">
|
||||
$("document").ready(function(){
|
||||
$(".upload_link").click(function(e){
|
||||
@ -428,7 +452,8 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
|
||||
$(".see_report").click(function(e){
|
||||
e.preventDefault();
|
||||
$(".report_error").remove();
|
||||
$(".report_error").empty();
|
||||
$(".report_error").hide();
|
||||
id_sale = $(this).data("id");
|
||||
type = $(this).data("type");
|
||||
data = {
|
||||
@ -444,16 +469,18 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
success: function(response) {
|
||||
if (response.error == \'true\') {
|
||||
$("#"+type+"_"+id_sale).append("<p class=\'report_error\'>"+response.message+"</p>");
|
||||
$(".div_report").css("text-align","center");
|
||||
} 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);
|
||||
$(".div_report").append("<h3>Rapport "+type+" vente "+id_sale+"</h3>"+response.report.report_data+"");
|
||||
|
||||
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);
|
||||
if(type == "ART") {
|
||||
$(".div_report").css("text-align","left");
|
||||
} else {
|
||||
$(".div_report").css("text-align","center");
|
||||
}
|
||||
|
||||
$(".div_report").show();
|
||||
$(".div_report_overlay").show();
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
@ -462,8 +489,10 @@ class AdminPhileaMagistor extends AdminTab {
|
||||
});
|
||||
});
|
||||
|
||||
$(document).click(function(e){
|
||||
$(".div_report").remove();
|
||||
$(".div_report_overlay").click(function(e){
|
||||
$(".div_report").empty();
|
||||
$(".div_report").hide();
|
||||
$(".div_report_overlay").hide();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -1,140 +1,148 @@
|
||||
<?php
|
||||
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
include('../../../config/settings.inc.php');
|
||||
include('../../../config/config.inc.php');
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
include('../../../config/settings.inc.php');
|
||||
include('../../../config/config.inc.php');
|
||||
|
||||
@ini_set('display_errors', 'on');
|
||||
include( dirname(__FILE__) . '/../philea_magistor.php');
|
||||
global $regex_file_in;
|
||||
$regex_file_in = '@^CRP(.*)\.(BAL|DAT)@';
|
||||
@ini_set('display_errors', 'on');
|
||||
include( dirname(__FILE__) . '/../philea_magistor.php');
|
||||
global $regex_file_in;
|
||||
$regex_file_in = '@^CRP(.*)\.(BAL|DAT)@';
|
||||
|
||||
$magistorModule = new philea_magistor();
|
||||
$magistorModule = new philea_magistor();
|
||||
|
||||
$CRP = array(
|
||||
'OP_CODE' => array(1,10),
|
||||
'CODE_SOC' => array(11,20),
|
||||
'N_CDE' => array(31,50),
|
||||
'NO_CLIENT' => array(81,8), // NO_VENTE
|
||||
'DATE_PREP' => array(89,8),
|
||||
'NO_LIGNE' => array(97,4),
|
||||
'NO_COLIS' => array(101,50), // N_CDE
|
||||
'CODE_ART' => array(151,50),
|
||||
'QTE' => array(201,10)
|
||||
);
|
||||
$CRP = array(
|
||||
'OP_CODE' => array(1,10),
|
||||
'CODE_SOC' => array(11,20),
|
||||
'N_CDE' => array(31,50),
|
||||
'NO_CLIENT' => array(81,8), // NO_VENTE
|
||||
'DATE_PREP' => array(89,8),
|
||||
'NO_LIGNE' => array(97,4),
|
||||
'NO_COLIS' => array(101,50), // N_CDE
|
||||
'CODE_ART' => array(151,50),
|
||||
'QTE' => array(201,10)
|
||||
);
|
||||
|
||||
$format = $CRP;
|
||||
$format = $CRP;
|
||||
|
||||
if($magistorModule->active) {
|
||||
require_once('connection_ftp.php');
|
||||
@set_time_limit(0);
|
||||
if($magistorModule->active) {
|
||||
require_once('connection_ftp.php');
|
||||
@set_time_limit(0);
|
||||
|
||||
// Checking for ".bal" files with a "CRP" prefix that has an equivalent ".dat" file and process them...
|
||||
// Checking for ".bal" files with a "CRP" prefix that has an equivalent ".dat" file and process them...
|
||||
|
||||
$inFolder = dirname(__FILE__) . '/IN/';
|
||||
$iterator = new DirectoryIterator($inFolder);
|
||||
$inFolder = dirname(__FILE__) . '/IN/';
|
||||
$iterator = new DirectoryIterator($inFolder);
|
||||
|
||||
foreach ($iterator as $fileinfo) {
|
||||
foreach ($iterator as $fileinfo) {
|
||||
|
||||
if ($fileinfo->isFile()) {
|
||||
if ($fileinfo->isFile()) {
|
||||
|
||||
if( preg_match( '@^CRP(.*)\.BAL@', $fileinfo->getFilename() ) ) {
|
||||
$datFile = $fileinfo->getPath() . '/' . preg_replace( '@BAL$@', 'DAT', $fileinfo->getFilename() );
|
||||
if( preg_match( '@^CRP(.*)\.BAL@', $fileinfo->getFilename() ) ) {
|
||||
$datFile = $fileinfo->getPath() . '/' . preg_replace( '@BAL$@', 'DAT', $fileinfo->getFilename() );
|
||||
|
||||
if( file_exists( $datFile ) ) {
|
||||
$content = file_get_contents( $datFile );
|
||||
$lines = preg_split( '@\n@', $content );
|
||||
if( file_exists( $datFile ) ) {
|
||||
$content = file_get_contents( $datFile );
|
||||
$lines = preg_split( '@\n@', $content );
|
||||
|
||||
// ANTADIS
|
||||
if( !empty($lines) ) {
|
||||
$order_details = array();
|
||||
foreach( $lines as $line ) {
|
||||
$data = array();
|
||||
foreach($format as $field => $value) {
|
||||
$data[] = substr($line, ($value[0]-1), $value[1]);
|
||||
}
|
||||
// ANTADIS
|
||||
if( !empty($lines) ) {
|
||||
$order_details = array();
|
||||
foreach( $lines as $line ) {
|
||||
$data = array();
|
||||
foreach($format as $field => $value) {
|
||||
$data[] = substr($line, ($value[0]-1), $value[1]);
|
||||
}
|
||||
|
||||
if( !isset($data[2]) || (isset($data[2]) && !$data[2]) )
|
||||
continue;
|
||||
if( !isset($data[2]) || (isset($data[2]) && !$data[2]) )
|
||||
continue;
|
||||
|
||||
// GET ORDER
|
||||
$order = (string) trim($data[2]);
|
||||
if(substr($order, 0, 2) == 'OP') {
|
||||
$order = explode('-', $order);
|
||||
if(count($order) < 2)
|
||||
continue;
|
||||
$id_sale = (int) str_replace('OP', '', $order[0]);
|
||||
$id_order = (int) $order[1];
|
||||
} else {
|
||||
$id_order = (int) $order;
|
||||
}
|
||||
if ($id_sale && !isset($order_details[$id_sale])) {
|
||||
$order_details[$id_sale] = array();
|
||||
}
|
||||
if ($id_sale && !isset($order_details[$id_sale][$id_order])) {
|
||||
$order_details[$id_sale][$id_order] = array();
|
||||
}
|
||||
// GET ORDER
|
||||
$order = (string) trim($data[2]);
|
||||
if(substr($order, 0, 2) == 'OP') {
|
||||
$order = explode('-', $order);
|
||||
if(count($order) < 2)
|
||||
continue;
|
||||
$id_sale = (int) str_replace('OP', '', $order[0]);
|
||||
$id_order = (int) $order[1];
|
||||
} else {
|
||||
$id_order = (int) $order;
|
||||
}
|
||||
|
||||
// GET PRODUCT
|
||||
$product = trim($data[7]);
|
||||
$product = explode('_', $product);
|
||||
$id_product = (int) $product[0];
|
||||
$id_product_attribute = (isset($product[1]) ? (int) $product[1] : 0);
|
||||
// GET PRODUCT
|
||||
$product = trim($data[7]);
|
||||
$product = explode('_', $product);
|
||||
$id_product = (int) $product[0];
|
||||
$id_product_attribute = (isset($product[1]) ? (int) $product[1] : 0);
|
||||
|
||||
// GET QTY
|
||||
$qty = (int) trim($data[8]);
|
||||
$order_details[$id_sale][$id_order][$id_product.'|'.$id_product_attribute] = $qty;
|
||||
if($detail = Db::getInstance()->getRow('
|
||||
SELECT `id_order_detail`, `product_quantity` - GREATEST(`product_quantity_return`, `product_quantity_refunded`) AS `quantity`
|
||||
FROM `'._DB_PREFIX_.'order_detail`
|
||||
WHERE `id_order` = '.(int) $id_order.'
|
||||
AND `product_id` = '.(int) $id_product.'
|
||||
AND `product_attribute_id` = '.(int) $id_product_attribute.'
|
||||
')) {
|
||||
if ($id_sale && !isset($order_details[$id_sale])) {
|
||||
$order_details[$id_sale] = array();
|
||||
}
|
||||
if ($id_sale && !isset($order_details[$id_sale][$id_order])) {
|
||||
$order_details[$id_sale][$id_order] = array();
|
||||
}
|
||||
|
||||
}
|
||||
foreach ($order_details as $sale => $orders) {
|
||||
$comments = "";
|
||||
foreach ($orders as $order => $products) {
|
||||
$errors = "";
|
||||
$count = 0;
|
||||
foreach ($products as $key => $qty) {
|
||||
$count += $qty;
|
||||
$product = explode('|', $key);
|
||||
$id_product = (int) $product[0];
|
||||
$id_product_attribute = (isset($product[1]) ? (int) $product[1] : 0);
|
||||
if (!$qty) {
|
||||
$errors .= "Produit ".$id_product.($id_product_attribute?" - attribute ".$id_product_attribute:"")." n'a pas été fourni <br />";
|
||||
}
|
||||
}
|
||||
$comments .= "<strong>Commande [".$order."] : ".($count<count($products)? "<span style='color:red;'>Produits manquants</span>": $count." quantités envoyées")."</strong><br />";
|
||||
if(!empty($errors)) {
|
||||
$comments .= $errors;
|
||||
}
|
||||
}
|
||||
if ($sale) {
|
||||
Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'philea_syncreport`
|
||||
VALUE (
|
||||
'.(int) $sale.',
|
||||
"'.pSQL(preg_replace('@BAL$@', 'DAT', $fileinfo->getFilename())).'",
|
||||
NOW(),
|
||||
NOW(),
|
||||
"'.pSQL($comments, TRUE).'"
|
||||
)
|
||||
');
|
||||
}
|
||||
}
|
||||
}
|
||||
// GET QTY
|
||||
$qty = (int) trim($data[8]);
|
||||
$order_details[$id_sale][$id_order][$id_product.'|'.$id_product_attribute] = (int) $detail['quantity'] - $qty;
|
||||
}
|
||||
}
|
||||
foreach ($order_details as $sale => $orders) {
|
||||
$comments = "";
|
||||
foreach ($orders as $order => $products) {
|
||||
$errors = "";
|
||||
$count = 0;
|
||||
foreach ($products as $key => $qty) {
|
||||
$count += $qty;
|
||||
$product = explode('|', $key);
|
||||
$id_product = (int) $product[0];
|
||||
$id_product_attribute = (isset($product[1]) ? (int) $product[1] : 0);
|
||||
if ($qty>0) {
|
||||
$errors .= "<li>".$qty." Produit #".$id_product.($id_product_attribute?" - attribute #".$id_product_attribute:"")." manquant</li>";
|
||||
}
|
||||
}
|
||||
$comments .= "<strong>Commande [".$order."] : ".($count>0? "<span style='color:red;'>Produits manquants</span>": "<span style='color:green;'>Commande préparée</span>")."</strong><br />";
|
||||
if(!empty($errors)) {
|
||||
$comments .= "<ul style='margin:0; padding:0 25px; list-style:none;'>".$errors."</ul>";
|
||||
}
|
||||
}
|
||||
if ($sale) {
|
||||
Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'philea_syncreport`
|
||||
VALUE (
|
||||
'.(int) $sale.',
|
||||
"'.pSQL(preg_replace('@BAL$@', 'DAT', $fileinfo->getFilename())).'",
|
||||
NOW(),
|
||||
NOW(),
|
||||
"'.pSQL($comments, TRUE).'"
|
||||
)
|
||||
');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$repo_archive = './archives/IN/PREPARATION/';
|
||||
$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);
|
||||
}
|
||||
$repo_archive = './archives/IN/PREPARATION/';
|
||||
$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($datFile, $repo_archive . preg_replace( '@BAL$@', 'DAT', $fileinfo->getFilename() ));
|
||||
copy($datFile, $repo_archive . preg_replace( '@BAL$@', 'DAT', $fileinfo->getFilename() ));
|
||||
|
||||
unlink($inFolder.$fileinfo->getFilename());
|
||||
unlink($datFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unlink($inFolder.$fileinfo->getFilename());
|
||||
unlink($datFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user