]); | ]); | ||||
$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, |
$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; | |||||
} | } | ||||
} | } | ||||
<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) • | <strong>Potentiel :</strong> <?= number_format($ca_potentiel,2); ?> € (<?= $poids_total ?> kg) • | ||||
<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"> |
'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, | ||||
]); ?> | ]); ?> |
$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, | ||||
]; | ]; |
$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]; |
{ | { | ||||
$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; | |||||
} | } | ||||
} | } | ||||
} | } |
$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 | ||||
]; | ]; | ||||
} | } |
<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"> |
'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 | ||||
]) ?> | ]) ?> | ||||
'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 | ||||
]) ?> | ]) ?> | ||||