2016-11-24 16:04:13 +01:00
< ? php
include ( dirname ( __FILE__ ) . '/../../config/config.inc.php' );
require_once ( dirname ( __FILE__ ) . '../../../init.php' );
include_once ( dirname ( __FILE__ ) . '/../../modules/blockordersummary/blockordersummary.php' );
global $cookie ;
global $smarty ;
if ( isset ( $_GET [ 'id_order' ]) && isset ( $_GET [ 'tokenAddress' ]) && isset ( $_GET [ 'tokenOrder' ])) {
$module = new BlockOrderSummary ();
$order = new Order (( int ) $_GET [ 'id_order' ]);
$cart = new Cart (( int ) $order -> id_cart );
$data = $module -> getOrderDetail ( $cart ,( int ) $cart -> id_lang , $order );
$status = array (
2 => array ( 'anticon-credit-card' , 'text-green-light' ),
4 => array ( 'anticon-truck' , 'text-purple-light' ),
5 => array ( 'anticon-home3' , 'text-purple' ),
6 => array ( 'anticon-blocked' , 'text-rose' ),
7 => array ( 'anticon-blocked' , 'text-rose' ),
8 => array ( 'anticon-blocked' , 'text-rose' ),
17 => array ( 'anticon-truck' , 'text-orange' ),
18 => array ( 'anticon-warning' , 'text-orange' ),
19 => array ( 'anticon-pause' , 'text-orange' ),
);
$currency = new Currency (( int )( Configuration :: get ( 'PS_CURRENCY_DEFAULT' )));
$currentState = OrderHistory :: getLastOrderState (( int ) $order -> id );
$addressDelivery = new Address ( $order -> id_address_delivery , ( int )( $cart -> id_lang ));
$addressInvoice = new Address ( $order -> id_address_invoice , ( int )( $cookie -> id_lang ));
$shipping_numbers = Db :: getInstance () -> ExecuteS ( '
SELECT DISTINCT lpws . `shipping_number` , lpws . `date_add`
FROM `'._DB_PREFIX_.'lapostews` lpws
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON ( od . `id_order_detail` = lpws . `id_order_detail` )
WHERE `id_order` = ' . ( int ) $order -> id
);
$shipping_numbers2 = Db :: getInstance () -> ExecuteS ( '
SELECT DISTINCT ppp . `shipping_number` , ppp . `date_add`
FROM `'._DB_PREFIX_.'philea_parcel` ppp
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON ( od . `id_order_detail` = ppp . `id_order_detail` )
WHERE od . `id_order` = ' . ( int ) $order -> id
);
//$carrier_socol = array(38,40,45);// local
//$carrier_socol = array(45,47,48);// dev
$carrier_socol = array ( 87 , 88 , 89 ); // prod
$html = '<h4>Récapitulatif <a target="_blank" href="?tab=AdminOrders&id_order=' . ( int ) $order -> id . '&vieworder&token=' . $_GET [ 'tokenOrder' ] . '">(#' . ( int ) $order -> id . ' ) </ a ></ h4 >
< div class = " order-info " >
< h5 > Statut de la commande </ h5 >
< p class = " '. $status[$currentState->id] [1].' " >< span class = " anticon '. $status[$currentState->id] [0].' " ></ span > < b > '.$currentState->name.' </ b ></ p > ' ;
if ( count ( $shipping_numbers ) > 0 || count ( $shipping_numbers2 ) > 0 ) {
$html .= '<h5>Numéros de suivi</h5>' ;
if ( count ( $shipping_numbers ) > 0 ){
foreach ( $shipping_numbers as $key => $number ) {
$date = new DateTime ( $number [ 'date_add' ]);
$html .= '<p>' . $number [ 'shipping_number' ] . ' ajouté le ' . $date -> format ( 'd/m/Y' ) . '</p>' ;
}
}
if ( count ( $shipping_numbers2 ) > 0 ){
foreach ( $shipping_numbers2 as $key => $number ) {
$date = new DateTime ( $number [ 'date_add' ]);
$html .= '<p>' . $number [ 'shipping_number' ] . ' ajouté le ' . $date -> format ( 'd/m/Y' ) . '</p>' ;
}
}
}
2016-11-24 16:34:12 +01:00
$html .= ' < h5 > Paiement </ h5 >
< p >< span class = " anticon anticon-credit-card " ></ span > < b > '.$order->payment.' </ b ></ p >
</ div >
2016-11-24 16:04:13 +01:00
< div class = " my-cart " >
< h5 > Produits </ h5 >
< ul > ' ;
foreach ( $cart -> getProducts () as $key => $product ) {
$html .= '<li>' . $product [ 'quantity' ] . ' x ' . mb_strimwidth ( $product [ 'name' ], 0 , 35 , " ... " ) . ' <span class="price">' . Tools :: displayPrice ( $product [ 'total_wt' ], $currency ) . '</span></li>' ;
}
$html .= ' </ ul >
< p > Total produits < span class = " price price_total " > '.Tools::displayPrice($cart->getOrderTotal(TRUE,1),$currency).' </ span ></ p > ' ;
if ( $cart -> getOrderTotal ( TRUE , 2 ) != 0 ){
$html .= '<p>Total réduction <span class="price price_total">' . Tools :: displayPrice ( $cart -> getOrderTotal ( TRUE , 2 ), $currency ) . '</span></p>' ;
}
$html .= ' </ div >
< div >
< h5 > Transport </ h5 >
< p class = " carrier-info " >< span class = " carrier-name " > '.$data[' carrier_name '].' </ span > < span class = " price price_total " > '.Tools::displayPrice($cart->getOrderTotal(TRUE, 5),$currency).' </ span ></ p >
</ div >
< div >
< h5 > Délai de livraison </ h5 >
< p class = " delivery-delay " > '.$data[' delay_name '].' </ p > ' ;
if ( isset ( $data [ 'delivery_date' ])){
foreach ( $data [ 'delivery_date' ] as $k => $date ) {
if ( $k == 1 ) {
$html .= ' < p class = " delivery-date " >
Date de réception prévue entre le < strong > '.$date[' date_start ']->format(' d / m / Y ').' </ strong > et le < strong > '.$date[' date_end ']->format(' d / m / Y ').' </ strong >
</ p > ' ;
} elseif ( $k == 5 ){
$html .= '<p class="delivery-date">Livraison prévue avant le <strong>24/12</strong></p>' ;
2016-11-25 10:49:10 +01:00
} elseif ( $k == 8 ){
$html .= '<p class="delivery-date">Envoi en 48h</p>' ;
2016-11-24 16:04:13 +01:00
}
}
}
$html .= ' </ div >
< div >
< h5 > Adresse de livraison ' .
(
2016-11-25 11:39:44 +01:00
( $currentState -> id != 8 && $currentState -> id != 18 && in_array (( int ) $order -> id_carrier , $carrier_socol ))
2016-11-24 16:04:13 +01:00
? '<a id="modif_address" data-url="scaddressedit.php?id_cart=' . ( int ) $order -> id_cart . '"><span class="anticon anticon-pencil" style="font-size: 16px; vertical-align: baseline;cursor:pointer;"></span></a>'
: (
2016-11-25 11:39:44 +01:00
( $currentState -> id != 8 && $currentState -> id != 18 && ! in_array (( int ) $order -> id_carrier , $carrier_socol ))
2016-11-24 16:04:13 +01:00
? '<a href="?tab=AdminAddresses&id_address=' . $addressDelivery -> id . '&addaddress&realedit=1&id_order=' . $order -> id . ( $addressDelivery -> id == $addressInvoice -> id ? '&address_type=1' : '' ) . '&token=' . $_GET [ 'tokenAddress' ] . '&back=' . urlencode ( $_SERVER [ 'REQUEST_URI' ]) . '"><span class="anticon anticon-pencil" style="font-size: 16px; vertical-align: baseline;cursor:pointer;"></span></a>'
: ''
)
) .
' </ h5 >
< p class = " address " > '.$data[' order_address '].' </ p >
</ div >
< div >
< h5 > Paiement </ h5 >
< p class = " order_total " > Total à régler < span class = " price price_total " > '.Tools::displayPrice($cart->getOrderTotal(TRUE),$currency).' </ span ></ p >
2016-11-25 11:50:52 +01:00
</ div >
< script >
$ ( document ) . ready ( function () {
$ ( " #modif_address " ) . click ( function (){
url = $ ( this ) . data ( " url " );
var p = window . open ( url , " Modification SoColissimo " , " width=720, height=360, resizable=1, scrollbars=1 " );
return false ;
});
});
</ script > ' ;
2016-11-24 16:04:13 +01:00
if ( ! empty ( $html )) {
echo $html ;
die ();
} else {
echo '<p>Order not found</p>' ;
die ();
}
} else {
echo '<p>An error occured, order not found.</p>' ;
die ();
}
die ();