|
|
|
|
|
|
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
use common\models\Order ; |
|
|
use common\models\Order ; |
|
|
|
|
|
use common\models\Product ; |
|
|
|
|
|
|
|
|
$dayWeek = date('w', strtotime($date)); |
|
|
$dayWeek = date('w', strtotime($date)); |
|
|
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; |
|
|
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; |
|
|
|
|
|
|
|
|
$add = false; |
|
|
$add = false; |
|
|
foreach ($order->productOrder as $productOrder) { |
|
|
foreach ($order->productOrder as $productOrder) { |
|
|
if ($product->id == $productOrder->id_product) { |
|
|
if ($product->id == $productOrder->id_product) { |
|
|
$strProducts .= $productOrder->quantity . ' ' . $product->name . ', '; |
|
|
|
|
|
|
|
|
$strProducts .= $product->name . ' (' .$productOrder->quantity . ' '.Product::strUnit($productOrder->unit, true, true).'), '; |
|
|
$add = true; |
|
|
$add = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$strProducts = ''; |
|
|
$strProducts = ''; |
|
|
foreach ($productsArray as $product) { |
|
|
foreach ($productsArray as $product) { |
|
|
$quantity = Order::getProductQuantity($product->id, $pointSale->orders); |
|
|
|
|
|
$strQuantity = ''; |
|
|
|
|
|
if ($quantity) { |
|
|
|
|
|
$strQuantity = $quantity; |
|
|
|
|
|
$strProducts .= $strQuantity .' '. $product->name . ', '; |
|
|
|
|
|
|
|
|
foreach(Product::$unitsArray as $unit => $dataUnit) { |
|
|
|
|
|
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); |
|
|
|
|
|
if ($quantity) { |
|
|
|
|
|
$strProducts .= $product->name . ' (' .$quantity . ' '.Product::strUnit($unit, true, true).'), '; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (count($pointSale->orders)) |
|
|
if (count($pointSale->orders)) |
|
|
{ |
|
|
{ |
|
|
$html .= '<tr><td>'.$pointSale->name.'</td><td>' ; |
|
|
$html .= '<tr><td>'.$pointSale->name.'</td><td>' ; |
|
|
|
|
|
|
|
|
foreach ($productsArray as $product) { |
|
|
foreach ($productsArray as $product) { |
|
|
$quantity = Order::getProductQuantity($product->id, $pointSale->orders); |
|
|
|
|
|
$strQuantity = ($quantity) ? $quantity : '' ; |
|
|
|
|
|
|
|
|
|
|
|
if(strlen($strQuantity)) { |
|
|
|
|
|
$html .= $strQuantity . ' '.$product->name.', ' ; |
|
|
|
|
|
|
|
|
foreach(Product::$unitsArray as $unit => $dataUnit) { |
|
|
|
|
|
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); |
|
|
|
|
|
if ($quantity) { |
|
|
|
|
|
$html .= $product->name . ' (' .$quantity . ' '.Product::strUnit($unit, true, true).'), '; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$html = substr($html, 0, strlen($html) - 2) ; |
|
|
$html = substr($html, 0, strlen($html) - 2) ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// total |
|
|
// total |
|
|
$html .= '<tr><td><strong>Total</strong></td><td>' ; |
|
|
$html .= '<tr><td><strong>Total</strong></td><td>' ; |
|
|
|
|
|
|
|
|
foreach ($productsArray as $product) { |
|
|
foreach ($productsArray as $product) { |
|
|
$quantity = Order::getProductQuantity($product->id, $ordersArray); |
|
|
|
|
|
if($quantity) { |
|
|
|
|
|
$html .= $quantity . ' '.$product->name.', ' ; |
|
|
|
|
|
|
|
|
foreach(Product::$unitsArray as $unit => $dataUnit) { |
|
|
|
|
|
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit); |
|
|
|
|
|
if ($quantity) { |
|
|
|
|
|
$html .= $product->name . ' (' .$quantity . ' '.Product::strUnit($unit, true, true).'), '; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|