Guillaume Bourgeois 1 год назад
Родитель
Сommit
1f60ecb484
1 измененных файлов: 27 добавлений и 1 удалений
  1. +27
    -1
      backend/controllers/DistributionController.php

+ 27
- 1
backend/controllers/DistributionController.php Просмотреть файл

@@ -137,7 +137,7 @@ class DistributionController extends BackendController
$json['products'] = $this->buildAjaxInfosResponseProducts($producer, $distribution, $productsArray, $ordersArray);
$json['distribution'] = $this->buildAjaxInfosResponseDistribution($distribution, $ordersArrayObject, $productsArray);
$json['orders'] = $this->buildAjaxInfosResponseOrders($ordersArray, $productsArray);
$json['points_sale'] = $pointSaleManager->findPointSalesByDistributionAsArray($distribution);
$json['points_sale'] = $this->buildAjaxInfosResponsePointsSale($distribution);
$json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date);
$json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray);
$json['users'] = $userManager->findUsers();
@@ -149,6 +149,32 @@ class DistributionController extends BackendController
return $json;
}

public function buildAjaxInfosResponsePointsSale(Distribution $distribution)
{
$pointSaleManager = $this->getPointSaleManager();
$pointSaleDistributionManager = $this->getPointSaleDistributionManager();

$pointsSaleArray = $pointSaleManager->findPointSalesByDistributionAsArray($distribution);

// @TODO : à gérer autrement
foreach($pointsSaleArray as &$pointSaleArray) {
$idPointSale = $pointSaleArray['id'];
$pointSale = $pointSaleManager->findOnePointSaleById($idPointSale);
if(!isset($pointSaleArray['pointSaleDistribution']) || !$pointSaleArray['pointSaleDistribution'] || !count($pointSaleArray['pointSaleDistribution'])) {
$pointSaleDistribution = $pointSaleDistributionManager->createPointSaleDistributionIfNotExist($distribution, $pointSale);
$pointSaleArray['pointSaleDistribution'] = [
[
'id_distribution' => $pointSaleDistribution->id_distribution,
'id_point_sale' => $pointSaleDistribution->id_point_sale,
'delivery' => $pointSaleDistribution->delivery
]
];
}
}

return $pointsSaleArray;
}

public function buildAjaxInfosResponseProducts(Producer $producer, Distribution $distribution, array &$productsArray, array $ordersArray)
{
$distributionManager = $this->getDistributionManager();

Загрузка…
Отмена
Сохранить