Browse Source

Merge branch 'fix/montant_pain' into dev

refactoring
Guillaume Bourgeois 6 years ago
parent
commit
974e446a1e
11 changed files with 21 additions and 53 deletions
  1. +9
    -19
      backend/controllers/CommandeController.php
  2. +1
    -1
      backend/controllers/StatsController.php
  3. +1
    -1
      backend/views/commande/_total_commandes.php
  4. +2
    -2
      backend/views/commande/index.php
  5. +1
    -1
      common/models/Commande.php
  6. +7
    -9
      common/models/Etablissement.php
  7. +0
    -4
      common/models/PointVente.php
  8. +0
    -9
      producer/controllers/CommandeController.php
  9. +0
    -5
      producer/views/commande/_liste_etablissements.php
  10. +0
    -1
      producer/views/commande/create.php
  11. +0
    -1
      producer/views/commande/update.php

+ 9
- 19
backend/controllers/CommandeController.php View File

]); ]);


$recettes = 0; $recettes = 0;
$recettes_pain = 0;
$recettes_vrac = 0;
$recettes_pain_livre = 0;
$poids_pain = 0;
$poids_vrac = 0;
$poids = 0 ;
$recettes_livre = 0;


foreach ($commandes as $c) { foreach ($commandes as $c) {
$c->init(); $c->init();
if(is_null($c->date_delete)) { if(is_null($c->date_delete)) {
$recettes += $c->montant; $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 ($c->id_point_vente != 1) {
$recettes_livre += $c->montant;
}
$poids += $c->poids;
} }
} }
$recettes = number_format($recettes, 2); $recettes = number_format($recettes, 2);
$recettes_pain = number_format($recettes_pain, 2);
$recettes_vrac = number_format($recettes_vrac, 2);


// init commandes point de vente // init commandes point de vente
foreach ($points_vente as $pv) { foreach ($points_vente as $pv) {
'produits_selec' => $produits_selec, 'produits_selec' => $produits_selec,
'users' => $arr_users, 'users' => $arr_users,
'recettes' => $recettes, 'recettes' => $recettes,
'recettes_pain' => $recettes_pain,
'recettes_vrac' => $recettes_vrac,
'recettes_pain_livre' => $recettes_pain_livre,
'poids_pain' => $poids_pain,
'poids_vrac' => $poids_vrac,
'recettes_livre' => $recettes_livre,
'poids' => $poids,
'ca_potentiel' => $ca_potentiel, 'ca_potentiel' => $ca_potentiel,
'poids_total' => $poids_total, 'poids_total' => $poids_total,
'model_commande_auto' => $model_commande_auto, 'model_commande_auto' => $model_commande_auto,

+ 1
- 1
backend/controllers/StatsController.php View File

$c->init(); $c->init();
$mois = date('m/Y', strtotime($c->production->date)); $mois = date('m/Y', strtotime($c->production->date));
if (isset($data_pain[$mois])) { if (isset($data_pain[$mois])) {
$data_pain[$mois] += $c->montant_pain;
$data_pain[$mois] += $c->montant;
} }
} }



+ 1
- 1
backend/views/commande/_total_commandes.php View File

<div class="panel-body"> <div class="panel-body">
<div class="alert alert-warning"> <div class="alert alert-warning">
<strong>Potentiel :</strong> <?= number_format($ca_potentiel,2); ?> € (<?= $poids_total ?> kg) &bull; <strong>Potentiel :</strong> <?= number_format($ca_potentiel,2); ?> € (<?= $poids_total ?> kg) &bull;
<strong>Commandé :</strong> <?= number_format($recettes_pain,2); ?> € (<?= $poids_pain ?> kg)
<strong>Commandé :</strong> <?= number_format($recettes,2); ?> € (<?= $poids ?> kg)
</div> </div>


<table class="table table-bordered tab-content table-produits table-header-rotated"> <table class="table table-bordered tab-content table-produits table-header-rotated">

+ 2
- 2
backend/views/commande/index.php View File

'produits' => $produits, 'produits' => $produits,
'commandes' => $commandes, 'commandes' => $commandes,
'produits_selec' => $produits_selec, 'produits_selec' => $produits_selec,
'recettes_pain' => $recettes_pain,
'poids_pain' => $poids_pain,
'recettes' => $recettes,
'poids' => $poids,
'ca_potentiel' => $ca_potentiel, 'ca_potentiel' => $ca_potentiel,
'poids_total' => $poids_total, 'poids_total' => $poids_total,
]); ?> ]); ?>

+ 1
- 1
common/models/Commande.php View File

$json_commande = [ $json_commande = [
'produits' => [], 'produits' => [],
'montant' => $commande->montant, 'montant' => $commande->montant,
'str_montant' => $commande->getMontantFormat(),
'str_montant' => $commande->getMontant(true),
'montant_paye' => $commande->getMontantPaye(), 'montant_paye' => $commande->getMontantPaye(),
'commentaire' => $commande->commentaire, 'commentaire' => $commande->commentaire,
]; ];

+ 7
- 9
common/models/Etablissement.php View File

