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.

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