選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

256 行
17KB

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