Browse Source

[Boutique] Gestion des accessoires

feature/rotating_product
Guillaume Bourgeois 6 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

@@ -613,7 +613,7 @@ class OrderController extends ProducerBaseController
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;
$productsArray = json_decode($productsJson, true);
@@ -622,7 +622,7 @@ class OrderController extends ProducerBaseController
$pointSale = $this->getPointSaleModule()->findOnePointSaleById($pointSaleId);
$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(
@@ -631,7 +631,8 @@ class OrderController extends ProducerBaseController
PointSale $pointSale = null,
User $user = null,
Order $order = null,
array $productsArray = null
array $productsArray = null,
bool $loadingProducts = false
)
{
$orderModule = $this->getOrderModule();
@@ -987,42 +988,38 @@ class OrderController extends ProducerBaseController
$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_max'] = $orderModule->getResolver()->getProductQuantityMax($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_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) {

$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_form'] = $quantityOrderUser * $coefficient_unit;
foreach ($order->productOrder as $productOrder) {
if ($productOrder->id_product == $product['id']) {
$product['wording_unit'] = $productModule->getSolver()->strUnit($productOrder->product, 'wording_unit', true);
$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;


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

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

Loading…
Cancel
Save