2016-01-04 12:49:26 +01:00
< ? php
2016-05-23 17:35:57 +02:00
include_once ( _PS_ROOT_DIR_ . '/modules/privatesales/Sale.php' );
2016-01-04 12:49:26 +01:00
class AdminStatsLogistic extends AdminTab {
2016-05-26 12:35:37 +02:00
public function __construct () {
$this -> table = 'stats_logistic' ;
$this -> lang = false ;
$this -> date_begin = date ( 'Y-m-d' );
2016-06-06 10:14:02 +02:00
2016-05-26 12:35:37 +02:00
$this -> date_end = date ( 'Y-m-d' );
$this -> date_stock = date ( 'Y-m-d' );
2016-06-06 10:14:02 +02:00
2016-05-26 12:35:37 +02:00
$this -> date_export_begin = date ( 'Y-m-d' );
$this -> date_export_end = date ( 'Y-m-d' );
2016-06-06 10:14:02 +02:00
$this -> date_expe_begin = date ( 'Y-m-d' );
$this -> date_expe_end = date ( 'Y-m-d' );
2016-10-12 18:13:45 +02:00
2016-05-26 12:35:37 +02:00
if ( ! empty ( $_GET [ 'date_begin' ])) {
$this -> date_begin = $_GET [ 'date_begin' ];
}
if ( ! empty ( $_GET [ 'date_end' ])){
$this -> date_end = $_GET [ 'date_end' ];
}
if ( ! empty ( $_GET [ 'date_stock' ])){
$this -> date_stock = $_GET [ 'date_stock' ];
}
parent :: __construct ();
}
public function postProcess ()
{
global $currentIndex , $cookie ;
if ( Tools :: getValue ( 'submitExport' )) {
$this -> date_export_begin = Tools :: getValue ( 'date_export_begin' , $this -> date_export_begin );
$this -> date_export_end = Tools :: getValue ( 'date_export_end' , $this -> date_export_end );
$sale_ids = $this -> getSales ();
if ( $sale_ids ) {
foreach ( $sale_ids as $sale ) {
2016-05-27 11:27:09 +02:00
//$ps = new Sale((int)$sale['id_sale']);
//$product_ids = $ps->getProducts();
$product_ids = $this -> getProducts (( int ) $sale [ 'id_sale' ]);
2017-06-16 14:20:34 +02:00
if ( ! $product_ids ){
continue ;
}
2016-05-26 12:35:37 +02:00
$products = $this -> getSaleDetails ( $product_ids );
2016-05-27 11:27:09 +02:00
/* foreach ( $products as $key => $product ) {
2016-05-27 10:45:22 +02:00
$order_detail_ids [] = ( int ) $product [ 'id_order_detail' ];
}
2016-05-27 11:27:09 +02:00
$packages = $this -> getPackageDetails ( $order_detail_ids ); */
2016-05-27 16:59:18 +02:00
//echo "<pre>";var_dump($product_ids, $products);echo "</pre>";die();
2016-05-26 12:35:37 +02:00
if ( $products ) {
$result [( int ) $sale [ 'id_sale' ]] = array (
2016-05-27 11:27:09 +02:00
/* 'name' => $ps -> title [ 2 ],
'date' => $ps -> date_start , */
2016-10-12 18:13:45 +02:00
'id' => $sale [ 'id_sale' ],
2016-05-27 11:27:09 +02:00
'name' => $sale [ 'title' ],
'date' => $sale [ 'date_start' ],
2016-05-26 12:35:37 +02:00
'ca_ttc' => 0 ,
'ca_refund' => 0 ,
'percent_ca_refund' => 0 ,
'quantity_sold' => 0 ,
'quantity_refund' => 0 ,
'percent_refund' => 0
);
2016-05-27 12:57:32 +02:00
$reasons = array ( 3 , 6 , 8 , 12 , 11 , 1 , 2 , 4 , 5 , 9 , 10 , 7 , 99 );
2016-05-26 12:35:37 +02:00
foreach ( $reasons as $key => $reason_id ) {
$result [( int ) $sale [ 'id_sale' ]][( int ) $reason_id ] = array (
'ca_refund' => 0 ,
'percent_ca_refund' => 0 ,
'quantity_refund' => 0 ,
'percent_refund' => 0 ,
);
}
$id_orders = array ();
$id_orders_error = array ();
$shipping_numbers = array ();
$result [( int ) $sale [ 'id_sale' ]][ 'nb_orders' ] = 0 ;
$result [( int ) $sale [ 'id_sale' ]][ 'nb_orders_error_log' ] = 0 ;
$result [( int ) $sale [ 'id_sale' ]][ 'percent_error_log' ] = 0 ;
$result [( int ) $sale [ 'id_sale' ]][ 'nb_package' ] = 0 ;
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_1' ] = 0 ;
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_2' ] = 0 ;
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_3' ] = 0 ;
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_4' ] = 0 ;
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_5' ] = 0 ;
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_6' ] = 0 ;
2016-05-27 10:45:22 +02:00
2016-05-26 12:35:37 +02:00
foreach ( $products as $row ) {
if ( ! in_array (( int ) $row [ 'id_order' ], $id_orders )) {
$id_orders [] = ( int ) $row [ 'id_order' ];
}
2016-05-27 10:45:22 +02:00
2016-05-27 11:27:09 +02:00
/* foreach ( $packages as $pack ) {
2016-05-27 10:45:22 +02:00
if (( int ) $pack [ 'id_order_detail' ] == ( int ) $row [ 'id_order_detail' ]) {
if ( ! isset ( $shipping_numbers [( int ) $pack [ 'id_employee' ]])) {
$shipping_numbers [( int ) $pack [ 'id_employee' ]] = array ();
}
if ( is_array ( $shipping_numbers [( int ) $pack [ 'id_employee' ]]) && ! in_array ( $pack [ 'shipping_number' ], $shipping_numbers [( int ) $pack [ 'id_employee' ]]) ) {
$shipping_numbers [( int ) $pack [ 'id_employee' ]][] = $pack [ 'shipping_number' ];
}
}
2016-05-27 11:27:09 +02:00
} */
if ( isset ( $row [ 'id_employee' ]) && ! isset ( $shipping_numbers [( int ) $row [ 'id_employee' ]])) {
$shipping_numbers [( int ) $row [ 'id_employee' ]] = array ();
}
if ( isset ( $row [ 'shipping_number' ]) && is_array ( $shipping_numbers [( int ) $row [ 'id_employee' ]]) && ! in_array ( $row [ 'shipping_number' ], $shipping_numbers [( int ) $row [ 'id_employee' ]]) ) {
$shipping_numbers [( int ) $row [ 'id_employee' ]][] = $row [ 'shipping_number' ];
2016-05-26 12:35:37 +02:00
}
2016-05-27 14:58:08 +02:00
/* $price = ( isset ( $row [ 'product_quantity_discount' ]) && $row [ 'product_quantity_discount' ] != 0 ) ? ( float ) $row [ 'product_quantity_discount' ] : ( float ) $row [ 'product_price' ];
2016-05-26 12:35:37 +02:00
$result [( int ) $sale [ 'id_sale' ]][ 'ca_ttc' ] += ((( int ) $row [ 'product_quantity' ] - ( int ) $row [ 'product_quantity_reinjected' ]) * $price );
2016-05-27 14:58:08 +02:00
$result [( int ) $sale [ 'id_sale' ]][ 'quantity_sold' ] += (( int ) $row [ 'product_quantity' ] - ( int ) $row [ 'product_quantity_reinjected' ]); */
$price = ( float ) $row [ 'price' ];
2016-05-27 16:59:18 +02:00
$result [( int ) $sale [ 'id_sale' ]][ 'ca_ttc' ] += (( int ) $row [ 'product_quantity' ] * $price );
$result [( int ) $sale [ 'id_sale' ]][ 'quantity_sold' ] += ( int ) $row [ 'product_quantity' ];
2016-05-26 12:35:37 +02:00
2016-05-27 16:59:18 +02:00
if ( $row [ 'product_quantity_reinjected' ] > 0 ) {
$result [( int ) $sale [ 'id_sale' ]][ 'quantity_refund' ] += ( int ) $row [ 'product_quantity_reinjected' ];
$result [( int ) $sale [ 'id_sale' ]][ 'ca_refund' ] += (( int ) $row [ 'product_quantity_reinjected' ] * $price );
2016-05-26 12:35:37 +02:00
if ( ! isset ( $row [ 'id_reason' ])) {
$row [ 'id_reason' ] = 99 ;
}
if (( int ) $row [ 'id_reason' ] == 6 && ! in_array (( int ) $row [ 'id_order' ], $id_orders_error )) {
$id_orders_error [] = ( int ) $row [ 'id_order' ];
}
2016-05-27 12:42:09 +02:00
if ( in_array (( int ) $row [ 'id_reason' ], $reasons )) {
if ( ! isset ( $result [( int ) $sale [ 'id_sale' ]][( int ) $row [ 'id_reason' ]])) {
$result [( int ) $sale [ 'id_sale' ]][( int ) $row [ 'id_reason' ]] = array (
'ca_refund' => 0 ,
'percent_ca_refund' => 0 ,
'quantity_refund' => 0 ,
'percent_refund' => 0 ,
);
}
2016-05-26 12:35:37 +02:00
2016-05-27 16:59:18 +02:00
$result [( int ) $sale [ 'id_sale' ]][( int ) $row [ 'id_reason' ]][ 'ca_refund' ] += round ((( int ) $row [ 'product_quantity_reinjected' ] * $price ), 2 );
$result [( int ) $sale [ 'id_sale' ]][( int ) $row [ 'id_reason' ]][ 'quantity_refund' ] += round (( int ) $row [ 'product_quantity_reinjected' ], 2 );
2016-05-27 12:42:09 +02:00
}
2016-05-26 12:35:37 +02:00
}
}
2016-05-27 11:27:09 +02:00
$result [( int ) $sale [ 'id_sale' ]][ 'percent_ca_refund' ] = number_format (( $result [( int ) $sale [ 'id_sale' ]][ 'ca_refund' ] / $result [( int ) $sale [ 'id_sale' ]][ 'ca_ttc' ]) * 100 , 2 );
$result [( int ) $sale [ 'id_sale' ]][ 'percent_refund' ] = number_format (( $result [( int ) $sale [ 'id_sale' ]][ 'quantity_refund' ] / $result [( int ) $sale [ 'id_sale' ]][ 'quantity_sold' ]) * 100 , 2 );
2016-05-26 12:35:37 +02:00
foreach ( $reasons as $key => $reason_id ) {
if ( isset ( $result [( int ) $sale [ 'id_sale' ]][ $reason_id ])) {
2016-05-27 11:27:09 +02:00
$result [( int ) $sale [ 'id_sale' ]][ $reason_id ][ 'percent_ca_refund' ] += round (( $result [( int ) $sale [ 'id_sale' ]][ $reason_id ][ 'ca_refund' ] / $result [( int ) $sale [ 'id_sale' ]][ 'ca_ttc' ]) * 100 , 2 );
$result [( int ) $sale [ 'id_sale' ]][ $reason_id ][ 'percent_refund' ] += round (( $result [( int ) $sale [ 'id_sale' ]][ $reason_id ][ 'quantity_refund' ] / $result [( int ) $sale [ 'id_sale' ]][ 'quantity_sold' ]) * 100 , 2 );
2016-05-26 12:35:37 +02:00
}
}
2016-05-27 11:27:09 +02:00
$result [( int ) $sale [ 'id_sale' ]][ 'ca_ttc' ] = round ( $result [( int ) $sale [ 'id_sale' ]][ 'ca_ttc' ], 2 );
2016-05-27 12:57:32 +02:00
$result [( int ) $sale [ 'id_sale' ]][ 'ca_refund' ] = round ( $result [( int ) $sale [ 'id_sale' ]][ 'ca_refund' ], 2 );
2016-05-26 12:35:37 +02:00
$result [( int ) $sale [ 'id_sale' ]][ 'nb_orders' ] = count ( $id_orders );
$result [( int ) $sale [ 'id_sale' ]][ 'nb_orders_error_log' ] = count ( $id_orders_error );
2016-05-27 11:27:09 +02:00
$result [( int ) $sale [ 'id_sale' ]][ 'percent_error_log' ] = number_format (( $result [( int ) $sale [ 'id_sale' ]][ 'nb_orders_error_log' ] / $result [( int ) $sale [ 'id_sale' ]][ 'nb_orders' ]) * 100 , 2 );
2016-05-26 12:35:37 +02:00
$nb_package = 0 ;
foreach ( $shipping_numbers as $id_employee => $value ) {
$nb_package += count ( $value );
switch ( $id_employee ) {
case '52' :
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_1' ] += count ( $value );
break ;
case '22' :
case '24' :
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_2' ] += count ( $value );
break ;
case '25' :
case '44' :
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_3' ] += count ( $value );
break ;
case '47' :
case '48' :
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_4' ] += count ( $value );
break ;
case '35' :
case '36' :
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_5' ] += count ( $value );
break ;
case '28' :
default :
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_6' ] += count ( $value );
break ;
}
}
$result [( int ) $sale [ 'id_sale' ]][ 'nb_package' ] = $nb_package ;
2016-05-27 11:27:09 +02:00
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_1' ] = number_format (( $result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_1' ] / $nb_package ) * 100 , 2 );
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_2' ] = number_format (( $result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_2' ] / $nb_package ) * 100 , 2 );
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_3' ] = number_format (( $result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_3' ] / $nb_package ) * 100 , 2 );
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_4' ] = number_format (( $result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_4' ] / $nb_package ) * 100 , 2 );
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_5' ] = number_format (( $result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_5' ] / $nb_package ) * 100 , 2 );
$result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_6' ] = number_format (( $result [( int ) $sale [ 'id_sale' ]][ 'nb_pole_6' ] / $nb_package ) * 100 , 2 );
2016-05-26 12:35:37 +02:00
}
}
if ( $result ) {
$fname = 'export-remb-' . $this -> date_export_begin . '-' . $this -> date_export_end . '.csv' ;
foreach ( glob ( dirname ( __FILE__ ) . '/*.csv' ) as $filename ) {
if ( $fname == $filename ) {
unlink ( $filename );
}
}
$this -> exportCSV ( $result , $fname );
echo '<p class="conf">' . $this -> l ( 'Export complete.' ) . ' <a onclick="window.open(this.href); return false;" href="http://' . $_SERVER [ 'HTTP_HOST' ] . __PS_BASE_URI__ . 'modules/stats_logistic/' . $fname . '">' . $this -> l ( 'Click here to download the file' ) . '</a></p>' ;
2016-05-27 11:27:09 +02:00
} else {
echo '<p class="conf">' . $this -> l ( 'No result for these dates.' ) . '</p>' ;
2016-05-26 12:35:37 +02:00
}
} else {
2016-05-27 11:27:09 +02:00
echo '<p class="conf">' . $this -> l ( 'No sale found.' ) . '</p>' ;
2016-05-26 12:35:37 +02:00
}
2017-06-16 14:20:34 +02:00
} elseif ( Tools :: isSubmit ( 'submitExportExpLP' ) || Tools :: isSubmit ( 'submitExportExpMR' ) || Tools :: isSubmit ( 'submitExportExpPH' )) {
2016-06-06 10:14:02 +02:00
$this -> date_expe_begin = Tools :: getValue ( 'date_expe_begin' , $this -> date_expe_begin );
$this -> date_expe_end = Tools :: getValue ( 'date_expe_end' , $this -> date_expe_end );
2017-06-16 14:20:34 +02:00
if ( Tools :: isSubmit ( 'submitExportExpLP' )) {
$details = $this -> getShippingDetails ();
} elseif ( Tools :: isSubmit ( 'submitExportExpMR' )) {
$details = $this -> getShippingMRDetails ();
} elseif ( Tools :: isSubmit ( 'submitExportExpPH' )) {
$details = $this -> getShippingPhileaDetails ();
}
2016-06-06 10:14:02 +02:00
if ( $details ) {
foreach ( $details as $key => & $row ) {
$sale_info = $this -> getSaleInfo (( int ) $row [ 'id_sale' ]);
$row [ 'sale_title' ] = $sale_info [ 'title' ];
}
$fname = 'export-expe-' . $this -> date_expe_begin . '-' . $this -> date_expe_end . '.csv' ;
foreach ( glob ( dirname ( __FILE__ ) . '/*.csv' ) as $filename ) {
if ( $fname == $filename ) {
unlink ( $filename );
}
}
$this -> exportExpeCSV ( $details , $fname );
echo '<p class="conf">' . $this -> l ( 'Export complete.' ) . ' <a onclick="window.open(this.href); return false;" href="http://' . $_SERVER [ 'HTTP_HOST' ] . __PS_BASE_URI__ . 'modules/stats_logistic/' . $fname . '">' . $this -> l ( 'Click here to download the file' ) . '</a></p>' ;
} else {
echo '<p class="conf">' . $this -> l ( 'No result for these dates.' ) . '</p>' ;
}
2016-05-26 12:35:37 +02:00
}
}
2016-10-12 18:13:45 +02:00
2016-05-26 12:35:37 +02:00
public function display () {
global $currentIndex , $cookie ;
$date = Configuration :: get ( 'MAJ_STAT_LOGISTIC' );
echo '
< style type = " text/css " >
. ui - datepicker . ui - datepicker - prev span , . ui - datepicker . ui - datepicker - next span {
font - size : 0 px ;
}
#ui-timepicker-div-day {
display : none ;
}
#date_begin, #date_end, #date_stock {
width : 115 px ;
text - align : right ;
padding : 2 px ;
}
label {
float : none ;
display : inline - block ;
margin - right : 5 px ;
}
. button {
margin - left : 10 px ;
cursor : pointer ;
}
fieldset label {
width : 160 px ;
}
span . date {
margin - left : 30 px ;
}
</ style >
< script type = " text/javascript " src = " '.__PS_BASE_URI__.'modules/privatesales_livestats/jquery-ui-1.8.20.custom.min.js " ></ script >
< script type = " text/javascript " src = " '.__PS_BASE_URI__.'modules/privatesales/jquery-ui-timepicker-addon.js " ></ script >
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( " input[name=date_end], input[name=date_begin] " ) . datepicker ({
showTime : false ,
dateFormat : " yy-mm-dd " ,
formattedDate : " yy-mm-dd " ,
maxDate : new Date ,
minDate : new Date ( 2014 , 1 , 1 )
});
$ ( " input[name=date_stock] " ) . datepicker ({
showTime : false ,
dateFormat : " yy-mm-dd " ,
formattedDate : " yy-mm-dd " ,
maxDate : null ,
minDate : new Date ( 2014 , 1 , 1 )
});
});
</ script >
< script type = " text/javascript " src = " '.__PS_BASE_URI__.'modules/privatesales_livestats/jquery-ui-fr.js " ></ script > ' ;
2016-10-12 18:13:45 +02:00
echo
2016-05-26 12:35:37 +02:00
' < fieldset >
< form method = " GET " action = " '. $currentIndex .' " > '
. '<span class="form-group">'
. '<label style="float: none;" class="control-label" for="date_begin">Date de début :</label>'
. '<input type="date" name="date_begin" value="' . pSQl ( $this -> date_begin ) . '" id="date_begin" class="form-control" />'
. '</span>'
. '<span class="form-group">'
. '<label style="float: none;" class="control-label" for="date_end">Date de fin :</label>'
. '<input type="date" name="date_end" value="' . pSQl ( $this -> date_end ) . '" id="date_end" class="form-control" />'
. '</span>'
. '<input type="hidden" name="token" value="' . Tools :: getAdminTokenLite ( __CLASS__ ) . '" />'
. '<input type="hidden" name="tab" value="' . __CLASS__ . '" />'
. ' < button type = " submit " class = " button " > Filtrer </ button >
< span class = " date " > Dernière mise à jour : < b > '.$date.' </ b ></ span > '
. ' </ form >
</ fieldset > '
;
$stats = $this -> getStats ();
$poles = array ();
2017-06-16 14:52:50 +02:00
for ( $i = 0 ; $i < 6 ; $i ++ ) {
2016-05-26 12:35:37 +02:00
$poles [] = array (
'recap' => array (
'quantity' => 0 ,
'nb_package' => 0
),
'employee' => array (),
);
}
$poles [ 0 ][ 'name' ] = 'Pôle 1 : Petites marques' ;
$poles [ 1 ][ 'name' ] = 'Pôle 2 : Marques moyenne' ;
$poles [ 2 ][ 'name' ] = 'Pôle 3 : Grosses marques' ;
$poles [ 3 ][ 'name' ] = 'Pôle 4 : Postes complementaires' ;
$poles [ 4 ][ 'name' ] = 'Pôle 5 : Multi' ;
$poles [ 5 ][ 'name' ] = 'Pôle 6 : Autre' ;
2016-06-06 10:24:06 +02:00
$total_quantity = 0 ;
2016-05-26 12:35:37 +02:00
foreach ( $stats as $key => $stat ) {
if ( ! isset ( $stat [ 'id_employee' ])) {
continue ;
}
2017-06-16 14:20:34 +02:00
switch (( int ) $stat [ 'id_employee' ]) {
2016-05-26 12:35:37 +02:00
case '52' :
$poles [ 0 ][ 'recap' ][ 'quantity' ] += $stat [ 'quantity' ];
$poles [ 0 ][ 'recap' ][ 'nb_package' ] += $stat [ 'nb_package' ];
$poles [ 0 ][ 'employee' ][] = $stat ;
break ;
case '22' :
case '24' :
$poles [ 1 ][ 'recap' ][ 'quantity' ] += $stat [ 'quantity' ];
$poles [ 1 ][ 'recap' ][ 'nb_package' ] += $stat [ 'nb_package' ];
$poles [ 1 ][ 'employee' ][] = $stat ;
break ;
case '25' :
case '44' :
$poles [ 2 ][ 'recap' ][ 'quantity' ] += $stat [ 'quantity' ];
$poles [ 2 ][ 'recap' ][ 'nb_package' ] += $stat [ 'nb_package' ];
$poles [ 2 ][ 'employee' ][] = $stat ;
break ;
case '47' :
case '48' :
$poles [ 3 ][ 'recap' ][ 'quantity' ] += $stat [ 'quantity' ];
$poles [ 3 ][ 'recap' ][ 'nb_package' ] += $stat [ 'nb_package' ];
$poles [ 3 ][ 'employee' ][] = $stat ;
break ;
case '35' :
case '36' :
$poles [ 4 ][ 'recap' ][ 'quantity' ] += $stat [ 'quantity' ];
$poles [ 4 ][ 'recap' ][ 'nb_package' ] += $stat [ 'nb_package' ];
$poles [ 4 ][ 'employee' ][] = $stat ;
break ;
case '28' :
default :
$poles [ 5 ][ 'recap' ][ 'quantity' ] += $stat [ 'quantity' ];
$poles [ 5 ][ 'recap' ][ 'nb_package' ] += $stat [ 'nb_package' ];
$poles [ 5 ][ 'employee' ][] = $stat ;
break ;
}
$total_quantity += $stat [ 'quantity' ];
}
$total_colis = $this -> getTotalColis ();
2016-10-12 18:13:45 +02:00
2016-05-26 12:35:37 +02:00
echo '
< h2 style = " margin-top:15px " > Stats de la logistique </ h2 >
< table class = " table " style = " width:100%; margin-top:15px " >
< thead >
< tr >
< th > Id Employee </ th >
< th > Prénom </ th >
< th > Nom </ th >
< th > Email </ th >
< th > Quantité </ th >
< th > Nombre de colis </ th >
< th >% total </ th >
</ tr >
</ thead >
< tbody > ' ;
foreach ( $poles as $k => $pole ) {
echo ' < tr style = " background:#99cef7; " >
< td colspan = " 4 " style = " color:#fff; " > '.$pole[' name '].' </ td >
< td style = " color:#fff; " > '.$pole[' recap '][' quantity '].' </ td >
< td style = " color:#fff; " > '.$pole[' recap '][' nb_package '].' </ td >
< td style = " color:#fff; " > '. number_format(($pole[' recap '][' nb_package ']* 100 / $total_colis), 2) .' %</ td >
</ tr > ' ;
foreach ( $pole [ 'employee' ] as $key => $stat ) {
echo ' < tr >
2017-06-16 14:52:50 +02:00
< td > '.$stat[' id_employee '].' </ td >
2017-06-16 14:20:34 +02:00
< td > '.(isset($stat[' firstname '])?$stat[' firstname ']:"").' </ td >
< td > '.(isset($stat[' lastname '])?$stat[' lastname ']:"").' </ td >
< td > '.(isset($stat[' email '])?$stat[' email ']:"").' </ td >
2016-05-26 12:35:37 +02:00
< td > '.$stat[' quantity '].' </ td >
< td > '.$stat[' nb_package '].' </ td >
< td > '. number_format(($stat[' nb_package ']* 100 / $total_colis), 2) .' %</ td >
</ tr > ' ;
}
}
echo ' < tbody >
< tfoot style = " font-weight:bold " >
< tr >
< td colspan = " 4 " > Total :</ td >
< td style = " background:#f1f1f1; " > '.$total_quantity.' </ td >
< td style = " background:#f1f1f1; " > '.$total_colis.' </ td >
< td style = " background:#f1f1f1; " > 100 %</ td >
</ tr >
</ tfoot >
</ table > ' ;
$reports = array (
'25' => array (
'name' => 'Nb commandes > 25j' ,
'payment' => $this -> getReport ( 25 , 2 ),
2016-07-05 15:11:33 +02:00
'partial' => $this -> getReport ( 25 , 17 ),
'pending' => $this -> getReport ( 25 , 19 )
2016-05-26 12:35:37 +02:00
),
'21' => array (
'name' => 'Nb commandes > 21j' ,
'payment' => $this -> getReport ( 21 , 2 ),
2016-07-05 15:11:33 +02:00
'partial' => $this -> getReport ( 21 , 17 ),
'pending' => $this -> getReport ( 21 , 19 )
2016-05-26 12:35:37 +02:00
),
'18' => array (
'name' => 'Nb commandes > 18j' ,
'payment' => $this -> getReport ( 18 , 2 ),
2016-07-05 15:11:33 +02:00
'partial' => $this -> getReport ( 18 , 17 ),
'pending' => $this -> getReport ( 18 , 19 )
2016-05-26 12:35:37 +02:00
),
'2' => array (
'name' => 'Nb commandes > 2j' ,
'payment' => $this -> getReport ( 2 , 2 ),
2016-07-05 15:11:33 +02:00
'partial' => $this -> getReport ( 2 , 17 ),
'pending' => $this -> getReport ( 2 , 19 )
2016-05-26 12:35:37 +02:00
)
);
echo ' < br >< br >< h2 style = " margin-top:15px " > Report Stock </ h2 >
< fieldset >
< form method = " GET " action = " '. $currentIndex .' " > '
. '<span class="form-group">'
. '<label style="float: none;" class="control-label" for="date_stock">Date :</label>'
. '<input type="date" name="date_stock" value="' . pSQl ( $this -> date_stock ) . '" id="date_stock" class="form-control" />'
. '<input type="hidden" name="date_begin" value="' . pSQl ( $this -> date_begin ) . '" class="form-control" />'
. '<input type="hidden" name="date_end" value="' . pSQl ( $this -> date_end ) . '" class="form-control" />'
. '</span>'
. '<input type="hidden" name="token" value="' . Tools :: getAdminTokenLite ( __CLASS__ ) . '" />'
. '<input type="hidden" name="tab" value="' . __CLASS__ . '" />'
. '<button type="submit" class="button">Filtrer</button>'
. ' </ form >
</ fieldset > '
;
echo ' < table class = " table " style = " width:100%; margin-top:15px " >
< thead >
< tr >
< th colspan = " 2 " ></ th >
< th > Paiement accepté </ th >
< th > Commande partiellement expédiée </ th >
2016-07-05 15:11:33 +02:00
< th > Commande en attente </ th >
2016-05-26 12:35:37 +02:00
</ tr >
</ thead >
< tbody > ' ;
foreach ( $reports as $k => $report ) {
echo ' < tr " >
< td > '.$report[' name '].' </ td >
< td > '.date(' Y - m - d ', strtotime($this->date_stock. ' - '.$k.' days ')).' </ td >
< td > '.$report[' payment '].' </ td >
< td > '.$report[' partial '].' </ td >
2016-07-05 15:11:33 +02:00
< td > '.$report[' pending '].' </ td >
2016-05-26 12:35:37 +02:00
</ tr > ' ;
}
echo ' < tbody >
</ table > ' ;
2016-06-06 10:14:02 +02:00
echo ' < br >< br >< h2 style = " margin-top:15px " > Export Remboursements </ h2 >
< fieldset >
< p > Exporter le détail des ventes dont la date de début est comprise entre : </ p >
< form method = " POST " action = " '. $currentIndex .' " > '
. '<span class="form-group">'
. '<label style="float: none;" class="control-label" for="date_export_begin">Date de début :</label>'
. '<input type="date" name="date_export_begin" value="' . pSQl ( $this -> date_export_begin ) . '" id="date_export_begin" class="form-control" />'
. '</span>'
. '<span class="form-group">'
. '<label style="float: none;" class="control-label" for="date_export_end">Date de fin :</label>'
. '<input type="date" name="date_export_end" value="' . pSQl ( $this -> date_export_end ) . '" id="date_export_end" class="form-control" />'
. '</span>'
. '<input type="hidden" name="token" value="' . Tools :: getAdminTokenLite ( __CLASS__ ) . '" />'
. '<input type="hidden" name="tab" value="' . __CLASS__ . '" />'
. '<input type="submit" class="button" name="submitExport" value="Exporter les Remboursements" />'
. ' </ form >
</ fieldset > ' ;
2017-06-16 14:20:34 +02:00
echo ' < br >< br >< h2 style = " margin-top:15px " > Export Expeditions </ h2 >
2016-06-07 11:22:35 +02:00
< fieldset >
< p > Exporter le détail des expeditions dont la date est comprise entre : </ p >
< form method = " POST " action = " '. $currentIndex .' " > '
. '<span class="form-group">'
. '<label style="float: none;" class="control-label" for="date_export_begin">Date de début :</label>'
. '<input type="date" name="date_expe_begin" value="' . pSQl ( $this -> date_expe_begin ) . '" id="date_expe_begin" class="form-control" />'
. '</span>'
. '<span class="form-group">'
. '<label style="float: none;" class="control-label" for="date_export_end">Date de fin :</label>'
. '<input type="date" name="date_expe_end" value="' . pSQl ( $this -> date_expe_end ) . '" id="date_expe_end" class="form-control" />'
. '</span>'
. '<input type="hidden" name="token" value="' . Tools :: getAdminTokenLite ( __CLASS__ ) . '" />'
. '<input type="hidden" name="tab" value="' . __CLASS__ . '" />'
2017-06-16 14:20:34 +02:00
. '<input type="submit" class="button" name="submitExportExpLP" value="Expé La Poste" />'
. '<input type="submit" class="button" name="submitExportExpMR" value="Expé Mondial Relay" />'
2016-06-07 11:22:35 +02:00
. ' </ form >
</ fieldset > '
;
2016-05-26 12:35:37 +02:00
}
public function getStats () {
2017-06-16 14:52:50 +02:00
return Db :: getInstance () -> executeS ( '
2016-05-26 12:35:37 +02:00
SELECT
2016-10-12 18:13:45 +02:00
e . `id_employee` ,
e . `email` ,
e . `lastname` ,
2016-05-26 12:35:37 +02:00
e . `firstname` ,
SUM ( s . `nb_product` ) AS `nb_product` ,
SUM ( s . `quantity` ) AS `quantity` ,
2016-10-12 18:13:45 +02:00
SUM ( s . `nb_package` ) AS `nb_package`
2016-05-26 12:35:37 +02:00
FROM `'._DB_PREFIX_.'stats_logistic` s
2016-10-12 18:13:45 +02:00
LEFT JOIN `'._DB_PREFIX_.'employee` e USING ( `id_employee` )
WHERE s . `date` BETWEEN " '.pSQL( $this->date_begin ).' " AND " '.pSQL( $this->date_end ).' "
2017-06-16 14:20:34 +02:00
AND e . `id_employee` IS NOT NULL
2016-05-26 12:35:37 +02:00
GROUP BY s . `id_employee`
' );
}
public function getTotalColis () {
return Db :: getInstance () -> getValue ( '
SELECT
2016-10-12 18:13:45 +02:00
SUM ( s . `nb_package` ) AS `nb_package`
2016-05-26 12:35:37 +02:00
FROM `'._DB_PREFIX_.'stats_logistic` s
WHERE s . `date` BETWEEN " '.pSQL( $this->date_begin ).' " AND " '.pSQL( $this->date_end ).' "
' );
}
public function getReport ( $day = 25 , $state = 2 ) {
return Db :: getInstance () -> getValue ( '
SELECT COUNT ( o . `id_order` )
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON ( oh . `id_order` = o . `id_order` )
2016-10-12 18:13:45 +02:00
WHERE o . `date_add` < DATE_SUB ( " '.pSQL( $this->date_stock ).' " , INTERVAL '.((int)$day-1).' DAY )
AND oh . `id_order_state` = '.(int)$state.'
2016-05-26 12:35:37 +02:00
AND oh . `id_order_history` = ( SELECT MAX ( `id_order_history` ) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh . `id_order` = o . `id_order` GROUP BY moh . `id_order` )
2016-10-12 18:13:45 +02:00
-- AND
2016-05-26 12:35:37 +02:00
-- (
2016-10-12 18:13:45 +02:00
-- SELECT `id_order_state`
2016-05-23 17:51:11 +02:00
-- FROM '._DB_PREFIX_.' order_history oh
-- WHERE o . id_order = oh . id_order
2016-10-12 18:13:45 +02:00
-- ORDER BY id_order_history DESC
2016-05-23 17:51:11 +02:00
-- LIMIT 1
-- ) = '.(int)$state.'
2016-05-26 12:35:37 +02:00
' );
}
public function getSaleDetails ( $product_ids ) {
2017-06-16 14:20:34 +02:00
$sale_details = array ();
$sale_details_lpw = Db :: getInstance () -> ExecuteS ( '
2016-10-12 18:13:45 +02:00
SELECT od .* , rr . `id_reason` , pws . `id_employee` , pws . `shipping_number` ,
2016-05-27 16:59:18 +02:00
ROUND ((( od . `product_price` * ( 1 - od . `reduction_percent` / 100 ) - od . `reduction_amount` ) * ( 1 - od . `group_reduction` / 100 ) * ( 1 + od . `tax_rate` / 100 )), 6 ) AS `price`
2016-10-12 18:13:45 +02:00
FROM `'._DB_PREFIX_.'order_detail` od
2016-05-27 10:45:22 +02:00
LEFT JOIN `'._DB_PREFIX_.'order_slip` os ON ( os . `id_order` = od . `id_order` )
2016-05-27 11:27:09 +02:00
LEFT JOIN `'._DB_PREFIX_.'lapostews` pws ON ( pws . `id_order_detail` = od . `id_order_detail` )
2016-05-27 10:45:22 +02:00
LEFT JOIN `'._DB_PREFIX_.'refundreason` rr ON ( rr . `id_order_slip` = os . `id_order_slip` )
2016-10-12 18:13:45 +02:00
WHERE od . `product_id` IN ( '.implode(' , ', $product_ids).' )
2017-06-16 14:20:34 +02:00
AND pws . id_order_detail IS NOT NULL
ORDER BY rr . `id_reason` ' );
$sale_details_mr = Db :: getInstance () -> ExecuteS ( '
SELECT od .* , rr . `id_reason` , mrp . `id_employee` , mrp . `shipping_number` ,
ROUND ((( od . `product_price` * ( 1 - od . `reduction_percent` / 100 ) - od . `reduction_amount` ) * ( 1 - od . `group_reduction` / 100 ) * ( 1 + od . `tax_rate` / 100 )), 6 ) AS `price`
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'order_slip` os ON ( os . `id_order` = od . `id_order` )
LEFT JOIN `'._DB_PREFIX_.'mondialrelay_parcel` mrp ON ( mrp . `id_order_detail` = od . `id_order_detail` )
LEFT JOIN `'._DB_PREFIX_.'refundreason` rr ON ( rr . `id_order_slip` = os . `id_order_slip` )
WHERE od . `product_id` IN ( '.implode(' , ', $product_ids).' )
AND mrp . id_order_detail IS NOT NULL
2016-05-27 10:45:22 +02:00
ORDER BY rr . `id_reason`
2016-05-26 12:35:37 +02:00
' );
2017-06-16 14:52:50 +02:00
$sale_details = array_merge ( $sale_details_lpw , $sale_details_mr );
2017-06-16 14:20:34 +02:00
return $sale_details ;
2016-05-26 12:35:37 +02:00
}
2017-06-16 14:20:34 +02:00
public function getPackageDetails ( $order_detail_ids ) {
2016-05-27 10:45:22 +02:00
return Db :: getInstance () -> ExecuteS ( '
SELECT pws . `id_order_detail` , pws . `id_employee` , pws . `shipping_number`
FROM `'._DB_PREFIX_.'lapostews` pws
WHERE pws . `id_order_detail` IN ( '.implode(' , ', $order_detail_ids).' )
' );
2017-06-16 14:20:34 +02:00
}
2016-05-27 10:45:22 +02:00
2017-06-16 14:20:34 +02:00
public function getShippingDetails () {
2016-06-06 10:14:02 +02:00
return Db :: getInstance () -> ExecuteS ( '
2016-10-12 18:13:45 +02:00
SELECT pws . `id_order_detail` , pws . `shipping_number` , pws . `date_add` , pws . `quantity` , e . `email` AS `poste` , od . `id_order` , od . `product_id` , od . `product_attribute_id` , od . `product_name` , psc . `id_sale` , od . `product_quantity` ,
2016-06-06 10:14:02 +02:00
ROUND ((( od . `product_price` * ( 1 - od . `reduction_percent` / 100 ) - od . `reduction_amount` ) * ( 1 - od . `group_reduction` / 100 ) * ( 1 + od . `tax_rate` / 100 )), 6 ) AS `price`
FROM `'._DB_PREFIX_.'lapostews` pws
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON ( od . `id_order_detail` = pws . `id_order_detail` )
2016-06-06 15:32:42 +02:00
LEFT JOIN `'._DB_PREFIX_.'employee` e ON ( e . `id_employee` = pws . `id_employee` )
2016-06-06 10:14:02 +02:00
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` psc ON ( psc . `id_product` = od . `product_id` )
2016-10-12 18:13:45 +02:00
WHERE pws . `date_add` BETWEEN " '.pSQL( $this->date_expe_begin ).' " AND " '.pSQL( $this->date_expe_end ).' "
2016-06-06 15:32:42 +02:00
ORDER BY pws . `date_add` ASC
2016-06-06 10:14:02 +02:00
' );
2017-06-16 14:20:34 +02:00
}
public function getShippingMRDetails () {
return Db :: getInstance () -> ExecuteS ( '
SELECT pmr . `id_order_detail` , pmr . `shipping_number` , pmr . `date_add` , pmr . `quantity` , e . `email` AS `poste` , od . `id_order` , od . `product_id` , od . `product_attribute_id` , od . `product_name` , psc . `id_sale` , od . `product_quantity` ,
ROUND ((( od . `product_price` * ( 1 - od . `reduction_percent` / 100 ) - od . `reduction_amount` ) * ( 1 - od . `group_reduction` / 100 ) * ( 1 + od . `tax_rate` / 100 )), 6 ) AS `price`
FROM `'._DB_PREFIX_.'mondialrelay_parcel` pmr
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON ( od . `id_order_detail` = pmr . `id_order_detail` )
LEFT JOIN `'._DB_PREFIX_.'employee` e ON ( e . `id_employee` = pmr . `id_employee` )
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` psc ON ( psc . `id_product` = od . `product_id` )
WHERE pmr . `date_add` BETWEEN " '.pSQL( $this->date_expe_begin ).' " AND " '.pSQL( $this->date_expe_end ).' "
ORDER BY pmr . `date_add` ASC
' );
}
public function getShippingPhileaDetails () {
return Db :: getInstance () -> ExecuteS ( '
SELECT pph . `id_order_detail` , pph . `shipping_number` , pph . `date_add` , pph . `quantity` , " Philéa " AS `poste` , od . `id_order` , od . `product_id` , od . `product_attribute_id` , od . `product_name` , psc . `id_sale` , od . `product_quantity` ,
ROUND ((( od . `product_price` * ( 1 - od . `reduction_percent` / 100 ) - od . `reduction_amount` ) * ( 1 - od . `group_reduction` / 100 ) * ( 1 + od . `tax_rate` / 100 )), 6 ) AS `price`
FROM `'._DB_PREFIX_.'philea_parcel` pph
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON ( od . `id_order_detail` = pph . `id_order_detail` )
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` psc ON ( psc . `id_product` = od . `product_id` )
WHERE pph . `date_add` BETWEEN " '.pSQL( $this->date_expe_begin ).' " AND " '.pSQL( $this->date_expe_end ).' "
ORDER BY pph . `date_add` ASC
' );
}
2016-06-06 10:14:02 +02:00
2016-05-26 12:35:37 +02:00
public function getSales () {
return Db :: getInstance () -> ExecuteS ( '
2016-05-27 11:27:09 +02:00
SELECT p . `id_sale` , p . `date_start` , l . `name` as title
FROM `'._DB_PREFIX_.'privatesale` p
LEFT JOIN `ps_privatesale_category` c ON ( c . `id_sale` = p . `id_sale` )
LEFT JOIN `ps_category_lang` l ON ( l . `id_category` = p . `id_category` )
2016-10-12 18:13:45 +02:00
WHERE p . `date_start` BETWEEN " '.pSQL( $this->date_export_begin ).' " AND " '.pSQL( $this->date_export_end ).' "
2016-05-27 11:27:09 +02:00
AND l . `id_lang` = '. (int) Context::getContext()->language->id.'
2016-05-26 12:35:37 +02:00
' );
}
2016-06-06 10:14:02 +02:00
public function getSaleInfo ( $id_sale ) {
return Db :: getInstance () -> getRow ( '
SELECT p . `date_start` , l . `name` as title
FROM `'._DB_PREFIX_.'privatesale` p
LEFT JOIN `ps_privatesale_category` c ON ( c . `id_sale` = p . `id_sale` )
LEFT JOIN `ps_category_lang` l ON ( l . `id_category` = p . `id_category` )
WHERE p . `id_sale` = '.(int)$id_sale.'
AND l . `id_lang` = '. (int) Context::getContext()->language->id.'
' );
}
2016-05-26 12:35:37 +02:00
public function getProducts ( $id_sale ) {
2016-05-27 11:27:09 +02:00
$product_ids = array ();
foreach ( Db :: getInstance () -> ExecuteS ( '
SELECT DISTINCT `id_product`
2016-10-12 18:13:45 +02:00
FROM `'._DB_PREFIX_.'product_ps_cache`
2016-05-26 12:35:37 +02:00
WHERE `id_sale` = '.(int)$id_sale.'
2016-05-27 11:27:09 +02:00
' ) as $row ) {
$product_ids [] = ( int ) $row [ 'id_product' ];
}
return $product_ids ;
2016-05-26 12:35:37 +02:00
}
2016-06-06 10:14:02 +02:00
public function exportExpeCSV ( $items , $filename ) {
$fp = fopen ( dirname ( __FILE__ ) . '/' . $filename , 'w' );
$delim = ';' ;
$row_definition = array (
'shipping_number' => 'N. de suivi' ,
'date_add' => 'date d\'expe' ,
'poste' => 'Poste d\'expe' ,
'id_order' => 'id_order' ,
'id_sale' => 'id_sale' ,
'sale_title' => 'sale_title' ,
'product_id' => 'id_product' ,
'product_name' => 'product_name' ,
'price' => 'product_price' ,
'product_quantity' => 'Quantite envoyee' ,
);
$data = array ();
foreach ( $row_definition as $col ) {
$data [] = $col ;
}
fputcsv ( $fp , $data , $delim );
foreach ( $items as $item ) {
$data = array ();
foreach ( $row_definition as $key => $col ) {
$data [] = ( isset ( $item [ $key ]) ? $item [ $key ] : '' );
}
fputcsv ( $fp , array_map ( 'utf8_decode' , array_values ( $data )), $delim );
}
fclose ( $fp );
}
2016-05-26 12:35:37 +02:00
public function exportCSV ( $result , $filename ) {
//$fp = fopen("php://output", 'w');
$fp = fopen ( dirname ( __FILE__ ) . '/' . $filename , 'w' );
$delim = ';' ;
2016-10-12 18:18:21 +02:00
$row_1 = array ( " " , " " , " " , " " , " " , " " , " " , " " , " " );
2016-10-12 18:13:45 +02:00
$row_2 = array ( " Vente " , " Marque " , " Date de Debut " , " CA produit TTC " , " CA remb TTC " , " % remb valeur " , " Quantite vendue " , " Quantite remb " , " % remb volume " );
2016-05-26 12:35:37 +02:00
$reasons = array ();
$reasons [] = array (
'id_reason' => 3 ,
'name' => " BBB : Erreur Achat / Prod " ,
);
$reasons [] = array (
'id_reason' => 6 ,
'name' => " BBB : Erreur Logistique " ,
);
$reasons [] = array (
'id_reason' => 8 ,
'name' => " BBB : Pbme Site / Paiment " ,
);
$reasons [] = array (
'id_reason' => 12 ,
'name' => " BBB : Suspicion de fraude " ,
);
$reasons [] = array (
'id_reason' => 11 ,
'name' => " CLIENT : Annulation pour re-achat " ,
);
$reasons [] = array (
'id_reason' => 1 ,
'name' => " CLIENT : Annulation pre-envoi " ,
);
2016-05-27 12:57:32 +02:00
$reasons [] = array (
2016-05-26 12:35:37 +02:00
'id_reason' => 2 ,
2016-05-27 16:59:18 +02:00
'name' => " CLIENT : Retractation post-envoi " ,
2016-05-27 12:57:32 +02:00
);
2016-05-26 12:35:37 +02:00
$reasons [] = array (
'id_reason' => 4 ,
'name' => " FEUR : Probleme SAV " ,
);
$reasons [] = array (
'id_reason' => 5 ,
'name' => " FEUR : Produit manquant " ,
);
$reasons [] = array (
'id_reason' => 9 ,
'name' => " TRANS : Colis detruit " ,
);
$reasons [] = array (
'id_reason' => 10 ,
'name' => " TRANS : Colis perdu " ,
);
$reasons [] = array (
'id_reason' => 7 ,
'name' => " Autre " ,
);
$reasons [] = array (
'id_reason' => 99 ,
'name' => " Vide " ,
);
foreach ( $reasons as $key => $reason ) {
$row_1 [] = $reason [ 'name' ] ;
$row_1 [] = " " ;
$row_1 [] = " " ;
$row_1 [] = " " ;
$row_2 [] = " CA remb TTC " ;
$row_2 [] = " % remb valeur " ;
$row_2 [] = " Quantite remb " ;
$row_2 [] = " % remb volume " ;
}
2016-05-27 10:19:09 +02:00
$row_2 = array_merge (
$row_2 ,
array (
" Nb commande " ,
" Nb commande erreur log " ,
" % erreur " , " NB colis " ,
" % colis Pole 1 " ,
" % colis Pole 2 " ,
" % colis Pole 3 " ,
" % colis Pole 4 " ,
" % colis Pole 5 " ,
2017-06-16 14:52:50 +02:00
" % colis Pole 6 "
2016-05-27 10:19:09 +02:00
)
);
2016-05-26 12:35:37 +02:00
fputcsv ( $fp , $row_1 , $delim );
fputcsv ( $fp , $row_2 , $delim );
foreach ( $result as $key => $row ) {
$data = array ();
foreach ( $row as $k => $value ) {
if ( is_array ( $value )){
foreach ( $value as $key => $val ) {
2016-10-12 18:13:45 +02:00
$data [] = $val ;
2016-05-26 12:35:37 +02:00
}
} else {
2017-06-16 14:20:34 +02:00
$data [] = $value ;
2016-05-26 12:35:37 +02:00
}
}
fputcsv ( $fp , array_map ( 'utf8_decode' , array_values ( $data )), $delim );
}
fclose ( $fp );
}
2016-01-04 12:49:26 +01:00
}