Browse Source

[Boutique] Gestion des accessoires

feature/rotating_product
Guillaume Bourgeois 5 months ago
parent
commit
8863f2aac5
2 changed files with 26 additions and 28 deletions
  1. +22
    -25
      producer/controllers/OrderController.php
  2. +4
    -3
      producer/web/js/vuejs/order-order.js

+ 22
- 25
producer/controllers/OrderController.php View File

return 0; return 0;
} }


public function actionAjaxInfos(string $date = '', int $pointSaleId = 0, string $productsJson = null)
public function actionAjaxInfos(string $date = '', int $pointSaleId = 0, string $productsJson = null, bool $loadingProducts = false)
{ {
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$productsArray = json_decode($productsJson, true); $productsArray = json_decode($productsJson, true);
$pointSale = $this->getPointSaleModule()->findOnePointSaleById($pointSaleId); $pointSale = $this->getPointSaleModule()->findOnePointSaleById($pointSaleId);
$order = $this->getOrderUser($date, $pointSale); $order = $this->getOrderUser($date, $pointSale);


return $this->buildJsonAjaxInfos($date, $producer, $pointSale, $user, $order, $productsArray);
return $this->buildJsonAjaxInfos($date, $producer, $pointSale, $user, $order, $productsArray, $loadingProducts);
} }
public function buildJsonAjaxInfos( public function buildJsonAjaxInfos(
PointSale $pointSale = null, PointSale $pointSale = null,
User $user = null, User $user = null,
Order $order = null, Order $order = null,
array $productsArray = null
array $productsArray = null,
bool $loadingProducts = false
) )
{ {
$orderModule = $this->getOrderModule(); $orderModule = $this->getOrderModule();
$product['photo'] = Image::getThumbnailSmall($product['photo']); $product['photo'] = Image::getThumbnailSmall($product['photo']);
} }


$quantityOrder = $orderModule->getResolver()->getProductQuantityByDistribution($productObject, $distribution);
$orderOverride = $order;
if(count($productsFormArray)) {
$productOrdersArray = [];
foreach($productsFormArray as $idProduct => $quantityProduct) {
if($idProduct) {
$productObject1 = $productModule->getRepository()->findOneProductById($idProduct);
$productOrdersArray[$idProduct] = [
'quantity' => $quantityProduct / $productModule->getSolver()->getUnitCoefficient($productObject1)
];
}
}
$orderOverride = $orderModule->getBuilder()->instanciateOrderFromProductOrdersArray($productOrdersArray, $orderOverride);
}

$quantityOrder = $orderModule->getResolver()->getProductQuantityByDistribution($productObject, $distribution, false, $orderOverride);
$product['quantity_ordered'] = $quantityOrder; $product['quantity_ordered'] = $quantityOrder;
$product['quantity_max'] = $orderModule->getResolver()->getProductQuantityMax($productObject, $distribution); $product['quantity_max'] = $orderModule->getResolver()->getProductQuantityMax($productObject, $distribution);
$product['quantity_remaining'] = $orderModule->getResolver()->getProductQuantityRemaining($productObject, $distribution); $product['quantity_remaining'] = $orderModule->getResolver()->getProductQuantityRemaining($productObject, $distribution);
$product['wording_unit'] = $unitModule->getSolver()->strUnit($product['unit'], UnitDefinition::WORDING_UNIT, true); $product['wording_unit'] = $unitModule->getSolver()->strUnit($product['unit'], UnitDefinition::WORDING_UNIT, true);
$product['wording_unit_ref'] = $unitModule->getSolver()->strUnit($product['unit'], UnitDefinition::WORDING_SHORT, true); $product['wording_unit_ref'] = $unitModule->getSolver()->strUnit($product['unit'], UnitDefinition::WORDING_SHORT, true);
$quantityOrderUser = $orderModule->getSolver()->getProductQuantity($productObject, $orderOverride ? [$orderOverride] : [], true);
$product['quantity_form'] = $quantityOrderUser * $coefficient_unit;
$product['wording_unit'] = $unitModule->getSolver()->strUnit($product['unit'], 'wording_unit', true);


if ($order) { if ($order) {

$orderOverride = $order;
if(count($productsFormArray)) {
$productOrdersArray = [];
foreach($productsFormArray as $idProduct => $quantityProduct) {
if($idProduct) {
$productObject1 = $productModule->getRepository()->findOneProductById($idProduct);
$productOrdersArray[$idProduct] = [
'quantity' => $quantityProduct / $productModule->getSolver()->getUnitCoefficient($productObject1)
];
}
}
$orderOverride = $orderModule->getBuilder()->instanciateOrderFromProductOrdersArray($productOrdersArray, $orderOverride);
}

$quantityOrderUser = $orderModule->getSolver()->getProductQuantity($productObject, [$orderOverride], true);
$product['quantity_ordered'] = $quantityOrder;
$product['quantity_remaining'] = $orderModule->getResolver()->getProductQuantityRemaining($productObject, $distribution, $orderOverride); $product['quantity_remaining'] = $orderModule->getResolver()->getProductQuantityRemaining($productObject, $distribution, $orderOverride);
$product['quantity_form'] = $quantityOrderUser * $coefficient_unit;
foreach ($order->productOrder as $productOrder) { foreach ($order->productOrder as $productOrder) {
if ($productOrder->id_product == $product['id']) { if ($productOrder->id_product == $product['id']) {
$product['wording_unit'] = $productModule->getSolver()->strUnit($productOrder->product, 'wording_unit', true); $product['wording_unit'] = $productModule->getSolver()->strUnit($productOrder->product, 'wording_unit', true);
$product['step'] = $productOrder->step; $product['step'] = $productOrder->step;
} }
} }
} else {
$product['quantity_form'] = 0;
$product['wording_unit'] = $unitModule->getSolver()->strUnit($product['unit'], 'wording_unit', true);
} }
$product['coefficient_unit'] = $coefficient_unit; $product['coefficient_unit'] = $coefficient_unit;



+ 4
- 3
producer/web/js/vuejs/order-order.js View File

}, },
mounted: function() { mounted: function() {
this.initDate(); this.initDate();
this.init('first');
this.init('first', false);
}, },
methods: { methods: {
initDate: function() { initDate: function() {
axios.get("ajax-infos",{params: { axios.get("ajax-infos",{params: {
date : this.getDate(), date : this.getDate(),
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0), pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0),
productsJson: this.getProductsArray()
productsJson: this.getProductsArray(),
loadingProducts: loadingProducts
}}) }})
.then(function(response) { .then(function(response) {
app.calendar.attrs = []; app.calendar.attrs = [];
} }
if(!this.errors.length) { if(!this.errors.length) {
this.step = step ; this.step = step ;
this.init('basic', oldStep, step) ;
this.init('basic', false) ;
} }
}, },
dayClickList: function(event) { dayClickList: function(event) {

Loading…
Cancel
Save