Quellcode durchsuchen

[Administration] Distributions : génération d'étiquettes #1244

feature/souke
Guillaume Bourgeois vor 1 Jahr
Ursprung
Commit
9f4e9f7f46
9 geänderte Dateien mit 154 neuen und 7 gelöschten Zeilen
  1. +12
    -0
      backend/controllers/DistributionController.php
  2. +1
    -1
      backend/views/dashboard/index.php
  3. +2
    -3
      backend/views/distribution/index.php
  4. +25
    -0
      backend/views/distribution/shopping-cart-labels.php
  5. +0
    -1
      common/logic/Distribution/Distribution/Service/DistributionReportPdfGenerator.php
  6. +108
    -0
      common/logic/Distribution/Distribution/Service/DistributionShoppingCartLabelsPdfGenerator.php
  7. +2
    -0
      common/logic/Distribution/Distribution/Wrapper/DistributionContainer.php
  8. +2
    -0
      common/logic/Distribution/Distribution/Wrapper/DistributionManager.php
  9. +2
    -2
      common/logic/Order/Order/Repository/OrderRepository.php

+ 12
- 0
backend/controllers/DistributionController.php Datei anzeigen

@@ -277,6 +277,9 @@ class DistributionController extends BackendController
'url_report_grid' => $this->getUrlManagerBackend()->createUrl(
['distribution/report-grid', 'date' => $distribution->date]
),
'url_export_shopping_cart_labels' => $this->getUrlManagerBackend()->createUrl(
['distribution/export-shopping-cart-labels', 'date' => $distribution->date]
),
];

// montant et poids des commandes
@@ -639,6 +642,15 @@ class DistributionController extends BackendController
}
}

public function actionExportShoppingCartLabels(string $date)
{
$distributionManager = $this->getDistributionManager();
$distribution = $distributionManager->findOneDistribution($date);
if($distribution) {
return $distributionManager->generateDistributionShoppingCartLabelsPdf($distribution);
}
}

public function actionAjaxProcessProductQuantityMax($idDistribution, $idProduct, $quantityMax)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

+ 1
- 1
backend/views/dashboard/index.php Datei anzeigen

@@ -219,7 +219,7 @@ $this->setTitle('Tableau de bord');
<div class="comment"><span class="glyphicon glyphicon-comment"></span> <?= nl2br(Html::encode($order->comment)) ; ?></div>
<?php endif; ?>
</td>
<td><?= $orderManager->getCartSummary($order) ; ?></td>
<td><?= $orderManager->getCartSummary($order); ?></td>
<td><?= $orderManager->getPointSaleSummary($order) ; ?></td>
<td><?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true) ; ?></td>
<td class="history"><?= $orderManager->getHistorySummary($order) ; ?></td>

+ 2
- 3
backend/views/distribution/index.php Datei anzeigen

@@ -210,12 +210,11 @@ $this->setPageTitle('Distributions') ;
<div class="info-box-content">
<span class="info-box-text">
{{ countOrders }} Commande<span v-if="countOrders > 1">s</span><br />
<a :href="distribution.url_report" class="btn btn-xs btn-default" v-if="countOrders > 0">Liste (PDF)</a>
<a :href="distribution.url_report+'&type=csv'" class="btn btn-xs btn-default" v-if="countOrders > 0">Tableau (CSV)</a>

<br v-if="producer && producer.option_display_export_grid && countOrders > 0" />
<br />
<a :href="distribution.url_report_grid" class="btn btn-xs btn-default" v-if="producer && producer.option_display_export_grid && countOrders > 0">Grille (PDF)</a>
<a :href="distribution.url_export_shopping_cart_labels" class="btn btn-xs btn-default" v-if="countOrders > 0">Étiquettes (PDF)</a>
</span>
</div>
</div>

+ 25
- 0
backend/views/distribution/shopping-cart-labels.php Datei anzeigen

@@ -0,0 +1,25 @@
<?php

use common\logic\Order\Order\Wrapper\OrderManager;
use yii\helpers\Html;

$orderManager = OrderManager::getInstance();
$index = 0

?>
<?php foreach($ordersArray as $order): ?>
<div class="shopping-cart-label shopping-cart-label-<?= $index ?>">
<div class="inner">
<div class="username">
<?= $orderManager->getOrderUsername($order); ?>
</div>
<div class="point-sale">
<?= Html::encode($order->pointSale->name); ?> &bull; <?= date('d/m', strtotime($distribution->date)); ?>
</div>
<div class="products">
<?= $orderManager->getCartSummary($order); ?>
</div>
</div>
</div>
<?php $index = ($index == 5) ? 0 : $index + 1; ?>
<?php endforeach; ?>

+ 0
- 1
common/logic/Distribution/Distribution/Service/DistributionReportPdfGenerator.php Datei anzeigen

@@ -18,7 +18,6 @@ use common\logic\Product\Product\Model\Product;
use common\logic\Product\Product\Repository\ProductRepository;
use common\logic\Product\Product\Service\ProductSolver;
use common\logic\User\User\Repository\UserRepository;
use common\logic\User\UserProducer\Model\UserProducer;
use kartik\mpdf\Pdf;

class DistributionReportPdfGenerator extends AbstractGenerator

+ 108
- 0
common/logic/Distribution/Distribution/Service/DistributionShoppingCartLabelsPdfGenerator.php Datei anzeigen

