Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <?php
  2. use yii\widgets\ActiveForm;
  3. ?>
  4. <div class="commande-form">
  5. <?php
  6. $form = ActiveForm::begin([
  7. 'enableClientScript' => false
  8. ]);
  9. ?>
  10. <?php
  11. if(count($jours_production) <= 1) :
  12. ?>
  13. <div class="alert alert-warning">Aucun jour de production n'a été programmé par le producteur.</div>
  14. <?php endif; ?>
  15. <?php if($id_etablissement && count($jours_production) > 1): ?>
  16. <div id="step-choix-date" class="col-md-6">
  17. <?= $form->field($model, 'id_production')->label('')->hiddenInput(); ?>
  18. <?php if (isset($model->id)): ?>
  19. <div class="date-commande"><span><?php echo date('d/m/Y', strtotime($production->date)); ?></span></div>
  20. <?= Html::hiddenInput('id_commande', $model->id,['id'=>'id-commande']); ?>
  21. <?= Html::hiddenInput('montant_paye', $model->getMontantPaye(),['id'=>'montant-paye']); ?>
  22. <?php endif; ?>
  23. <div id="datepicker-production" <?php if (isset($model->id)): ?>style="display:none"<?php endif; ?>>
  24. </div>
  25. <?php if (!isset($model->id)): ?>
  26. <br />
  27. <?php endif; ?>
  28. <div id="dates" style="display:none;">
  29. <?php
  30. foreach ($jours_production as $id_production => $j) {
  31. if ($j != '--') {
  32. echo '<div><span class="date">' . $j . '</span><span class="id_production">' . $id_production . '</span></div>';
  33. }
  34. }
  35. ?>
  36. </div>
  37. <div class="clr"></div>
  38. <div id="commandes-en-cours" style="display:none;">
  39. <?php foreach ($commandes_en_cours as $c): ?>
  40. <?php echo '<div class="commande" data-idproduction="' . $c->id_production . '" data-id="' . $c->id . '" data-href="' . Yii::$app->urlManager->createUrl(['commande/update', 'id' => $c->id, 'id_etablissement' => $c->production->id_etablissement]) . '"></div>'; ?>
  41. <?php endforeach; ?>
  42. </div>
  43. <div id="has-commande-en-cours" style="display:none;" class="alert alert-danger">Vous avez déjà une commande en cours pour cette date. <a href="#">Cliquez ici</a> pour la modifier.</div>
  44. </div>
  45. <div class="col-md-6">
  46. <?php if(strlen($etablissement->infos_commande)): ?>
  47. <div id="infos-commande">
  48. <?= nl2br(Html::encode($etablissement->infos_commande)) ?>
  49. </div>
  50. <?php endif; ?>
  51. </div>
  52. <div class="clr"></div>
  53. <div id="depots">
  54. <h3 id="step-choix-depot"><span>Points de vente</span></h3>
  55. <?=
  56. $form->field($model, 'id_point_vente')
  57. ->label('')
  58. ->hiddenInput();
  59. //->dropDownList($points_vente) ;
  60. ?>
  61. <input type="hidden" id="livraison" value="<?php if (!is_null($production) && $production->livraison): ?>1<?php else: ?>0<?php endif; ?>" />
  62. <ul id="points-vente" class="blocs">
  63. <?php
  64. foreach ($points_vente as $pv) {
  65. $commentaire = '' ;
  66. if(isset($pv->pointVenteUser) && is_array($pv->pointVenteUser) && count($pv->pointVenteUser))
  67. {
  68. foreach($pv->pointVenteUser as $pvu)
  69. {
  70. if($pvu->id_user == Yii::$app->user->identity->id && strlen($pvu->commentaire))
  71. {
  72. $commentaire = '<div class="commentaire"><span>'.Html::encode($pvu->commentaire).'</span></div>' ;
  73. }
  74. }
  75. }
  76. $html_code = '' ;
  77. $data_code = '0' ;
  78. $code = '' ;
  79. if(strlen($pv->code))
  80. {
  81. if(!isset($model->id_point_vente) || $model->id_point_vente != $pv->id)
  82. {
  83. $html_code .= '<span class="glyphicon glyphicon-lock"></span> ' ;
  84. $data_code = '1' ;
  85. }
  86. else {
  87. $code = $pv->code ;
  88. }
  89. }
  90. echo '<li class="bloc point-vente point-vente-' . $pv->id . '" data-code="'.$data_code.'" data-vrac="' . (int) $pv->vrac . '" data-pain="' . (int) $pv->pain . '" data-credit-pain="'.(int) $pv->credit_pain.'"><div class="contenu">' .
  91. '<span style="display:none;" class="id">' . $pv->id . '</span>' .
  92. '<div class="nom">' .$html_code. Html::encode($pv->nom) . '</div>' .
  93. '<div class="adresse">à ' . Html::encode($pv->localite) . '</div>' .
  94. $commentaire .
  95. '<input type="hidden" name="code_point_vente_'.$pv->id.'" value="'.$code.'" />'.
  96. '</div></li>';
  97. }
  98. ?>
  99. </ul>
  100. <div class="clr"></div>
  101. <div id="step-infos-pv">
  102. <?php
  103. foreach ($points_vente as $pv) {
  104. echo '<div class="alert alert-warning infos-pv infos-pv-'.$pv->id.'"><h4>Infos : <span>'.Html::encode($pv->nom).'</span></h4>' .
  105. '<div class="jour jour-1">' . $pv->strInfos('lundi') . '</div>' .
  106. '<div class="jour jour-2">' . $pv->strInfos('mardi') . '</div>' .
  107. '<div class="jour jour-3">' . $pv->strInfos('mercredi') . '</div>' .
  108. '<div class="jour jour-4">' . $pv->strInfos('jeudi') . '</div>' .
  109. '<div class="jour jour-5">' . $pv->strInfos('vendredi') . '</div>' .
  110. '<div class="jour jour-6">' . $pv->strInfos('samedi') . '</div>' .
  111. '<div class="jour jour-0">' . $pv->strInfos('dimanche') . '</div>' .
  112. '</div>' ;
  113. }
  114. ?>
  115. </div>
  116. <div class="clr"></div>
  117. </div>
  118. <div id="produits">
  119. <h3 id="step-choix-produits"><span>Produits</span></h3>
  120. <?php // confiance ?>
  121. <input type="hidden" id="confiance" value="<?php echo (int) Yii::$app->user->identity->confiance; ?>" />
  122. <?php if (!Yii::$app->user->identity->confiance): ?>
  123. <div id="mess-limit-quantity" class="alert alert-warning"><strong>Attention,</strong> vous ne pouvez commander que 3 produits.</div>
  124. <?php endif; ?>
  125. <?php // erreur ?>
  126. <?php if (Yii::$app->session->getFlash('error')): ?>
  127. <div class="alert alert-danger"><div class="icon"></div><?= Yii::$app->session->getFlash('error'); ?></div>
  128. <?php endif; ?>
  129. <div id="pain">
  130. <div class="alert alert-warning indisponible">Pain indisponible pour ce point de vente</div>
  131. <table class="table table-bordered" id="table-produits">
  132. <thead>
  133. <tr>
  134. <th class="th-photo">Photo</th>
  135. <th class="produit">Produit</th>
  136. <th class="prix-unit">Prix unitaire</th>
  137. <th class="colonne-quantite">Quantité</th>
  138. <th class="total">Total</th>
  139. </tr>
  140. </thead>
  141. <tbody>
  142. <?php foreach ($produits as $p): ?>
  143. <?php
  144. $quantite = 0;
  145. if (isset($produits_selec[$p->id]))
  146. $quantite = $produits_selec[$p->id];
  147. ?>
  148. <tr class="produit-<?php echo $p->id; ?>" data-no-limit="<?php if(!$p->quantite_max): ?>1<?php else: ?>0<?php endif; ?>" data-quantite-max="<?= $quantite ?>" <?php if (count($produits_dispos) && !$produits_dispos[$p->id]['actif']): ?>style="display:none;"<?php endif; ?>>
  149. <td class="td-photo">
  150. <?php if (strlen($p->photo) && file_exists(dirname(__FILE__).'/../../web/uploads/' . $p->photo)): ?><a href="<?= Yii::$app->urlManager->getBaseUrl() . '/uploads/' . $p->photo ?>" data-lightbox="produit-<?php echo $p->id; ?>"><img class="photo img-rounded" src="<?= Yii::$app->urlManager->getBaseUrl() . '/uploads/' . $p->photo ?>" alt="Photo <?= Html::encode($p->nom); ?>" /></a><?php endif; ?>
  151. </td>
  152. <td class="produit">
  153. <span class="nom"><?= Html::encode($p->nom); ?></span> - <span class="description"><?= Html::encode($p->getDescription()); ?></span><br />
  154. <span class="recette"><?= Html::encode($p->recette); ?></span>
  155. </td>
  156. <td class="prix-unit"><span class="prix"><?= number_format($p->prix, 2); ?></span> €</td>
  157. <td class="colonne-quantite">
  158. <div class="input-group" <?php if (isset($produits_dispos[$p->id]) && $produits_dispos[$p->id]['quantite_restante'] == 0 && $quantite == 0): ?>style="display:none;"<?php endif; ?>>
  159. <span class="input-group-btn">
  160. <button type="button" class="btn btn-default move-quantity moins">-</button>
  161. </span>
  162. <input type="text" value="<?php if (isset($produits_selec[$p->id])): echo $produits_selec[$p->id];
  163. else: ?>0<?php endif; ?>" readonly name="Produit[produit_<?php echo $p->id; ?>]" class="quantity form-control">
  164. <span class="input-group-btn">
  165. <button type="button" class="btn btn-default move-quantity plus">+</button>
  166. </span>
  167. </div>
  168. <div class="quantite-restante">Reste <span class="nb"><?php if (isset($produits_dispos[$p->id])): echo $produits_dispos[$p->id]['quantite_restante'] + $quantite;
  169. endif; ?></span> <?php echo Html::encode(strtolower($p->nom)); ?>(s)
  170. </div>
  171. <div class="epuise">Épuisé</div>
  172. </td>
  173. <td class="total"><strong></strong></td>
  174. </tr>
  175. <?php endforeach; ?>
  176. </tbody>
  177. <tfoot>
  178. <tr>
  179. <td></td>
  180. <td></td>
  181. <td></td>
  182. <!-- <td><strong><span id="total-commande">0</span> €</strong></td> -->
  183. <td id="total-commande"><strong></strong></td>
  184. </tr>
  185. </tfoot>
  186. </table>
  187. </div>
  188. </div>
  189. <?php if($id_etablissement): ?>
  190. <?php
  191. $etablissement = Etablissement::findOne($id_etablissement);
  192. ?>
  193. <div id="bar-fixed" class="<?php if($etablissement->credit_pain): ?>credit-pain<?php else: ?>no-credit-pain<?php endif; ?>">
  194. <div class="container">
  195. <?php if (isset($model->id)): ?>
  196. <a href="<?php echo Yii::$app->urlManager->createUrl(['commande/annuler', 'id' => $model->id]); ?>" class="btn btn-danger annuler-commande">Annuler ma commande</a>
  197. <?php endif; ?>
  198. <span id="total-commande-bottom"><span></span> €</span>
  199. <?= Html::submitButton('<span class="glyphicon glyphicon-comment"></span> Commentaire', ['class' => 'btn btn-default btn-commentaire', 'data-placement' => 'top', 'data-toggle' => 'tooltip', 'data-original-title' => 'Ajouter un commentaire']) ?>
  200. <?php
  201. if($etablissement->credit_pain):
  202. $lien_credit_pain = '<a class="info-credit-pain" href="'.Yii::$app->urlManager->createUrl(['site/creditpain']) .'" data-toggle="tooltip" data-placement="bottom" title="En savoir plus sur le Crédit Pain"><span class="glyphicon glyphicon-info-sign"></span></a>' ; ;
  203. ?>
  204. <div id="checkbox-credit-pain" >
  205. <?php if($credit || $model->getMontantPaye()): ?>
  206. <?= Html::checkbox('credit_pain', true, ['label' => 'Utiliser mon compte Crédit Pain <span class="the-credit" data-toggle="tooltip" data-placement="top" data-original-title="Vous avez actuellement '.number_format($credit,2).' € sur votre compte Crédit Pain">'.number_format($credit,2).' €</span><br /><span class="info"></span>']) ?>
  207. <?= Html::hiddenInput('montant_credit_pain', $credit, ['id' => 'montant-credit-pain']) ?>
  208. <?= Html::hiddenInput('str_montant_credit_pain', number_format($credit,2).' €', ['id' => 'str-montant-credit-pain']) ?>
  209. <?php else: ?>
  210. <div id="info-credit-vide">
  211. Votre compte Crédit Pain est vide <?= $lien_credit_pain ?>
  212. </div>
  213. <?php endif; ?>
  214. <div id="credit-pain-disabled">Le Crédit Pain est désactivé<br /> pour ce point de vente <?= $lien_credit_pain ?></div>
  215. </div>
  216. <div class="clr"></div>
  217. <?php endif; ?>
  218. <?= $form->field($model, 'commentaire')->textarea(['rows' => 3, 'placeholder' => 'Un commentaire ?'])->label(''); ?>
  219. <div id="bloc-valider-commande">
  220. <?= Html::submitButton('<span class="glyphicon glyphicon-ok"></span> Valider ma commande', ['class' => 'btn btn-primary valider-commande']) ?>
  221. </div>
  222. <?php endif; ?>
  223. </div>
  224. </div>
  225. <?php
  226. // id_etablissement
  227. endif; ?>
  228. <?php ActiveForm::end(); ?>
  229. <!-- modal code point de vente -->
  230. <div class="modal fade" id="modal-code" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  231. <div class="modal-dialog modal-lg" role="document">
  232. <div class="modal-content">
  233. <div class="modal-header">
  234. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  235. <h4 class="modal-title" id="myModalLabel">Code d'accès</h4>
  236. </div>
  237. <div class="modal-body">
  238. <div class="alert alert-warning">
  239. Ce point de vente nécessite un code d'accès.
  240. </div>
  241. <form action="index.php?r=commande/verif-code" method="post">
  242. <input type="hidden" value="" name="id_point_vente" id="id-point-vente" />
  243. <div class="form-group field-code required">
  244. <label class="control-label" for="code">Code d'accès :</label>
  245. <input type="password" class="form-control" id="code" name="code" />
  246. <p class="help-block help-block-error" style="display:none;">Code incorrect</p>
  247. </div>
  248. <div class="form-group">
  249. <button type="submit" class="btn btn-primary">Valider</button>
  250. </div>
  251. </form>
  252. </div>
  253. </div>
  254. </div>
  255. </div>
  256. </div><!-- commande-form -->