Parcourir la source

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

feature/souke
Guillaume Bourgeois il y a 1 an
Parent
révision
2deabd56be
1 fichiers modifiés avec 26 ajouts et 0 suppressions
  1. +26
    -0
      common/logic/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php

+ 26
- 0
common/logic/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php Voir le fichier

@@ -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 '

Chargement…
Annuler
Enregistrer