Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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