Browse Source

[Administration] Export étiquettes PDF : ajout de l'information du paiement de la commande

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
daa135b7b0
2 changed files with 37 additions and 2 deletions
  1. +1
    -1
      backend/views/distribution/shopping-cart-labels.php
  2. +36
    -1
      common/logic/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php

+ 1
- 1
backend/views/distribution/shopping-cart-labels.php View File

foreach($ordersArray as $key => $order) { foreach($ordersArray as $key => $order) {
$index ++; $index ++;


echo $distributionShoppingCartLabelsPdfGenerator->getShoppingCartLabelAsHtml($order, $index);
echo $distributionShoppingCartLabelsPdfGenerator->getShoppingCartLabelAsHtml($order, $index, $isSpecificFormat);


if($index == $shoppingCartLabelsPerColumn) { if($index == $shoppingCartLabelsPerColumn) {
$index = 0; $index = 0;

+ 36
- 1
common/logic/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php View File

use common\logic\Feature\Feature\FeatureManager; use common\logic\Feature\Feature\FeatureManager;
use common\logic\Order\Order\Model\Order; use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Repository\OrderRepository; use common\logic\Order\Order\Repository\OrderRepository;
use common\logic\Order\Order\Service\OrderBuilder;
use common\logic\Order\Order\Service\OrderSolver; use common\logic\Order\Order\Service\OrderSolver;
use common\logic\Producer\Producer\Service\ProducerSolver; use common\logic\Producer\Producer\Service\ProducerSolver;
use kartik\mpdf\Pdf; use kartik\mpdf\Pdf;
protected OrderRepository $orderRepository; protected OrderRepository $orderRepository;
protected OrderSolver $orderSolver; protected OrderSolver $orderSolver;
protected FeatureChecker $featureChecker; protected FeatureChecker $featureChecker;
protected OrderBuilder $orderBuilder;


public function loadDependencies(): void public function loadDependencies(): void
{ {
$this->orderRepository = $this->loadService(OrderRepository::class); $this->orderRepository = $this->loadService(OrderRepository::class);
$this->orderSolver = $this->loadService(OrderSolver::class); $this->orderSolver = $this->loadService(OrderSolver::class);
$this->featureChecker = $this->loadService(FeatureChecker::class); $this->featureChecker = $this->loadService(FeatureChecker::class);
$this->orderBuilder = $this->loadService(OrderBuilder::class);
} }


public function getSpecificFormatDetailsArray(): array public function getSpecificFormatDetailsArray(): array
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution); $ordersArray = $this->orderRepository->findOrdersByDistribution($distribution);
$ordersArray = $this->filterOrdersExcludedUsersAndPointSales($ordersArray); $ordersArray = $this->filterOrdersExcludedUsersAndPointSales($ordersArray);


foreach($ordersArray as $order) {
$this->orderBuilder->initOrder($order);
}

$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,
'ordersArray' => $ordersArray, 'ordersArray' => $ordersArray,
height: '.$specificFormatHeight.'mm; height: '.$specificFormatHeight.'mm;
display: block; display: block;
float: left; float: left;
}
.shopping-cart-label .amount-and-payment {
margin-top: 8px;
font-size: 10px;
/*border-top: dotted 1px gray;*/
}
.shopping-cart-label .amount-and-payment .amount {
display: inline-block;
background-color: #e0e0e0;
color: #333;
font-weight: bold;
padding: 3px 8px;
border-radius: 8px;
}'; }';
} }
else { else {
return $css; return $css;
} }


public function getShoppingCartLabelAsHtml(Order $order, int $index): string
public function getShoppingCartLabelAsHtml(Order $order, int $index, bool $isSpecificFormat): string
{ {
$amountAndPayment = '';
if($isSpecificFormat) {
$amountAndPayment = '<div class="amount-and-payment">';
$amountAndPayment .= '<span class="amount">'.$this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true).'</span>';

$paymentLabelPaid = $this->orderRepository->getPaymentLabelPaid($order);
if($paymentLabelPaid && strlen($paymentLabelPaid)) {
$amountAndPayment .= ' / '.$paymentLabelPaid;
}
$amountAndPayment .= '</div>';
}

return '<div class="shopping-cart-label shopping-cart-label-'.$index.'"> return '<div class="shopping-cart-label shopping-cart-label-'.$index.'">
<div class="inner"> <div class="inner">
<div class="username"> <div class="username">
<div class="products"> <div class="products">
'.$this->orderRepository->getCartSummary($order).' '.$this->orderRepository->getCartSummary($order).'
</div> </div>
'.$amountAndPayment.'
</div> </div>
</div>'; </div>';
} }

Loading…
Cancel
Save