Procházet zdrojové kódy

[backend] Distributions : bug chargement produits

refactoring
Guillaume Bourgeois před 5 roky
rodič
revize
d030db8ca7
5 změnil soubory, kde provedl 14 přidání a 3 odebrání
  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 Zobrazit soubor

@@ -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 ;
}

+ 2
- 1
backend/controllers/ProductController.php Zobrazit soubor

@@ -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,
]);

+ 4
- 1
backend/views/product/_form.php Zobrazit soubor

@@ -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">

+ 2
- 0
common/models/Distribution.php Zobrazit soubor

@@ -265,6 +265,8 @@ class Distribution extends ActiveRecordCommon
}

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

+ 1
- 1
common/models/Product.php Zobrazit soubor

@@ -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 ;

Načítá se…
Zrušit
Uložit