@@ -270,6 +270,9 @@ class DistributionController extends BackendController | |||
'url_export_shopping_cart_labels' => $this->getUrlManagerBackend()->createUrl( | |||
['distribution/export-shopping-cart-labels', 'date' => $distribution->date] | |||
), | |||
'url_report_total_products' => $this->getUrlManagerBackend()->createUrl( | |||
['distribution/report-total-products', 'date' => $distribution->date] | |||
), | |||
'url_order' => $distributionModule->getLinkOrder($distribution), | |||
]; | |||
@@ -605,10 +608,12 @@ class DistributionController extends BackendController | |||
if ($distribution) { | |||
if ($type == 'pdf') { | |||
return $distributionModule->generateDistributionReportPdf($distribution, $save); | |||
return $distributionModule->getReportPdfGenerator() | |||
->generateDistributionReportPdf($distribution, $save); | |||
} | |||
elseif ($type == 'csv') { | |||
$distributionModule->generateDistributionReportCsv($distribution); | |||
$distributionModule->getReportCsvGenerator() | |||
->generateDistributionReportCsv($distribution); | |||
} | |||
} | |||
} | |||
@@ -630,6 +635,16 @@ class DistributionController extends BackendController | |||
} | |||
} | |||
public function actionReportTotalProductsCsv(string $date = '') | |||
{ | |||
$distributionModule = $this-> getDistributionModule(); | |||
$distribution = $distributionModule->getRepository()->findOneDistribution($date); | |||
if ($distribution) { | |||
$distributionModule->getReportTotalProductCsvGenerator()->generateCsv($distribution); | |||
} | |||
} | |||
public function actionExportShoppingCartLabels(string $date) | |||
{ | |||
$distributionModule = $this-> getDistributionModule(); |
@@ -218,6 +218,7 @@ $this->setPageTitle('Distributions') ; | |||
<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> | |||
<a :href="distribution.url_report_total_products" class="btn btn-xs btn-default" v-if="countOrders > 0">Total produits (CSV)</a> | |||
</span> | |||
</div> | |||
</div> |
@@ -10,6 +10,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\DistributionReportTotalProductCsvGenerator; | |||
use common\logic\Distribution\Distribution\Service\DistributionShoppingCartLabelsPdfGenerator; | |||
use common\logic\Distribution\Distribution\Service\DistributionSolver; | |||
@@ -22,6 +23,7 @@ use common\logic\Distribution\Distribution\Service\DistributionSolver; | |||
* @mixin DistributionReportGridPdfGenerator | |||
* @mixin DistributionReportPdfGenerator | |||
* @mixin DistributionShoppingCartLabelsPdfGenerator | |||
* @mixin DistributionReportTotalProductCsvGenerator | |||
*/ | |||
class DistributionModule extends AbstractModule | |||
{ | |||
@@ -35,7 +37,8 @@ class DistributionModule extends AbstractModule | |||
DistributionReportCsvGenerator::class, | |||
DistributionReportGridPdfGenerator::class, | |||
DistributionReportPdfGenerator::class, | |||
DistributionShoppingCartLabelsPdfGenerator::class | |||
DistributionShoppingCartLabelsPdfGenerator::class, | |||
DistributionReportTotalProductCsvGenerator::class | |||
]; | |||
} | |||
@@ -78,4 +81,9 @@ class DistributionModule extends AbstractModule | |||
{ | |||
return DistributionShoppingCartLabelsPdfGenerator::getInstance(); | |||
} | |||
public function getReportTotalProductCsvGenerator(): DistributionReportTotalProductCsvGenerator | |||
{ | |||
return DistributionReportTotalProductCsvGenerator::getInstance(); | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution\Service; | |||
use common\helpers\CSV; | |||
use common\logic\AbstractGenerator; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Order\Order\Repository\OrderRepository; | |||
use common\logic\Order\Order\Service\OrderSolver; | |||
use common\logic\Product\Product\Repository\ProductRepository; | |||
use common\logic\Product\Product\Service\ProductSolver; | |||
class DistributionReportTotalProductCsvGenerator extends AbstractGenerator | |||
{ | |||
protected ProductRepository $productRepository; | |||
protected ProductSolver $productSolver; | |||
protected OrderRepository $orderRepository; | |||
protected OrderSolver $orderSolver; | |||
public function loadDependencies(): void | |||
{ | |||
$this->productRepository = $this->loadService(ProductRepository::class); | |||
$this->orderRepository = $this->loadService(OrderRepository::class); | |||
$this->productSolver = $this->loadService(ProductSolver::class); | |||
$this->orderSolver = $this->loadService(OrderSolver::class); | |||
} | |||
public function generateCsv(Distribution $distribution) | |||
{ | |||
$datas = []; | |||
$productsArray = $this->productRepository->findProductsByDistribution($distribution); | |||
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution); | |||
foreach($productsArray as $product) { | |||
$datas[] = [ | |||
$this->productSolver->getNameExport($product), | |||
$this->orderSolver->getProductQuantityPieces($product, $ordersArray) | |||
]; | |||
} | |||
CSV::send('Total_produits_' . $distribution->date . '.csv', $datas); | |||
} | |||
} |