|
|
|
|
|
|
|
|
|
|
|
|
|
|
use common\logic\AbstractGenerator; |
|
|
use common\logic\AbstractGenerator; |
|
|
use common\logic\Distribution\Distribution\Model\Distribution; |
|
|
use common\logic\Distribution\Distribution\Model\Distribution; |
|
|
|
|
|
use common\logic\Order\Order\Model\Order; |
|
|
use common\logic\Order\Order\Repository\OrderRepository; |
|
|
use common\logic\Order\Order\Repository\OrderRepository; |
|
|
use common\logic\Producer\Producer\Service\ProducerSolver; |
|
|
use common\logic\Producer\Producer\Service\ProducerSolver; |
|
|
use kartik\mpdf\Pdf; |
|
|
use kartik\mpdf\Pdf; |
|
|
|
|
|
|
|
|
public function generate(Distribution $distribution, bool $save = false) |
|
|
public function generate(Distribution $distribution, bool $save = false) |
|
|
{ |
|
|
{ |
|
|
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution); |
|
|
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution); |
|
|
|
|
|
$ordersArray = $this->filterOrdersExcludedUsersAndPointSales($ordersArray); |
|
|
|
|
|
|
|
|
$content = \Yii::$app->getView()->render('@backend/views/distribution/shopping-cart-labels.php', [ |
|
|
$content = \Yii::$app->getView()->render('@backend/views/distribution/shopping-cart-labels.php', [ |
|
|
'distribution' => $distribution, |
|
|
'distribution' => $distribution, |
|
|
|
|
|
|
|
|
return $pdf->render(); |
|
|
return $pdf->render(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function filterOrdersExcludedUsersAndPointSales(array $ordersArray) |
|
|
|
|
|
{ |
|
|
|
|
|
$ordersArrayFilter = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach($ordersArray as $order) { |
|
|
|
|
|
if(!$this->isOrderUserExcludeExport($order) |
|
|
|
|
|
&& !$this->isOrderPointSaleExcludeExport($order)) { |
|
|
|
|
|
$ordersArrayFilter[] = $order; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $ordersArrayFilter; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function isOrderUserExcludeExport(Order $order): bool |
|
|
|
|
|
{ |
|
|
|
|
|
return $order->user && $order->user->exclude_export_shopping_cart_labels; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function isOrderPointSaleExcludeExport(Order $order): bool |
|
|
|
|
|
{ |
|
|
|
|
|
return $order->pointSale && $order->pointSale->exclude_export_shopping_cart_labels; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function getCss(): string |
|
|
public function getCss(): string |
|
|
{ |
|
|
{ |
|
|
return ' |
|
|
return ' |