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.

_form.php 15KB

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