2016-01-04 12:49:26 +01:00
< ? php
require_once ( dirname ( __FILE__ ) . '/../../config/config.inc.php' );
require_once ( dirname ( __FILE__ ) . '/../../init.php' );
require_once ( _PS_MODULE_DIR_ . 'privatesales/Sale.php' );
require_once ( 'AdminPrivateSalesLogistique.php' );
require_once dirname ( __FILE__ ) . '/classes/SaleStats.php' ;
set_include_path ( get_include_path () . PATH_SEPARATOR . _PS_MODULE_DIR_ . 'privatesales_logistique/classes/' );
include_once ( 'PHPExcel.php' );
include_once ( 'PHPExcel/Writer/Excel2007.php' );
include_once ( 'PHPExcel/Style/NumberFormat.php' );
include_once ( 'PHPExcel/Worksheet/Drawing.php' );
include_once ( 'PHPExcel/Style/Alignment.php' );
include_once ( 'PHPExcel/Style/Font.php' );
$tax = new Tax ( 1 );
$TVA = number_format ( $tax -> rate , 2 );
if ( Tools :: getValue ( 'action' ) == 'getOrderForm' && ( ( $id_category = Tools :: getValue ( 'id' , false ) ) || ( Validate :: isInt ( Tools :: getValue ( 'id_exportorderform' , false )) && Validate :: isLoadedObject ( $OrderForm = new OrderForm ( Tools :: getValue ( 'id_exportorderform' ) ) ) ) ) )
{
$array_service = array (
1 , //1 : bon de commande
2 , //2 : état des ventes
3 , //3 : stats des ventes
2016-04-04 17:23:15 +02:00
4 , //4 : BDC logistique
2016-01-04 12:49:26 +01:00
);
$lang_id = Tools :: getValue ( 'lang' , 'fr' );
$array_lang = array (
'en' => array (
'Product ID' => 'Product ID' ,
'EAN' => 'EAN' ,
'Reference BB' => 'BB Boutik ID' ,
'Product Name' => 'Product Name' ,
'Attribute' => 'Size' ,
2016-02-09 10:46:07 +01:00
'Quantity' => 'Quantities sold' ,
'Total quantity' => 'Booked quantities' ,
'Remaining quantity' => 'Remaining quantities' ,
2016-01-04 12:49:26 +01:00
'Unit Price' => 'Unit Price' ,
'Total Amount' => 'Total Amount' ,
2016-04-04 17:23:15 +02:00
'Purchase order' => 'Purchase order' ,
'Purchase order logistic' => 'Purchase order logistic' ,
2016-01-04 12:49:26 +01:00
'State order' => 'Sales report' ,
'The number below must be present on each document regarding this order, delivery note, invoice :' => 'The number below must be present on each document regarding this order, delivery note, invoice :' ,
'PURCHASE ORDER NUMBER' => 'PURCHASE ORDER NUMBER' ,
'Delivery adress' => 'Delivery address' ,
'PURCHASE ORDER DATE' => 'PURCHASE ORDER DATE' ,
'DELIVERY DUTY PAID' => 'DELIVERY DUTY PAID' ,
'YES' => 'YES' ,
),
'fr' => array (
'Product ID' => 'Référence' ,
'EAN' => 'EAN' ,
'Reference BB' => 'Référence BBB' ,
'Product Name' => 'Nom du produit' ,
'Attribute' => 'Déclinaison' ,
2016-02-09 10:46:07 +01:00
'Quantity' => 'Quantités vendues' ,
2016-01-04 12:49:26 +01:00
'Total quantity' => 'Stock initial' ,
2016-02-09 10:46:07 +01:00
'Remaining quantity' => 'Stock restant' ,
2016-01-04 12:49:26 +01:00
'Unit Price' => 'PU HT' ,
'Total Amount' => 'Prix Total HT' ,
2016-04-04 17:23:15 +02:00
'Purchase order' => 'Bon de commande' ,
'Purchase order logistic' => 'Bon de commande logistique' ,
2016-01-04 12:49:26 +01:00
'State order' => 'Etat des ventes' ,
'YES' => 'OUI' ,
'PURCHASE ORDER NUMBER' => 'NUMERO DE BON DE COMMANDE' ,
'Delivery adress' => 'Adresse de livraison' ,
'PURCHASE ORDER DATE' => 'DATE DU BON DE COMMANDE' ,
'DELIVERY DUTY PAID' => 'FRANCO DE PORT' ,
'The number below must be present on each document regarding this order, delivery note, invoice :' => 'Le numéro suivant doit apparaître sur toute la correspondance annexe, les papiers de livraison et les factures :' ,
)
);
$lang = $array_lang [ $lang_id ];
if ( ! Tools :: getValue ( 'type' ) || ! in_array ( ( $type = Tools :: getValue ( 'type' )), $array_service ))
die ( 'Vous devez saisir un type valide' );
$test = ( bool ) ( Tools :: getValue ( 'test' , false ) );
if ( ! Validate :: isLoadedObject ( $OrderForm ))
{
$loaded = false ;
if ( Tools :: getValue ( 'last' ) !== false )
{
$date = OrderForm :: getLastByCategory ( $id_category );
$date_from = new DateManager ( $date );
$date_from -> updateDate ( 1 );
$date_to = new DateManager ( date ( 'Y-m-d H:i:s' ));
}
else
{
$date_from = new DateManager ( Tools :: getValue ( 'from' ));
$date_to = new DateManager ( Tools :: getValue ( 'to' ));
}
if ( $type == 1 )
{
if ( ! Validate :: isDate ( $date_from -> getDate ( 'SQL' )) || ! Validate :: isDate ( $date_to -> getDate ( 'SQL' )))
die ( 'Une des deux dates est invalide' );
$OrderForm = new OrderForm ();
$OrderForm -> from = $date_from -> getDate ( 'SQL' );
$OrderForm -> to = $date_to -> getDate ( 'SQL' );
$OrderForm -> id_category = $id_category ;
$OrderForm -> save ();
}
}
else
{
$date_from = new DateManager ( $OrderForm -> from );
$date_to = new DateManager ( $OrderForm -> to );
$id_category = $OrderForm -> id_category ;
$loaded = true ;
}
2016-02-09 10:46:07 +01:00
$date_of_extract = new DateManager ( date ( 'Y-m-d H:i:s' ));
$date_of_extract -> setLangue ( strtoupper ( $lang_id ));
2016-01-04 12:49:26 +01:00
$date_from -> setLangue ( strtoupper ( $lang_id ));
$date_to -> setLangue ( strtoupper ( $lang_id ));
if ( ! Validate :: isDate ( $date_from -> getDate ( 'SQL' )) || ! Validate :: isDate ( $date_to -> getDate ( 'SQL' )))
die ( 'Une des deux dates est invalide' );
$date_to_sql = $date_to ;
$sale = Sale :: getSaleFromCategory ( $id_category );
$category = new Category ( $id_category , $cookie -> id_lang );
$products = MakeStats :: getProductsByCat ( $id_category );
$lines = array ();
$array_product = array ();
if ( $type == 1 || $type == 2 || $type == 3 ) {
$arrayProduct = array ();
foreach ( $products as $product )
$array_product [ $product [ 'id_product' ]] = $arrayProduct [ $product [ 'id_product' ]] = new Product ( $product [ 'id_product' ]);
$order_states = explode ( ',' , Configuration :: get ( 'PS_IT_OF_ORDER_STATES' ));
$lines = MakeStats :: getOrdersByIdsProduct ( array_keys ( $arrayProduct ), $order_states , $date_from -> getDate ( 'SQL' ), $date_to -> getDate ( 'SQL' ));
2016-02-09 10:46:07 +01:00
// adding - fev 2016
if ( $type == 2 ) {
$lines = MakeStats :: getDetailsByIdsProduct ( array_keys ( $arrayProduct ), $order_states , $date_from -> getDate ( 'SQL' ), $date_to -> getDate ( 'SQL' ));
}
// end adding
2016-01-04 12:49:26 +01:00
// for stats
$lines_tmp = $lines ;
$lines = MakeStats :: getArrayLines ( $lines );
} else {
die ( " Type d'export invalide " );
}
if ( $type == 3 ) {
$stats = new SaleStats ( $sale , $category );
$stats -> loadData ();
$total_sale_product = array ();
$total_bdc_ht = 0 ;
foreach ( $lines_tmp as $key => $order_line ) {
$id_product = $order_line [ 'product_id' ];
$id_product_attribute = $order_line [ 'product_attribute_id' ];
$current_product = $array_product [ $id_product ];
if ( $id_product_attribute != 0 ) {
$combination = new Combination ( $id_product_attribute );
if ( $combination -> wholesale_price == 0 ) {
$wholesale_price = $current_product -> wholesale_price ;
} else {
$wholesale_price = $combination -> wholesale_price ;
}
} else {
$wholesale_price = $current_product -> wholesale_price ;
}
$quantity_to_cmd = $order_line [ 'product_quantity' ] - $order_line [ 'product_quantity_reinjected' ];
$total_sale_ht += $quantity_to_cmd * $wholesale_price ;
if ( ! is_array ( $total_sale_product [( int ) $id_product . '-' . ( int ) $id_product_attribute ]) ){
$total_sale_product [( int ) $id_product . '-' . ( int ) $id_product_attribute ] = array ();
$total_sale_product [( int ) $id_product . '-' . ( int ) $id_product_attribute ][ 'total_ht' ] = 0 ;
$total_sale_product [( int ) $id_product . '-' . ( int ) $id_product_attribute ][ 'quantiy' ] = 0 ;
$total_sale_product [( int ) $id_product . '-' . ( int ) $id_product_attribute ][ 'name' ] = $current_product -> name [ 2 ];
}
$price_ht = $current_product -> getPrice ( false , $id_product_attribute , 2 );
$price_ttc = $current_product -> getPrice ( true , $id_product_attribute , 2 );
$total_sale_product [( int ) $id_product . '-' . ( int ) $id_product_attribute ][ 'total_ht' ] += $price_ht ;
$total_sale_product [( int ) $id_product . '-' . ( int ) $id_product_attribute ][ 'quantiy' ] += $quantity_to_cmd ;
}
$stats -> addToStats ( 'total_bdc_ht' , $total_sale_ht );
$bestsales = MakeStats :: orderMultiArray ( $total_sale_product , 'total_ht' );
$bestsales_extract = array_slice ( $bestsales , 0 , 3 );
$i = 1 ;
foreach ( $bestsales_extract as $key => $bestsalesProduct ) {
$stats -> addToStats ( 'bestsale_' . $i . '_product' , $bestsalesProduct [ 'name' ]);
$stats -> addToStats ( 'bestsale_' . $i . '_quantity' , $bestsalesProduct [ 'quantiy' ]);
$stats -> addToStats ( 'bestsale_' . $i . '_ca' , $bestsalesProduct [ 'total_ht' ]);
$i ++ ;
}
$stats -> loadDataForSubCategory ();
// export
$stats -> export ();
die ;
}
if ( count ( $lines ) == 0 )
die ( " Aucune vente pour cette vente privée " );
// $authorized_ip = array(
// '80.13.158.176',
// '88.120.248.124'
// );
// if(in_array($_SERVER['REMOTE_ADDR'], $authorized_ip))
// {
// p($lines);
// die;
// }
$arrayTmp = array ();
foreach ( $lines as $id_product => $arrayProduct )
{
foreach ( $arrayProduct as $id_product_attribute => $values )
{
$arrayTmp [ $values [ 'line' ][ 'product_id' ]][ $values [ 'line' ][ 'product_attribute_id' ]] = $values ;
}
}
// associate position
$arrayTmp2 = array ();
foreach ( $products as $key => $product_order ) {
$arrayTmp2 [] = $arrayTmp [ $product_order [ 'id_product' ]];
}
// $lines2 = $arrayTmp;
$lines2 = $arrayTmp2 ;
// ksort($lines2);
$have_declinaison = false ;
foreach ( $lines2 as $lines_attributes )
{
foreach ( $lines_attributes as $values )
{
if ( $values [ 'line' ][ 'product_attribute_name_base' ] != '' ) {
$have_declinaison = true ;
break 2 ;
}
}
}
switch ( $type )
{
case '1' :
$title = $lang [ 'Purchase order' ] . ' ' . $category -> name . ' - Bébé Boutik ' . $date_from -> getNomMois () . ' ' . $date_from -> getAnnee ();
break ;
case '2' :
$extrafields = Category :: getSalesInfos ( array (( int ) $category -> id_category ));
$title = $lang [ 'State order' ] . ' ' . $category -> name . ' - ' . $extrafields [( int ) $category -> id_category ][ 'sales' ][ 1 ];
break ;
2016-04-04 17:23:15 +02:00
case '4' :
$title = $lang [ 'Purchase order logistic' ] . ' ' . $category -> name . ' - Bébé Boutik ' . $date_from -> getNomMois () . ' ' . $date_from -> getAnnee ();
break ;
2016-01-04 12:49:26 +01:00
}
$firstColumn = 'A' ;
if ( $have_declinaison === true )
{
2016-04-04 17:23:15 +02:00
if ( $type == 4 ) {
2016-04-05 16:14:32 +02:00
$lastColumn = 'K' ;
2016-04-04 17:23:15 +02:00
$letter_product_ref_interne = 'B' ;
$letter_product_name = 'C' ;
$letter_product_attribute_name = 'D' ;
$letter_product_ht = 'E' ;
2016-04-05 16:14:32 +02:00
$letter_product_M1_M2 = 'F' ;
$letter_product_multi = 'G' ;
$letter_product_colisage = 'H' ;
$letter_product_stock3btk = 'I' ;
$letter_product_missing = 'J' ;
$letter_product_total_qty = 'K' ;
2016-04-04 17:23:15 +02:00
2016-01-04 12:49:26 +01:00
} else {
2016-04-04 17:23:15 +02:00
if ( $type == 1 ) {
$lastColumn = 'H' ;
} else {
$lastColumn = 'J' ;
}
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$letter_bdc_title = 'C' ;
$letter_end_address = 'B' ;
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$letter_date = 'C' ;
$letter_franco = 'D' ;
$letter_condition = 'E' ;
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$letter_product_ean = 'B' ;
$letter_product_ref_interne = 'C' ;
$letter_product_name = 'D' ;
$letter_product_attribute_name = 'E' ;
/*$letter_product_qty = 'F';*/
if ( $type == 1 ) {
$letter_product_qty = 'F' ;
$letter_product_ht = 'G' ;
$letter_product_total = 'H' ;
} else {
$letter_product_total_qty = 'F' ;
$letter_product_qty = 'G' ;
$letter_product_remaining_qty = 'H' ;
$letter_product_ht = 'I' ;
$letter_product_total = 'J' ;
}
2016-01-04 12:49:26 +01:00
}
}
else
{
2016-04-04 17:23:15 +02:00
if ( $type == 4 ) {
2016-04-05 16:14:32 +02:00
$lastColumn = 'J' ;
2016-04-04 17:23:15 +02:00
$letter_product_ref_interne = 'B' ;
$letter_product_name = 'C' ;
2016-04-05 16:14:32 +02:00
//$letter_product_attribute_name = 'D';
$letter_product_ht = 'D' ;
$letter_product_M1_M2 = 'E' ;
$letter_product_multi = 'F' ;
$letter_product_colisage = 'G' ;
$letter_product_stock3btk = 'H' ;
$letter_product_missing = 'I' ;
$letter_product_total_qty = 'J' ;
2016-04-04 17:23:15 +02:00
2016-01-04 12:49:26 +01:00
} else {
2016-04-04 17:23:15 +02:00
if ( $type == 1 ) {
$lastColumn = 'G' ;
} else {
$lastColumn = 'I' ;
}
$letter_bdc_title = 'C' ;
$letter_end_address = 'B' ;
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$letter_date = 'C' ;
$letter_franco = 'D' ;
$letter_condition = 'E' ;
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$letter_product_ean = 'B' ;
$letter_product_ref_interne = 'C' ;
$letter_product_name = 'D' ;
// $letter_product_attribute_name = 'C';
/* $letter_product_qty = 'E';*/
if ( $type == 1 ) {
$letter_product_qty = 'E' ;
$letter_product_ht = 'F' ;
$letter_product_total = 'G' ;
} else {
$letter_product_total_qty = 'E' ;
$letter_product_qty = 'F' ;
$letter_product_remaining_qty = 'G' ;
$letter_product_ht = 'H' ;
$letter_product_total = 'I' ;
}
2016-01-04 12:49:26 +01:00
}
}
// if($loaded === true)
// {
// header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
// header('Content-Disposition: attachment;filename="'.$title.'.xlsx"');
// echo file_get_contents($OrderForm->getFile());
// exit;
// }
$objPHPExcel = new PHPExcel ();
$objPHPExcel -> getProperties () -> setCreator ( " Antadis " );
$objPHPExcel -> getProperties () -> setTitle ( $title );
$objPHPExcel -> getProperties () -> setSubject ( $title );
$objPHPExcel -> getProperties () -> setDescription ( $title );
$objPHPExcel -> getActiveSheet () -> getStyle ( $firstColumn . '1:' . $lastColumn . '300' ) -> getFont () -> setSize ( 10 );
$objPHPExcel -> getActiveSheet () -> getStyle ( $firstColumn . '1:' . $lastColumn . '300' ) -> getFont () -> setName ( 'calibri' );
// $objPHPExcel->getFont()->setSize(10);
// $objPHPExcel->getFont()->setName('Colibri');
$arrayBorder = array (
'borders' => array (
'allborders' => array (
'style' => PHPExcel_Style_Border :: BORDER_THIN ,
'color' => array (
'rgb' => '000000'
)
)
)
);
$arrayBorderAutour = array (
'borders' => array (
'left' => array (
'style' => PHPExcel_Style_Border :: BORDER_THIN ,
),
'right' => array (
'style' => PHPExcel_Style_Border :: BORDER_THIN ,
),
'bottom' => array (
'style' => PHPExcel_Style_Border :: BORDER_THIN ,
),
'top' => array (
'style' => PHPExcel_Style_Border :: BORDER_THIN ,
)
)
);
$arrayConfig = array (
'PS_IT_OF_ORGANISATION_' . $lang_id ,
'PS_IT_OF_ADDRESS_' . $lang_id ,
'PS_IT_OF_ADDRESS_2_' . $lang_id ,
'PS_IT_OF_CP_CITY_' . $lang_id ,
'PS_IT_OF_NUMBER_PHONE_' . $lang_id
);
if ( ! Configuration :: get ( 'PS_IT_OF_ADDRESS_2_' . $lang_id ))
unset ( $arrayConfig [ array_search ( 'PS_IT_OF_ADDRESS_2_' . $lang_id , $arrayConfig )]);
$activeSheet = $objPHPExcel -> getActiveSheet ();
$i = 1 ;
if ( $type == 1 )
{
//LOGO
// $activeSheet->getRowDimension($i)->setRowHeight(80);
// $objDrawing = new PHPExcel_Worksheet_Drawing();
// $objDrawing->setWorksheet($activeSheet);
// $objDrawing->setName("name");
// $objDrawing->setDescription("Description");
// $objDrawing->setPath(_PS_IMG_DIR_.'logo.jpg');
// $objDrawing->setCoordinates($firstColumn.$i);
// $objDrawing->setOffsetX(1);
// $objDrawing->setOffsetY(5);
//ADRESSE DE LIVRAISON
// $activeSheet->SetCellValue($firstColumn.$i, 'Adresse de livraison : ');
// $activeSheet->getStyle($firstColumn.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
// $activeSheet->getStyle($firstColumn.$i)->getFont()->setBold(true);
// $activeSheet->getStyle($firstColumn.$i)->getFont()->setSize(12);
// $activeSheet->getStyle($firstColumn.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
// $styleArray = array(
// 'font' => array(
// 'underline' => PHPExcel_Style_Font::UNDERLINE_SINGLE
// )
// );
// $activeSheet->getStyle($firstColumn.$i)->applyFromArray($styleArray);
// $objPHPExcel->getActiveSheet()->getStyle('A1')->applyFromArray($styleArray);
$iOri = $i ;
foreach ( $arrayConfig as $k => $cfg )
{
$activeSheet -> SetCellValue ( $firstColumn . $i , Configuration :: get ( $cfg ) );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setSize ( 10 );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_LEFT );
$activeSheet -> mergeCells ( $firstColumn . $i . ':' . $letter_end_address . $i );
if ( $k == 0 )
{
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setBold ( true );
$i ++ ;
$activeSheet -> SetCellValue ( $firstColumn . $i , Configuration :: get ( 'PS_IT_OF_SLOGAN_' . $lang_id ) );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setSize ( 10 );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_LEFT );
$activeSheet -> mergeCells ( $firstColumn . $i . ':' . $letter_end_address . $i );
$i ++ ;
}
$i ++ ;
}
$activeSheet -> SetCellValue ( $firstColumn . $i , Configuration :: get ( 'PS_IT_OF_EMAIL_' . $lang_id ) );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setSize ( 10 );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_LEFT );
$activeSheet -> mergeCells ( $firstColumn . $i . ':' . $letter_end_address . $i );
$i ++ ;
$activeSheet -> SetCellValue ( $firstColumn . $i , Configuration :: get ( 'PS_IT_OF_TVA_' . $lang_id ) );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setSize ( 10 );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_LEFT );
$activeSheet -> mergeCells ( $firstColumn . $i . ':' . $letter_end_address . $i );
$i ++ ;
//BON DE COMMANDE
$activeSheet -> getCell ( $letter_bdc_title . $iOri ) -> setValue ( $lang [ 'Purchase order' ] . ' ' . chr ( 13 ) . ' ' . $category -> name );
$activeSheet -> getStyle ( $letter_bdc_title . $iOri ) -> getAlignment () -> setWrapText ( true );
$activeSheet -> getStyle ( $letter_bdc_title . $iOri ) -> getFont () -> setBold ( true );
$activeSheet -> getStyle ( $letter_bdc_title . $iOri ) -> getFont () -> setSize ( 18 );
$activeSheet -> getStyle ( $letter_bdc_title . $iOri ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> getStyle ( $letter_bdc_title . $iOri ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> mergeCells ( $letter_bdc_title . $iOri . ':' . $lastColumn . ( $i - 1 ));
// $activeSheet->getStyle($firstColumn.($iOri).':'.$lastColumn.($i-1))->applyFromArray($arrayBorderAutour);
$i ++ ;
//TEXTE
$activeSheet -> SetCellValue ( $firstColumn . $i , $lang [ 'The number below must be present on each document regarding this order, delivery note, invoice :' ]);
$activeSheet -> mergeCells ( $firstColumn . $i . ':' . $letter_end_address . $i );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_JUSTIFY );
$activeSheet -> getRowDimension ( $i ) -> setRowHeight ( 30 );
$i ++ ;
$activeSheet -> SetCellValue ( $firstColumn . $i , $lang [ 'PURCHASE ORDER NUMBER' ] . ' : ' . $OrderForm -> id );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setSize ( 10 );
// $activeSheet->getStyle($firstColumn.$i)->getFont()->getColor()->setRGB('FF0000');
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setBold ( true );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_JUSTIFY );
$activeSheet -> mergeCells ( $firstColumn . $i . ':' . $letter_end_address . $i );
$i ++ ;
//ADRESSE DE LIVRAISON BIS
$letter = 'D' ;
$activeSheet -> SetCellValue ( $letter . $i , $lang [ 'Delivery adress' ] . ' :' );
$activeSheet -> getStyle ( $letter . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_TOP );
$activeSheet -> getStyle ( $letter . $i ) -> getFont () -> setBold ( true );
$activeSheet -> getStyle ( $letter . $i ) -> getFont () -> setSize ( 12 );
$activeSheet -> getStyle ( $letter . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_LEFT );
// $styleArray = array(
// 'font' => array(
// 'underline' => PHPExcel_Style_Font::UNDERLINE_SINGLE
// )
// );
// $activeSheet->getStyle($letter.$i)->applyFromArray($styleArray);
$activeSheet -> mergeCells ( $letter . $i . ':' . $lastColumn . $i );
$i ++ ;
$iOri = $i ;
foreach ( $arrayConfig as $cfg )
{
$activeSheet -> SetCellValue ( $letter . $i , Configuration :: get ( $cfg ) );
$activeSheet -> getStyle ( $letter . $i ) -> getFont () -> setSize ( 10 );
$activeSheet -> mergeCells ( $letter . $i . ':' . $lastColumn . $i );
$activeSheet -> getStyle ( $letter . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_LEFT );
$i ++ ;
}
$i ++ ;
$activeSheet -> SetCellValue ( $letter_date . $i , $lang [ 'PURCHASE ORDER DATE' ] );
$activeSheet -> SetCellValue ( $letter_franco . $i , $lang [ 'DELIVERY DUTY PAID' ] );
$activeSheet -> SetCellValue ( $letter_condition . $i , 'CONDITIONS' );
$activeSheet -> getStyle ( $letter_date . $i . ':' . $letter_condition . $i ) -> getFont () -> setBold ( true );
$activeSheet -> getStyle ( $letter_date . $i . ':' . $letter_condition . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_JUSTIFY );
$activeSheet -> getStyle ( $letter_date . $i . ':' . $letter_condition . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$i ++ ;
$activeSheet -> SetCellValue ( $letter_date . $i , date ( 'd/m/Y' ));
$activeSheet -> SetCellValue ( $letter_franco . $i , $lang [ 'YES' ] );
$activeSheet -> SetCellValue ( $letter_condition . $i , 'N/A' );
$activeSheet -> getStyle ( $letter_date . ( $i - 1 ) . ':' . $letter_condition . $i ) -> applyFromArray ( $arrayBorderAutour );
$activeSheet -> getStyle ( $letter_date . $i . ':' . $letter_condition . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$i ++ ;
if ( isset ( Sale :: $otherVar ))
{
$iOriSaleVar = $i ;
$value = '' ;
/* $activeSheet -> SetCellValue ( $firstColumn . $i , 'Fournisseur : ' );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_TOP );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setBold ( true );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setSize ( 13 );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_RIGHT ); */
$p = 0 ;
foreach ( Sale :: $otherVar as $var )
if ( ! empty ( $sale -> $var ))
{
$value = $sale -> $var ;
$activeSheet -> getCell ( $firstColumn . $i ) -> setValue ( $value );
if ( $var == 'supplier_name' )
{
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setSize ( 14 );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setBold ( true );
$activeSheet -> getRowDimension ( $i ) -> setRowHeight ( 20 );
}
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setWrapText ( true );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_TOP );
$activeSheet -> mergeCells ( $firstColumn . $i . ':F' . $i );
$i ++ ;
$p ++ ;
}
if ( $p == 0 )
{
$activeSheet -> getCell ( $firstColumn . $i ) -> setValue ( 'Aucune information fournisseur' );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setWrapText ( true );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_TOP );
$activeSheet -> mergeCells ( $firstColumn . $i . ':F' . $i );
$i ++ ;
}
$activeSheet -> getStyle ( $firstColumn . ( $i - 1 )) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $firstColumn . ( $i - 1 ) . ':' . $lastColumn . ( $i - 1 )) -> applyFromArray ( $arrayBorderAutour );
if ( $iOriSaleVar != $i )
$activeSheet -> mergeCells ( $firstColumn . $iOriSaleVar . ':' . $firstColumn . ( $i - 1 ) );
// if(!empty($value))
// {
// $activeSheet->getCell('C'.$i)->setValue($value);
// $activeSheet->getStyle('C'.$i)->getFont()->setSize(13);
// $activeSheet->getStyle('C'.$i)->getAlignment()->setWrapText(true);
// $activeSheet->getStyle('C'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
// $activeSheet->mergeCells('C'.$i.':F'.$i);
// $activeSheet->getRowDimension($i)->setRowHeight(90);
// $i++;
// }
}
$i ++ ;
}
2016-04-04 17:23:15 +02:00
if ( $type == 4 ) {
$activeSheet -> SetCellValue ( $firstColumn . $i , $title );
2016-02-09 10:46:07 +01:00
$i ++ ; $i ++ ;
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$activeSheet -> SetCellValue ( $letter_product_ref_interne . $i , $lang [ 'Reference BB' ]);
$activeSheet -> getStyle ( $letter_product_ref_interne . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> SetCellValue ( $letter_product_name . $i , $lang [ 'Product Name' ]);
$activeSheet -> getStyle ( $letter_product_name . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
if ( $have_declinaison === true ) {
$activeSheet -> SetCellValue ( $letter_product_attribute_name . $i , $lang [ 'Attribute' ]);
$activeSheet -> getStyle ( $letter_product_attribute_name . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
}
$activeSheet -> setCellValue ( $letter_product_ht . $i , $lang [ 'Unit Price' ]);
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
2016-04-05 16:14:32 +02:00
$activeSheet -> setCellValue ( $letter_product_M1_M2 . $i , 'M1+M2' );
$activeSheet -> getStyle ( $letter_product_M1_M2 . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_M1_M2 . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> setCellValue ( $letter_product_multi . $i , 'Multi' );
$activeSheet -> getStyle ( $letter_product_multi . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_multi . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> setCellValue ( $letter_product_colisage . $i , 'Colisage/ferme' );
$activeSheet -> getStyle ( $letter_product_colisage . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_colisage . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> setCellValue ( $letter_product_stock3btk . $i , 'Stock 3BTK' );
$activeSheet -> getStyle ( $letter_product_stock3btk . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_stock3btk . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> setCellValue ( $letter_product_missing . $i , 'Manquant' );
$activeSheet -> getStyle ( $letter_product_missing . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_missing . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> setCellValue ( $letter_product_total_qty . $i , 'Total qty' );
$activeSheet -> getStyle ( $letter_product_total_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_total_qty . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
2016-04-04 17:23:15 +02:00
} else {
if ( $type == 2 ) {
$activeSheet -> SetCellValue ( $firstColumn . $i , $date_of_extract -> getJour () . ' ' . $date_of_extract -> getNomMois () . ' ' . $date_of_extract -> getAnnee ());
$i ++ ; $i ++ ;
}
$activeSheet -> SetCellValue ( $firstColumn . $i , $lang [ 'Product ID' ]);
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> SetCellValue ( $letter_product_ean . $i , $lang [ 'EAN' ]);
$activeSheet -> getStyle ( $letter_product_ean . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> SetCellValue ( $letter_product_ref_interne . $i , $lang [ 'Reference BB' ]);
$activeSheet -> getStyle ( $letter_product_ref_interne . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
//$activeSheet->getStyle('E'.$i)->getBorders()->setBold(true);
$activeSheet -> SetCellValue ( $letter_product_name . $i , $lang [ 'Product Name' ]);
$activeSheet -> getStyle ( $letter_product_name . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
if ( $have_declinaison === true ) {
$activeSheet -> SetCellValue ( $letter_product_attribute_name . $i , $lang [ 'Attribute' ]);
$activeSheet -> getStyle ( $letter_product_attribute_name . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
}
$activeSheet -> SetCellValue ( $letter_product_qty . $i , $lang [ 'Quantity' ]);
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getAlignment () -> setWrapText ( true );
if ( $type == 2 ) {
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getFill () -> applyFromArray (
array (
'type' => PHPExcel_Style_Fill :: FILL_SOLID ,
'rotation' => 0 ,
'startcolor' => array (
'rgb' => 'D9D9D9'
),
'endcolor' => array (
'argb' => 'D9D9D9D9'
)
2016-02-09 10:46:07 +01:00
)
2016-04-04 17:23:15 +02:00
);
$activeSheet -> SetCellValue ( $letter_product_total_qty . $i , $lang [ 'Total quantity' ]);
$activeSheet -> getStyle ( $letter_product_total_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_total_qty . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> SetCellValue ( $letter_product_remaining_qty . $i , $lang [ 'Remaining quantity' ]);
$activeSheet -> getStyle ( $letter_product_remaining_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_remaining_qty . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
}
$activeSheet -> setCellValue ( $letter_product_ht . $i , $lang [ 'Unit Price' ]);
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
$activeSheet -> setCellValue ( $letter_product_total . $i , $lang [ 'Total Amount' ]);
$activeSheet -> getStyle ( $letter_product_total . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_total . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_CENTER );
2016-01-04 12:49:26 +01:00
}
$i ++ ;
$iOri = $i ;
//p(count($lines));
$count = 0 ;
if ( $type == 1 || $type == 2 )
foreach ( $lines as $line )
foreach ( $line as $l )
$count += $l [ 'total' ];
switch ( $type )
{
2016-04-05 16:14:32 +02:00
case '4' :
foreach ( $lines2 as $lines_attributes )
{
foreach ( $lines_attributes as $values )
{
$id_product_attribute = $values [ 'line' ][ 'product_attribute_id' ];
$id_product = $values [ 'line' ][ 'product_id' ];
$current_product = $array_product [ $id_product ];
if ( $id_product_attribute != 0 )
{
$combination = new Combination ( $id_product_attribute );
if ( $combination -> wholesale_price == 0 )
$wholesale_price = $current_product -> wholesale_price ;
else
$wholesale_price = $combination -> wholesale_price ;
}
else
{
$wholesale_price = $current_product -> wholesale_price ;
}
$activeSheet -> SetCellValue ( $letter_product_ref_interne . $i , $values [ 'line' ][ 'product_reference' ]);
$activeSheet -> SetCellValue ( $letter_product_name . $i , $values [ 'line' ][ 'product_name_base' ]);
if ( $have_declinaison === true )
$activeSheet -> SetCellValue ( $letter_product_attribute_name . $i , $values [ 'line' ][ 'product_attribute_name_base' ]);
$activeSheet -> setCellValue ( $letter_product_ht . $i , ( float ) $wholesale_price );
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_CURRENCY_EUR );
$activeSheet -> setCellValue ( $letter_product_total_qty . $i , '=' . $letter_product_M1_M2 . $i . '+' . $letter_product_multi . $i . '+' . $letter_product_colisage . $i . '-' . $letter_product_stock3btk . $i . '-' . $letter_product_missing . $i );
$activeSheet -> getStyle ( $letter_product_total . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_CURRENCY_EUR );
$i ++ ;
}
}
break ;
2016-01-04 12:49:26 +01:00
case '2' :
foreach ( $lines2 as $lines_attributes )
{
foreach ( $lines_attributes as $values )
{
$id_product_attribute = $values [ 'line' ][ 'product_attribute_id' ];
$id_product = $values [ 'line' ][ 'product_id' ];
$current_product = $array_product [ $id_product ];
if ( $id_product_attribute != 0 )
{
$combination = new Combination ( $id_product_attribute );
if ( $combination -> wholesale_price == 0 )
$wholesale_price = $current_product -> wholesale_price ;
else
$wholesale_price = $combination -> wholesale_price ;
}
else
{
$wholesale_price = $current_product -> wholesale_price ;
}
$activeSheet -> SetCellValue ( $firstColumn . $i , $values [ 'line' ][ 'product_supplier_reference' ]);
$activeSheet -> getStyle ( $firstColumn . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_TEXT );
$activeSheet -> SetCellValue ( $letter_product_ean . $i , $values [ 'line' ][ 'product_ean13' ]);
$activeSheet -> getStyle ( $letter_product_ean ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_NUMBER );
$activeSheet -> getStyle ( $letter_product_ean . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_NUMBER );
$activeSheet -> getStyle ( $letter_product_ean . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_LEFT );
$activeSheet -> SetCellValue ( $letter_product_ref_interne . $i , $values [ 'line' ][ 'product_reference' ]);
2016-02-09 10:46:07 +01:00
$activeSheet -> SetCellValue ( $letter_product_name . $i , $values [ 'line' ][ 'product_name_base' ]);
if ( $have_declinaison === true )
2016-01-04 12:49:26 +01:00
$activeSheet -> SetCellValue ( $letter_product_attribute_name . $i , $values [ 'line' ][ 'product_attribute_name_base' ]);
$activeSheet -> SetCellValue ( $letter_product_qty . $i , $values [ 'total' ]);
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
2016-02-09 10:46:07 +01:00
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getFill () -> applyFromArray (
array (
'type' => PHPExcel_Style_Fill :: FILL_SOLID ,
'rotation' => 0 ,
'startcolor' => array (
'rgb' => 'D9D9D9'
),
'endcolor' => array (
'argb' => 'D9D9D9D9'
)
)
);
$activeSheet -> SetCellValue ( $letter_product_total_qty . $i , ( $values [ 'stock' ] + $values [ 'total' ]));
2016-01-04 12:49:26 +01:00
$activeSheet -> getStyle ( $letter_product_total_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
2016-02-09 10:46:07 +01:00
$activeSheet -> SetCellValue ( $letter_product_remaining_qty . $i , $values [ 'stock' ]);
2016-01-04 12:49:26 +01:00
$activeSheet -> getStyle ( $letter_product_remaining_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> setCellValue ( $letter_product_ht . $i , ( float ) $wholesale_price );
$activeSheet -> setCellValue ( $letter_product_total . $i , '=' . $letter_product_qty . $i . '*' . $letter_product_ht . $i );
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_CURRENCY_EUR );
$activeSheet -> getStyle ( $letter_product_total . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_CURRENCY_EUR );
$i ++ ;
}
}
break ;
case '1' :
foreach ( $lines2 as $lines_attributes )
{
foreach ( $lines_attributes as $values )
{
$id_product_attribute = $values [ 'line' ][ 'product_attribute_id' ];
$id_product = $values [ 'line' ][ 'product_id' ];
$current_product = $array_product [ $id_product ];
if ( $id_product_attribute != 0 )
{
$combination = new Combination ( $id_product_attribute );
if ( $combination -> wholesale_price == 0 )
$wholesale_price = $current_product -> wholesale_price ;
else
$wholesale_price = $combination -> wholesale_price ;
}
else
{
$wholesale_price = $current_product -> wholesale_price ;
}
$activeSheet -> SetCellValue ( $firstColumn . $i , $values [ 'line' ][ 'product_supplier_reference' ]);
$activeSheet -> getStyle ( $firstColumn . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_TEXT );
$activeSheet -> SetCellValue ( $letter_product_ean . $i , $values [ 'line' ][ 'product_ean13' ]);
$activeSheet -> getStyle ( $letter_product_ean ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_NUMBER );
$activeSheet -> getStyle ( $letter_product_ean . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_NUMBER );
$activeSheet -> getStyle ( $letter_product_ean . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_LEFT );
$activeSheet -> SetCellValue ( $letter_product_ref_interne . $i , $values [ 'line' ][ 'product_reference' ]);
2016-02-09 10:46:07 +01:00
$activeSheet -> SetCellValue ( $letter_product_name . $i , $values [ 'line' ][ 'product_name_base' ]);
2016-01-04 12:49:26 +01:00
if ( $have_declinaison === true )
$activeSheet -> SetCellValue ( $letter_product_attribute_name . $i , $values [ 'line' ][ 'product_attribute_name_base' ]);
$activeSheet -> SetCellValue ( $letter_product_qty . $i , $values [ 'total' ]);
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> setCellValue ( $letter_product_ht . $i , ( float ) $wholesale_price );
$activeSheet -> setCellValue ( $letter_product_total . $i , '=' . $letter_product_qty . $i . '*' . $letter_product_ht . $i );
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_CURRENCY_EUR );
$activeSheet -> getStyle ( $letter_product_total . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_CURRENCY_EUR );
$i ++ ;
}
}
break ;
}
2016-04-04 17:23:15 +02:00
if ( $type = 4 ) {
2016-01-04 12:49:26 +01:00
2016-04-05 16:14:32 +02:00
$activeSheet -> getColumnDimension ( $firstColumn ) -> setWidth ( 10 );
2016-04-04 17:23:15 +02:00
$activeSheet -> getColumnDimension ( $letter_product_ref_interne ) -> setWidth ( 25 );
$activeSheet -> getColumnDimension ( $letter_product_name ) -> setWidth ( 40 );
2016-04-05 16:14:32 +02:00
if ( $have_declinaison === true ) {
2016-04-04 17:23:15 +02:00
$activeSheet -> getColumnDimension ( $letter_product_attribute_name ) -> setWidth ( 20 );
2016-04-05 16:14:32 +02:00
}
2016-04-04 17:23:15 +02:00
$activeSheet -> getColumnDimension ( $letter_product_ht ) -> setWidth ( 13 );
2016-04-05 16:14:32 +02:00
$activeSheet -> getColumnDimension ( $letter_product_M1_M2 ) -> setWidth ( 13 );
$activeSheet -> getColumnDimension ( $letter_product_multi ) -> setWidth ( 13 );
$activeSheet -> getColumnDimension ( $letter_product_colisage ) -> setWidth ( 13 );
$activeSheet -> getColumnDimension ( $letter_product_stock3btk ) -> setWidth ( 13 );
$activeSheet -> getColumnDimension ( $letter_product_missing ) -> setWidth ( 13 );
$activeSheet -> getColumnDimension ( $letter_product_total_qty ) -> setWidth ( 13 );
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$i ++ ;
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$activeSheet -> setCellValue ( $firstColumn . $i , '' );
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
} else {
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$activeSheet -> SetCellValue ( $firstColumn . $i , 'Total' );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_LEFT );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> setBold ( true );
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$activeSheet -> SetCellValue ( $letter_product_qty . $i , '=SUM(' . $letter_product_qty . ( $iOri ) . ':' . $letter_product_qty . ( $i - 1 ) . ')' );
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getFont () -> setBold ( true );
if ( $type == 2 ) {
$activeSheet -> getStyle ( $letter_product_qty . $i ) -> getFill () -> applyFromArray (
array (
'type' => PHPExcel_Style_Fill :: FILL_SOLID ,
'rotation' => 0 ,
'startcolor' => array (
'rgb' => 'D9D9D9'
),
'endcolor' => array (
'argb' => 'D9D9D9D9'
)
)
);
$activeSheet -> SetCellValue ( $letter_product_total_qty . $i , '=SUM(' . $letter_product_total_qty . ( $iOri ) . ':' . $letter_product_total_qty . ( $i - 1 ) . ')' );
$activeSheet -> getStyle ( $letter_product_total_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_total_qty . $i ) -> getFont () -> setBold ( true );
$activeSheet -> SetCellValue ( $letter_product_remaining_qty . $i , '=SUM(' . $letter_product_remaining_qty . ( $iOri ) . ':' . $letter_product_remaining_qty . ( $i - 1 ) . ')' );
$activeSheet -> getStyle ( $letter_product_remaining_qty . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_CENTER );
$activeSheet -> getStyle ( $letter_product_remaining_qty . $i ) -> getFont () -> setBold ( true );
}
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$activeSheet -> getStyle ( $firstColumn . ( $iOri - 1 ) . ':' . $lastColumn . $i ) -> applyFromArray ( $arrayBorder );
$i ++ ;
$activeSheet -> setCellValue ( $letter_product_ht . $i , $lang [ 'Total Amount' ]);
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_RIGHT );
if ( $type == 1 )
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getFont () -> setBold ( true );
$activeSheet -> setCellValue ( $letter_product_total . $i , '=SUM(' . $letter_product_total . ( $iOri ) . ':' . $letter_product_total . ( $i - 2 ) . ')' );
$activeSheet -> getStyle ( $letter_product_total . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_CURRENCY_EUR );
if ( $lang_id != 'en' )
{
$i ++ ;
$activeSheet -> setCellValue ( $letter_product_ht . $i , 'TVA ' . $TVA );
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_RIGHT );
if ( $type == 1 )
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getFont () -> setBold ( true );
$activeSheet -> setCellValue ( $letter_product_total . $i , '=' . $letter_product_total . ( $i - 1 ) . '*' . ( $TVA / 100 ) );
$activeSheet -> getStyle ( $letter_product_total . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_CURRENCY_EUR );
$i ++ ;
$activeSheet -> setCellValue ( $letter_product_ht . $i , 'TOTAL TTC' );
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getAlignment () -> setHorizontal ( PHPExcel_Style_Alignment :: HORIZONTAL_RIGHT );
$activeSheet -> getStyle ( $letter_product_ht . $i ) -> getFont () -> setBold ( true );
$activeSheet -> setCellValue ( $letter_product_total . $i , '=' . $letter_product_total . ( $i - 1 ) . '+' . $letter_product_total . ( $i - 2 ) );
$activeSheet -> getStyle ( $letter_product_total . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_CURRENCY_EUR );
$activeSheet -> getStyle ( $letter_product_total . $i ) -> getFont () -> setBold ( true );
$activeSheet -> getStyle ( $letter_product_ht . ( $i - 3 ) . ':' . $lastColumn . $i ) -> applyFromArray ( $arrayBorder );
}
else
{
$activeSheet -> getStyle ( $letter_product_ht . ( $i - 1 ) . ':' . $lastColumn . $i ) -> applyFromArray ( $arrayBorder );
}
if ( $type == 1 )
{
$value = Configuration :: get ( 'PS_IT_OF_BAS_PAGE_' . $lang_id );
if ( $value != '' )
{
$i ++ ;
$value = str_replace ( '<br />' , ' ' , nl2br ( $value ));
$activeSheet -> setCellValue ( $firstColumn . $i , $value );
$activeSheet -> mergeCells ( $firstColumn . $i . ':' . $lastColumn . $i );
$activeSheet -> getRowDimension ( $i ) -> setRowHeight ( 80 );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_TOP );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_TEXT );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setWrapText ( true );
}
$value = Configuration :: get ( 'PS_IT_OF_BAS_PAGE_BIS_' . $lang_id );
if ( $value != '' )
{
$i ++ ;
$value = str_replace ( '<br />' , ' ' , nl2br ( $value ));
$activeSheet -> setCellValue ( $firstColumn . $i , $value );
$activeSheet -> mergeCells ( $firstColumn . $i . ':' . $lastColumn . $i );
$activeSheet -> getRowDimension ( $i ) -> setRowHeight ( 80 );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setVertical ( PHPExcel_Style_Alignment :: VERTICAL_TOP );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getAlignment () -> setWrapText ( true );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getFont () -> getColor () -> setRGB ( 'FF0000' );
$activeSheet -> getStyle ( $firstColumn . $i ) -> getNumberFormat () -> setFormatCode ( PHPExcel_Style_NumberFormat :: FORMAT_TEXT );
}
}
$activeSheet -> getColumnDimension ( $firstColumn ) -> setWidth ( 25 );
$activeSheet -> getColumnDimension ( $letter_product_ean ) -> setWidth ( 25 );
$activeSheet -> getColumnDimension ( $letter_product_ref_interne ) -> setWidth ( 25 );
$activeSheet -> getColumnDimension ( $letter_product_qty ) -> setWidth ( 18 );
$activeSheet -> getColumnDimension ( $letter_product_name ) -> setWidth ( 40 );
if ( $have_declinaison === true )
$activeSheet -> getColumnDimension ( $letter_product_attribute_name ) -> setWidth ( 20 );
$activeSheet -> getColumnDimension ( $letter_product_qty ) -> setWidth ( 13 );
if ( $type == 2 ) {
$activeSheet -> getColumnDimension ( $letter_product_total_qty ) -> setWidth ( 13 );
$activeSheet -> getColumnDimension ( $letter_product_remaining_qty ) -> setWidth ( 13 );
}
$activeSheet -> getColumnDimension ( $letter_product_ht ) -> setWidth ( 13 );
$activeSheet -> getColumnDimension ( $letter_product_total ) -> setWidth ( 13 );
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$i ++ ;
2016-01-04 12:49:26 +01:00
2016-04-04 17:23:15 +02:00
$activeSheet -> setCellValue ( $firstColumn . $i , '' );
2016-01-04 12:49:26 +01:00
}
header ( 'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
header ( 'Content-Disposition: attachment;filename="' . $title . '.xlsx"' );
$objWriter = new PHPExcel_Writer_Excel2007 ( $objPHPExcel );
if ( $type == 1 &&
Validate :: isLoadedObject ( $OrderForm ))
{
$objWriter -> save ( $OrderForm -> getFile ());
echo file_get_contents ( $OrderForm -> getFile ());
}
else
{
$objWriter -> save ( 'php://output' );
}
exit ;
}