Ver código fonte

Merge branch 'feature/commande_deleted' into dev

dev
keun 6 anos atrás
pai
commit
fc712960d5
12 arquivos alterados com 370 adições e 272 exclusões
  1. +21
    -13
      backend/controllers/CommandeController.php
  2. +4
    -0
      backend/views/commande/index.php
  3. +2
    -7
      backend/views/site/index.php
  4. +4
    -2
      backend/views/user/commandes.php
  5. +3
    -2
      backend/views/user/index.php
  6. BIN
      backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc
  7. +208
    -199
      backend/web/css/screen.css
  8. +60
    -43
      backend/web/sass/screen.scss
  9. +46
    -3
      common/models/Commande.php
  10. +3
    -1
      common/models/PointVente.php
  11. +16
    -0
      console/migrations/m181107_104051_add_champs_commande_deleted.php
  12. +3
    -2
      producer/controllers/CommandeController.php

+ 21
- 13
backend/controllers/CommandeController.php Ver arquivo



$commandes = Commande::findBy([ $commandes = Commande::findBy([
'date' => $date, 'date' => $date,
'date_delete' => 'NULL',
'id_etablissement' => $id_etablissement, 'id_etablissement' => $id_etablissement,
'orderby' => 'commentaire_point_vente ASC, user.nom ASC' 'orderby' => 'commentaire_point_vente ASC, user.nom ASC'
]); ]);


// commandes // commandes
$commandes = Commande::findBy([ $commandes = Commande::findBy([
'date' => $date
]);
'date' => $date,
'date_delete' => 'NULL'
]);


$recettes = 0; $recettes = 0;
$recettes_pain = 0; $recettes_pain = 0;


foreach ($commandes as $c) { foreach ($commandes as $c) {
$c->init(); $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 = number_format($recettes, 2);
$recettes_pain = number_format($recettes_pain, 2); $recettes_pain = number_format($recettes_pain, 2);


// commandes // commandes
$commandes = Commande::find() $commandes = Commande::find()
->with('commandeProduits', 'user')
->with('commandeProduits','commandeProduits.produit', 'user')
->joinWith('production') ->joinWith('production')
->where(['production.date' => $date]) ->where(['production.date' => $date])
->andWhere(['production.id_etablissement' => Yii::$app->user->identity->id_etablissement]) ->andWhere(['production.id_etablissement' => Yii::$app->user->identity->id_etablissement])
$poids_pain = 0; $poids_pain = 0;
foreach ($commandes as $c) { foreach ($commandes as $c) {
$c->init(); $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 // produits selec pour production

+ 4
- 0
backend/views/commande/index.php Ver arquivo

<?php else: ?> <?php else: ?>
<?= Html::encode($c->username); ?> <?= Html::encode($c->username); ?>
<?php endif; ?> <?php endif; ?>
<?php if(!is_null($c->date_delete)): ?>
(<span class="glyphicon glyphicon-remove"></span> Annulée)
<?php endif; ?>
</span> </span>
<?php if (strlen($c->commentaire)): ?> <?php if (strlen($c->commentaire)): ?>

+ 2
- 7
backend/views/site/index.php Ver arquivo

</thead> </thead>
<tbody> <tbody>
<?php foreach($commandes as $c): ?> <?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="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"> <td class="date">
<div class="bloc-date"> <div class="bloc-date">
<div class="jour"><?= strftime('%A', strtotime($c->production->date)) ?></div> <div class="jour"><?= strftime('%A', strtotime($c->production->date)) ?></div>

+ 4
- 2
backend/views/user/commandes.php Ver arquivo

<?php if(count($commandes)): ?> <?php if(count($commandes)): ?>
<table id="historique-commandes" class="table table-striped table-bordered"> <table id="historique-commandes" class="table table-striped table-bordered">
<thead> <thead>
<tr>
<tr>
<th>Historique</th>
<th>Date livraison</th> <th>Date livraison</th>
<th>Résumé</th> <th>Résumé</th>
<th>Point de vente</th> <th>Point de vente</th>
</thead> </thead>
<tbody> <tbody>
<?php foreach($commandes as $c): ?> <?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><?php echo date('d/m/Y',strtotime($c->production->date)); ?></td>
<td class="resume"><?= $c->getResumePanier() ; ?></td> <td class="resume"><?= $c->getResumePanier() ; ?></td>
<td><?= $c->getResumePointVente(); ?></td> <td><?= $c->getResumePointVente(); ?></td>

+ 3
- 2
backend/views/user/index.php Ver arquivo

<?php
0<?php


use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
$count_commandes = Commande::find() $count_commandes = Commande::find()
->joinWith('production') ->joinWith('production')
->where([ ->where([
'id_user' => $model['user_id'],
'id_user' => $model['user_id'],
'production.id_etablissement' => Yii::$app->user->identity->id_etablissement]) 'production.id_etablissement' => Yii::$app->user->identity->id_etablissement])
->andWhere('date_delete IS NULL')
->count() ; ->count() ;
$html = '' ; $html = '' ;
if($count_commandes) if($count_commandes)

BIN
backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc Ver arquivo


+ 208
- 199
backend/web/css/screen.css
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 60
- 43
backend/web/sass/screen.scss Ver arquivo

} }
} }


