'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday'];
$fieldInfosPointSale = 'infos_' . $dayWeekArray[$dayWeek];
$html = '' ;
// par point de vente
foreach ($pointsSaleArray as $pointSale) {
if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale)) {
$html .= '
'.$pointSale->name.'
' ;
$colCredit = ($pointSale->credit) ? 'Rappel crédit | ' : '' ;
$html .= ''
. ''
. ''
. 'Client | '
. 'Produits | '
. 'Commentaire | '
. $colCredit
. 'Montant | '
. '
'
. '';
foreach ($pointSale->orders as $order) {
$html .= '' ;
$strUser = '';
// username
if ($order->user) {
$strUser = $order->user->name . " " . $order->user->lastname;
} else {
$strUser = $order->username;
}
if(strlen($order->comment_point_sale))
{
$strUser .= '
'.$order->comment_point_sale.'' ;
}
// téléphone
if (isset($order->user) && strlen($order->user->phone)) {
$strUser .= '
' . $order->user->phone . '';
}
$html .= ''.$strUser.' | ';
// produits
$strProducts = '';
foreach ($productsArray as $product) {
$add = false;
foreach ($order->productOrder as $productOrder) {
if ($product->id == $productOrder->id_product) {
$strProducts .= $productOrder->quantity . ' ' . $product->name . ', ';
$add = true;
}
}
}
$html .= ''.substr($strProducts, 0, strlen($strProducts) - 2).' | ';
$html .= ''.$order->comment.' | ';
if($pointSale->credit) {
$credit = '' ;
if(isset($order->user) && isset($order->user->userProducer)) {
$credit = number_format($order->user->userProducer[0]->credit,2).' €' ;
}
$html .= ''.$credit.' | ' ;
}
$html .= ''.number_format($order->amount, 2) . ' € ';
if($orderManager->getPaymentStatus($order) == Order::PAYMENT_PAID)
{
$html .= '(payé)' ;
}
elseif($orderManager->getPaymentStatus($order) == Order::PAYMENT_UNPAID && $orderManager->getOrderAmount($order, Order::AMOUNT_PAID))
{
$html .= '(reste '.$orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING, true).' à payer)' ;
}
elseif($orderManager->getPaymentStatus($order) == Order::PAYMENT_SURPLUS)
{
$html .= '(surplus : '.$orderManager->getOrderAmount($order, Order::PAYMENT_SURPLUS, true).' à rembourser)' ;
}
$html .= ' | ' ;
$html .= '
' ;
}
$html .= 'Total | ' ;
$strProducts = '';
foreach ($productsArray as $product) {
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders);
$strQuantity = '';
if ($quantity) {
$strQuantity = $quantity;
$strProducts .= $strQuantity .' '. $product->name . ', ';
}
}
$strProducts = substr($strProducts, 0, strlen($strProducts) - 2) ;
$html .= ''.$strProducts.' | | ' ;
if($pointSale->credit) {
$html .= ' | ' ;
}
$html .= ''.number_format($pointSale->revenues, 2) . ' € | ';
$html .= '
' ;
}
}
// par point de vente
$html .= 'Points de vente
' ;
$html .= ''
. ''
. ''
. 'Point de vente | '
. 'Produits | '
. 'Montant | '
. '
'
. '';
$revenues = 0 ;
foreach ($pointsSaleArray as $pointSale)
{
if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale))
{
$html .= ''.$pointSale->name.' | ' ;
foreach ($productsArray as $product) {
$quantity = $orderManager->getProductQuantity($product, $pointSale->orders);
$strQuantity = ($quantity) ? $quantity : '' ;
if(strlen($strQuantity)) {
$html .= $strQuantity . ' '.$product->name.', ' ;
}
}
$html = substr($html, 0, strlen($html) - 2) ;
$html .= ' | '.number_format($pointSale->revenues, 2).' € |
' ;
$revenues += $pointSale->revenues ;
}
}
// total
$html .= 'Total | ' ;
foreach ($productsArray as $product) {
$quantity = $orderManager->getProductQuantity($product, $ordersArray);
if($quantity) {
$html .= $quantity . ' '.$product->name.', ' ;
}
}
$html = substr($html, 0, strlen($html) - 2) ;
$html .= ' | '.number_format($revenues, 2).' € |
' ;
$html .= '
' ;
echo $html ;
?>