Browse Source

[Administration] Distribution > étiquettes : finalisation première version #1343

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
2deabd56be
1 changed files with 26 additions and 0 deletions
  1. +26
    -0
      common/logic/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php

+ 26
- 0
common/logic/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php View File



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 '

Loading…
Cancel
Save