You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

268 lines
18KB

  1. <?php
  2. use yii\helpers\Html;
  3. use common\models\Commande;
  4. use common\models\User ;
  5. use yii\helpers\ArrayHelper ;
  6. use yii\widgets\ActiveForm;
  7. $this->title = 'Commande';
  8. $cpt_non_vrac = 0;
  9. foreach ($produits as $p) {
  10. if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) {
  11. if (!$p->vrac) {
  12. $cpt_non_vrac ++;
  13. }
  14. }
  15. }
  16. ?>
  17. <div id="page-commande">
  18. <div class="col-md-3" id="col-left">
  19. <div class="panel panel-default">
  20. <div class="panel-heading">
  21. <h3 class="panel-title">Calendrier</h3>
  22. </div>
  23. <div class="panel-body">
  24. <?php
  25. // chargement assets
  26. common\components\fullcalendar\FullcalendarWidget::widget();
  27. // --> lancement du js en manuel (via lechatdesnoisettes.js)
  28. ?>
  29. <div id="calendar"></div>
  30. </div>
  31. </div>
  32. <?php if ($date != ''): ?>
  33. <div id="bloc-production">
  34. <input type="hidden" id="date-production" value="<?= $date ?>" />
  35. <input type="hidden" id="id-production" value="<?= $production->id ?>" />
  36. <div class="panel panel-default">
  37. <div class="panel-heading">
  38. <h3 class="panel-title">Production du <strong><?php echo date('d/m/Y', strtotime($date)); ?></strong></h3>
  39. </div>
  40. <div class="panel-body">
  41. <strong>Production</strong><br />
  42. <div class="btn-group" role="group">
  43. <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>
  44. <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>
  45. </div>
  46. <br />
  47. <br />
  48. <?php if ($production->actif): ?>
  49. <?php if($production->livraison && count($arr_productions_point_vente)): ?>
  50. <div id="productions-point-vente">
  51. <strong>Points de vente : </strong>
  52. <div class="checkbox-list">
  53. <?= Html::activeCheckboxList(
  54. $production_point_vente,
  55. 'productions_point_vente',
  56. $arr_productions_point_vente ,
  57. ['encode' => false, 'class' => '']) ?>
  58. </div>
  59. </div>
  60. <?php endif; ?>
  61. <?php endif; ?>
  62. </div>
  63. </div>
  64. </div>
  65. <?php endif; ?>
  66. <?php if ($production): ?>
  67. <div id="bloc-produits">
  68. <div class="panel panel-default">
  69. <div class="panel-heading">
  70. <h3 class="panel-title">Produits</h3>
  71. </div>
  72. <div class="panel-body">
  73. <!-- produits sélectionnés -->
  74. <form id="produits-production" action="<?php echo Yii::$app->urlManager->createUrl(['commande/index', 'date' => $date]); ?>" method="post">
  75. <div class="overflow">
  76. <table class="table table-condensed">
  77. <thead>
  78. <tr>
  79. <th class="td-actif">Actif</th>
  80. <th class="td-produit">Produit</th>
  81. <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>
  82. </tr>
  83. </thead>
  84. <tbody>
  85. <?php foreach ($produits as $p): ?>
  86. <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; ?>>
  87. <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>
  88. <td class="td-produit"><label for="produit-<?php echo $p->id; ?>"><?= Html::encode($p->nom) ?></label></td>
  89. <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>
  90. </tr>
  91. <?php endforeach; ?>
  92. </tbody>
  93. </table>
  94. </div>
  95. <input type="submit" name="valider_produit_selec" class="btn btn-default" value="Valider" />
  96. </form>
  97. </div>
  98. </div>
  99. </div>
  100. <?php endif; ?>
  101. </div>
  102. <div class="col-md-9" id="col-right">
  103. <input type="hidden" value="<?php echo $date; ?>" id="current-date" />
  104. <ul id="jours-production">
  105. <?php foreach ($jours_production as $j) : ?>
  106. <li><?php echo $j->date; ?></li>
  107. <?php endforeach; ?>
  108. </ul>
  109. <?php if ($date != ''): ?>
  110. <div id="bloc-totaux">
  111. <?= $this->render('_total_commandes.php',[
  112. 'produits' => $produits,
  113. 'commandes' => $commandes,
  114. 'produits_selec' => $produits_selec,
  115. 'recettes_pain' => $recettes_pain,
  116. 'poids_pain' => $poids_pain,
  117. 'ca_potentiel' => $ca_potentiel,
  118. 'poids_total' => $poids_total,
  119. ]); ?>
  120. </div>
  121. <?php
  122. $num_jour_semaine = date('w', strtotime($date));
  123. $arr_jour_semaine = [0 => 'dimanche', 1 => 'lundi', 2 => 'mardi', 3 => 'mercredi', 4 => 'jeudi', 5 => 'vendredi', 6 => 'samedi'];
  124. $champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine];
  125. ?>
  126. <div class="panel panel-default" id="panel-commandes">
  127. <div class="panel-heading">
  128. <h3 class="panel-title">
  129. Commandes
  130. <?php if (!count($commandes)): ?><span class="label label-danger">0</span>
  131. <?php else: ?><span class="label label-success"><?= count($commandes) ?></span>
  132. <?php endif; ?>
  133. <?php if (count($commandes)): ?>
  134. <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>
  135. <?php endif; ?>
  136. </h3>
  137. </div>
  138. <div class="panel-body">
  139. <div class="col-md-12">
  140. <div class="alert alert-danger" style="display:none;">Aucun point de vente activé</div>
  141. <!-- Nav tabs -->
  142. <ul id="tabs-points-vente" class="nav nav-tabs" role="tablist">
  143. <?php foreach($points_vente as $pv): ?>
  144. <li role="presentation" class="<?php if($pv->point_fabrication): ?>active<?php endif; ?>">
  145. <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>
  146. </li>
  147. <?php endforeach; ?>
  148. </ul>
  149. <!-- Tab panes -->
  150. <div class="tab-content" id="commandes-points-vente">
  151. <?php foreach($points_vente as $pv): ?>
  152. <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 ?>">
  153. <div class="col-md-12">
  154. <div class="alert alert-warning recap-pv <?php if(!count($pv->commandes)): ?>no-commande<?php endif; ?>">
  155. <?php if(count($pv->commandes)): ?>
  156. <strong class="commandes"><?= count($pv->commandes) ?> commande<?php if(count($pv->commandes) > 1): ?>s<?php endif; ?></strong>
  157. <span class="recettes"><?= number_format($pv->recettes, 2) ?> €</span>
  158. <?php else: ?>
  159. <strong class="commandes">Aucune commande</strong>
  160. <span class="recettes"></span>
  161. <?php endif; ?>
  162. </div>
  163. <ul class="liste-commandes btn-group-vertical<?php if(!count($pv->commandes)): ?> no-commande<?php endif; ?>">
  164. <?php foreach($pv->commandes as $c): ?>
  165. <li>
  166. <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)); ?>">
  167. <span class="montant <?php if($c->montant_paye >= $c->montant): ?>paye<?php endif; ?>">
  168. <?= Html::encode(number_format($c->montant, 2)); ?> €
  169. <?php if($c->montant_paye - $c->montant > 0.01): ?><span class="glyphicon glyphicon-warning-sign"></span><?php endif; ?>
  170. </span>
  171. <span class="user">
  172. <?php if($c->type): ?>
  173. <?php if($c->type == Commande::TYPE_ADMIN): ?>
  174. <span class="label label-warning">vous</span>
  175. <?php elseif($c->type == Commande::TYPE_AUTO): ?>
  176. <span class="label label-default">auto</span>
  177. <?php elseif($c->type == Commande::TYPE_USER): ?>
  178. <span class="label label-success">client</span>
  179. <?php endif; ?>
  180. <?php endif; ?>
  181. <?php if(isset($c->user)): ?>
  182. <?= Html::encode($c->user->nom.' '.$c->user->prenom); ?>
  183. <?php else: ?>
  184. <?= Html::encode($c->username); ?>
  185. <?php endif; ?>
  186. </span>
  187. <?php if (strlen($c->commentaire)): ?>
  188. <span class="glyphicon glyphicon-comment"></span>
  189. <?php endif; ?>
  190. </a>
  191. </li>
  192. <?php endforeach; ?>
  193. </ul>
  194. <?= 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]) ?>
  195. </div>
  196. <div class="col-md-12 bloc-commande">
  197. <h2 class="title-user">
  198. <span class="buttons-edit-remove">
  199. <?= Html::a('<span class="glyphicon glyphicon-trash"></span> Supprimer', 'javascript:void(0);', ['class' => 'btn btn-default btn-remove']) ?>
  200. <?= Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', 'javascript:void(0);', ['class' => 'btn btn-default btn-edit']) ?>
  201. </span>
  202. <span class="buttons-save-cancel">
  203. <?= Html::a('<span class="glyphicon glyphicon-ok"></span> Sauvegarder', 'javascript:void(0);', ['class' => 'btn btn-primary btn-save']) ?>
  204. <?= Html::a('<span class="glyphicon glyphicon-remove"></span> Annuler', 'javascript:void(0);', ['class' => 'btn btn-default btn-cancel']) ?>
  205. </span>
  206. <span class="the-title"></span>
  207. <span class="choix-user">
  208. <?= 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) {
  209. return $model['nom'].' '.$model['prenom'];
  210. }), ['prompt' => '--','class' => 'form-control user-id']) ?>
  211. OU <input type="text" class="form-control username" placeholder="Choisissez un nom" />
  212. </span>
  213. </h2>
  214. <div class="commentaire alert alert-info">
  215. </div>
  216. <textarea name="commentaire" class="form-control textarea-commentaire" placeholder="Commentaire"></textarea>
  217. <table class="table table-bordered table-condensed tab-content table-produits">
  218. <tbody>
  219. <?php foreach ($produits as $p): ?>
  220. <?php if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?>
  221. <tr class="produit-<?= $p->id ?>" data-id-produit="<?= $p->id ?>">
  222. <td class="td-commande"></td>
  223. <td class="td-produit"><?php echo Html::encode($p->getLibelleAdmin()); ?></td>
  224. </tr>
  225. <?php endif; ?>
  226. <?php endforeach; ?>
  227. <tr class="tr-total">
  228. <td class="td-total"></td>
  229. <td class="td-paiement"></td>
  230. </tr>
  231. </tbody>
  232. </table>
  233. </div>
  234. </div>
  235. <?php endforeach; ?>
  236. </div>
  237. </div>
  238. </div>
  239. </div>
  240. <?php endif; ?>
  241. </div>
  242. </div>