|
- <?php
-
- use yii\helpers\Html;
- use common\models\Commande;
- use common\models\User ;
- use yii\helpers\ArrayHelper ;
- use yii\widgets\ActiveForm;
-
- $this->title = 'Commande';
-
- $cpt_non_vrac = 0;
- foreach ($produits as $p) {
- if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) {
- if (!$p->vrac) {
- $cpt_non_vrac ++;
- }
- }
- }
- ?>
-
- <div id="page-commande">
-
- <div class="col-md-3" id="col-left">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">Calendrier</h3>
- </div>
- <div class="panel-body">
- <?php
- // chargement assets
- common\components\fullcalendar\FullcalendarWidget::widget();
- // --> lancement du js en manuel (via lechatdesnoisettes.js)
- ?>
- <div id="calendar"></div>
- </div>
-
- </div>
-
- <?php if ($date != ''): ?>
- <div id="bloc-production">
- <input type="hidden" id="date-production" value="<?= $date ?>" />
- <input type="hidden" id="id-production" value="<?= $production->id ?>" />
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">Production du <strong><?php echo date('d/m/Y', strtotime($date)); ?></strong></h3>
- </div>
- <div class="panel-body">
- <strong>Production</strong><br />
- <div class="btn-group" role="group">
- <a class="btn btn-default<?php if ($production->actif): ?> btn-success<?php endif; ?>" href="<?php echo Yii::$app->urlManager->createUrl(['commande/change-state', 'date' => $date, 'actif' => 1]); ?>">Activé</a>
- <a class="btn btn-default<?php if (!$production->actif): ?> btn-danger<?php endif; ?>" href="<?php echo Yii::$app->urlManager->createUrl(['commande/change-state', 'date' => $date, 'actif' => 0]); ?>">Désactivé</a>
- </div>
- <br />
- <br />
-
- <?php if ($production->actif): ?>
- <?php if($production->livraison && count($arr_productions_point_vente)): ?>
- <div id="productions-point-vente">
- <strong>Points de vente : </strong>
- <div class="checkbox-list">
- <?= Html::activeCheckboxList(
- $production_point_vente,
- 'productions_point_vente',
- $arr_productions_point_vente ,
- ['encode' => false, 'class' => '']) ?>
- </div>
- </div>
- <?php endif; ?>
- <?php endif; ?>
- </div>
- </div>
- </div>
- <?php endif; ?>
-
- <?php if ($production): ?>
- <div id="bloc-produits">
-
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">Produits</h3>
- </div>
- <div class="panel-body">
- <!-- produits sélectionnés -->
- <form id="produits-production" action="<?php echo Yii::$app->urlManager->createUrl(['commande/index', 'date' => $date]); ?>" method="post">
- <div class="overflow">
- <table class="table table-condensed">
- <thead>
- <tr>
- <th class="td-actif">Actif</th>
- <th class="td-produit">Produit</th>
- <th class="td-max">Max. <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="top" data-original-title="Quantité disponible à la commande. Laisser vide si vous ne souhaitez pas avoir de limite de commande. La valeur par défaut est configurable dans vos produits."></span></th>
- </tr>
- </thead>
- <tbody>
- <?php foreach ($produits as $p): ?>
- <tr<?php if ($p->vrac): ?> style="display:none;"<?php endif; ?> <?php if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?>class="active"<?php endif; ?>>
- <td class="td-actif"><input id="produit-<?php echo $p->id; ?>" name="Produit[<?php echo $p->id; ?>][actif]" type="checkbox" <?php if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?>checked="checked"<?php endif; ?> /></td>
- <td class="td-produit"><label for="produit-<?php echo $p->id; ?>"><?= Html::encode($p->nom) ?></label></td>
- <td class="td-max"><input class="quantite-max" name="Produit[<?php echo $p->id; ?>][quantite_max]" type="text" value="<?php if (isset($produits_selec[$p->id])) echo $produits_selec[$p->id]['quantite_max']; ?>" /></td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- </div>
- <input type="submit" name="valider_produit_selec" class="btn btn-default" value="Valider" />
- </form>
- </div>
- </div>
- </div>
- <?php endif; ?>
- </div>
-
-
- <div class="col-md-9" id="col-right">
- <input type="hidden" value="<?php echo $date; ?>" id="current-date" />
- <ul id="jours-production">
- <?php foreach ($jours_production as $j) : ?>
- <li><?php echo $j->date; ?></li>
- <?php endforeach; ?>
- </ul>
- <?php if ($date != ''): ?>
-
- <div id="bloc-totaux">
- <?= $this->render('_total_commandes.php',[
- 'produits' => $produits,
- 'commandes' => $commandes,
- 'produits_selec' => $produits_selec,
- 'recettes_pain' => $recettes_pain,
- 'poids_pain' => $poids_pain,
- 'ca_potentiel' => $ca_potentiel,
- 'poids_total' => $poids_total,
- ]); ?>
- </div>
-
-
- <?php
- $num_jour_semaine = date('w', strtotime($date));
- $arr_jour_semaine = [0 => 'dimanche', 1 => 'lundi', 2 => 'mardi', 3 => 'mercredi', 4 => 'jeudi', 5 => 'vendredi', 6 => 'samedi'];
- $champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine];
- ?>
-
- <div class="panel panel-default" id="panel-commandes">
- <div class="panel-heading">
- <h3 class="panel-title">
- Commandes
- <?php if (!count($commandes)): ?><span class="label label-danger">0</span>
- <?php else: ?><span class="label label-success"><?= count($commandes) ?></span>
- <?php endif; ?>
- <?php if (count($commandes)): ?>
- <a id="btn-export-commandes" class="btn btn-primary" href="<?php echo Yii::$app->urlManager->createUrl(['commande/report', 'date' => $date, 'id_point_vente' => 0, 'global' => 1]); ?>"><span class="glyphicon glyphicon-download-alt"></span> Exporter</a>
- <?php endif; ?>
- </h3>
- </div>
- <div class="panel-body">
-
- <div class="col-md-12">
-
- <div class="alert alert-danger" style="display:none;">Aucun point de vente activé</div>
-
- <!-- Nav tabs -->
- <ul id="tabs-points-vente" class="nav nav-tabs" role="tablist">
- <?php foreach($points_vente as $pv): ?>
- <li role="presentation" class="<?php if($pv->point_fabrication): ?>active<?php endif; ?>">
- <a href="#point-vente-<?= $pv->id ?>" id="btn-point-vente-<?= $pv->id ?>" aria-controls="point-vente-<?= $pv->id ?>" role="tab" data-toggle="tab"><?= Html::encode($pv->nom) ?> <span class="badge badge-<?php if(count($pv->commandes)): ?>success<?php else: ?>danger<?php endif; ?>"><?php echo count($pv->commandes); ?></span></a>
- </li>
- <?php endforeach; ?>
- </ul>
-
- <!-- Tab panes -->
- <div class="tab-content" id="commandes-points-vente">
- <?php foreach($points_vente as $pv): ?>
- <div role="tabpanel" data-id-pv="<?= $pv->id ?>" class="bloc-point-vente tab-pane <?php if($pv->point_fabrication): ?> active<?php endif; ?>" id="point-vente-<?= $pv->id ?>">
- <div class="col-md-12">
- <div class="alert alert-warning recap-pv <?php if(!count($pv->commandes)): ?>no-commande<?php endif; ?>">
- <?php if(count($pv->commandes)): ?>
- <strong class="commandes"><?= count($pv->commandes) ?> commande<?php if(count($pv->commandes) > 1): ?>s<?php endif; ?></strong>
- <span class="recettes"><?= number_format($pv->recettes, 2) ?> €</span>
- <?php else: ?>
- <strong class="commandes">Aucune commande</strong>
- <span class="recettes"></span>
- <?php endif; ?>
- </div>
-
- <ul class="liste-commandes btn-group-vertical<?php if(!count($pv->commandes)): ?> no-commande<?php endif; ?>">
- <?php foreach($pv->commandes as $c): ?>
- <li>
- <a href="javascript:void(0);" class="btn btn-default" data-pv-id="<?= $pv->id ?>" data-id-commande="<?= $c->id ?>" data-commande='<?= $pv->data_options_commandes[$c->id]['data-commande'] ?>' data-commentaire="<?= Html::encode($c->commentaire) ?>" data-date="<?= date('d/m à H:i',strtotime($c->date)); ?>">
- <span class="montant <?php if($c->montant_paye >= $c->montant): ?>paye<?php endif; ?>">
- <?= Html::encode(number_format($c->montant, 2)); ?> €
- <?php if($c->montant_paye - $c->montant > 0.01): ?><span class="glyphicon glyphicon-warning-sign"></span><?php endif; ?>
- </span>
- <span class="user">
- <?php if($c->type): ?>
- <?php if($c->type == Commande::TYPE_ADMIN): ?>
- <span class="label label-warning">vous</span>
- <?php elseif($c->type == Commande::TYPE_AUTO): ?>
- <span class="label label-default">auto</span>
- <?php elseif($c->type == Commande::TYPE_USER): ?>
- <span class="label label-success">client</span>
- <?php endif; ?>
- <?php endif; ?>
- <?php if(isset($c->user)): ?>
- <?= Html::encode($c->user->nom.' '.$c->user->prenom); ?>
- <?php else: ?>
- <?= Html::encode($c->username); ?>
- <?php endif; ?>
-
- </span>
- <?php if (strlen($c->commentaire)): ?>
- <span class="glyphicon glyphicon-comment"></span>
- <?php endif; ?>
- </a>
- </li>
- <?php endforeach; ?>
- </ul>
- <?= Html::a('<span class="glyphicon glyphicon-plus"></span> Créer une commande', 'javascript:void(0);', ['class' => 'btn btn-default creer-commande', 'data-pv-id' => $pv->id]) ?>
- </div>
-
- <div class="col-md-12 bloc-commande">
- <h2 class="title-user">
- <span class="buttons-edit-remove">
- <?= Html::a('<span class="glyphicon glyphicon-trash"></span> Supprimer', 'javascript:void(0);', ['class' => 'btn btn-default btn-remove']) ?>
- <?= Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', 'javascript:void(0);', ['class' => 'btn btn-default btn-edit']) ?>
- </span>
- <span class="buttons-save-cancel">
- <?= Html::a('<span class="glyphicon glyphicon-ok"></span> Sauvegarder', 'javascript:void(0);', ['class' => 'btn btn-primary btn-save']) ?>
- <?= Html::a('<span class="glyphicon glyphicon-remove"></span> Annuler', 'javascript:void(0);', ['class' => 'btn btn-default btn-cancel']) ?>
- </span>
- <span class="the-title"></span>
- <span class="choix-user">
- <?= Html::activeDropDownList(new User, 'id', ArrayHelper::map(User::find()->joinWith('userEtablissement')->where('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement)->andWhere('user_etablissement.actif = 1')->orderBy('user.nom ASC, user.prenom ASC')->all(), 'id', function($model, $defaultValue) {
- return $model['nom'].' '.$model['prenom'];
- }), ['prompt' => '--','class' => 'form-control user-id']) ?>
- OU <input type="text" class="form-control username" placeholder="Choisissez un nom" />
- </span>
- </h2>
- <div class="commentaire alert alert-info">
- </div>
- <textarea name="commentaire" class="form-control textarea-commentaire" placeholder="Commentaire"></textarea>
- <table class="table table-bordered table-condensed tab-content table-produits">
- <tbody>
- <?php foreach ($produits as $p): ?>
- <?php if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?>
- <tr class="produit-<?= $p->id ?>" data-id-produit="<?= $p->id ?>">
- <td class="td-commande"></td>
- <td class="td-produit"><?php echo Html::encode($p->getLibelleAdmin()); ?></td>
- </tr>
- <?php endif; ?>
- <?php endforeach; ?>
- <tr class="tr-total">
- <td class="td-total"></td>
- <td class="td-paiement"></td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- </div>
-
-
-
- </div>
- </div>
- <?php endif; ?>
- </div>
- </div>
|