@@ -41,6 +41,7 @@ class CommandeController extends BackendController { | |||
$commandes = Commande::findBy([ | |||
'date' => $date, | |||
'date_delete' => 'NULL', | |||
'id_etablissement' => $id_etablissement, | |||
'orderby' => 'commentaire_point_vente ASC, user.nom ASC' | |||
]); | |||
@@ -293,8 +294,9 @@ class CommandeController extends BackendController { | |||
// commandes | |||
$commandes = Commande::findBy([ | |||
'date' => $date | |||
]); | |||
'date' => $date, | |||
'date_delete' => 'NULL' | |||
]); | |||
$recettes = 0; | |||
$recettes_pain = 0; | |||
@@ -305,14 +307,17 @@ class CommandeController extends BackendController { | |||
foreach ($commandes as $c) { | |||
$c->init(); | |||
$recettes += $c->montant; | |||
$recettes_pain += $c->montant_pain; | |||
$recettes_vrac += $c->montant_vrac; | |||
if ($c->id_point_vente != 1) | |||
$recettes_pain_livre += $c->montant_pain; | |||
$poids_pain += $c->poids_pain; | |||
$poids_vrac += $c->poids_vrac; | |||
if(is_null($c->date_delete)) { | |||
$recettes += $c->montant; | |||
$recettes_pain += $c->montant_pain; | |||
$recettes_vrac += $c->montant_vrac; | |||
if ($c->id_point_vente != 1) | |||
$recettes_pain_livre += $c->montant_pain; | |||
$poids_pain += $c->poids_pain; | |||
$poids_vrac += $c->poids_vrac; | |||
} | |||
} | |||
$recettes = number_format($recettes, 2); | |||
$recettes_pain = number_format($recettes_pain, 2); | |||
@@ -1072,7 +1077,7 @@ class CommandeController extends BackendController { | |||
// commandes | |||
$commandes = Commande::find() | |||
->with('commandeProduits', 'user') | |||
->with('commandeProduits','commandeProduits.produit', 'user') | |||
->joinWith('production') | |||
->where(['production.date' => $date]) | |||
->andWhere(['production.id_etablissement' => Yii::$app->user->identity->id_etablissement]) | |||
@@ -1083,8 +1088,11 @@ class CommandeController extends BackendController { | |||
$poids_pain = 0; | |||
foreach ($commandes as $c) { | |||
$c->init(); | |||
$recettes += $c->montant; | |||
$poids_pain += $c->poids_pain; | |||
if(is_null($c->date_delete)) { | |||
$recettes += $c->montant; | |||
$poids_pain += $c->poids_pain; | |||
} | |||
} | |||
// produits selec pour production |
@@ -228,6 +228,10 @@ foreach ($produits as $p) { | |||
<?php else: ?> | |||
<?= Html::encode($c->username); ?> | |||
<?php endif; ?> | |||
<?php if(!is_null($c->date_delete)): ?> | |||
(<span class="glyphicon glyphicon-remove"></span> Annulée) | |||
<?php endif; ?> | |||
</span> | |||
<?php if (strlen($c->commentaire)): ?> |
@@ -252,14 +252,9 @@ $this->title = 'Tableau de bord'; | |||
</thead> | |||
<tbody> | |||
<?php foreach($commandes as $c): ?> | |||
<tr class="<?php if(!is_null($c->date_update)): ?>commande-update<?php endif; ?>"> | |||
<tr class="<?= $c->getClassHistorique() ; ?>"> | |||
<td class="infos"><?= $c->getStrType(true); ?></td> | |||
<td class="historique"> | |||
<div class="small"><span class="glyphicon glyphicon-plus"></span> Création <br /> <strong><?= date('d/m/Y à G\hi', strtotime($c->date)) ?></strong></div> | |||
<?php if(!is_null($c->date_update)): ?> | |||
<div class="small"><span class="update"><span class="glyphicon glyphicon-pencil"></span> Dernière modification</span><br /> <strong><?= date('d/m/Y à G\hi', strtotime($c->date_update)) ?></strong></div> | |||
<?php endif; ?> | |||
</td> | |||
<td class="historique"><?= $c->getStrHistorique() ; ?></td> | |||
<td class="date"> | |||
<div class="bloc-date"> | |||
<div class="jour"><?= strftime('%A', strtotime($c->production->date)) ?></div> |
@@ -20,7 +20,8 @@ $this->params['breadcrumbs'][] = 'Créditer'; | |||
<?php if(count($commandes)): ?> | |||
<table id="historique-commandes" class="table table-striped table-bordered"> | |||
<thead> | |||
<tr> | |||
<tr> | |||
<th>Historique</th> | |||
<th>Date livraison</th> | |||
<th>Résumé</th> | |||
<th>Point de vente</th> | |||
@@ -29,7 +30,8 @@ $this->params['breadcrumbs'][] = 'Créditer'; | |||
</thead> | |||
<tbody> | |||
<?php foreach($commandes as $c): ?> | |||
<tr> | |||
<tr class="<?= $c->getClassHistorique() ; ?>"> | |||
<td class="historique"><?= $c->getStrHistorique() ; ?></td> | |||
<td><?php echo date('d/m/Y',strtotime($c->production->date)); ?></td> | |||
<td class="resume"><?= $c->getResumePanier() ; ?></td> | |||
<td><?= $c->getResumePointVente(); ?></td> |
@@ -1,4 +1,4 @@ | |||
<?php | |||
0<?php | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
@@ -103,8 +103,9 @@ $this->params['breadcrumbs'][] = $this->title; | |||
$count_commandes = Commande::find() | |||
->joinWith('production') | |||
->where([ | |||
'id_user' => $model['user_id'], | |||
'id_user' => $model['user_id'], | |||
'production.id_etablissement' => Yii::$app->user->identity->id_etablissement]) | |||
->andWhere('date_delete IS NULL') | |||
->count() ; | |||
$html = '' ; | |||
if($count_commandes) |
@@ -264,44 +264,26 @@ a { | |||
} | |||
} | |||
// tableau de bord | |||
.site-index { | |||
.panel { | |||
.panel-title { | |||
.btn { | |||
float: right ; | |||
font-family: 'myriadpro-regular' ; | |||
&.btn-success { | |||
background-color: #5cb85c ; | |||
color: white ; | |||
border-color: #5cb85c ; | |||
} | |||
&.margin-left { | |||
margin-left: 5px ; | |||
} | |||
} | |||
} | |||
.panel-body { | |||
//height: 250px ; | |||
} | |||
} | |||
#dernieres-commandes { | |||
// liste de commandes | |||
.site-index, .user-commandes { | |||
#dernieres-commandes, #historique-commandes { | |||
tr.commande-update { | |||
td { | |||
background-color: $color2 ; | |||
} | |||
.update { | |||
color: $color1 ; | |||
} | |||
} | |||
.small, .localite { | |||
font-size: 12px ; | |||
color: gray ; | |||
} | |||
.commentaire { | |||
font-size: 12px ; | |||
tr.commande-delete { | |||
td { | |||
background-color: lighten(#C9302C, 40); | |||
} | |||
.delete { | |||
color: #C9302C ; | |||
} | |||
} | |||
td.historique { | |||
@@ -309,39 +291,49 @@ a { | |||
.small { | |||
margin-bottom: 7px ; | |||
} | |||
strong { | |||
margin-left: 15px ; | |||
//margin-left: 15px ; | |||
} | |||
.update { | |||
color: $color1 ; | |||
} | |||
/*.label { | |||
color: gray ; | |||
border: solid 1px gray ; | |||
}*/ | |||
} | |||
.small, .localite { | |||
font-size: 12px ; | |||
color: gray ; | |||
} | |||
.commentaire { | |||
font-size: 12px ; | |||
} | |||
.date { | |||
text-align: center ; | |||
.bloc-date { | |||
width: 50% ; | |||
margin: 0px auto ; | |||
padding-top: 0px ; | |||
} | |||
.jour { | |||
text-transform: capitalize ; | |||
line-height: 13px ; | |||
font-size: 10px ; | |||
text-transform: uppercase ; | |||
} | |||
.num { | |||
font-size: 23px ; | |||
line-height: 28px ; | |||
font-weight: bold ; | |||
} | |||
.mois { | |||
text-transform: uppercase ; | |||
line-height: 13px ; | |||
@@ -349,6 +341,31 @@ a { | |||
} | |||
} | |||
} | |||
} | |||
// tableau de bord | |||
.site-index { | |||
.panel { | |||
.panel-title { | |||
.btn { | |||
float: right ; | |||
font-family: 'myriadpro-regular' ; | |||
&.btn-success { | |||
background-color: #5cb85c ; | |||
color: white ; | |||
border-color: #5cb85c ; | |||
} | |||
&.margin-left { | |||
margin-left: 5px ; | |||
} | |||
} | |||
} | |||
.panel-body { | |||
//height: 250px ; | |||
} | |||
} | |||
#facturation { | |||
h2 { |
@@ -48,6 +48,8 @@ class Commande extends \yii\db\ActiveRecord { | |||
foreach ($this->commandeProduits as $p) { | |||
if ($p->mode_vente == 'unite') { | |||
$this->montant_pain += $p->prix * $p->quantite; | |||
if(isset($p->produit)) | |||
$this->poids_pain += ($p->quantite * $p->produit->poids) / 1000 ; | |||
} elseif ($p->mode_vente == 'poids') { | |||
$this->montant_pain += $p->prix * $p->quantite / 1000; | |||
} | |||
@@ -71,9 +73,11 @@ class Commande extends \yii\db\ActiveRecord { | |||
if (isset($commandes) && is_array($commandes) && count($commandes)) { | |||
foreach ($commandes as $c) { | |||
foreach ($c->commandeProduits as $cp) { | |||
if ($cp->id_produit == $id_produit) | |||
$quantite += $cp->quantite; | |||
if(is_null($c->date_delete)) { | |||
foreach ($c->commandeProduits as $cp) { | |||
if ($cp->id_produit == $id_produit) | |||
$quantite += $cp->quantite; | |||
} | |||
} | |||
} | |||
} | |||
@@ -382,4 +386,43 @@ class Commande extends \yii\db\ActiveRecord { | |||
return $str; | |||
} | |||
public function getStrHistorique() { | |||
$arr = [ | |||
'class' => 'create', | |||
'glyphicon' => 'plus', | |||
'str' => 'Ajoutée', | |||
'date' => $this->date | |||
] ; | |||
if(!is_null($this->date_update)) { | |||
$arr = [ | |||
'class' => 'update', | |||
'glyphicon' => 'pencil', | |||
'str' => 'Modifiée', | |||
'date' => $this->date_update | |||
] ; | |||
} | |||
if(!is_null($this->date_delete)) { | |||
$arr = [ | |||
'class' => 'delete', | |||
'glyphicon' => 'remove', | |||
'str' => 'Annulée', | |||
'date' => $this->date_delete | |||
] ; | |||
} | |||
$html = '<div class="small"><span class="'.$arr['class'].'"><span class="glyphicon glyphicon-'.$arr['glyphicon'].'"></span> '.$arr['str'].'</span> le <strong>'.date('d/m/Y à G\hi', strtotime($arr['date'])).'</strong></div>' ; | |||
return $html ; | |||
} | |||
public function getClassHistorique() { | |||
if(!is_null($this->date_delete)) { | |||
return 'commande-delete' ; | |||
} | |||
if(!is_null($this->date_update)) { | |||
return 'commande-update' ; | |||
} | |||
return 'commande-create' ; | |||
} | |||
} |
@@ -101,7 +101,9 @@ class PointVente extends \yii\db\ActiveRecord { | |||
if ($this->id == $c->id_point_vente) { | |||
$this->commandes[] = $c; | |||
$this->recettes += (float) $c->montant; | |||
if(is_null($c->date_delete)) { | |||
$this->recettes += (float) $c->montant; | |||
} | |||
$this->recettes_pain += (float) $c->montant_pain; | |||
$this->recettes_vrac += (float) $c->montant_vrac; | |||
} |
@@ -191,6 +191,7 @@ 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, | |||
@@ -469,8 +470,8 @@ class CommandeController extends ProducerBaseController { | |||
); | |||
} | |||
// delete | |||
$commande->delete(); | |||
CommandeProduit::deleteAll(['id_commande' => $commande->id]); | |||
$commande->date_delete = date('Y-m-d H:i:s'); | |||
$commande->save() ; | |||
Yii::$app->session->setFlash('success','Votre commande a bien été annulée.') ; | |||
} |