Bläddra i källkod

Merge branch 'fix/bug_commande_vide' into dev

refactoring
Guillaume Bourgeois 5 år sedan
förälder
incheckning
5dd0f38ca6
2 ändrade filer med 42 tillägg och 37 borttagningar
  1. +6
    -37
      backend/controllers/CommandeController.php
  2. +36
    -0
      common/models/Production.php

+ 6
- 37
backend/controllers/CommandeController.php Visa fil

@@ -396,44 +396,12 @@ class CommandeController extends BackendController {
}
}

// init produits sélectionnés pour cette production
$produits_selec = [];
if ($production) {
$day_production = date('N', strtotime($production->date));
$produits_production = ProductionProduit::find()->where(['id_production' => $production->id])->all();

if (!count($produits_production)) {
foreach ($produits as $p) {
$pp = new ProductionProduit();
$pp->id_production = $production->id;
$pp->id_produit = $p->id;

$pp->actif = 0;
if ($p->actif && $day_production == 1 && $p->lundi)
$pp->actif = 1;
if ($p->actif && $day_production == 2 && $p->mardi)
$pp->actif = 1;
if ($p->actif && $day_production == 3 && $p->mercredi)
$pp->actif = 1;
if ($p->actif && $day_production == 4 && $p->jeudi)
$pp->actif = 1;
if ($p->actif && $day_production == 5 && $p->vendredi)
$pp->actif = 1;
if ($p->actif && $day_production == 6 && $p->samedi)
$pp->actif = 1;
if ($p->actif && $day_production == 7 && $p->dimanche)
$pp->actif = 1;

$pp->quantite_max = $p->quantite_max;

$pp->save();
}
}

$produits_selec = [] ;
if($production) {
// produits selec pour production
$produits_selec = ProductionProduit::findProduits($production->id);
}
// produit en vrac forcément activé
if ($date != '') {
foreach ($produits as $p) {
@@ -455,9 +423,10 @@ class CommandeController extends BackendController {
}

// produits
if ($production)
if ($production) {
$produits = Produit::getByProduction($production->id);

}
// poids total de la production et CA potentiel
$ca_potentiel = 0;
$poids_total = 0;

+ 36
- 0
common/models/Production.php Visa fil

@@ -164,6 +164,42 @@ class Production extends \yii\db\ActiveRecord
}
}
// init produits sélectionnés pour cette production
$produits = Produit::getAll();
if ($production) {
$day_production = date('N', strtotime($production->date));
$produits_production = ProductionProduit::find()->where(['id_production' => $production->id])->all();

if (!count($produits_production)) {
foreach ($produits as $p) {
$pp = new ProductionProduit();
$pp->id_production = $production->id;
$pp->id_produit = $p->id;

$pp->actif = 0;
if ($p->actif && $day_production == 1 && $p->lundi)
$pp->actif = 1;
if ($p->actif && $day_production == 2 && $p->mardi)
$pp->actif = 1;
if ($p->actif && $day_production == 3 && $p->mercredi)
$pp->actif = 1;
if ($p->actif && $day_production == 4 && $p->jeudi)
$pp->actif = 1;
if ($p->actif && $day_production == 5 && $p->vendredi)
$pp->actif = 1;
if ($p->actif && $day_production == 6 && $p->samedi)
$pp->actif = 1;
if ($p->actif && $day_production == 7 && $p->dimanche)
$pp->actif = 1;

$pp->quantite_max = $p->quantite_max;

$pp->save();
}
}
}
return $production ;
}


Laddar…
Avbryt
Spara