浏览代码

Merge branch 'fix/commandes_annulee' into dev

refactoring
父节点
当前提交
e12bceb343
共有 3 个文件被更改,包括 36 次插入22 次删除
  1. +4
    -4
      producer/controllers/CommandeController.php
  2. +3
    -2
      producer/views/commande/_form.php
  3. +29
    -16
      producer/views/commande/historique.php

+ 4
- 4
producer/controllers/CommandeController.php 查看文件

@@ -233,7 +233,6 @@ class CommandeController extends ProducerBaseController
'id_user' => Yii::$app->user->id,
'production.id_etablissement' => $this->getProducer()->id
])
->andWhere('date_delete IS NULL')
->orderBy('production.date DESC'),
'pagination' => [
'pageSize' => 10,
@@ -308,7 +307,6 @@ class CommandeController extends ProducerBaseController
*/
public function actionUpdate($id)
{

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


return $this->render('update', array_merge($this->initForm($commande), [
'model' => $commande,
'commande_introuvable' => !$commande,
@@ -427,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();
@@ -502,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 查看文件

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

+ 29
- 16
producer/views/commande/historique.php 查看文件

@@ -96,24 +96,37 @@ GridView::widget([
'label' => 'Statut',
'format' => 'raw',
'value' => function($c) {
if($c->getEtat() == Commande::ETAT_LIVREE) {
return 'Livrée' ;
$html = '' ;
if($c->date_delete) {
$html .= '<span class="label label-danger">Annulée</span><br />' ;
if($c->getEtat() == Commande::ETAT_MODIFIABLE) {
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['commande/update','id'=>$c->id, 'id_etablissement'=>$c->production->etablissement->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>' ;
}
}
elseif($c->getEtat() == Commande::ETAT_PREPARATION) {
return 'En préparation' ;
}
elseif($c->getEtat() == Commande::ETAT_MODIFIABLE) {
return '<div class="btn-group">
<a href="'.Yii::$app->urlManager->createUrl(['commande/update','id'=>$c->id, 'id_etablissement'=>$c->production->etablissement->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="'.Yii::$app->urlManager->createUrl(['commande/annuler','id'=>$c->id]).'"><span class="glyphicon glyphicon-trash"></span> Annuler la commande</a></li>
</ul>
</div>' ;
else {
if($c->getEtat() == Commande::ETAT_LIVREE) {
$html .= '<span class="label label-success">Livrée</span>' ;
}
elseif($c->getEtat() == Commande::ETAT_PREPARATION) {
$html .= '<span class="label label-warning">En préparation</span>' ;
}
elseif($c->getEtat() == Commande::ETAT_MODIFIABLE) {
$html .= '<span class="label label-default">Ouverte</span><br />' ;
$html .= '<div class="btn-group">
<a href="'.Yii::$app->urlManager->createUrl(['commande/update','id'=>$c->id, 'id_etablissement'=>$c->production->etablissement->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="'.Yii::$app->urlManager->createUrl(['commande/annuler','id'=>$c->id]).'"><span class="glyphicon glyphicon-trash"></span> Annuler la commande</a></li>
</ul>
</div>' ;
}
}
return $html ;
}
],
]

正在加载...
取消
保存