|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <?php
-
-
-
- use common\models\Order ;
- use common\models\Product ;
-
- $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)) {
-
- $html .= '<h3>'.$pointSale->name.'</h3>' ;
- $colCredit = ($pointSale->credit) ? '<th>Rappel crédit</th>' : '' ;
-
- $html .= '<table class="">'
- . '<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 = '';
-
-
- $strUser = $order->getStrUser() ;
-
- 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) {
- $unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '.Product::strUnit($productOrder->unit, 'wording_short', true) ;
- $strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />';
- $add = true;
- }
- }
- }
-
- $html .= '<td>'.substr($strProducts, 0, strlen($strProducts) - 6).'</td>';
- $html .= '<td>'.$order->comment.'</td>';
-
- if($pointSale->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_with_tax, 2) . ' € ';
-
- if($order->getPaymentStatus() == Order::PAYMENT_PAID)
- {
- $html .= '(payé)' ;
- }
- elseif($order->getPaymentStatus() == Order::PAYMENT_UNPAID && $order->getAmount(Order::AMOUNT_PAID))
- {
- $html .= '(reste '.$order->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ;
- }
- elseif($order->getPaymentStatus() == Order::PAYMENT_SURPLUS)
- {
- $html .= '(surplus : '.$order->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ;
- }
-
- $html .= '</strong></td>' ;
-
- $html .= '</tr>' ;
-
- }
-
- $html .= '<tr><td><strong>Total</strong></td>' ;
-
- $strProducts = '';
- foreach ($productsArray as $product) {
- foreach(Product::$unitsArray as $unit => $dataUnit) {
- $quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
- if ($quantity) {
- $theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '.Product::strUnit($unit, 'wording_short', true) ;
- $strProducts .= $product->name . ' (' .$quantity .$theUnit.')<br />';
- }
- }
- }
-
- $strProducts = substr($strProducts, 0, strlen($strProducts) - 6) ;
-
- $html .= '<td>'.$strProducts.'</td><td></td>' ;
- if($pointSale->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="">'
- . '<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))
- {
- $html .= '<tr><td>'.$pointSale->name.'</td><td>' ;
-
- foreach ($productsArray as $product) {
- foreach(Product::$unitsArray as $unit => $dataUnit) {
- $quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
- if ($quantity) {
- $theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '.Product::strUnit($unit, 'wording_short', true) ;
- $html .= $product->name . ' (' .$quantity .$theUnit.')<br />';
- }
- }
- }
-
- $html = substr($html, 0, strlen($html) - 6) ;
-
- $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) {
- foreach(Product::$unitsArray as $unit => $dataUnit) {
- $quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit);
- if ($quantity) {
- $theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '.Product::strUnit($unit, 'wording_short', true) ;
- $html .= $product->name . ' (' .$quantity .$theUnit.')<br />';
- }
- }
- }
-
- $html = substr($html, 0, strlen($html) - 6) ;
-
- $html .= '</td><td><strong>'.number_format($revenues, 2).' €</strong></td></tr>' ;
-
- $html .= '</tbody></table>' ;
-
- echo $html ;
-
- ?>
|