bebeboutik/modules/ant_wp/GenerateWp.php

497 lines
46 KiB
PHP
Raw Normal View History

2017-10-27 13:16:02 +02:00
<?php
class GenerateWp
{
public $objPHPExcel;
public $objWriter;
public $columns;
public $columns_es;
public function __construct()
{
$this->objPHPExcel = new PHPExcel();
$this->columns_es = array(
'B' => 'EAN',
'C' => 'Ref fournisseur',
'D' => 'Id produit',
'E' => 'Nom du produit',
'F' => 'Catégorie',
'G' => 'Sous-catégorie',
'H' => 'Sous-sous-catégorie',
'I' => 'Description courte',
'J' => 'Bon à savoir',
'K' => 'Les plus',
'L' => 'Vidéos',
'M' => 'Livraison',
);
$this->columns = array(
'B' => 'EAN',
'C' => 'Ref fournisseur',
'D' => 'Nom du produit',
'E' => 'Type de produit',
'F' => 'Nom / Collection',
'G' => 'Coloris / Déclinaison',
2017-11-17 11:16:30 +01:00
'H' => 'Taille HA',
2017-11-22 16:31:51 +01:00
'I' => 'Taille (old)',
2017-11-17 11:16:30 +01:00
'J' => 'Nom du produit HA',
'K' => 'Nom du produit (old)',
'L' => 'Nb de caract. Titre',
'M' => 'Order',
'N' => 'Catégorie',
'O' => 'Sous-catégorie',
'P' => 'Sous-sous-catégorie',
'Q' => 'Nb de photos',
'R' => 'Ordre Logistique',
'S' => 'Ref Bébé Boutik',
'T' => 'Nb de caract. Ref',
'U' => 'Description courte',
'V' => 'Bon à savoir',
'W' => 'Les plus',
'X' => 'Vidéo',
'Y' => 'Livraison',
'Z' => 'Poids',
'AA' => 'Vente old',
'AB' => 'BDC old',
'AC' => 'Quantité réservée',
'AD' => 'Taille',
'AE' => 'TVA appliquée',
'AF' => 'PPC TTC',
'AG' => 'PPC old',
'AH' => 'Prix achat HT',
'AI' => 'Prix HA old',
'AJ' => 'Différence',
'AK' => 'PV 3BTK appliqué',
2017-12-07 10:37:02 +01:00
'AL' => 'Prix vente old',
2017-11-17 11:16:30 +01:00
'AM' => 'Remise membre',
'AN' => 'Marge',
'AO' => 'Photos',
'AP' => 'Photos old',
'AQ' => 'BDC Potentiel',
'AR' => 'Custom code',
'AS' => 'Pays de fabrication',
'AT' => 'Date de la vente');
2017-10-27 13:16:02 +02:00
}
public function generate($params)
{
$sheets = array(0,1);
$lastLine = count($params['lines'])+4;
2017-10-31 12:32:41 +01:00
$this->objPHPExcel->removeSheetByIndex(0);
2017-10-27 13:16:02 +02:00
foreach ($sheets as $key => $sheet) {
2017-10-31 12:32:41 +01:00
$this->objPHPExcel->createSheet();
2017-10-27 13:16:02 +02:00
$this->objPHPExcel->setActiveSheetIndex($key);
2017-10-31 12:32:41 +01:00
$this->objPHPExcel->setActiveSheetIndex($key)->setCellValue('A1','Vente - '.(String)$params['marque']);
2017-10-27 13:16:02 +02:00
$activeSheet = $this->objPHPExcel->getActiveSheet();
if($key == 0){
2017-10-31 12:32:41 +01:00
$activeSheet->setTitle('WP-Vente FR');
2017-10-27 13:16:02 +02:00
}else{
2017-10-31 12:32:41 +01:00
$activeSheet->setTitle('WP-Vente ES');
2017-10-27 13:16:02 +02:00
}
$activeSheet->mergeCells('A1:B1');
if($key == 0){
2017-11-22 16:31:51 +01:00
$activeSheet->setCellValue('AO1',(String)$params['marque']);
$activeSheet->getStyle('AO1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
$activeSheet->getStyle('AO1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$activeSheet->getStyle('AO1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$activeSheet->getStyle('AO1')->getFill()->applyFromArray(
2017-10-27 13:16:02 +02:00
array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'rotation' => 0,
'startcolor' => array(
'rgb' => '000000'
),
'endcolor' => array(
'rgb' => '000000'
)
)
);
}
2017-11-22 16:31:51 +01:00
$activeSheet->getStyle('A1:AT'.$lastLine)->getFont()->setSize(10);
$activeSheet->getStyle('A1:AT'.$lastLine)->getFont()->setName('calibri');
2017-10-27 13:16:02 +02:00
}
$borders_style = array(
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN
)
)
);
$i=4;
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension('A')->setWidth(3);
2017-10-27 13:16:02 +02:00
foreach ($this->columns as $key => $value) {
$this->objPHPExcel->setActiveSheetIndex(0);
$activeSheet = $this->objPHPExcel->getActiveSheet();
$activeSheet->getRowDimension($i)->setRowHeight(25);
2017-11-22 16:31:51 +01:00
if(in_array($key,array('B','C','N','O','P','S','V','W','X','Y'))){
$activeSheet->getColumnDimension($key)->setWidth(16);
} elseif(in_array($key,array('E','F','G','H','I','J','K'))){
$activeSheet->getColumnDimension($key)->setWidth(20);
} elseif(in_array($key,array('L','M','Q','R','T'))){
2017-10-27 13:16:02 +02:00
$activeSheet->getColumnDimension($key)->setWidth(10);
2017-11-22 16:31:51 +01:00
} elseif(in_array($key,array('Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN'))){
2017-10-27 13:16:02 +02:00
$activeSheet->getColumnDimension($key)->setWidth(11);
2017-11-22 16:31:51 +01:00
} elseif(in_array($key,array('U','AO'))){
$activeSheet->getColumnDimension($key)->setWidth(45);
} elseif(in_array($key,array('AQ','AR','AS','AT'))){
$activeSheet->getColumnDimension($key)->setWidth(12);
} elseif(in_array($key,array('D'))){
$activeSheet->getColumnDimension($key)->setWidth(25);
} elseif(in_array($key,array('AP'))){
$activeSheet->getColumnDimension($key)->setWidth(40);
2017-10-27 13:16:02 +02:00
}
2017-11-22 16:31:51 +01:00
// elseif(in_array($key,array('U','AO','AP'))) {
// $activeSheet->getColumnDimension($key)->setWidth(35);
// } elseif(in_array($key,array('D'))) {
// $activeSheet->getColumnDimension($key)->setWidth(25);
// } elseif(in_array($key,array('E','F','G','H','I','J','K'))) {
// $activeSheet->getColumnDimension($key)->setWidth(20);
// } elseif(in_array($key,array('Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AQ','AR','AS','AT'))) {
// $activeSheet->getColumnDimension($key)->setWidth(8);
// } elseif(in_array($key,array('L','M','Q','R','T'))){
// $activeSheet->getColumnDimension($key)->setWidth(7);
// } else {
// $activeSheet->getColumnDimension($key)->setWidth(13);
// }
2017-10-27 13:16:02 +02:00
$activeSheet->setCellValue($key.$i,$value);
$activeSheet->getStyle($key.$i)->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
$activeSheet->getStyle($key.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$activeSheet->getStyle($key.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
2017-11-22 16:31:51 +01:00
$activeSheet->getStyle($key.$i)->getAlignment()->setWrapText(true);
2017-10-27 13:16:02 +02:00
$activeSheet->getStyle($key.$i)->applyFromArray($borders_style);
$activeSheet->getStyle($key.$i)->getFill()->applyFromArray(
array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'rotation' => 0,
'startcolor' => array(
'rgb' => '6C8DCD'
),
'endcolor' => array(
'rgb' => '6C8DCD'
)
)
);
}
foreach ($this->columns_es as $key => $value) {
$this->objPHPExcel->setActiveSheetIndex(1);
$activeSheet = $this->objPHPExcel->getActiveSheet();
$activeSheet->getRowDimension($i)->setRowHeight(25);
2017-11-22 16:31:51 +01:00
if(in_array($key,array('B','C','D','F','G','H','J'))) {
$activeSheet->getColumnDimension($key)->setWidth(13);
} elseif(in_array($key,array('E','J'))) {
$activeSheet->getColumnDimension($key)->setWidth(25);
2017-10-27 13:16:02 +02:00
} elseif(in_array($key,array('I'))) {
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension($key)->setWidth(35);
2017-10-27 13:16:02 +02:00
} else {
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension($key)->setWidth(8);
2017-10-27 13:16:02 +02:00
}
$activeSheet->setCellValue($key.$i,$value);
$activeSheet->getStyle($key.$i)->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
$activeSheet->getStyle($key.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$activeSheet->getStyle($key.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
2017-11-22 16:31:51 +01:00
$activeSheet->getStyle($key.$i)->getAlignment()->setWrapText(true);
2017-10-27 13:16:02 +02:00
$activeSheet->getStyle($key.$i)->applyFromArray($borders_style);
$activeSheet->getStyle($key.$i)->getFill()->applyFromArray(
array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'rotation' => 0,
'startcolor' => array(
'rgb' => '6C8DCD'
),
'endcolor' => array(
'rgb' => '6C8DCD'
)
)
);
}
2017-10-31 12:32:41 +01:00
2017-10-27 13:16:02 +02:00
$i++;
2017-11-06 17:36:53 +01:00
$sales = array();
2017-12-07 10:37:02 +01:00
$order_states = explode(',', Configuration::get('PS_IT_OF_ORDER_STATES'));
2017-10-27 13:16:02 +02:00
foreach ($params['lines'] as $key => $row) {
2017-10-30 15:45:23 +01:00
if(isset($row['id_product'])){
$id_categories = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_category`
FROM `'._DB_PREFIX_.'category_product`
WHERE `id_product` = '.(int) $row['id_product'].'
') as $cat) {
$id_categories[] = (int) $cat['id_category'];
}
sort($id_categories);
2017-10-27 13:16:02 +02:00
2017-11-06 17:36:53 +01:00
if(!isset($sales[$id_categories[0]])){
$sales[$id_categories[0]] = Db::getInstance()->getValue('
SELECT `date_start`
FROM `'._DB_PREFIX_.'privatesale`
WHERE `id_category` = '.(int) $id_categories[0].'
');
}
2017-10-30 15:45:23 +01:00
$categories_title = array(2 => array(0 => '', 1 => '', 2 => ''), 3 => array(0 => '', 1 => '', 2 => ''));
foreach ($id_categories as $key => $id_category) {
foreach (Db::getInstance()->executeS('
SELECT `name`,`id_lang`
FROM `'._DB_PREFIX_.'category_lang`
WHERE `id_category` = '.(int) $id_category.'
AND (`id_lang` = 2 OR `id_lang` = 3)
') as $title) {
$categories_title[$title['id_lang']][$key] = $title['name'];
}
2017-10-27 13:16:02 +02:00
}
2017-10-30 15:45:23 +01:00
$images = array();
foreach(Db::getInstance()->ExecuteS('
SELECT i.`id_image`, l.`legend`
FROM `'._DB_PREFIX_.'image` i
LEFT JOIN `'._DB_PREFIX_.'image_lang` l ON l.`id_image` = i.`id_image`
WHERE l.`id_lang` = 2
AND i.`id_product` = '.(int) $row['id_product'].'
ORDER BY i.`position`
') as $img) {
$link_image = str_split($img['id_image']);
$images[] = 'https://static.bebeboutik.com/img/p/'.implode('/', $link_image) .'/'. $img['id_image'].'.jpg';
}
$price = Product::getPriceStatic($row['id_product'],TRUE, NULL, 2, NULL, FALSE, FALSE);
$price2 = Product::getPriceStatic($row['id_product'],TRUE, NULL, 2);
2017-10-27 13:16:02 +02:00
2017-12-07 10:37:02 +01:00
if(isset($row['id_product_attribute'])){
$quantity_sold = (int) Db::getInstance()->getValue('
SELECT SUM(d.`product_quantity` - d.`product_quantity_reinjected`)
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
lEFT JOIN `'._DB_PREFIX_.'order_state_current` sc ON sc.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int)$row['id_product'].'
AND d.`product_attribute_id` = '.(int)$row['id_product_attribute'].'
AND sc.id_order_state IN ("'.implode('","', $order_states).'")
');
} else {
$quantity_sold = (int) Db::getInstance()->getValue('
SELECT SUM(d.`product_quantity` - d.`product_quantity_reinjected`)
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
lEFT JOIN `'._DB_PREFIX_.'order_state_current` sc ON sc.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int)$row['id_product'].'
AND d.`product_attribute_id` = 0
AND sc.id_order_state IN ("'.implode('","', $order_states).'")
');
}
2017-10-30 15:45:23 +01:00
$this->objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$i, (String)$row['ean'])
2017-11-22 16:31:51 +01:00
->setCellValue('C'.$i, (String)$row['supplier_reference'])
2017-10-31 12:32:41 +01:00
->setCellValue('D'.$i, '=IF(AND(E'.$i.'="",F'.$i.'="",G'.$i.'=""),"",E'.$i.'&" "&F'.$i.'&" - "&G'.$i.')')
2017-10-30 15:45:23 +01:00
->setCellValue('E'.$i, '')
->setCellValue('F'.$i, '')
->setCellValue('G'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('H'.$i, $row['name_attribute_ha'])
->setCellValue('I'.$i, (isset($row['attribute_name'])?$row['attribute_name']:''))
->setCellValue('J'.$i, $row['name_ha'])
->setCellValue('K'.$i, $row['lang'][2]['name'])
->setCellValue('L'.$i, '=LEN(D'.$i.')')
->setCellValue('M'.$i, (int)$row['position'])
->setCellValue('N'.$i, $categories_title[2][0])
->setCellValue('O'.$i, $categories_title[2][1])
->setCellValue('P'.$i, $categories_title[2][2])
->setCellValue('Q'.$i, count($images))
->setCellValue('R'.$i, '')
2017-11-22 16:31:51 +01:00
->setCellValue('S'.$i, '=AO1&"-"&R'.$i.'&"-"&LEFT(C'.$i.',9)')
->setCellValue('T'.$i, '=IF(S'.$i.'="","",LEN(S'.$i.'))')
2017-11-17 11:16:30 +01:00
->setCellValue('U'.$i, $row['lang'][2]['description_short'])
->setCellValue('V'.$i, $row['lang'][2]['description'])
->setCellValue('W'.$i, $row['lang'][2]['description_more'])
->setCellValue('X'.$i, $row['lang'][2]['videos'])
->setCellValue('Y'.$i, $row['lang'][2]['description_delivery'])
->setCellValue('Z'.$i, $row['weight'])
2017-12-07 10:37:02 +01:00
->setCellValue('AA'.$i, $quantity_sold)
->setCellValue('AB'.$i, Tools::ps_round(($quantity_sold * $row['wholesale_price']),2))
2017-11-17 11:16:30 +01:00
->setCellValue('AC'.$i, $row['quantity'])
->setCellValue('AD'.$i, $row['height'])
->setCellValue('AE'.$i, $row['id_tax_rules_group'])
->setCellValue('AF'.$i, $row['ppc'])
2017-12-07 10:37:02 +01:00
->setCellValue('AG'.$i, Product::getPriceStatic($row['id_product'],TRUE, (int) $k, 2, NULL, FALSE, FALSE))
2017-11-17 11:16:30 +01:00
->setCellValue('AH'.$i, $row['prix_ha'])
->setCellValue('AI'.$i, Tools::ps_round($row['wholesale_price'], 2))
2017-11-22 16:31:51 +01:00
->setCellValue('AJ'.$i, '=IF(AI'.$i.'="","",IF((AH'.$i.'-AI'.$i.')>0,"ATTENTION",IF((AH'.$i.'-AI'.$i.')<0,"COOL",IF((AH'.$i.'-AI'.$i.')=0,"OK",""))))')
->setCellValue('AK'.$i, '=IF(AH'.$i.'="","",(AH'.$i.'*1.85))')
2017-11-17 11:16:30 +01:00
->setCellValue('AL'.$i, $price2)
2017-11-22 16:31:51 +01:00
->setCellValue('AM'.$i, '=IF(AND(AF'.$i.'="",AK'.$i.'=""),"",ROUND((1-AK'.$i.'/AF'.$i.')*100,4))')
->setCellValue('AN'.$i, '=IF(AND(AH'.$i.'="",AK'.$i.'=""),"",1-AH'.$i.'/(AK'.$i.'/1.2))')
->setCellValue('AO'.$i, '=IF(Q'.$i.'="","",IF(Q'.$i.'=1,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg",IF(Q'.$i.'=2,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg",IF(Q'.$i.'=3,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg",IF(Q'.$i.'=4,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg",IF(Q'.$i.'='.$i.',"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg",IF(Q'.$i.'=6,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg",IF(Q'.$i.'=7,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-6.jpg",IF(Q'.$i.'=8,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-7.jpg",IF(Q'.$i.'=9,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-8.jpg",IF(Q'.$i.'=10,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-9.jpg",IF(Q'.$i.'=11,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.co
2017-11-17 11:16:30 +01:00
->setCellValue('AP'.$i, implode(', ', $images))
2017-11-22 16:31:51 +01:00
->setCellValue('AQ'.$i, '=AC'.$i.'*AH'.$i)
2017-11-17 11:16:30 +01:00
->setCellValue('AR'.$i, isset($row['nc8'])?$row['nc8']:"")
->setCellValue('AS'.$i, isset($row['id_country'])?$row['id_country']:"")
->setCellValue('AT'.$i, date('d/m/Y',strtotime($sales[$id_categories[0]])));
$this->objPHPExcel->setActiveSheetIndex(0)->getStyle('B'.$i.':AT'.$i.'')->applyFromArray($borders_style);
2017-10-27 13:16:02 +02:00
$this->objPHPExcel->setActiveSheetIndex(1)->setCellValue('B'.$i, (String)$row['ean'])
2017-11-22 16:31:51 +01:00
->setCellValue('C'.$i, (String)$row['supplier_reference'])
2017-12-07 10:37:02 +01:00
->setCellValue('D'.$i, '')
2017-10-27 13:16:02 +02:00
->setCellValue('E'.$i, $row['lang'][3]['name'])
->setCellValue('F'.$i, $categories_title[3][0])
->setCellValue('G'.$i, $categories_title[3][1])
->setCellValue('H'.$i, $categories_title[3][2])
->setCellValue('I'.$i, $row['lang'][3]['description_short'])
->setCellValue('J'.$i, $row['lang'][3]['description'])
->setCellValue('K'.$i, $row['lang'][3]['description_more'])
->setCellValue('L'.$i, $row['lang'][3]['videos'])
->setCellValue('M'.$i, $row['lang'][3]['description_delivery']);
$this->objPHPExcel->setActiveSheetIndex(1)->getStyle('B'.$i.':M'.$i.'')->applyFromArray($borders_style);
2017-10-30 15:45:23 +01:00
} else {
$this->objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$i, (String)$row['ean'])
2017-11-22 16:31:51 +01:00
->setCellValue('C'.$i, (String)$row['supplier_ref'])
2017-10-31 12:32:41 +01:00
->setCellValue('D'.$i, '=IF(AND(E'.$i.'="",F'.$i.'="",G'.$i.'=""),"",E'.$i.'&" "&F'.$i.'&" - "&G'.$i.')')
2017-10-30 15:45:23 +01:00
->setCellValue('E'.$i, '')
->setCellValue('F'.$i, '')
->setCellValue('G'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('H'.$i, $row['name_attribute_ha'])
2017-10-31 12:41:11 +01:00
->setCellValue('I'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('J'.$i, $row['name_ha'])
2017-10-30 15:45:23 +01:00
->setCellValue('K'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('L'.$i, '=LEN(D'.$i.')')
2017-10-30 15:45:23 +01:00
->setCellValue('M'.$i, '')
->setCellValue('N'.$i, '')
->setCellValue('O'.$i, '')
->setCellValue('P'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('Q'.$i, '')
->setCellValue('R'.$i, '')
2017-11-22 16:31:51 +01:00
->setCellValue('S'.$i, '=AO1&"-"&R'.$i.'&"-"&LEFT(C'.$i.',9)')
->setCellValue('T'.$i, '=IF(S'.$i.'="","",LEN(S'.$i.'))')
2017-10-30 15:45:23 +01:00
->setCellValue('U'.$i, '')
->setCellValue('V'.$i, '')
->setCellValue('W'.$i, '')
->setCellValue('X'.$i, '')
->setCellValue('Y'.$i, '')
->setCellValue('Z'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('AA'.$i, '')
2017-10-30 15:45:23 +01:00
->setCellValue('AB'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('AC'.$i, $row['quantity'])
->setCellValue('AD'.$i, '')
2017-10-30 15:45:23 +01:00
->setCellValue('AE'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('AF'.$i, $row['ppc'])
2017-10-30 15:45:23 +01:00
->setCellValue('AG'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('AH'.$i, $row['prix_ha'])
->setCellValue('AI'.$i, '')
2017-11-22 16:31:51 +01:00
->setCellValue('AJ'.$i, '=IF(AI'.$i.'="","",IF((AH'.$i.'-AI'.$i.')>0,"ATTENTION",IF((AH'.$i.'-AI'.$i.')<0,"COOL",IF((AH'.$i.'-AI'.$i.')=0,"OK",""))))')
->setCellValue('AK'.$i, '=IF(AH'.$i.'="","",(AH'.$i.'*1.85))')
2017-11-17 11:16:30 +01:00
->setCellValue('AL'.$i, '')
2017-11-22 16:31:51 +01:00
->setCellValue('AM'.$i, '=IF(AND(AF'.$i.'="",AK'.$i.'=""),"",ROUND((1-AK'.$i.'/AF'.$i.')*100,4))')
->setCellValue('AN'.$i, '=IF(AND(AH'.$i.'="",AK'.$i.'=""),"",1-AH'.$i.'/(AK'.$i.'/1.2))')
->setCellValue('AO'.$i, '=IF(Q'.$i.'="","",IF(Q'.$i.'=1,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg",IF(Q'.$i.'=2,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg",IF(Q'.$i.'=3,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg",IF(Q'.$i.'=4,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg",IF(Q'.$i.'='.$i.',"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg",IF(Q'.$i.'=6,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg",IF(Q'.$i.'=7,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-6.jpg",IF(Q'.$i.'=8,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-7.jpg",IF(Q'.$i.'=9,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-8.jpg",IF(Q'.$i.'=10,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-9.jpg",IF(Q'.$i.'=11,"https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&AO1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.co
2017-10-30 15:45:23 +01:00
->setCellValue('AP'.$i, '')
2017-11-22 16:31:51 +01:00
->setCellValue('AQ'.$i, '=AC'.$i.'*AH'.$i)
2017-11-17 11:16:30 +01:00
->setCellValue('AR'.$i, '')
->setCellValue('AS'.$i, '')
->setCellValue('AT'.$i, '');
$this->objPHPExcel->setActiveSheetIndex(0)->getStyle('B'.$i.':AT'.$i.'')->applyFromArray($borders_style);
2017-10-30 15:45:23 +01:00
$this->objPHPExcel->setActiveSheetIndex(1)->setCellValue('B'.$i, (String)$row['ean'])
->setCellValue('C'.$i, $row['supplier_ref'])
->setCellValue('D'.$i, '')
->setCellValue('E'.$i, '')
->setCellValue('F'.$i, '')
->setCellValue('G'.$i, '')
->setCellValue('H'.$i, '')
->setCellValue('I'.$i, '')
->setCellValue('J'.$i, '')
->setCellValue('K'.$i, '')
->setCellValue('L'.$i, '')
->setCellValue('M'.$i, '');
$this->objPHPExcel->setActiveSheetIndex(1)->getStyle('B'.$i.':M'.$i.'')->applyFromArray($borders_style);
}
2017-10-27 13:16:02 +02:00
$i++;
}
$this->objPHPExcel->setActiveSheetIndex(0);
2017-10-31 12:32:41 +01:00
$this->objPHPExcel->getActiveSheet()
->getStyle('B5:B'.$lastLine)
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
2017-11-22 16:31:51 +01:00
$this->objPHPExcel->getActiveSheet()
->getStyle('C5:C'.$lastLine)
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$this->objPHPExcel->getActiveSheet()
->getStyle('L5:L'.$lastLine)
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
$this->objPHPExcel->getActiveSheet()
->getStyle('L5:L'.$lastLine)
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('R5:R'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
2017-11-22 16:31:51 +01:00
$this->objPHPExcel->getActiveSheet()
->getStyle('T5:T'.$lastLine)
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
$this->objPHPExcel->getActiveSheet()
->getStyle('T5:T'.$lastLine)
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AB5:AB'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
2017-11-22 16:31:51 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AF5:AF'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
2017-11-22 16:31:51 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AG5:AG'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
2017-11-22 16:31:51 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AH5:AH'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
2017-11-22 16:31:51 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AI5:AI'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
2017-11-22 16:31:51 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AK5:AK'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
2017-11-22 16:31:51 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AL5:AL'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
2017-11-22 16:31:51 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AM5:AM'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AN5:AN'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AQ5:AQ'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
2017-11-22 16:31:51 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR);
$this->objPHPExcel->getActiveSheet()
->getStyle('AQ5:AQ'.$lastLine)
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2017-11-17 11:16:30 +01:00
->getStyle('AT5:AT'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY);
2017-10-31 12:32:41 +01:00
$this->objPHPExcel->setActiveSheetIndex(1);
$this->objPHPExcel->getActiveSheet()
->getStyle('B5:B'.$lastLine)
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
$this->objPHPExcel->setActiveSheetIndex(0);
2017-10-27 13:16:02 +02:00
$this->objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, 'Excel2007');
}
2017-10-31 12:32:41 +01:00
}