@@ -0,0 +1,108 @@
<?php

namespace common\logic\Distribution\Distribution\Service;

use common\logic\AbstractGenerator;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Order\Order\Repository\OrderRepository;
use kartik\mpdf\Pdf;

class DistributionShoppingCartLabelsPdfGenerator extends AbstractGenerator
{
protected OrderRepository $orderRepository;

public function loadDependencies(): void
{
$this->orderRepository = $this->loadService(OrderRepository::class);
}

public function generateDistributionShoppingCartLabelsPdf(Distribution $distribution)
{
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution);

$content = \Yii::$app->getView()->render('@backend/views/distribution/shopping-cart-labels.php', [
'distribution' => $distribution,
'ordersArray' => $ordersArray,
]);

$pdf = new Pdf([
'mode' => Pdf::MODE_UTF8,
'format' => Pdf::FORMAT_A4,
'orientation' => Pdf::ORIENT_PORTRAIT,
'destination' => Pdf::DEST_BROWSER,
'filename' => \Yii::getAlias(
'@app/web/pdf/Etiquettes-' . $distribution->date . '-' . $this->getProducerContextId() . '.pdf'
),
'content' => $content,
'cssInline' => $this->getCss(),
'methods' => [
'SetHeader' => ['Étiquettes du ' . date('d/m/Y', strtotime($distribution->date))],
'SetFooter' => ['{PAGENO}'],
]
]);

return $pdf->render();
}

public function getCss(): string
{
return '
@page {
margin: 0px 0px 0px 0px !important;
padding: 0px 0px 0px 0px !important;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
}
.clr {
clear: both;
}
.shopping-cart-label {
box-sizing: border-box;
width: 49.9%;
height: 368px;
float: left;
text-align: center;
}
.shopping-cart-label.shopping-cart-label-0,
.shopping-cart-label.shopping-cart-label-2 {
border-bottom: solid 1px #e0e0e0;
border-right: solid 1px #e0e0e0;
}
.shopping-cart-label.shopping-cart-label-1,
.shopping-cart-label.shopping-cart-label-3 {
border-bottom: solid 1px #e0e0e0;
}
.shopping-cart-label.shopping-cart-label-4 {
border-right: solid 1px #e0e0e0;
}
.shopping-cart-label .inner {
padding: 20px;
}
.shopping-cart-label .username {
margin-bottom: 3px;
font-weight: bold;
font-size: 18px;
}
.shopping-cart-label .point-sale {
margin-bottom: 10px;
font-size: 15px;
text-transform: uppercase;
}
.shopping-cart-label .products {
}
';
}
}

+ 2
- 0
common/logic/Distribution/Distribution/Wrapper/DistributionContainer.php Datei anzeigen

@@ -9,6 +9,7 @@ use common\logic\Distribution\Distribution\Service\DistributionDefinition;
use common\logic\Distribution\Distribution\Service\DistributionReportCsvGenerator;
use common\logic\Distribution\Distribution\Service\DistributionReportGridPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionReportPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionShoppingCartLabelsPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionSolver;

class DistributionContainer extends AbstractContainer
@@ -23,6 +24,7 @@ class DistributionContainer extends AbstractContainer
DistributionReportCsvGenerator::class,
DistributionReportGridPdfGenerator::class,
DistributionReportPdfGenerator::class,
DistributionShoppingCartLabelsPdfGenerator::class
];
}


+ 2
- 0
common/logic/Distribution/Distribution/Wrapper/DistributionManager.php Datei anzeigen

@@ -9,6 +9,7 @@ use common\logic\Distribution\Distribution\Service\DistributionDefinition;
use common\logic\Distribution\Distribution\Service\DistributionReportCsvGenerator;
use common\logic\Distribution\Distribution\Service\DistributionReportGridPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionReportPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionShoppingCartLabelsPdfGenerator;
use common\logic\Distribution\Distribution\Service\DistributionSolver;

/**
@@ -19,6 +20,7 @@ use common\logic\Distribution\Distribution\Service\DistributionSolver;
* @mixin DistributionReportCsvGenerator
* @mixin DistributionReportGridPdfGenerator
* @mixin DistributionReportPdfGenerator
* @mixin DistributionShoppingCartLabelsPdfGenerator
*/
class DistributionManager extends AbstractManager
{

+ 2
- 2
common/logic/Order/Order/Repository/OrderRepository.php Datei anzeigen

@@ -71,7 +71,6 @@ class OrderRepository extends AbstractRepository
'productOrder',
'productOrder.product',
'productOrder.taxRate',
'pointSale',
'payment',
'payment.user',
'payment.userAction',
@@ -83,6 +82,7 @@ class OrderRepository extends AbstractRepository
'distribution',
'user',
'user.userProducer',
'pointSale',
],
self::ORDER_BY => 'order.date ASC',
self::ATTRIBUTE_ID_PRODUCER => 'distribution.id_producer'
@@ -130,7 +130,7 @@ class OrderRepository extends AbstractRepository
->filterByDistributionDate($distribution->date)
->filterIsValid()
->filterByCondition($conditionAppend)
->orderBy('user.lastname ASC, user.name ASC, comment_point_sale ASC')
->orderBy('point_sale.name ASC, user.lastname ASC, user.name ASC, comment_point_sale ASC')
->find();
}


Laden…
Abbrechen
Speichern