瀏覽代碼

[Administration] Étiquettes : ajustements

develop
Guillaume Bourgeois 2 月之前
父節點
當前提交
db0835537d
共有 2 個文件被更改,包括 71 次插入14 次删除
  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 查看文件

@@ -8,7 +8,7 @@ $i = 0;
foreach($ordersArray as $key => $order) {
$index ++;

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

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

+ 70
- 13
domain/Distribution/Distribution/Export/DistributionShoppingCartLabelsPdfGenerator.php 查看文件

@@ -46,6 +46,9 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
{
$isSpecificFormat = false;
$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($exportShoppingCartLabelsFormat) {
$isSpecificFormat = true;
@@ -67,11 +70,13 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
'distribution' => $distribution,
'ordersArray' => $ordersArray,
'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) {
$pdfInCartLabelSpecificFormat = $this->producerSolver->getConfig('export_shopping_cart_labels_pdf_in_cart_label_specific_format');
$pdf = $this->getPdf($distribution, $content, $pdfInCartLabelSpecificFormat, true, $specificFormatWidth, $specificFormatHeight);
}
else {
@@ -131,6 +136,30 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple

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 = '
@page {
margin: 0px 0px 0px 0px !important;
@@ -139,24 +168,32 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
}
.shopping-cart-label .username {
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 {
font-size: 10px;
line-height: 12px;
font-size: '.$fontSizeArray['pointSale'].'px;
text-transform: uppercase;
margin-bottom: 3px;
margin-bottom: 12px;
}
.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) {
$paddingWidthShoppingCartLabel = 8;
@@ -177,10 +214,15 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
float: left;
}
.shopping-cart-label .producer-logo {
width: 100px;
height: 100px;
padding-bottom: 20px;
}
.shopping-cart-label .amount-and-payment {
margin-top: 8px;
font-size: 10px;
/*border-top: dotted 1px gray;*/
}
.shopping-cart-label .amount-and-payment .amount {
@@ -210,7 +252,7 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
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 = '';
if($isSpecificFormat) {
@@ -221,14 +263,29 @@ class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator imple
if($paymentLabelPaid && strlen($paymentLabelPaid)) {
$amountAndPayment .= ' / '.$paymentLabelPaid;
}
else {
$amountAndPayment .= ' / À régler';
}
$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.'">
<div class="inner">
'.$producerLogo.'
<div class="username">
'.$this->orderSolver->getOrderUsername($order).'
</div>
'.$phoneNumber.'
<div class="point-sale">
'.date('d/m', strtotime($order->distribution->date)).' &bull;
'.$order->pointSale->name.'

Loading…
取消
儲存