Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

292 linhas
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->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. <div id="btn-commandes-auto" class="btn-group">
  149. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  150. <span class="glyphicon glyphicon-repeat"></span> Commandes récurrentes <span class="caret"></span>
  151. </button>
  152. <ul class="dropdown-menu">
  153. <li><a href="<?= Yii::$app->urlManager->createUrl(['commande/add-commandes-auto', 'date' => $date]); ?>">Importer toutes les commandes</a></li>
  154. </ul>
  155. </div>
  156. </h3>
  157. </div>
  158. <div class="panel-body">
  159. <div class="col-md-12">
  160. <div class="alert alert-danger" style="display:none;">Aucun point de vente activé</div>
  161. <!-- Nav tabs -->
  162. <ul id="tabs-points-vente" class="nav nav-tabs" role="tablist">
  163. <?php foreach($points_vente as $pv): ?>
  164. <li role="presentation" class="<?php if($pv->point_fabrication): ?>active<?php endif; ?>">
  165. <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>
  166. </li>
  167. <?php endforeach; ?>
  168. </ul>
  169. <!-- Tab panes -->
  170. <div class="tab-content" id="commandes-points-vente">
  171. <?php foreach($points_vente as $pv): ?>
  172. <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 ?>">
  173. <div class="col-md-12">
  174. <div class="alert alert-warning recap-pv <?php if(!count($pv->commandes)): ?>no-commande<?php endif; ?>">
  175. <?php if(count($pv->commandes)): ?>
  176. <strong class="commandes"><?= count($pv->commandes) ?> commande<?php if(count($pv->commandes) > 1): ?>s<?php endif; ?></strong>
  177. <span class="recettes"><?= number_format($pv->recettes, 2) ?> €</span>
  178. <?php else: ?>
  179. <strong class="commandes">Aucune commande</strong>
  180. <span class="recettes"></span>
  181. <?php endif; ?>
  182. </div>
  183. <ul class="liste-commandes btn-group-vertical<?php if(!count($pv->commandes)): ?> no-commande<?php endif; ?>">
  184. <?php foreach($pv->commandes as $c): ?>
  185. <li>
  186. <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)); ?>">
  187. <span class="montant <?php if(number_format($c->montant_paye,2) >= number_format($c->montant,2)): ?>paye<?php endif; ?>">
  188. <?= Html::encode(number_format($c->montant, 2)); ?> €
  189. <?php if($c->montant_paye - $c->montant > 0.01): ?><span class="glyphicon glyphicon-warning-sign"></span><?php endif; ?>
  190. </span>
  191. <span class="user">
  192. <?php if($c->type): ?>
  193. <?php if($c->type == Commande::TYPE_ADMIN): ?>
  194. <span class="label label-warning">vous</span>
  195. <?php elseif($c->type == Commande::TYPE_AUTO): ?>
  196. <span class="label label-default">auto</span>
  197. <?php elseif($c->type == Commande::TYPE_USER): ?>
  198. <span class="label label-success">client</span>
  199. <?php endif; ?>
  200. <?php endif; ?>
  201. <?php if(isset($c->user)): ?>
  202. <?= Html::encode($c->user->nom.' '.$c->user->prenom); ?>
  203. <?php else: ?>
  204. <?= Html::encode($c->username); ?>
  205. <?php endif; ?>
  206. </span>
  207. <?php if (strlen($c->commentaire)): ?>
  208. <span class="glyphicon glyphicon-comment"></span>
  209. <?php endif; ?>
  210. </a>
  211. </li>
  212. <?php endforeach; ?>
  213. </ul>
  214. <?= 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]) ?>
  215. </div>
  216. <div class="col-md-12 bloc-commande">
  217. <h2 class="title-user">
  218. <span class="buttons-edit-remove">
  219. <?= Html::a('<span class="glyphicon glyphicon-trash"></span> Supprimer', 'javascript:void(0);', ['class' => 'btn btn-default btn-remove']) ?>
  220. <?= Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', 'javascript:void(0);', ['class' => 'btn btn-default btn-edit']) ?>
  221. </span>
  222. <span class="buttons-save-cancel">
  223. <?= Html::a('<span class="glyphicon glyphicon-ok"></span> Sauvegarder', 'javascript:void(0);', ['class' => 'btn btn-primary btn-save']) ?>
  224. <?= Html::a('<span class="glyphicon glyphicon-remove"></span> Annuler', 'javascript:void(0);', ['class' => 'btn btn-default btn-cancel']) ?>
  225. </span>
  226. <span class="the-title"></span>
  227. <span class="choix-user">
  228. <?= 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) {
  229. return $model['nom'].' '.$model['prenom'];
  230. }), ['prompt' => '--','class' => 'form-control user-id']) ?>
  231. OU <input type="text" class="form-control username" placeholder="Choisissez un nom" />
  232. </span>
  233. </h2>
  234. <div class="commentaire alert alert-info">
  235. </div>
  236. <textarea name="commentaire" class="form-control textarea-commentaire" placeholder="Commentaire"></textarea>
  237. <table class="table table-bordered table-condensed tab-content table-produits">
  238. <tbody>
  239. <?php foreach ($produits as $p): ?>
  240. <?php if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?>
  241. <tr class="produit-<?= $p->id ?>" 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 endif; ?>
  246. <?php endforeach; ?>
  247. <tr class="tr-total">
  248. <td class="td-total"></td>
  249. <td class="td-paiement"></td>
  250. </tr>
  251. </tbody>
  252. </table>
  253. </div>
  254. </div>
  255. <?php endforeach; ?>
  256. </div>
  257. </div>
  258. </div>
  259. </div>
  260. <?php endif; ?>
  261. </div>
  262. </div>