Browse Source

Réactivation d'une commande lors d'une modification.

Adaptation du formulaire (boutons du bas) de modification en fonction de l'état annulé ou non de la commande.
refactoring
Guillaume Bourgeois 6 years ago
parent
commit
07f55e82c1
2 changed files with 7 additions and 5 deletions
  1. +4
    -3
      producer/controllers/CommandeController.php
  2. +3
    -2
      producer/views/commande/_form.php

+ 4
- 3
producer/controllers/CommandeController.php View File

@@ -307,7 +307,6 @@ class CommandeController extends ProducerBaseController
*/
public function actionUpdate($id)
{

$commande = Commande::find()
->with('production')
->where(['id' => $id])
@@ -324,7 +323,6 @@ class CommandeController extends ProducerBaseController
$this->gestionForm($commande);
}


return $this->render('update', array_merge($this->initForm($commande), [
'model' => $commande,
'commande_introuvable' => !$commande,
@@ -426,6 +424,9 @@ class CommandeController extends ProducerBaseController
else
$commande->commentaire_point_vente = '';

// la commande est automatiquement réactivée lors d'une modification
$commande->date_delete = null ;
// sauvegarde de la commande
$commande->save();
@@ -501,7 +502,7 @@ class CommandeController extends ProducerBaseController
);
}
}
// redirection
$this->redirect(Yii::$app->urlManager->createUrl(['commande/historique', 'commande_ok' => true, 'pate_deja_petrie' => $pate_deja_petrie]));
} else {

+ 3
- 2
producer/views/commande/_form.php View File

@@ -264,7 +264,7 @@ use yii\widgets\ActiveForm;
?>
<div id="bar-fixed" class="<?php if($etablissement->credit_pain): ?>credit-pain<?php else: ?>no-credit-pain<?php endif; ?>">
<div class="container">
<?php if (isset($model->id)): ?>
<?php if (isset($model->id) && !$model->date_delete): ?>
<a href="<?php echo Yii::$app->urlManager->createUrl(['commande/annuler', 'id' => $model->id]); ?>" class="btn btn-danger annuler-commande">Annuler ma commande</a>
<?php endif; ?>
<span id="total-commande-bottom"><span></span> €</span>
@@ -292,7 +292,8 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'commentaire')->textarea(['rows' => 3, 'placeholder' => 'Un commentaire ?'])->label(''); ?>
<div id="bloc-valider-commande">
<?= Html::submitButton('<span class="glyphicon glyphicon-ok"></span> Valider ma commande', ['class' => 'btn btn-primary valider-commande']) ?>
<?php if($model->date_delete): $str_btn_valider = 'Réactiver ma commande' ; else: $str_btn_valider = 'Valider ma commande' ; endif; ?>
<?= Html::submitButton('<span class="glyphicon glyphicon-ok"></span> '.$str_btn_valider, ['class' => 'btn btn-primary valider-commande']) ?>
</div>
<?php endif; ?>
</div>

Loading…
Cancel
Save