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.

преди 6 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. '<div class="horaires">' .
  95. '<div class="jour jour-1">' . (strlen($pv->horaires_lundi) ? nl2br(Html::encode($pv->horaires_lundi)) : 'Fermé') . '</div>' .
  96. '<div class="jour jour-2">' . (strlen($pv->horaires_mardi) ? nl2br(Html::encode($pv->horaires_mardi)) : 'Fermé') . '</div>' .
  97. '<div class="jour jour-3">' . (strlen($pv->horaires_mercredi) ? nl2br(Html::encode($pv->horaires_mercredi)) : 'Fermé') . '</div>' .
  98. '<div class="jour jour-4">' . (strlen($pv->horaires_jeudi) ? nl2br(Html::encode($pv->horaires_jeudi)) : 'Fermé') . '</div>' .
  99. '<div class="jour jour-5">' . (strlen($pv->horaires_vendredi) ? nl2br(Html::encode($pv->horaires_vendredi)) : 'Fermé') . '</div>' .
  100. '<div class="jour jour-6">' . (strlen($pv->horaires_samedi) ? nl2br(Html::encode($pv->horaires_samedi)) : 'Fermé') . '</div>' .
  101. '<div class="jour jour-0">' . (strlen($pv->horaires_dimanche) ? nl2br(Html::encode($pv->horaires_dimanche)) : 'Fermé') . '</div>' .
  102. '</div>'
  103. . $commentaire .
  104. '<input type="hidden" name="code_point_vente_'.$pv->id.'" value="'.$code.'" />'.
  105. '</div></li>';
  106. }
  107. ?>
  108. </ul>
  109. <div class="clr"></div>
  110. </div>
  111. <div id="produits">
  112. <h3 id="step-choix-produits"><span>Produits</span></h3>
  113. <?php // confiance ?>
  114. <input type="hidden" id="confiance" value="<?php echo (int) Yii::$app->user->identity->confiance; ?>" />
  115. <?php if (!Yii::$app->user->identity->confiance): ?>
  116. <div id="mess-limit-quantity" class="alert alert-warning"><strong>Attention,</strong> vous ne pouvez commander que 3 produits.</div>
  117. <?php endif; ?>
  118. <?php // erreur ?>
  119. <?php if (Yii::$app->session->getFlash('error')): ?>
  120. <div class="alert alert-danger"><div class="icon"></div><?= Yii::$app->session->getFlash('error'); ?></div>
  121. <?php endif; ?>
  122. <div id="pain">
  123. <div class="alert alert-warning indisponible">Pain indisponible pour ce point de vente</div>
  124. <table class="table table-bordered" id="table-produits">
  125. <thead>
  126. <tr>
  127. <th class="th-photo">Photo</th>
  128. <th class="produit">Produit</th>
  129. <th class="prix-unit">Prix unitaire</th>
  130. <th class="colonne-quantite">Quantité</th>
  131. <th class="total">Total</th>
  132. </tr>
  133. </thead>
  134. <tbody>
  135. <?php foreach ($produits as $p): ?>
  136. <?php
  137. $quantite = 0;
  138. if (isset($produits_selec[$p->id]))
  139. $quantite = $produits_selec[$p->id];
  140. ?>
  141. <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; ?>>
  142. <td class="td-photo">
  143. <?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; ?>
  144. </td>
  145. <td class="produit">
  146. <span class="nom"><?= Html::encode($p->nom); ?></span> - <span class="description"><?= Html::encode($p->getDescription()); ?></span><br />
  147. <span class="recette"><?= Html::encode($p->recette); ?></span>
  148. </td>
  149. <td class="prix-unit"><span class="prix"><?= number_format($p->prix, 2); ?></span> €</td>
  150. <td class="colonne-quantite">
  151. <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; ?>>
  152. <span class="input-group-btn">
  153. <button type="button" class="btn btn-default move-quantity moins">-</button>
  154. </span>
  155. <input type="text" value="<?php if (isset($produits_selec[$p->id])): echo $produits_selec[$p->id];
  156. else: ?>0<?php endif; ?>" readonly name="Produit[produit_<?php echo $p->id; ?>]" class="quantity form-control">
  157. <span class="input-group-btn">
  158. <button type="button" class="btn btn-default move-quantity plus">+</button>
  159. </span>
  160. </div>
  161. <div class="quantite-restante">Reste <span class="nb"><?php if (isset($produits_dispos[$p->id])): echo $produits_dispos[$p->id]['quantite_restante'] + $quantite;
  162. endif; ?></span> <?php echo Html::encode(strtolower($p->nom)); ?>(s)
  163. </div>
  164. <div class="epuise">Épuisé</div>
  165. </td>
  166. <td class="total"><strong></strong></td>
  167. </tr>
  168. <?php endforeach; ?>
  169. </tbody>
  170. <tfoot>
  171. <tr>
  172. <td></td>
  173. <td></td>
  174. <td></td>
  175. <!-- <td><strong><span id="total-commande">0</span> €</strong></td> -->
  176. <td id="total-commande"><strong></strong></td>
  177. </tr>
  178. </tfoot>
  179. </table>
  180. </div>
  181. </div>
  182. <?php if($id_etablissement): ?>
  183. <?php
  184. $etablissement = Etablissement::findOne($id_etablissement);
  185. ?>
  186. <div id="bar-fixed" class="<?php if($etablissement->credit_pain): ?>credit-pain<?php else: ?>no-credit-pain<?php endif; ?>">
  187. <div class="container">
  188. <?php if (isset($model->id)): ?>
  189. <a href="<?php echo Yii::$app->urlManager->createUrl(['commande/annuler', 'id' => $model->id]); ?>" class="btn btn-danger annuler-commande">Annuler ma commande</a>
  190. <?php endif; ?>
  191. <span id="total-commande-bottom"><span></span> €</span>
  192. <?= 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']) ?>
  193. <?php
  194. if($etablissement->credit_pain):
  195. $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>' ; ;
  196. ?>
  197. <div id="checkbox-credit-pain" >
  198. <?php if($credit || $model->getMontantPaye()): ?>
  199. <?= 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>']) ?>
  200. <?= Html::hiddenInput('montant_credit_pain', $credit, ['id' => 'montant-credit-pain']) ?>
  201. <?= Html::hiddenInput('str_montant_credit_pain', number_format($credit,2).' €', ['id' => 'str-montant-credit-pain']) ?>
  202. <?php else: ?>
  203. <div id="info-credit-vide">
  204. Votre compte Crédit Pain est vide <?= $lien_credit_pain ?>
  205. </div>
  206. <?php endif; ?>
  207. <div id="credit-pain-disabled">Le Crédit Pain est désactivé<br /> pour ce point de vente <?= $lien_credit_pain ?></div>
  208. </div>
  209. <div class="clr"></div>
  210. <?php endif; ?>
  211. <?= $form->field($model, 'commentaire')->textarea(['rows' => 3, 'placeholder' => 'Un commentaire ?'])->label(''); ?>
  212. <div id="bloc-valider-commande">
  213. <?= Html::submitButton('<span class="glyphicon glyphicon-ok"></span> Valider ma commande', ['class' => 'btn btn-primary valider-commande']) ?>
  214. </div>
  215. <?php endif; ?>
  216. </div>
  217. </div>
  218. <?php
  219. // id_etablissement
  220. endif; ?>
  221. <?php ActiveForm::end(); ?>
  222. <!-- modal code point de vente -->
  223. <div class="modal fade" id="modal-code" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  224. <div class="modal-dialog modal-lg" role="document">
  225. <div class="modal-content">
  226. <div class="modal-header">
  227. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  228. <h4 class="modal-title" id="myModalLabel">Code d'accès</h4>
  229. </div>
  230. <div class="modal-body">
  231. <div class="alert alert-warning">
  232. Ce point de vente nécessite un code d'accès.
  233. </div>
  234. <form action="index.php?r=commande/verif-code" method="post">
  235. <input type="hidden" value="" name="id_point_vente" id="id-point-vente" />
  236. <div class="form-group field-code required">
  237. <label class="control-label" for="code">Code d'accès :</label>
  238. <input type="password" class="form-control" id="code" name="code" />
  239. <p class="help-block help-block-error" style="display:none;">Code incorrect</p>
  240. </div>
  241. <div class="form-group">
  242. <button type="submit" class="btn btn-primary">Valider</button>
  243. </div>
  244. </form>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. </div><!-- commande-form -->