Browse Source

[Administration] Étiquettes : ajustements

develop
Guillaume Bourgeois 2 months ago
parent
commit
db0835537d
2 changed files with 71 additions and 14 deletions
  1. +1
    -1
      backend/views/distribution/shopping-cart-labels.php
  2. +70
    -13
      domain/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, $isSpecificFormat);
echo $distributionShoppingCartLabelsPdfGenerator->getShoppingCartLabelAsHtml($order, $index, $isSpecificFormat, $specificFormatWidth, $specificFormatHeight, $pdfInCartLabelSpecificFormat);


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

+ 70
- 13
domain/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php View File

{ {
$isSpecificFormat = false; $isSpecificFormat = false;
$exportShoppingCartLabelsFormat = $this->producerSolver->getConfig('export_shopping_cart_labels_format'); $exportShoppingCartLabelsFormat = $this->producerSolver->getConfig('export_shopping_cart_labels_format');
$pdfInCartLabelSpecificFormat = $this->producerSolver->getConfig('export_shopping_cart_labels_pdf_in_cart_label_specific_format');
$specificFormatWidth = 0;
$specificFormatHeight = 0;
if($this->featureChecker->isEnabled(Feature::ALIAS_EXPORT_SHOPPING_CART_LABELS_ADVANCED)) { if($this->featureChecker->isEnabled(Feature::ALIAS_EXPORT_SHOPPING_CART_LABELS_ADVANCED)) {
if($exportShoppingCartLabelsFormat) { if($exportShoppingCartLabelsFormat) {
$isSpecificFormat = true; $isSpecificFormat = true;
'distribution' => $distribution, 'distribution' => $distribution,
'ordersArray' => $ordersArray, 'ordersArray' => $ordersArray,
'isSpecificFormat' => $isSpecificFormat, 'isSpecificFormat' => $isSpecificFormat,
'shoppingCartLabelsPerColumn' => $this->producerSolver->getConfig('export_shopping_cart_labels_number_per_column') ?: 8
'specificFormatWidth' => $specificFormatWidth,
'specificFormatHeight' => $specificFormatHeight,
'shoppingCartLabelsPerColumn' => $this->producerSolver->getConfig('export_shopping_cart_labels_number_per_column') ?: 8,
'pdfInCartLabelSpecificFormat' => $isSpecificFormat && $pdfInCartLabelSpecificFormat
]); ]);


if($isSpecificFormat) { if($isSpecificFormat) {
$pdfInCartLabelSpecificFormat = $this->producerSolver->getConfig('export_shopping_cart_labels_pdf_in_cart_label_specific_format');
$pdf = $this->getPdf($distribution, $content, $pdfInCartLabelSpecificFormat, true, $specificFormatWidth, $specificFormatHeight); $pdf = $this->getPdf($distribution, $content, $pdfInCartLabelSpecificFormat, true, $specificFormatWidth, $specificFormatHeight);
} }
else { else {


public function getCss(bool $isSpecificFormat = false, float $specificFormatWidth = 0, float $specificFormatHeight = 0): string public function getCss(bool $isSpecificFormat = false, float $specificFormatWidth = 0, float $specificFormatHeight = 0): string
{ {
$fontSizeArray = [
'normal' => [
'username' => 14,
'phoneNumber' => 10,
'pointSale' => 10,
'products' => 10,
'amount' => 10,
],
'big' => [
'username' => 18,
'phoneNumber' => 14,
'pointSale' => 14,
'products' => 14,
'amount' => 14,
]
];

if($specificFormatWidth >= 100 && $specificFormatHeight >= 100) {
$fontSizeArray = $fontSizeArray['big'];
}
else {
$fontSizeArray = $fontSizeArray['normal'];
}

$css = ' $css = '
@page { @page {
margin: 0px 0px 0px 0px !important; margin: 0px 0px 0px 0px !important;
body { body {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
} }
.shopping-cart-label .username { .shopping-cart-label .username {
font-weight: bold; font-weight: bold;
font-size: 16px;
font-size: '.$fontSizeArray['username'].'px;
}
.shopping-cart-label .phonenumber {
font-size: '.$fontSizeArray['phoneNumber'].'px;
} }
.shopping-cart-label .point-sale { .shopping-cart-label .point-sale {
font-size: 10px;
line-height: 12px;
font-size: '.$fontSizeArray['pointSale'].'px;
text-transform: uppercase; text-transform: uppercase;
margin-bottom: 3px;
margin-bottom: 12px;
} }
.shopping-cart-label .products { .shopping-cart-label .products {
font-size: 10px;
}';
font-size: '.$fontSizeArray['products'].'px;
}
.shopping-cart-label .amount-and-payment {
font-size: '.$fontSizeArray['amount'].'px;
margin-top: 15px;
}
';


if($isSpecificFormat) { if($isSpecificFormat) {
$paddingWidthShoppingCartLabel = 8; $paddingWidthShoppingCartLabel = 8;
float: left; float: left;
} }
.shopping-cart-label .producer-logo {
width: 100px;
height: 100px;
padding-bottom: 20px;
}
.shopping-cart-label .amount-and-payment { .shopping-cart-label .amount-and-payment {
margin-top: 8px;
font-size: 10px;
/*border-top: dotted 1px gray;*/
} }
.shopping-cart-label .amount-and-payment .amount { .shopping-cart-label .amount-and-payment .amount {
return $css; return $css;
} }


public function getShoppingCartLabelAsHtml(Order $order, int $index, bool $isSpecificFormat): string
public function getShoppingCartLabelAsHtml(Order $order, int $index, bool $isSpecificFormat, int $specificFormatWidth, int $specificFormatHeight, bool $pdfInCartLabelSpecificFormat): string
{ {
$amountAndPayment = ''; $amountAndPayment = '';
if($isSpecificFormat) { if($isSpecificFormat) {
if($paymentLabelPaid && strlen($paymentLabelPaid)) { if($paymentLabelPaid && strlen($paymentLabelPaid)) {
$amountAndPayment .= ' / '.$paymentLabelPaid; $amountAndPayment .= ' / '.$paymentLabelPaid;
} }
else {
$amountAndPayment .= ' / À régler';
}
$amountAndPayment .= '</div>'; $amountAndPayment .= '</div>';
} }


$producerLogo = '';
if($isSpecificFormat && $specificFormatWidth >= 100 && $specificFormatHeight >= 150) {
$producerLogo = '<div class="producer-logo"><img src="'.$this->producerSolver->getUrlLogo($this->getProducerContext()).'" /></div>';
}

$phoneNumber = '';
if($this->orderSolver->hasPhone($order)) {
$phoneNumber = '<div class="phonenumber">'.$this->orderSolver->getPhone($order).'</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">
'.$producerLogo.'
<div class="username"> <div class="username">
'.$this->orderSolver->getOrderUsername($order).' '.$this->orderSolver->getOrderUsername($order).'
</div> </div>
'.$phoneNumber.'
<div class="point-sale"> <div class="point-sale">
'.date('d/m', strtotime($order->distribution->date)).' &bull; '.date('d/m', strtotime($order->distribution->date)).' &bull;
'.$order->pointSale->name.' '.$order->pointSale->name.'

Loading…
Cancel
Save