@@ -164,6 +164,11 @@ class DistributionController extends BackendController | |||
foreach($productsArray as &$theProduct) { | |||
$quantityOrder = Order::getProductQuantity($theProduct['id'], $ordersArray) ; | |||
$theProduct['quantity_ordered'] = $quantityOrder ; | |||
if(!isset($theProduct['productDistribution'][0])) { | |||
$theProduct['productDistribution'][0] = $distribution->linkProduct($theProduct) ; | |||
} | |||
if(!is_numeric($theProduct['productDistribution'][0]['quantity_max'])) { | |||
$theProduct['quantity_remaining'] = null ; | |||
} |
@@ -121,7 +121,8 @@ class ProductController extends BackendController | |||
Yii::$app->getSession()->setFlash('success', 'Produit <strong>'.Html::encode($model->name).'</strong> ajouté'); | |||
return $this->redirect(['index']); | |||
} else { | |||
} | |||
else { | |||
return $this->render('create', [ | |||
'model' => $model, | |||
]); |
@@ -48,7 +48,10 @@ use yii\helpers\ArrayHelper ; | |||
<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 class="col-md-8"> |
@@ -265,6 +265,8 @@ class Distribution extends ActiveRecordCommon | |||
} | |||
$productDistribution->save(); | |||
return $productDistribution ; | |||
} | |||
/** |
@@ -120,7 +120,7 @@ class Product extends ActiveRecordCommon | |||
[['name', 'description', 'photo', 'unit'], 'string', 'max' => 255], | |||
[['recipe'], 'string', 'max' => 1000], | |||
['step', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) { | |||
if($model->unit == 'piece') { | |||
if($model->unit != 'piece') { | |||
return true ; | |||
} | |||
return false ; |