|
- <?php
-
-
-
- use domain\Order\Order\Order;
- use domain\Order\Order\OrderModule;
-
- $orderModule = OrderModule::getInstance();
-
- $dayWeek = date('w', strtotime($date));
- $dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday'];
- $fieldInfosPointSale = 'infos_' . $dayWeekArray[$dayWeek];
-
- $html = '' ;
-
-
- foreach ($pointsSaleArray as $pointSale) {
- if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale)) {
-
- $html .= '<h3>'.$pointSale->name.'</h3>' ;
- $colCredit = ($pointSale->payment_method_credit) ? '<th>Cagnotte</th>' : '' ;
-
- $html .= '<table class="table table-bordered">'
- . '<thead>'
- . '<tr>'
- . '<th>Client</th>'
- . '<th>Produits</th>'
- . '<th>Commentaire</th>'
- . $colCredit
- . '<th>Montant</th>'
- . '</tr>'
- . '<tbody>';
-
- foreach ($pointSale->orders as $order) {
- $html .= '<tr>' ;
- $strUser = '';
-
-
- if ($order->user) {
- $strUser = $order->user->name . " " . $order->user->lastname;
- } else {
- $strUser = $order->username;
- }
-
- if(strlen($order->comment_point_sale))
- {
- $strUser .= '<br /><em>'.$order->comment_point_sale.'</em>' ;
- }
-
-
- if (isset($order->user) && strlen($order->user->phone)) {
- $strUser .= '<br />' . $order->user->phone . '';
- }
-
- $html .= '<td>'.$strUser.'</td>';
-
-
- $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 .= '<td>'.substr($strProducts, 0, strlen($strProducts) - 2).'</td>';
- $html .= '<td>'.$order->comment.'</td>';
-
- if($pointSale->payment_method_credit) {
- $credit = '' ;
- if(isset($order->user) && isset($order->user->userProducer)) {
- $credit = number_format($order->user->userProducer[0]->credit,2).' €' ;
- }
- $html .= '<td>'.$credit.'</td>' ;
- }
-
- $html .= '<td><strong>'.number_format($order->amount, 2) . ' € ';
-
- if($orderModule->getPaymentStatus($order) == Order::PAYMENT_PAID)
- {
- $html .= '(débité)' ;
- }
- elseif($orderModule->getPaymentStatus($order) == Order::PAYMENT_UNPAID && $orderModule->getOrderAmount($order, Order::AMOUNT_PAID))
- {
- $html .= '(reste '.$orderModule->getOrderAmount($order, Order::AMOUNT_REMAINING, true).' à débiter)' ;
- }
- elseif($orderModule->getPaymentStatus($order) == Order::PAYMENT_SURPLUS)
- {
- $html .= '(surplus : '.$orderModule->getOrderAmount($order, Order::PAYMENT_SURPLUS, true).' à rembourser)' ;
- }
-
- $html .= '</strong></td>' ;
-
- $html .= '</tr>' ;
-
- }
-
- $html .= '<tr><td><strong>Total</strong></td>' ;
-
- $strProducts = '';
- foreach ($productsArray as $product) {
- $quantity = $orderModule->getProductQuantity($product, $pointSale->orders);
- $strQuantity = '';
- if ($quantity) {
- $strQuantity = $quantity;
- $strProducts .= $strQuantity .' '. $product->name . ', ';
- }
- }
-
- $strProducts = substr($strProducts, 0, strlen($strProducts) - 2) ;
-
- $html .= '<td>'.$strProducts.'</td><td></td>' ;
- if($pointSale->payment_method_credit) {
- $html .= '<td></td>' ;
- }
- $html .= '<td><strong>'.number_format($pointSale->revenues, 2) . ' €</strong></td>';
-
- $html .= '</tbody></table><pagebreak>' ;
- }
- }
-
-
- $html .= '<h3>Points de vente</h3>' ;
- $html .= '<table class="table table-bordered">'
- . '<thead>'
- . '<tr>'
- . '<th>Point de vente</th>'
- . '<th>Produits</th>'
- . '<th>Montant</th>'
- . '</tr>'
- . '<tbody>';
-
- $revenues = 0 ;
- foreach ($pointsSaleArray as $pointSale)
- {
- if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale))
- {
- $html .= '<tr><td>'.$pointSale->name.'</td><td>' ;
- foreach ($productsArray as $product) {
- $quantity = $orderModule->getProductQuantity($product, $pointSale->orders);
- $strQuantity = ($quantity) ? $quantity : '' ;
-
- if(strlen($strQuantity)) {
- $html .= $strQuantity . ' '.$product->name.', ' ;
- }
-
- }
-
- $html = substr($html, 0, strlen($html) - 2) ;
-
- $html .= '</td><td>'.number_format($pointSale->revenues, 2).' €</td></tr>' ;
- $revenues += $pointSale->revenues ;
- }
- }
-
-
- $html .= '<tr><td><strong>Total</strong></td><td>' ;
- foreach ($productsArray as $product) {
- $quantity = $orderModule->getProductQuantity($product, $ordersArray);
- if($quantity) {
- $html .= $quantity . ' '.$product->name.', ' ;
- }
- }
-
- $html = substr($html, 0, strlen($html) - 2) ;
-
- $html .= '</td><td><strong>'.number_format($revenues, 2).' €</strong></td></tr>' ;
-
- $html .= '</tbody></table>' ;
-
- echo $html ;
-
- ?>
|