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

*/ */
public function actionUpdate($id) public function actionUpdate($id)
{ {

$commande = Commande::find() $commande = Commande::find()
->with('production') ->with('production')
->where(['id' => $id]) ->where(['id' => $id])
$this->gestionForm($commande); $this->gestionForm($commande);
} }



return $this->render('update', array_merge($this->initForm($commande), [ return $this->render('update', array_merge($this->initForm($commande), [
'model' => $commande, 'model' => $commande,
'commande_introuvable' => !$commande, 'commande_introuvable' => !$commande,
else else
$commande->commentaire_point_vente = ''; $commande->commentaire_point_vente = '';


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

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

?> ?>
<div id="bar-fixed" class="<?php if($etablissement->credit_pain): ?>credit-pain<?php else: ?>no-credit-pain<?php endif; ?>"> <div id="bar-fixed" class="<?php if($etablissement->credit_pain): ?>credit-pain<?php else: ?>no-credit-pain<?php endif; ?>">
<div class="container"> <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> <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; ?> <?php endif; ?>
<span id="total-commande-bottom"><span></span> €</span> <span id="total-commande-bottom"><span></span> €</span>
<?= $form->field($model, 'commentaire')->textarea(['rows' => 3, 'placeholder' => 'Un commentaire ?'])->label(''); ?> <?= $form->field($model, 'commentaire')->textarea(['rows' => 3, 'placeholder' => 'Un commentaire ?'])->label(''); ?>
<div id="bloc-valider-commande"> <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> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>

Loading…
Cancel
Save