Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

292 lines
19KB

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