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.

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