Browse Source

Merge branch 'develop'

master
Guillaume Bourgeois 1 year ago
parent
commit
1f60ecb484
1 changed files with 27 additions and 1 deletions
  1. +27
    -1
      backend/controllers/DistributionController.php

+ 27
- 1
backend/controllers/DistributionController.php View File

$json['products'] = $this->buildAjaxInfosResponseProducts($producer, $distribution, $productsArray, $ordersArray); $json['products'] = $this->buildAjaxInfosResponseProducts($producer, $distribution, $productsArray, $ordersArray);
$json['distribution'] = $this->buildAjaxInfosResponseDistribution($distribution, $ordersArrayObject, $productsArray); $json['distribution'] = $this->buildAjaxInfosResponseDistribution($distribution, $ordersArrayObject, $productsArray);
$json['orders'] = $this->buildAjaxInfosResponseOrders($ordersArray, $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['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date);
$json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray); $json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray);
$json['users'] = $userManager->findUsers(); $json['users'] = $userManager->findUsers();
return $json; 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) public function buildAjaxInfosResponseProducts(Producer $producer, Distribution $distribution, array &$productsArray, array $ordersArray)
{ {
$distributionManager = $this->getDistributionManager(); $distributionManager = $this->getDistributionManager();

Loading…
Cancel
Save