<?php if($featureChecker->isEnabled(Feature::ALIAS_EXPORT_SHOPPING_CART_LABELS_ADVANCED)): ?> | <?php if($featureChecker->isEnabled(Feature::ALIAS_EXPORT_SHOPPING_CART_LABELS_ADVANCED)): ?> | ||||
<?= $form->field($model, 'export_shopping_cart_labels_format') | <?= $form->field($model, 'export_shopping_cart_labels_format') | ||||
->dropDownList($distributionExportManager->getGenerator(ExportManager::SHOPPING_CART_LABELS_PDF)->populateDropdownSpecificFormats()); ?> | ->dropDownList($distributionExportManager->getGenerator(ExportManager::SHOPPING_CART_LABELS_PDF)->populateDropdownSpecificFormats()); ?> | ||||
<?= $form->field($model, 'export_shopping_cart_labels_pdf_in_cart_label_specific_format') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?php else: ?> | <?php else: ?> | ||||
<?= $form->field($model, 'export_shopping_cart_labels_number_per_column') | <?= $form->field($model, 'export_shopping_cart_labels_number_per_column') | ||||
->dropDownList(Dropdown::numberChoices(1, 20)); ?> | ->dropDownList(Dropdown::numberChoices(1, 20)); ?> |
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
/** | |||||
* Class m240912_071102_add_column_producer_export_shopping_cart_labels_pdf_in_cart_label_specific_format | |||||
*/ | |||||
class m240912_071102_add_column_producer_export_shopping_cart_labels_pdf_in_cart_label_specific_format extends Migration | |||||
{ | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'export_shopping_cart_labels_pdf_in_cart_label_specific_format', Schema::TYPE_BOOLEAN); | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'export_shopping_cart_labels_pdf_in_cart_label_specific_format'); | |||||
} | |||||
} |
class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator implements DistributionExportGeneratorInterface | class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator implements DistributionExportGeneratorInterface | ||||
{ | { | ||||
const FORMAT_70_42 = '70x42'; | const FORMAT_70_42 = '70x42'; | ||||
const FORMAT_100_150 = '100x150'; | |||||
protected ProducerSolver $producerSolver; | protected ProducerSolver $producerSolver; | ||||
protected OrderRepository $orderRepository; | protected OrderRepository $orderRepository; | ||||
public function getSpecificFormatDetailsArray(): array | public function getSpecificFormatDetailsArray(): array | ||||
{ | { | ||||
return [ | return [ | ||||
self::FORMAT_70_42 => [70, 42] | |||||
self::FORMAT_70_42 => [70, 42], | |||||
self::FORMAT_100_150 => [100, 150], | |||||
]; | ]; | ||||
} | } | ||||
]); | ]); | ||||
if($isSpecificFormat) { | if($isSpecificFormat) { | ||||
$pdf = $this->getPdf($distribution, $content, true, $specificFormatWidth, $specificFormatHeight); | |||||
$pdfInCartLabelSpecificFormat = $this->producerSolver->getConfig('export_shopping_cart_labels_pdf_in_cart_label_specific_format'); | |||||
$pdf = $this->getPdf($distribution, $content, $pdfInCartLabelSpecificFormat, true, $specificFormatWidth, $specificFormatHeight); | |||||
} | } | ||||
else { | else { | ||||
$pdf = $this->getPdf($distribution, $content, false); | |||||
$pdf = $this->getPdf($distribution, $content, false, false); | |||||
$pdf->getApi()->SetColumns(4); | $pdf->getApi()->SetColumns(4); | ||||
$pdf->getApi()->keepColumns = true; | $pdf->getApi()->keepColumns = true; | ||||
} | } | ||||
return $pdf->render(); | return $pdf->render(); | ||||
} | } | ||||
public function getPdf(Distribution $distribution, string $content, bool $isSpecificFormat, float $specificFormatWidth = 0, float $specificFormatHeight = 0) | |||||
public function getPdf(Distribution $distribution, string $content, bool $pdfInCartLabelSpecificFormat, bool $isSpecificFormat, float $specificFormatWidth = 0, float $specificFormatHeight = 0) | |||||
{ | { | ||||
if($pdfInCartLabelSpecificFormat) { | |||||
$format = [$specificFormatWidth, $specificFormatHeight]; | |||||
} | |||||
else { | |||||
$format = Pdf::FORMAT_A4; | |||||
} | |||||
return new Pdf([ | return new Pdf([ | ||||
'mode' => Pdf::MODE_UTF8, | 'mode' => Pdf::MODE_UTF8, | ||||
'format' => Pdf::FORMAT_A4, | |||||
'format' => $format, | |||||
'orientation' => Pdf::ORIENT_PORTRAIT, | 'orientation' => Pdf::ORIENT_PORTRAIT, | ||||
'destination' => Pdf::DEST_BROWSER, | 'destination' => Pdf::DEST_BROWSER, | ||||
'filename' => \Yii::getAlias( | 'filename' => \Yii::getAlias( |
'option_leave_period_message_display', | 'option_leave_period_message_display', | ||||
'sponsorship_sponsor_reward', | 'sponsorship_sponsor_reward', | ||||
'sponsorship_godson_reward', | 'sponsorship_godson_reward', | ||||
'export_shopping_cart_labels_pdf_in_cart_label_specific_format' | |||||
], | ], | ||||
'boolean' | 'boolean' | ||||
], | ], | ||||
'option_document_width_logo' => 'Largeur du logo dans les documents', | 'option_document_width_logo' => 'Largeur du logo dans les documents', | ||||
'export_shopping_cart_labels_number_per_column' => "Étiquettes (PDF) : nombre d'étiquettes par colonne", | 'export_shopping_cart_labels_number_per_column' => "Étiquettes (PDF) : nombre d'étiquettes par colonne", | ||||
'export_shopping_cart_labels_format' => 'Étiquettes (PDF) : format', | 'export_shopping_cart_labels_format' => 'Étiquettes (PDF) : format', | ||||
'export_shopping_cart_labels_pdf_in_cart_label_specific_format' => 'Étiquettes (PDF) : PDF au format d\'étiquette spécifique', | |||||
'option_document_display_price_unit_reference' => "Afficher les prix au kilogramme", | 'option_document_display_price_unit_reference' => "Afficher les prix au kilogramme", | ||||
'id_user_group_default' => "Groupe utilisateur par défaut attribué à l'inscription", | 'id_user_group_default' => "Groupe utilisateur par défaut attribué à l'inscription", | ||||
'option_check_by_default_prevent_user_credit' => "Par défaut, prévenir l'utilisateur quand on crédite sa cagnotte", | 'option_check_by_default_prevent_user_credit' => "Par défaut, prévenir l'utilisateur quand on crédite sa cagnotte", |