bebeboutik/modules/ant_wp/GenerateWp.php

777 lines
55 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;
2018-02-14 18:53:23 +01:00
public $excludedProducts;
2017-10-27 13:16:02 +02:00
public function __construct()
{
2018-01-18 18:29:59 +01:00
@ini_set('display_errors', 'on');
2017-10-27 13:16:02 +02:00
$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',
2018-01-24 16:50:32 +01:00
'D' => 'Ref modifiée',
'E' => 'Nom du produit',
'F' => 'Type de produit',
'G' => 'Nom / Collection',
'H' => 'Coloris / Déclinaison',
'I' => 'Taille HA',
'J' => 'Taille (old)',
'K' => 'Nom du produit HA',
'L' => 'Nom du produit (old)',
'M' => 'Nb de caract. Titre',
'N' => 'Order',
'O' => 'Catégorie',
'P' => 'Sous-catégorie',
'Q' => 'Sous-sous-catégorie',
'R' => 'Nb de photos',
'S' => 'Ordre Logistique',
'T' => 'Ref Bébé Boutik',
'U' => 'Nb de caract. Ref',
'V' => 'Description courte',
'W' => 'Bon à savoir',
'X' => 'Les plus',
'Y' => 'Vidéo',
'Z' => 'Livraison',
'AA'=> 'Poids',
'AB' => 'Vente old',
'AC' => 'BDC old',
'AD' => 'Quantité réservée',
'AE' => 'Taille',
'AF' => 'TVA appliquée',
'AG' => 'PPC TTC',
'AH' => 'PPC old',
'AI' => 'Prix achat HT',
'AJ' => 'Prix HA old',
'AK' => 'Différence',
'AL' => 'PV 3BTK appliqué',
'AM' => 'Prix vente old',
'AN' => 'Remise membre',
'AO' => 'Marge',
'AP' => 'Photos',
'AQ' => 'Photos old',
'AR' => 'BDC Potentiel',
'AS' => 'Custom code',
'AT' => 'Pays de fabrication',
'AU' => 'Date de la vente');
2018-02-14 18:53:23 +01:00
$this->excludedProducts = array();
2017-10-27 13:16:02 +02:00
}
public static $FORMAT_DARK_BLUE = '214A7B';
public static $FORMAT_LIGHT_BLUE = '6C8DCD';
public static $FORMAT_LIGHTER_DARK_BLUE = 'C6D9F0';
2018-01-18 18:29:59 +01:00
public static $FORMAT_BG_LIGHT_RED = 'FEC7CE';
2018-01-24 16:50:32 +01:00
public static $FORMAT_BG_DARK_RED = 'FF9A0511';
2018-01-18 18:29:59 +01:00
public static $FORMAT_BG_LIGHT_GREEN = 'C7EECF';
2018-01-24 16:50:32 +01:00
public static $FORMAT_BG_DARK_GREEN = 'FF09600B';
2018-01-18 18:29:59 +01:00
public static $FORMAT_BG_LIGHT_YELLOW = 'FEEAA0';
2018-01-24 16:50:32 +01:00
public static $FORMAT_BG_DARK_YELLOW = 'FFA36415';
2017-10-27 13:16:02 +02:00
2018-01-24 16:50:32 +01:00
public function generate($params, &$timer_table, $callStartTime)
2017-10-27 13:16:02 +02:00
{
$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
2018-01-24 16:50:32 +01:00
$borders_style = array(
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array(
'rgb' => '000000'
)
)
)
);
$borders_style_none = array(
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array(
'rgb' => 'FFFFFF'
)
)
)
);
$darker_light_blue_style = array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'rotation' => 0,
'startcolor' => array(
'rgb' => self::$FORMAT_LIGHTER_DARK_BLUE
),
'endcolor' => array(
'rgb' => self::$FORMAT_LIGHTER_DARK_BLUE
)
);
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();
2018-01-24 16:50:32 +01:00
2017-10-27 13:16:02 +02:00
$activeSheet->mergeCells('A1:B1');
2018-01-24 16:50:32 +01:00
if($key === 0){
$activeSheet->setTitle('WP-Vente FR');
$activeSheet->setCellValue('AP1',(String)$params['marque']);
$activeSheet->getStyle('AP1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
$activeSheet->getStyle('AP1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$activeSheet->getStyle('AP1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$activeSheet->getStyle('AP1')->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'
)
)
);
2018-01-24 16:50:32 +01:00
}elseif($key === 1){
$activeSheet->setTitle('WP-Vente ES');
}
$activeSheet->getStyle('A1:AZ'.($lastLine+20))->applyFromArray($borders_style_none);
$activeSheet->getStyle('A1:AU'.$lastLine)->getFont()->setSize(10);
$activeSheet->getStyle('A1:AU'.$lastLine)->getFont()->setName('calibri');
$activeSheet->getColumnDimension('A')->setWidth(3);
$activeSheet->freezePane('E5');
2017-10-27 13:16:02 +02:00
}
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Excel sheet format done for the 3 first lines in '.(microtime(true)-$callStartTime);
2017-10-27 13:16:02 +02:00
$i=4;
2018-01-24 16:50:32 +01:00
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);
2018-01-24 16:50:32 +01:00
if(in_array($key, array('B','C','D','O','P','Q','T','W','X','Y','Z'), true)){
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension($key)->setWidth(16);
2018-01-24 16:50:32 +01:00
} elseif(in_array($key, array('F','G','H','I','J','K','L'), true)){
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension($key)->setWidth(20);
2018-01-24 16:50:32 +01:00
} elseif(in_array($key, array('M','N','R','S','U'), true)){
2017-10-27 13:16:02 +02:00
$activeSheet->getColumnDimension($key)->setWidth(10);
2018-01-24 16:50:32 +01:00
} elseif(in_array($key, array('AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO'), true)){
2017-10-27 13:16:02 +02:00
$activeSheet->getColumnDimension($key)->setWidth(11);
2018-01-24 16:50:32 +01:00
} elseif(in_array($key, array('V','AP'), true)){
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension($key)->setWidth(45);
2018-01-24 16:50:32 +01:00
} elseif(in_array($key, array('AR','AS','AT', 'AU'), true)){
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension($key)->setWidth(12);
2018-01-24 16:50:32 +01:00
} elseif('E' === $key){
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension($key)->setWidth(25);
2018-01-24 16:50:32 +01:00
} elseif('AQ' === $key){
2017-11-22 16:31:51 +01:00
$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);
2018-01-24 16:50:32 +01:00
if(in_array($key,array('AB','AC','AH','AJ','AK','AM'),true)){
$activeSheet->getStyle($key.$i)->getFill()->applyFromArray(
array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'rotation' => 0,
'startcolor' => array(
'rgb' => self::$FORMAT_DARK_BLUE //dark blue
),
'endcolor' => array(
'rgb' => self::$FORMAT_DARK_BLUE //dark blue
)
)
);
}else{
$activeSheet->getStyle($key.$i)->getFill()->applyFromArray(
array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'rotation' => 0,
'startcolor' => array(
'rgb' => self::$FORMAT_LIGHT_BLUE //light blue
),
'endcolor' => array(
'rgb' => self::$FORMAT_LIGHT_BLUE //light blue
)
)
);
}
2017-10-27 13:16:02 +02:00
}
foreach ($this->columns_es as $key => $value) {
$this->objPHPExcel->setActiveSheetIndex(1);
$activeSheet = $this->objPHPExcel->getActiveSheet();
$activeSheet->getRowDimension($i)->setRowHeight(25);
2018-01-24 16:50:32 +01:00
if(in_array($key, array('B','C','D','E','G','H','I'), true)) {
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension($key)->setWidth(13);
2018-01-24 16:50:32 +01:00
} elseif(in_array($key, array('F','K'), true)) {
2017-11-22 16:31:51 +01:00
$activeSheet->getColumnDimension($key)->setWidth(25);
2018-01-24 16:50:32 +01:00
} elseif('J' === $key) {
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' => self::$FORMAT_LIGHT_BLUE
2017-10-27 13:16:02 +02:00
),
'endcolor' => array(
'rgb' => self::$FORMAT_LIGHT_BLUE
2017-10-27 13:16:02 +02:00
)
)
);
}
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Excel sheet format done for the 4 first lines in '.(microtime(true)-$callStartTime);
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'));
2018-01-24 16:50:32 +01:00
2017-10-27 13:16:02 +02:00
foreach ($params['lines'] as $key => $row) {
2018-01-24 16:50:32 +01:00
$image_line = '=IF(R'.$i.'="","",IF(R'.$i.'=1,
"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg",
IF(R'.$i.'=2,
"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg",
IF(R'.$i.'=3,
"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg",
IF(R'.$i.'=4,
"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg",
IF(R'.$i.'=5,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
2018-01-24 16:50:32 +01:00
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg",
IF(R'.$i.'=6,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg",
IF(R'.$i.'=7,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-6.jpg",
IF(R'.$i.'=8,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-6.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-7.jpg",
IF(R'.$i.'=9,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-6.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-7.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-8.jpg",
IF(R'.$i.'=10,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-6.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-7.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-8.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-9.jpg",
IF(R'.$i.'=11,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-6.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-7.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-8.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-9.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-10.jpg",
IF(R'.$i.'=12,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-6.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-7.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-8.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-9.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-10.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-11.jpg",
IF(R'.$i.'=13,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-6.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-7.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-8.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-9.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-10.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-11.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-12.jpg",
IF(R'.$i.'=14,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-6.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-7.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-8.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-9.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-10.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-11.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-12.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-13.jpg",
2018-02-14 18:53:23 +01:00
IF(R'.$i.'=15,"https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&".jpg,
2018-01-24 16:50:32 +01:00
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-1.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-2.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-3.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-4.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-5.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-6.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-7.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-8.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-9.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-10.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-11.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-12.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-13.jpg,
https://static.bebeboutik.com/img_import/"&AP1&"/"&D'.$i.'&"-14.jpg"))))))))))))))))';
$image_line = str_replace(array("\r", "\n", ' '), '', $image_line);
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 => ''));
2018-01-24 16:50:32 +01:00
foreach ($id_categories as $key_cat => $id_category) {
2017-10-30 15:45:23 +01:00
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) {
2018-01-24 16:50:32 +01:00
$categories_title[$title['id_lang']][$key_cat] = $title['name'];
2017-10-30 15:45:23 +01:00
}
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);
2018-02-14 18:53:23 +01:00
if(isset($row['ean']) && trim($row['ean']) !== ''){
$best_sales = Product::getBestSales(array('ean'=>$row['ean']), $this->excludedProducts, true);
}elseif(isset($row['supplier_ref']) && trim($row['supplier_ref']) !== ''){
$best_sales = Product::getBestSales(array('ean'=>$row['supplier_ref']), $this->excludedProducts, true);
2017-12-07 10:37:02 +01:00
}
2018-02-14 18:53:23 +01:00
if(count($best_sales) > 0){
$quantity_sold = $best_sales[0]['quantity_sold'];
$total_revenue = Tools::ps_round($quantity_sold * $row['wholesale_price'], 2);
}else{
2018-01-24 16:50:32 +01:00
$quantity_sold = '';
$total_revenue = '';
}
2017-10-30 15:45:23 +01:00
$this->objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$i, (String)$row['ean'])
2018-01-24 16:50:32 +01:00
->setCellValue('C'.$i, (String)$row['supplier_ref'])
->setCellValue('D'.$i, (String)$row['supplier_reference'])
->setCellValue('E'.$i, '=IF(AND(F'.$i.'="",G'.$i.'="",H'.$i.'=""),"",F'.$i.'&" "&G'.$i.'&" - "&H'.$i.')')
2017-10-30 15:45:23 +01:00
->setCellValue('F'.$i, '')
->setCellValue('G'.$i, '')
2018-01-24 16:50:32 +01:00
->setCellValue('H'.$i, '')
->setCellValue('I'.$i, $row['name_attribute_ha'])
->setCellValue('J'.$i, (isset($row['attribute_name'])?$row['attribute_name']:''))
->setCellValue('K'.$i, $row['name_ha'])
->setCellValue('L'.$i, $row['lang'][2]['name'])
->setCellValue('M'.$i, '=LEN(E'.$i.')')
->setCellValue('N'.$i, (int)$row['position'])
->setCellValue('O'.$i, $categories_title[2][0])
->setCellValue('P'.$i, $categories_title[2][1])
->setCellValue('Q'.$i, $categories_title[2][2])
->setCellValue('R'.$i, count($images))
->setCellValue('S'.$i, '')
->setCellValue('T'.$i, '=AP1&"-"&S'.$i.'&"-"&LEFT(D'.$i.',9)')
->setCellValue('U'.$i, '=IF(T'.$i.'="","",LEN(T'.$i.'))')
->setCellValue('V'.$i, $row['lang'][2]['description_short'])
->setCellValue('W'.$i, $row['lang'][2]['description'])
->setCellValue('X'.$i, $row['lang'][2]['description_more'])
->setCellValue('Y'.$i, $row['lang'][2]['videos'])
->setCellValue('Z'.$i, $row['lang'][2]['description_delivery'])
->setCellValue('AA'.$i, $row['weight'])
->setCellValue('AB'.$i, $quantity_sold)
->setCellValue('AC'.$i, $total_revenue)
->setCellValue('AD'.$i, $row['quantity'])
->setCellValue('AE'.$i, $row['height'])
->setCellValue('AF'.$i, $row['id_tax_rules_group'])
->setCellValue('AG'.$i, $row['ppc'])
->setCellValue('AH'.$i, Product::getPriceStatic($row['id_product'],TRUE, NULL, 2, NULL, FALSE, FALSE))
->setCellValue('AI'.$i, $row['prix_ha'])
->setCellValue('AJ'.$i, Tools::ps_round($row['wholesale_price'], 2))
->setCellValue('AK'.$i, '=IF(AJ'.$i.'="","",IF((AI'.$i.'-AJ'.$i.')>0,"ATTENTION",IF((AI'.$i.'-AJ'.$i.')<0,"COOL",IF((AI'.$i.'-AJ'.$i.')=0,"OK",""))))')
->setCellValue('AL'.$i, '=IF(AI'.$i.'="","",(AI'.$i.'*1.85))')
->setCellValue('AM'.$i, $price2)
->setCellValue('AN'.$i, '=IF(AND(AG'.$i.'="",AL'.$i.'=""),"",ROUND((1-AL'.$i.'/AG'.$i.')*100,4))')
->setCellValue('AO'.$i, '=IF(AND(AI'.$i.'="",AL'.$i.'=""),"",1-AI'.$i.'/(AL'.$i.'/1.2))')
->setCellValue('AP'.$i, $image_line)
->setCellValue('AQ'.$i, implode(', ', $images))
->setCellValue('AR'.$i, '=AD'.$i.'*AI'.$i)
->setCellValue('AS'.$i, isset($row['nc8'])?$row['nc8']:"")
->setCellValue('AT'.$i, isset($row['id_country'])?$row['id_country']:"")
->setCellValue('AU'.$i, date('d/m/Y',strtotime($sales[$id_categories[0]])));
$this->objPHPExcel->setActiveSheetIndex(0)->getStyle('B'.$i.':AU'.$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'])
2018-01-24 16:50:32 +01:00
->setCellValue('D'.$i, (String)$row['supplier_reference'])
->setCellValue('E'.$i, '=IF(AND(F'.$i.'="",G'.$i.'="",H'.$i.'=""),"",F'.$i.'&" "&G'.$i.'&" - "&H'.$i.')')
2017-10-30 15:45:23 +01:00
->setCellValue('F'.$i, '')
->setCellValue('G'.$i, '')
2018-01-24 16:50:32 +01:00
->setCellValue('H'.$i, '')
->setCellValue('I'.$i, $row['name_attribute_ha'])
->setCellValue('J'.$i, '')
->setCellValue('K'.$i, $row['name_ha'])
->setCellValue('L'.$i, '')
->setCellValue('M'.$i, '=LEN(E'.$i.')')
2017-10-30 15:45:23 +01:00
->setCellValue('N'.$i, '')
->setCellValue('O'.$i, '')
->setCellValue('P'.$i, '')
2017-11-17 11:16:30 +01:00
->setCellValue('Q'.$i, '')
->setCellValue('R'.$i, '')
2018-01-24 16:50:32 +01:00
->setCellValue('S'.$i, '')
->setCellValue('T'.$i, '=AP1&"-"&S'.$i.'&"-"&LEFT(D'.$i.',9)')
->setCellValue('U'.$i, '=IF(T'.$i.'="","",LEN(T'.$i.'))')
2017-10-30 15:45:23 +01:00
->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, '')
2018-01-24 16:50:32 +01:00
->setCellValue('AC'.$i, '')
->setCellValue('AD'.$i, $row['quantity'])
2017-10-30 15:45:23 +01:00
->setCellValue('AE'.$i, '')
2018-01-24 16:50:32 +01:00
->setCellValue('AF'.$i, '')
->setCellValue('AG'.$i, $row['ppc'])
->setCellValue('AH'.$i, '')
->setCellValue('AI'.$i, $row['prix_ha'])
->setCellValue('AJ'.$i, '')
->setCellValue('AK'.$i, '=IF(AJ'.$i.'="","",IF((AI'.$i.'-AJ'.$i.')>0,"ATTENTION",IF((AI'.$i.'-AJ'.$i.')<0,"COOL",IF((AI'.$i.'-AJ'.$i.')=0,"OK",""))))')
->setCellValue('AL'.$i, '=IF(AI'.$i.'="","",(AI'.$i.'*1.85))')
->setCellValue('AM'.$i, '')
->setCellValue('AN'.$i, '=IF(AND(AG'.$i.'="",AL'.$i.'=""),"",ROUND((1-AL'.$i.'/AG'.$i.')*100,4))')
->setCellValue('AO'.$i, '=IF(AND(AI'.$i.'="",AL'.$i.'=""),"",1-AI'.$i.'/(AL'.$i.'/1.2))')
->setCellValue('AP'.$i, $image_line)
->setCellValue('AQ'.$i, '')
->setCellValue('AR'.$i, '=AD'.$i.'*AI'.$i)
2017-11-17 11:16:30 +01:00
->setCellValue('AS'.$i, '')
2018-01-24 16:50:32 +01:00
->setCellValue('AT'.$i, '')
->setCellValue('AU'.$i, '');
$this->objPHPExcel->setActiveSheetIndex(0)->getStyle('B'.$i.':AU'.$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++;
}
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Excel sheet data inserted after '.(microtime(true)-$callStartTime);
2017-10-27 13:16:02 +02:00
$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()
2018-01-24 16:50:32 +01:00
->getStyle('D5:D'.$lastLine)
2017-11-22 16:31:51 +01:00
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('I5:I'.$lastLine)
2017-11-22 16:31:51 +01:00
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('I5:I'.$lastLine)
2017-11-22 16:31:51 +01:00
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('S5:S'.$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()
2018-01-24 16:50:32 +01:00
->getStyle('U5:U'.$lastLine)
2017-11-22 16:31:51 +01:00
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('U5:U'.$lastLine)
2017-11-22 16:31:51 +01:00
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AC5:AC'.$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()
2018-01-24 16:50:32 +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()
2018-01-24 16:50:32 +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);
$this->objPHPExcel->getActiveSheet()
->getStyle('AB5:AB' . $lastLine)
->getFill()->applyFromArray($darker_light_blue_style);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AC5:AC' . $lastLine)
->getFill()->applyFromArray($darker_light_blue_style);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AH5:AH' . $lastLine)
->getFill()->applyFromArray($darker_light_blue_style);
$this->objPHPExcel->getActiveSheet()
->getStyle('AJ5:AJ' . $lastLine)
->getFill()->applyFromArray($darker_light_blue_style);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AK5:AK' . $lastLine)
->getFill()->applyFromArray($darker_light_blue_style);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AM5:AM' . $lastLine)
->getFill()->applyFromArray($darker_light_blue_style);
$this->objPHPExcel->getActiveSheet()
->getStyle('AB5:AB' . $lastLine)
->getFont()->setBold(true);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AC5:AC' . $lastLine)
->getFont()->setBold(true);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AH5:AH' . $lastLine)
->getFont()->setBold(true);
$this->objPHPExcel->getActiveSheet()
->getStyle('AJ5:AJ' . $lastLine)
->getFont()->setBold(true);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AK5:AK' . $lastLine)
->getFont()->setBold(true);
$this->objPHPExcel->getActiveSheet()
->getStyle('AM5:AM' . $lastLine)
->getFont()->setBold(true);
2018-02-14 18:53:23 +01:00
//Conditionnal formating for column M
$nb_max_char = 50;
2018-01-18 18:29:59 +01:00
$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION)
2018-01-24 16:50:32 +01:00
->addCondition('M5>'.$nb_max_char);
2018-01-18 18:29:59 +01:00
$objConditional1->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(self::$FORMAT_BG_LIGHT_RED);
2018-01-24 16:50:32 +01:00
$objConditional1->getStyle()->getFont()->setColor(new PHPExcel_Style_Color(self::$FORMAT_BG_DARK_RED));
2018-01-18 18:29:59 +01:00
$objConditional2 = new PHPExcel_Style_Conditional();
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION)
2018-01-24 16:50:32 +01:00
->addCondition('M5='.$nb_max_char);
2018-01-18 18:29:59 +01:00
$objConditional2->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(self::$FORMAT_BG_LIGHT_YELLOW);
2018-01-24 16:50:32 +01:00
$objConditional2->getStyle()->getFont()->setColor(new PHPExcel_Style_Color(self::$FORMAT_BG_DARK_YELLOW));
2018-01-18 18:29:59 +01:00
$objConditional3 = new PHPExcel_Style_Conditional();
$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION)
2018-01-24 16:50:32 +01:00
->addCondition('M5<'.$nb_max_char);
2018-01-18 18:29:59 +01:00
$objConditional3->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(self::$FORMAT_BG_LIGHT_GREEN);
2018-01-24 16:50:32 +01:00
$objConditional3->getStyle()->getFont()->setColor(new PHPExcel_Style_Color(self::$FORMAT_BG_DARK_GREEN));
2018-01-18 18:29:59 +01:00
2018-01-24 16:50:32 +01:00
$conditionalStyles = $this->objPHPExcel->getActiveSheet()->getStyle('M5:M'.$lastLine)->getConditionalStyles();
2018-01-18 18:29:59 +01:00
$conditionalStyles[] = $objConditional1;
$conditionalStyles[] = $objConditional2;
$conditionalStyles[] = $objConditional3;
2018-01-24 16:50:32 +01:00
$this->objPHPExcel->getActiveSheet()->getStyle('M5:M'.$lastLine)->setConditionalStyles($conditionalStyles);
2018-01-18 18:29:59 +01:00
$nb_max_char = 17;
2018-02-14 18:53:23 +01:00
//Conditionnal formating for column U
2018-01-18 18:29:59 +01:00
$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION)
2018-01-24 16:50:32 +01:00
->addCondition('U5>'.$nb_max_char);
2018-01-18 18:29:59 +01:00
$objConditional1->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(self::$FORMAT_BG_LIGHT_RED);
2018-01-24 16:50:32 +01:00
$objConditional1->getStyle()->getFont()->setColor(new PHPExcel_Style_Color(self::$FORMAT_BG_DARK_RED));
2018-01-18 18:29:59 +01:00
$objConditional2 = new PHPExcel_Style_Conditional();
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION)
2018-01-24 16:50:32 +01:00
->addCondition('U5='.$nb_max_char);
2018-01-18 18:29:59 +01:00
$objConditional2->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(self::$FORMAT_BG_LIGHT_YELLOW);
2018-01-24 16:50:32 +01:00
$objConditional2->getStyle()->getFont()->setColor(new PHPExcel_Style_Color(self::$FORMAT_BG_DARK_YELLOW));
2018-01-18 18:29:59 +01:00
$objConditional3 = new PHPExcel_Style_Conditional();
$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION)
2018-01-24 16:50:32 +01:00
->addCondition('U5<'.$nb_max_char);
2018-01-18 18:29:59 +01:00
$objConditional3->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(self::$FORMAT_BG_LIGHT_GREEN);
2018-01-24 16:50:32 +01:00
$objConditional3->getStyle()->getFont()->setColor(new PHPExcel_Style_Color(self::$FORMAT_BG_DARK_GREEN));
2018-01-24 16:50:32 +01:00
$conditionalStyles = $this->objPHPExcel->getActiveSheet()->getStyle('U5:U'.$lastLine)->getConditionalStyles();
$conditionalStyles[] = $objConditional1;
2018-01-18 18:29:59 +01:00
$conditionalStyles[] = $objConditional2;
$conditionalStyles[] = $objConditional3;
2018-01-24 16:50:32 +01:00
$this->objPHPExcel->getActiveSheet()->getStyle('U5:U'.$lastLine)->setConditionalStyles($conditionalStyles);
2018-01-18 18:29:59 +01:00
//Conditionnal formating for column AJ
$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT)
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT)
->setText('ATTENTION');
$objConditional1->getStyle()->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_RED));
$objConditional2 = new PHPExcel_Style_Conditional();
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT)
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT)
->setText('COOL');
$objConditional2->getStyle()->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_GREEN));
2018-01-24 16:50:32 +01:00
$conditionalStyles = $this->objPHPExcel->getActiveSheet()->getStyle('AK5:AK'.$lastLine)->getConditionalStyles();
2018-01-18 18:29:59 +01:00
$conditionalStyles[] = $objConditional1;
$conditionalStyles[] = $objConditional2;
2018-01-24 16:50:32 +01:00
$this->objPHPExcel->getActiveSheet()->getStyle('AK5:AK'.$lastLine)->setConditionalStyles($conditionalStyles);
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()
2018-01-24 16:50:32 +01:00
->getStyle('AJ5:AJ'.$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()
2018-01-24 16:50:32 +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('AN5:AN'.$lastLine)
2017-11-06 16:51:48 +01:00
->getNumberFormat()
2018-01-24 16:50:32 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00);
$this->objPHPExcel->getActiveSheet()
->getStyle('AO5:AO'.$lastLine)
->getNumberFormat()
2017-11-06 16:51:48 +01:00
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AR5:AR'.$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()
2018-01-24 16:50:32 +01:00
->getStyle('AR5:AR'.$lastLine)
2017-11-22 16:31:51 +01:00
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
2017-11-06 16:51:48 +01:00
$this->objPHPExcel->getActiveSheet()
2018-01-24 16:50:32 +01:00
->getStyle('AU5:AU'.$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');
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Excel sheet process done after '.(microtime(true)-$callStartTime);
2017-10-27 13:16:02 +02:00
}
2017-10-31 12:32:41 +01:00
}