$data_etablissements_dispos = []; $data_etablissements_dispos = [];
$options_etablissements_dispos = []; $options_etablissements_dispos = [];
foreach ($etablissements_dispos as $e) { foreach ($etablissements_dispos as $e) {
if ($e->etatPaiement() == self::PAIEMENT_OK || $e->etatPaiement() == self::PAIEMENT_ESSAI) {
if (!key_exists('d' . substr($e->code_postal, 0, 2), $data_etablissements_dispos)) {
$data_etablissements_dispos['d' . substr($e->code_postal, 0, 2)] = '<strong>' . $departements[substr($e->code_postal, 0, 2)] . '</strong>';
$options_etablissements_dispos['d' . substr($e->code_postal, 0, 2)] = ['disabled' => true];
}
if (!key_exists('d' . substr($e->code_postal, 0, 2), $data_etablissements_dispos)) {
$data_etablissements_dispos['d' . substr($e->code_postal, 0, 2)] = '<strong>' . $departements[substr($e->code_postal, 0, 2)] . '</strong>';
$options_etablissements_dispos['d' . substr($e->code_postal, 0, 2)] = ['disabled' => true];
}


$data_etablissements_dispos[$e->id] = '<span class="glyphicon glyphicon-lock"></span> ' . Html::encode($e->nom) . ' - ' . Html::encode($e->code_postal) . ' ' . Html::encode($e->ville) . ' <span class="glyphicon glyphicon-lock"></span>';
$data_etablissements_dispos[$e->id] = '<span class="glyphicon glyphicon-lock"></span> ' . Html::encode($e->nom) . ' - ' . Html::encode($e->code_postal) . ' ' . Html::encode($e->ville) . ' <span class="glyphicon glyphicon-lock"></span>';


if (strlen($e->code))
$options_etablissements_dispos[$e->id] = ['class' => 'lock'];
}
if (strlen($e->code))
$options_etablissements_dispos[$e->id] = ['class' => 'lock'];
} }


return ['data' => $data_etablissements_dispos, 'options' => $options_etablissements_dispos]; return ['data' => $data_etablissements_dispos, 'options' => $options_etablissements_dispos];

+ 0
- 4
common/models/PointVente.php View File

{ {
$this->commandes = []; $this->commandes = [];
$this->recettes = 0; $this->recettes = 0;
$this->recettes_pain = 0;
$this->recettes_vrac = 0;


foreach ($commandes as $c) { foreach ($commandes as $c) {
if ($this->id == $c->id_point_vente) { if ($this->id == $c->id_point_vente) {
if(is_null($c->date_delete)) { if(is_null($c->date_delete)) {
$this->recettes += (float) $c->montant; $this->recettes += (float) $c->montant;
} }
$this->recettes_pain += (float) $c->montant_pain;
$this->recettes_vrac += (float) $c->montant_vrac;
} }
} }
} }

+ 0
- 9
producer/controllers/CommandeController.php View File

$etablissements = Yii::$app->user->identity->getEtablissementsFavoris(); $etablissements = Yii::$app->user->identity->getEtablissementsFavoris();
$id_etablissement = $this->getProducer()->id; $id_etablissement = $this->getProducer()->id;


$etablissement_paiement_ok = false;
if ($id_etablissement) {
$etablissement = Etablissement::findOne($id_etablissement);
if ($etablissement->etatPaiement() == Etablissement::PAIEMENT_OK || $etablissement->etatPaiement() == Etablissement::PAIEMENT_ESSAI) {
$etablissement_paiement_ok = true;
}
}

// etablissement // etablissement
$etablissement = Etablissement::findOne($id_etablissement); $etablissement = Etablissement::findOne($id_etablissement);


'etablissements' => $etablissements, 'etablissements' => $etablissements,
'id_etablissement' => $id_etablissement, 'id_etablissement' => $id_etablissement,
'etablissement' => $etablissement, 'etablissement' => $etablissement,
'etablissement_paiement_ok' => $etablissement_paiement_ok,
'credit' => $credit 'credit' => $credit
]; ];
} }

+ 0
- 5
producer/views/commande/_liste_etablissements.php View File

<div class="liste-etablissements"> <div class="liste-etablissements">
<?php if(count($etablissements)): ?> <?php if(count($etablissements)): ?>
<?php if(isset($id_etablissement) && $id_etablissement &&
isset($etablissement_paiement_ok) && !$etablissement_paiement_ok): ?>
<div class="alert alert-warning">Ce producteur est désactivé.</div>
<?php endif; ?>
<?php foreach($etablissements as $e): ?> <?php foreach($etablissements as $e): ?>
<div class="col-md-6 boulangerie <?php if(isset($id_etablissement) && $e['id'] == $id_etablissement): ?>selected<?php endif; ?>"> <div class="col-md-6 boulangerie <?php if(isset($id_etablissement) && $e['id'] == $id_etablissement): ?>selected<?php endif; ?>">
<div class="panel panel-default"> <div class="panel panel-default">

+ 0
- 1
producer/views/commande/create.php View File

'etablissements' => $etablissements, 'etablissements' => $etablissements,
'id_etablissement' => $id_etablissement, 'id_etablissement' => $id_etablissement,
'etablissement' => $etablissement, 'etablissement' => $etablissement,
'etablissement_paiement_ok' => $etablissement_paiement_ok,
'credit' => $credit 'credit' => $credit
]) ?> ]) ?>



+ 0
- 1
producer/views/commande/update.php View File

'etablissements' => $etablissements, 'etablissements' => $etablissements,
'etablissement' => $etablissement, 'etablissement' => $etablissement,
'id_etablissement' => $id_etablissement, 'id_etablissement' => $id_etablissement,
'etablissement_paiement_ok' => $etablissement_paiement_ok,
'credit' => $credit 'credit' => $credit
]) ?> ]) ?>

Loading…
Cancel
Save