|
|
@@ -4,6 +4,7 @@ namespace common\logic\Distribution\Distribution\Export; |
|
|
|
|
|
|
|
use common\logic\AbstractGenerator; |
|
|
|
use common\logic\Distribution\Distribution\Model\Distribution; |
|
|
|
use common\logic\Order\Order\Model\Order; |
|
|
|
use common\logic\Order\Order\Repository\OrderRepository; |
|
|
|
use common\logic\Producer\Producer\Service\ProducerSolver; |
|
|
|
use kartik\mpdf\Pdf; |
|
|
@@ -22,6 +23,7 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple |
|
|
|
public function generate(Distribution $distribution, bool $save = false) |
|
|
|
{ |
|
|
|
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution); |
|
|
|
$ordersArray = $this->filterOrdersExcludedUsersAndPointSales($ordersArray); |
|
|
|
|
|
|
|
$content = \Yii::$app->getView()->render('@backend/views/distribution/shopping-cart-labels.php', [ |
|
|
|
'distribution' => $distribution, |
|
|
@@ -51,6 +53,30 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple |
|
|
|
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 |
|
|
|
{ |
|
|
|
return ' |