Browse Source

[backend] Distributions : bug chargement produits

dev
Guillaume Bourgeois 5 years ago
parent
commit
d030db8ca7
5 changed files with 14 additions and 3 deletions
  1. +5
    -0
      backend/controllers/DistributionController.php
  2. +2
    -1
      backend/controllers/ProductController.php
  3. +4
    -1
      backend/views/product/_form.php
  4. +2
    -0
      common/models/Distribution.php
  5. +1
    -1
      common/models/Product.php

+ 5
- 0
backend/controllers/DistributionController.php View File

foreach($productsArray as &$theProduct) { foreach($productsArray as &$theProduct) {
$quantityOrder = Order::getProductQuantity($theProduct['id'], $ordersArray) ; $quantityOrder = Order::getProductQuantity($theProduct['id'], $ordersArray) ;
$theProduct['quantity_ordered'] = $quantityOrder ; $theProduct['quantity_ordered'] = $quantityOrder ;
if(!isset($theProduct['productDistribution'][0])) {
$theProduct['productDistribution'][0] = $distribution->linkProduct($theProduct) ;
}
if(!is_numeric($theProduct['productDistribution'][0]['quantity_max'])) { if(!is_numeric($theProduct['productDistribution'][0]['quantity_max'])) {
$theProduct['quantity_remaining'] = null ; $theProduct['quantity_remaining'] = null ;
} }

+ 2
- 1
backend/controllers/ProductController.php View File

Yii::$app->getSession()->setFlash('success', 'Produit <strong>'.Html::encode($model->name).'</strong> ajouté'); Yii::$app->getSession()->setFlash('success', 'Produit <strong>'.Html::encode($model->name).'</strong> ajouté');


return $this->redirect(['index']); return $this->redirect(['index']);
} else {
}
else {
return $this->render('create', [ return $this->render('create', [
'model' => $model, 'model' => $model,
]); ]);

+ 4
- 1
backend/views/product/_form.php View File



<div class="product-form"> <div class="product-form">


<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?php $form = ActiveForm::begin([
'enableClientValidation' => false,
'options' => ['enctype' => 'multipart/form-data']
]); ?>


<div> <div>
<div class="col-md-8"> <div class="col-md-8">

+ 2
- 0
common/models/Distribution.php View File

} }


$productDistribution->save(); $productDistribution->save();
return $productDistribution ;
} }
/** /**

+ 1
- 1
common/models/Product.php View File

[['name', 'description', 'photo', 'unit'], 'string', 'max' => 255], [['name', 'description', 'photo', 'unit'], 'string', 'max' => 255],
[['recipe'], 'string', 'max' => 1000], [['recipe'], 'string', 'max' => 1000],
['step', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) { ['step', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) {
if($model->unit == 'piece') {
if($model->unit != 'piece') {
return true ; return true ;
} }
return false ; return false ;

Loading…
Cancel
Save