|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
-
- use domain\Order\Order\OrderModule;
- use domain\Producer\Producer\Producer;
- use domain\Product\Product\ProductModule;
-
- $orderModule = OrderModule::getInstance();
-
- $html = '';
-
- foreach ($pointsSaleArray as $keyPointSale => $pointSale) {
-
- if (isset($ordersArray[$pointSale->id]) && count($ordersArray[$pointSale->id]) > 0) {
- $html .= '<h1>' . $pointSale->name . '</h1>';
-
- foreach ($ordersArray[$pointSale->id] as $indexPage => $orders) {
-
- $html .= '<table class="">'
- . '<thead>'
- . '<tr>'
- . '<th></th>';
-
- foreach ($orders as $order) {
- $html .= '<th class="th-user" text-rotate="90">'
- . '<div class="user">' . $orderModule->getOrderUsername($order) . '</div>'
- //.'<div class="amount">'.number_format($order->amount_with_tax, 2) .' € </div>'
- . '</th>';
- }
-
- $html .= '</tr>'
- . '<thead>'
- . '<tbody>';
-
-
- foreach ($categoriesArray as $category) {
- if ($category) {
- $html .= '<tr><td class="category-name">' . $category->name . '</td><td colspan="' . (count($orders)) . '"></td></tr>';
- }
-
- foreach ($productsArray as $product) {
- if (($category && $product->id_product_category == $category->id) || (!$category && !$product->id_product_category)) {
- $html .= line_product($product, $orders);
- }
- }
- }
-
- $html .= '</tbody>'
- . '</table>';
- $html .= '<pagebreak>';
-
-
- $html .= '<table class="">'
- . '<thead>'
- . '<tr>'
- . '<th>Client</th>'
- . '<th>Contact</th>'
- . '<th>Commentaire</th>'
- . '<th>Montant</th>'
- . '</thead>'
- . '<tbody>';
-
- foreach ($orders as $order) {
- $html .= '<tr>';
- $strUser = $orderModule->getOrderUsername($order);
- if ($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) {
- $strUser .= '<br />' . $order->reference;
- }
-
- $html .= '<td>' . $strUser . '</td>';
- $contactUser = '';
- if ($order->user) {
- $contactUser .= $order->user->phone . '<br />' . $order->user->email;
- }
- $html .= '<td>' . $contactUser . '</td>';
- $html .= '<td>' . nl2br($order->comment) . '</td>';
- $html .= '<td>' . number_format($order->amount_with_tax, 2) . ' € </td>';
- $html .= '</tr>';
- }
-
- $html .= '</tbody></table>';
-
- $html .= ' <pagebreak>';
- }
- }
- }
-
- $html = substr($html, 0, strlen($html) - 11);
-
- echo $html;
-
- function line_product($product, $orders)
- {
- $productModule = ProductModule::getInstance();
- $html = '';
-
- if (has_quantity($product, $orders)) {
- $html .= '<tr>';
- $html .= '<td>' . $product->name . '</td>';
-
- foreach ($orders as $order) {
- $quantity = '';
- foreach ($order->productOrder as $productOrder) {
- if ($product->id == $productOrder->id_product) {
- $unit = ($productModule->getSolver()->strUnit($productOrder->product, 'wording_short', true) == 'p.') ? '' : ' ' . $productModule->getSolver()->strUnit($productOrder->product, 'wording_short', true);
-
- $quantity .= $productOrder->quantity . $unit;
- if ($productOrder->quantity > 1) {
- $quantity = '<strong>' . $quantity . '</strong>';
- }
- }
- }
-
- $html .= '<td class="td-nb-products">' . $quantity . '</td>';
- }
-
- $html .= '</tr>';
- }
-
- return $html;
- }
-
- function has_quantity($product, $orders)
- {
- foreach ($orders as $order) {
- foreach ($order->productOrder as $productOrder) {
- if ($product->id == $productOrder->id_product) {
- return true;
- }
- }
- }
-
- return false;
- }
|