// 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 { tr.commande-update {
td { td {
background-color: $color2 ; 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 { td.historique {
.small { .small {
margin-bottom: 7px ; margin-bottom: 7px ;
} }
strong { 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 { .date {
text-align: center ; text-align: center ;
.bloc-date { .bloc-date {
width: 50% ; width: 50% ;
margin: 0px auto ; margin: 0px auto ;
padding-top: 0px ; padding-top: 0px ;
} }
.jour { .jour {
text-transform: capitalize ; text-transform: capitalize ;
line-height: 13px ; line-height: 13px ;
font-size: 10px ; font-size: 10px ;
text-transform: uppercase ; text-transform: uppercase ;
} }
.num { .num {
font-size: 23px ; font-size: 23px ;
line-height: 28px ; line-height: 28px ;
font-weight: bold ; font-weight: bold ;
} }
.mois { .mois {
text-transform: uppercase ; text-transform: uppercase ;
line-height: 13px ; line-height: 13px ;
} }
} }
} }
}

// 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 { #facturation {
h2 { h2 {

+ 46
- 3
common/models/Commande.php Ver arquivo

foreach ($this->commandeProduits as $p) { foreach ($this->commandeProduits as $p) {
if ($p->mode_vente == 'unite') { if ($p->mode_vente == 'unite') {
$this->montant_pain += $p->prix * $p->quantite; $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') { } elseif ($p->mode_vente == 'poids') {
$this->montant_pain += $p->prix * $p->quantite / 1000; $this->montant_pain += $p->prix * $p->quantite / 1000;
} }


if (isset($commandes) && is_array($commandes) && count($commandes)) { if (isset($commandes) && is_array($commandes) && count($commandes)) {
foreach ($commandes as $c) { 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;
}
} }
} }
} }
return $str; 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' ;
}
} }

+ 3
- 1
common/models/PointVente.php Ver arquivo

if ($this->id == $c->id_point_vente) { if ($this->id == $c->id_point_vente) {
$this->commandes[] = $c; $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_pain += (float) $c->montant_pain;
$this->recettes_vrac += (float) $c->montant_vrac; $this->recettes_vrac += (float) $c->montant_vrac;
} }

+ 16
- 0
console/migrations/m181107_104051_add_champs_commande_deleted.php Ver arquivo

<?php

use yii\db\Migration;

class m181107_104051_add_champs_commande_deleted extends Migration
{
public function up()
{
$this->addColumn('commande', 'date_delete', Schema::TYPE_DATETIME.' DEFAULT NULL') ;
}

public function down()
{
$this->dropColumn('commande', 'date_delete') ;
}
}

+ 3
- 2
producer/controllers/CommandeController.php Ver arquivo

'id_user' => Yii::$app->user->id, 'id_user' => Yii::$app->user->id,
'production.id_etablissement' => $this->getProducer()->id 'production.id_etablissement' => $this->getProducer()->id
]) ])
->andWhere('date_delete IS NULL')
->orderBy('production.date DESC'), ->orderBy('production.date DESC'),
'pagination' => [ 'pagination' => [
'pageSize' => 10, 'pageSize' => 10,
); );
} }
// delete // 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.') ; Yii::$app->session->setFlash('success','Votre commande a bien été annulée.') ;
} }

Carregando…
Cancelar
Salvar