From caf88c2c7ee36d7e49d687300ce4c8c962239b0d Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Tue, 31 Oct 2017 12:32:41 +0100 Subject: [PATCH] correction of formulae --- modules/ant_wp/AdminAntWp.php | 119 ++++++++++++++++++-- modules/ant_wp/GenerateWp.php | 201 ++++++++++------------------------ 2 files changed, 164 insertions(+), 156 deletions(-) diff --git a/modules/ant_wp/AdminAntWp.php b/modules/ant_wp/AdminAntWp.php index 3c3298f8..60228256 100644 --- a/modules/ant_wp/AdminAntWp.php +++ b/modules/ant_wp/AdminAntWp.php @@ -1,7 +1,9 @@ _html .= HelperFormBootstrap::displaySuccess($this->l('Génération complète
Produit trouvés : '.Tools::getValue('found').'
Produit nouveau : '.Tools::getValue('new'))); - // if ($res) { - // } else { - // $this->_html .= HelperFormBootstrap::displayErrors($this->l('Des erreurs sont survenues : ')); - // } - } elseif(Tools::getValue('error_file')) { - $this->_html .= HelperFormBootstrap::displayErrors($this->l('Veuillez charger un fichier correct !')); + if(isset($_FILES['csvfile']) && $_FILES['csvfile']['name'] != '') { + $filename = Tools::getValue('filename')?'WP-Vente '.Tools::getValue('filename'):'WP-Vente'; + $marque = Tools::getValue('filename')?Tools::getValue('filename'):'Marque'; + $params = array('marque' => $marque, 'filename' => $filename, 'lines' => array()); + + $f = fopen($_FILES['csvfile']['tmp_name'], 'r'); + fgetcsv($f, 0, ';'); + $products = array(); + $product_info = array(); + $refs = array(); + $eans = array(); + while($line = fgetcsv($f, 0, ';')) { + if($line[0] == '' && $line[1] == '') { + continue; + } + if($line[0] != '') { + $ean = trim($line[0]); + $products[$ean] = array( + 'ean' => $ean, + 'supplier_ref' => trim($line[1]), + 'name_ha' => trim($line[2]), + 'quantity' => trim($line[3]), + 'ppc' => trim($line[4]), + 'prix_ha' => trim($line[5]) + ); + $eans[] = $ean; + } else { + $ref = trim($line[1]); + $products[$ref] = array( + 'ean' => trim($line[0]), + 'supplier_ref' => $ref, + 'name_ha' => trim($line[2]), + 'quantity' => trim($line[3]), + 'ppc' => trim($line[4]), + 'prix_ha' => trim($line[5]) + ); + $refs[] = $ref; + } + } + + $product_info = array(); + $product_found = 0; + $ids = array(); + foreach (Db::getInstance()->executeS(' + SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, p.`ean13`, p.`price`, p.`wholesale_price`, + p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.* + FROM + `'._DB_PREFIX_.'product` p + INNER JOIN (SELECT date_add, max(id_product) as maxid FROM `'._DB_PREFIX_.'product` GROUP BY ean13) as b + ON p.`id_product` = b.maxid + LEFT JOIN `'._DB_PREFIX_.'category_product` c + ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`) + LEFT JOIN `'._DB_PREFIX_.'product_customs` cu + ON (cu.`id_product` = p.`id_product`) + WHERE p.`ean13` IN ("'.implode('","',$eans).'") + '.(!empty($refs)?' OR p.`supplier_reference` IN ("'.implode('","',$refs).'")':'').' + ORDER BY c.`position` + ') as $row) { + if($row['ean13']!='' && isset($products[$row['ean13']])){ + $products[$row['ean13']] = array_merge($products[$row['ean13']], $row); + $product_found++; + } elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){ + $products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row); + $product_found++; + } + $ids[] = (int)$row['id_product']; + } + $new_products = count($ids) - $product_found; + if(!empty($ids)){ + foreach (Db::getInstance()->executeS(' + SELECT p.`ean13`, p.`supplier_reference`, pl.* + FROM ps_product_lang pl + LEFT JOIN ps_product p ON (pl.`id_product` = p.`id_product`) + WHERE pl.`id_product` IN ('.implode(',',$ids).') + AND (pl.id_lang = 2 OR pl.id_lang = 3) + ORDER BY pl.`id_product` + ') as $row) { + if($row['ean13']!='' && isset($products[$row['ean13']])){ + if(!isset($products[$row['ean13']]['lang'])){ + $products[$row['ean13']]['lang'] = array(); + } + if(!isset($products[$row['ean13']]['lang'][(int)$row['id_lang']])){ + $products[$row['ean13']]['lang'][(int)$row['id_lang']] = $row; + } + } elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){ + if(!isset($products[$row['supplier_reference']]['lang'])){ + $products[$row['supplier_reference']]['lang'] = array(); + } + if(!isset($products[$row['supplier_reference']]['lang'][(int)$row['id_lang']])){ + $products[$row['supplier_reference']]['lang'][(int)$row['id_lang']] = $row; + } + } + } + } + $params['lines'] = $products; + if(!empty($params['lines'])){ + $wp = new GenerateWp(); + $wp->generate($params); + $wp->objWriter->save(dirname(__FILE__).'/'.$filename.'.xlsx'); + $this->_html .= HelperFormBootstrap::displaySuccess('Génération complète
Télécharger le XLS
Produits trouvés : '.$product_found.'
Produits nouveaux : '.$new_products); + } else { + $this->_html .= HelperFormBootstrap::displayErrors($this->l('Veuillez charger un fichier correct !')); + } } } @@ -110,8 +207,8 @@ class AdminAntWp extends AdminTab $ps_url = ((Configuration::get('PS_SSL_ENABLED') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PORT'] == '443')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].__PS_BASE_URI__; $this->helperForm->_forms = array( array( - // 'action' => $currentIndex . '&token=' . Tools::getAdminTokenLite('AdminAntWp'), - 'action' => $ps_url.'modules/ant_wp/GenerateWp.php?url='.$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminAntWp'), + 'action' => $currentIndex . '&token=' . Tools::getAdminTokenLite('AdminAntWp'), + // 'action' => $ps_url.'modules/ant_wp/GenerateWp.php?url='.$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminAntWp'), 'title' => ' '.$this->l('WP'), 'class' => 'form-horizontal', 'class_div' => 'col-md-12', diff --git a/modules/ant_wp/GenerateWp.php b/modules/ant_wp/GenerateWp.php index 891fb32c..8e5f0f6a 100644 --- a/modules/ant_wp/GenerateWp.php +++ b/modules/ant_wp/GenerateWp.php @@ -1,8 +1,8 @@ objPHPExcel->removeSheetByIndex(0); foreach ($sheets as $key => $sheet) { - if($key>0){ - $this->objPHPExcel->createSheet(1); - } + $this->objPHPExcel->createSheet(); $this->objPHPExcel->setActiveSheetIndex($key); - $this->objPHPExcel->setActiveSheetIndex($key)->setCellValue('A1','Vente - '.$params['marque']); + $this->objPHPExcel->setActiveSheetIndex($key)->setCellValue('A1','Vente - '.(String)$params['marque']); $activeSheet = $this->objPHPExcel->getActiveSheet(); if($key == 0){ - $activeSheet->setTitle('Vente FR'); + $activeSheet->setTitle('WP-Vente FR'); }else{ - $activeSheet->setTitle('Vente ES'); + $activeSheet->setTitle('WP-Vente ES'); } $activeSheet->mergeCells('A1:B1'); if($key == 0){ - $activeSheet->setCellValue('AM1',$params['marque']); + $activeSheet->setCellValue('AM1',(String)$params['marque']); $activeSheet->getStyle('AM1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE); $activeSheet->getStyle('AM1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $activeSheet->getStyle('AM1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); @@ -124,7 +123,6 @@ class GenerateWp ) ); - $i=4; foreach ($this->columns as $key => $value) { $this->objPHPExcel->setActiveSheetIndex(0); @@ -190,6 +188,7 @@ class GenerateWp ) ); } + $i++; foreach ($params['lines'] as $key => $row) { if(isset($row['id_product'])){ @@ -232,7 +231,7 @@ class GenerateWp $this->objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$i, (String)$row['ean']) ->setCellValue('C'.$i, $row['supplier_reference']) - ->setCellValue('D'.$i, '=IF(AND(E'.$i.'="";F'.$i.'="";G'.$i.'="");"";E'.$i.'&" "&F'.$i.'&" - "&G'.$i.')') + ->setCellValue('D'.$i, '=IF(AND(E'.$i.'="",F'.$i.'="",G'.$i.'=""),"",E'.$i.'&" "&F'.$i.'&" - "&G'.$i.')') ->setCellValue('E'.$i, '') ->setCellValue('F'.$i, '') ->setCellValue('G'.$i, '') @@ -245,8 +244,8 @@ class GenerateWp ->setCellValue('N'.$i, $categories_title[2][2]) ->setCellValue('O'.$i, count($images)) ->setCellValue('P'.$i, '') - ->setCellValue('Q'.$i, '=AM1 & "-" & P'.$i.' & "-" & LEFT(C'.$i.';9)') - ->setCellValue('R'.$i, '=IF(Q'.$i.'="";"";LEN(Q'.$i.'))') + ->setCellValue('Q'.$i, '=AM1&"-"&P'.$i.'&"-"&LEFT(C'.$i.',9)') + ->setCellValue('R'.$i, '=IF(Q'.$i.'="","",LEN(Q'.$i.'))') ->setCellValue('S'.$i, $row['lang'][2]['description_short']) ->setCellValue('T'.$i, $row['lang'][2]['description']) ->setCellValue('U'.$i, $row['lang'][2]['description_more']) @@ -262,12 +261,12 @@ class GenerateWp ->setCellValue('AE'.$i, '') ->setCellValue('AF'.$i, $row['prix_ha']) ->setCellValue('AG'.$i, Tools::ps_round($row['wholesale_price'], 2)) - ->setCellValue('AH'.$i, '=IF(AG'.$i.'="";"";IF((AF'.$i.'-AG'.$i.')>0;"ATTENTION";IF((AF'.$i.'-AG'.$i.')<0;"COOL";IF((AF'.$i.'-AG'.$i.')=0;"OK";""))))') - ->setCellValue('AI'.$i, '=IF(AF'.$i.'="";"";(AF'.$i.'*1,85))') + ->setCellValue('AH'.$i, '=IF(AG'.$i.'="","",IF((AF'.$i.'-AG'.$i.')>0,"ATTENTION",IF((AF'.$i.'-AG'.$i.')<0,"COOL",IF((AF'.$i.'-AG'.$i.')=0,"OK",""))))') + ->setCellValue('AI'.$i, '=IF(AF'.$i.'="","",(AF'.$i.'*1.85))') ->setCellValue('AJ'.$i, $price2) - ->setCellValue('AK'.$i, '=IF(AND(AD'.$i.'="";AI'.$i.'="");"";ROUND((1-AI'.$i.'/AD'.$i.')*100;4))') - ->setCellValue('AL'.$i, '=IF(AND(AF'.$i.'="";AI'.$i.'="");"";1-AF'.$i.'/(AI'.$i.'/1,2))') - ->setCellValue('AM'.$i, '=IF(O'.$i.'="";"";IF(O'.$i.'=1;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg";IF(O'.$i.'=2;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg";IF(O'.$i.'=3;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg";IF(O'.$i.'=4;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg";IF(O'.$i.'='.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg";IF(O'.$i.'=6;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg";IF(O'.$i.'=7;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg";IF(O'.$i.'=8;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg";IF(O'.$i.'=9;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg";IF(O'.$i.'=10;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg";IF(O'.$i.'=11;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg";IF(O'.$i.'=12;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg";IF(O'.$i.'=13;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg";IF(O'.$i.'=14;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg";IF(O'.$i.'=1'.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-14.jpg"))))))))))))))))') + ->setCellValue('AK'.$i, '=IF(AND(AD'.$i.'="",AI'.$i.'=""),"",ROUND((1-AI'.$i.'/AD'.$i.')*100,4))') + ->setCellValue('AL'.$i, '=IF(AND(AF'.$i.'="",AI'.$i.'=""),"",1-AF'.$i.'/(AI'.$i.'/1.2))') + ->setCellValue('AM'.$i, '=IF(O'.$i.'="","",IF(O'.$i.'=1,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg",IF(O'.$i.'=2,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg",IF(O'.$i.'=3,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg",IF(O'.$i.'=4,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg",IF(O'.$i.'='.$i.',"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg",IF(O'.$i.'=6,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg",IF(O'.$i.'=7,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg",IF(O'.$i.'=8,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg",IF(O'.$i.'=9,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg",IF(O'.$i.'=10,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg",IF(O'.$i.'=11,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg",IF(O'.$i.'=12,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg",IF(O'.$i.'=13,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg",IF(O'.$i.'=14,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg",IF(O'.$i.'=1'.$i.',"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-14.jpg"))))))))))))))))') ->setCellValue('AN'.$i, implode(', ', $images)) ->setCellValue('AO'.$i, '=AA'.$i.'*AF'.$i) ->setCellValue('AP'.$i, isset($row['nc8'])?$row['nc8']:"") @@ -291,7 +290,7 @@ class GenerateWp } else { $this->objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$i, (String)$row['ean']) ->setCellValue('C'.$i, $row['supplier_ref']) - ->setCellValue('D'.$i, '=IF(AND(E'.$i.'="";F'.$i.'="";G'.$i.'="");"";E'.$i.'&" "&F'.$i.'&" - "&G'.$i.')') + ->setCellValue('D'.$i, '=IF(AND(E'.$i.'="",F'.$i.'="",G'.$i.'=""),"",E'.$i.'&" "&F'.$i.'&" - "&G'.$i.')') ->setCellValue('E'.$i, '') ->setCellValue('F'.$i, '') ->setCellValue('G'.$i, '') @@ -304,8 +303,8 @@ class GenerateWp ->setCellValue('N'.$i, '') ->setCellValue('O'.$i, '') ->setCellValue('P'.$i, '') - ->setCellValue('Q'.$i, '=AM1 & "-" & P'.$i.' & "-" & LEFT(C'.$i.';9)') - ->setCellValue('R'.$i, '=IF(Q'.$i.'="";"";LEN(Q'.$i.'))') + ->setCellValue('Q'.$i, '=AM1 & "-" & P'.$i.' & "-" & LEFT(C'.$i.',9)') + ->setCellValue('R'.$i, '=IF(Q'.$i.'="","",LEN(Q'.$i.'))') ->setCellValue('S'.$i, '') ->setCellValue('T'.$i, '') ->setCellValue('U'.$i, '') @@ -321,12 +320,12 @@ class GenerateWp ->setCellValue('AE'.$i, '') ->setCellValue('AF'.$i, $row['prix_ha']) ->setCellValue('AG'.$i, '') - ->setCellValue('AH'.$i, '=IF(AG'.$i.'="";"";IF((AF'.$i.'-AG'.$i.')>0;"ATTENTION";IF((AF'.$i.'-AG'.$i.')<0;"COOL";IF((AF'.$i.'-AG'.$i.')=0;"OK";""))))') - ->setCellValue('AI'.$i, '=IF(AF'.$i.'="";"";(AF'.$i.'*1,85))') + ->setCellValue('AH'.$i, '=IF(AG'.$i.'="","",IF((AF'.$i.'-AG'.$i.')>0,"ATTENTION",IF((AF'.$i.'-AG'.$i.')<0,"COOL",IF((AF'.$i.'-AG'.$i.')=0,"OK",""))))') + ->setCellValue('AI'.$i, '=IF(AF'.$i.'="","",(AF'.$i.'*1.85))') ->setCellValue('AJ'.$i, '') - ->setCellValue('AK'.$i, '=IF(AND(AD'.$i.'="";AI'.$i.'="");"";ROUND((1-AI'.$i.'/AD'.$i.')*100;4))') - ->setCellValue('AL'.$i, '=IF(AND(AF'.$i.'="";AI'.$i.'="");"";1-AF'.$i.'/(AI'.$i.'/1,2))') - ->setCellValue('AM'.$i, '=IF(O'.$i.'="";"";IF(O'.$i.'=1;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg";IF(O'.$i.'=2;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg";IF(O'.$i.'=3;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg";IF(O'.$i.'=4;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg";IF(O'.$i.'='.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg";IF(O'.$i.'=6;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg";IF(O'.$i.'=7;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg";IF(O'.$i.'=8;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg";IF(O'.$i.'=9;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg";IF(O'.$i.'=10;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg";IF(O'.$i.'=11;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg";IF(O'.$i.'=12;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg";IF(O'.$i.'=13;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg";IF(O'.$i.'=14;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg";IF(O'.$i.'=1'.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-14.jpg"))))))))))))))))') + ->setCellValue('AK'.$i, '=IF(AND(AD'.$i.'="",AI'.$i.'=""),"",ROUND((1-AI'.$i.'/AD'.$i.')*100,4))') + ->setCellValue('AL'.$i, '=IF(AND(AF'.$i.'="",AI'.$i.'=""),"",1-AF'.$i.'/(AI'.$i.'/1.2))') + ->setCellValue('AM'.$i, '=IF(O'.$i.'="","",IF(O'.$i.'=1,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg",IF(O'.$i.'=2,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg",IF(O'.$i.'=3,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg",IF(O'.$i.'=4,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg",IF(O'.$i.'='.$i.',"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg",IF(O'.$i.'=6,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg",IF(O'.$i.'=7,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg",IF(O'.$i.'=8,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg",IF(O'.$i.'=9,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg",IF(O'.$i.'=10,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg",IF(O'.$i.'=11,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg",IF(O'.$i.'=12,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg",IF(O'.$i.'=13,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg",IF(O'.$i.'=14,"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg",IF(O'.$i.'=1'.$i.',"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-14.jpg"))))))))))))))))') ->setCellValue('AN'.$i, '') ->setCellValue('AO'.$i, '=AA'.$i.'*AF'.$i) ->setCellValue('AP'.$i, '') @@ -351,122 +350,34 @@ class GenerateWp $i++; } $this->objPHPExcel->setActiveSheetIndex(0); + $this->objPHPExcel->getActiveSheet() + ->getStyle('B5:B'.$lastLine) + ->getNumberFormat() + ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER); + $this->objPHPExcel->setActiveSheetIndex(1); + $this->objPHPExcel->getActiveSheet() + ->getStyle('B5:B'.$lastLine) + ->getNumberFormat() + ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER); + // $this->objPHPExcel->setActiveSheetIndex(0); + // foreach ($this->columns as $col => $value) { + // for($row = 5; $row <= count($params['lines']); ++$row) { + // if ((!is_null($formula = $this->objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) && + // ($formula[0] == '=')) { + // $this->objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue(); + // } + // } + // } + // $this->objPHPExcel->setActiveSheetIndex(1); + // foreach ($this->columns_es as $col => $value) { + // for($row = 5; $row <= count($params['lines']); ++$row) { + // if ((!is_null($formula = $this->objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) && + // ($formula[0] == '=')) { + // $this->objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue(); + // } + // } + // } + $this->objPHPExcel->setActiveSheetIndex(0); $this->objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, 'Excel2007'); } -} - -if(isset($_FILES['csvfile']) && $_FILES['csvfile']['name'] != '') { - $filename = Tools::getValue('filename')?'WP-Vente '.Tools::getValue('filename'):'WP-Vente'; - $marque = Tools::getValue('filename')?Tools::getValue('filename'):'Marque'; - $params = array('marque' => $marque, 'filename' => $filename, 'lines' => array()); - - $f = fopen($_FILES['csvfile']['tmp_name'], 'r'); - fgetcsv($f, 0, ';'); - $products = array(); - $product_info = array(); - $refs = array(); - $eans = array(); - while($line = fgetcsv($f, 0, ';')) { - if($line[0] == '' && $line[1] == '') { - continue; - } - if($line[0] != '') { - $ean = trim($line[0]); - $products[$ean] = array( - 'ean' => $ean, - 'supplier_ref' => trim($line[1]), - 'name_ha' => trim($line[2]), - 'quantity' => trim($line[3]), - 'ppc' => trim($line[4]), - 'prix_ha' => trim($line[5]) - ); - $eans[] = $ean; - } else { - $ref = trim($line[1]); - $products[$ref] = array( - 'ean' => trim($line[0]), - 'supplier_ref' => $ref, - 'name_ha' => trim($line[2]), - 'quantity' => trim($line[3]), - 'ppc' => trim($line[4]), - 'prix_ha' => trim($line[5]) - ); - $refs[] = $ref; - } - } - - $product_info = array(); - $product_found = 0; - $ids = array(); - foreach (Db::getInstance()->executeS(' - SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, p.`ean13`, p.`price`, p.`wholesale_price`, - p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.* - FROM - `'._DB_PREFIX_.'product` p - INNER JOIN (SELECT date_add, max(id_product) as maxid FROM `'._DB_PREFIX_.'product` GROUP BY ean13) as b - ON p.`id_product` = b.maxid - LEFT JOIN `'._DB_PREFIX_.'category_product` c - ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`) - LEFT JOIN `'._DB_PREFIX_.'product_customs` cu - ON (cu.`id_product` = p.`id_product`) - WHERE p.`ean13` IN ("'.implode('","',$eans).'") - '.(!empty($refs)?' OR p.`supplier_reference` IN ("'.implode('","',$refs).'")':'').' - ORDER BY c.`position` - ') as $row) { - if($row['ean13']!='' && isset($products[$row['ean13']])){ - $products[$row['ean13']] = array_merge($products[$row['ean13']], $row); - $product_found++; - } elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){ - $products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row); - $product_found++; - } - $ids[] = (int)$row['id_product']; - } - $new_products = count($ids) - $product_found; - if(!empty($ids)){ - foreach (Db::getInstance()->executeS(' - SELECT p.`ean13`, p.`supplier_reference`, pl.* - FROM ps_product_lang pl - LEFT ps_product p ON (pl.`id_product` = p.`id_product`) - WHERE pl.`id_product` IN ('.implode(',',$ids).') - AND (pl.id_lang = 2 OR pl.id_lang = 3) - ORDER BY pl.`id_product` - ') as $row) { - if($row['ean13']!='' && isset($products[$row['ean13']])){ - if(!isset($products[$row['ean13']]['lang'])){ - $products[$row['ean13']]['lang'] = array(); - } - if(!isset($products[$row['ean13']]['lang'][(int)$row['id_lang']])){ - $products[$row['ean13']]['lang'][(int)$row['id_lang']] = $row; - } - } elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){ - if(!isset($products[$row['supplier_reference']]['lang'])){ - $products[$row['supplier_reference']]['lang'] = array(); - } - if(!isset($products[$row['supplier_reference']]['lang'][(int)$row['id_lang']])){ - $products[$row['supplier_reference']]['lang'][(int)$row['id_lang']] = $row; - } - } - } - } - - $params['lines'] = $products; - - if(!empty($params['lines'])){ - $wp = new GenerateWp(); - $wp->generate($params); - header('Content-Type: application/vnd.oasis.opendocument.spreadsheet'); - header('Content-Disposition: attachment;filename="'.$filename.'.xlsx"'); - header('Cache-Control: max-age=0'); - // If you're serving to IE 9, then the following may be needed - header('Cache-Control: max-age=1'); - - // If you're serving to IE over SSL, then the following may be needed - header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past - header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified - header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 - header ('Pragma: public'); // HTTP/1.0 - - $wp->objWriter->save('php://output'); - } -} +} \ No newline at end of file