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.

155 lines
7.0KB

  1. <?php
  2. /* @var $this yii\web\View */
  3. use yii\helpers\Html;
  4. use yii\bootstrap\ActiveForm;
  5. use common\models\Commande ;
  6. $this->title = 'Commande' ;
  7. ?>
  8. <div id="index-commande">
  9. <h1 class="title-systeme-commande"><span class="glyphicon glyphicon-th-list"></span> Tableau de bord</h1>
  10. <h2>Boulangeries</h2>
  11. <?php if($commande_ok): ?>
  12. <div class="alert alert-success">
  13. <div class="icon"></div>
  14. Votre commande a bien été prise en compte.
  15. </div>
  16. <?php endif; ?>
  17. <?php if($annule_ok): ?>
  18. <div class="alert alert-success"><div class="icon"></div>Votre commande a bien été annulée.</div>
  19. <?php endif; ?>
  20. <div id="liste-boulangeries">
  21. <?=
  22. $this->render('_liste_etablissements.php',[
  23. 'etablissements' => $etablissements,
  24. 'context' => 'index'
  25. ]) ;
  26. ?>
  27. <div class="col-md-6" id="bloc-add-etablissement">
  28. <div class="panel panel-default">
  29. <div class="panel-heading">
  30. <h3 class="panel-title"><span class="glyphicon glyphicon-plus"></span> Ajouter une boulangerie</h3>
  31. </div>
  32. <div class="panel-body">
  33. <?php $form = ActiveForm::begin(['id' => 'form-add-boulanger','enableClientValidation'=> false]); ?>
  34. <?= $form->field($model_form_etablissement, 'id_etablissement')
  35. ->label('')
  36. ->dropDownList($data_etablissements_dispos,
  37. ['prompt' => '--',
  38. 'encode' => false,
  39. 'options' => $options_etablissements_dispos
  40. ]) ; ?>
  41. <div id="bloc-code-acces">
  42. <?= $form->field($model_form_etablissement, 'code',[
  43. 'inputTemplate' => '<div class="input-group"><span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>{input}</div>',
  44. ])
  45. ->label('Code')
  46. ->hint('Renseignez-vous auprès de votre boulangerie pour qu\'elle vous fournisse le code d\'accès') ; ?>
  47. </div>
  48. <?= Html::submitButton('<span class="glyphicon glyphicon-plus"></span> Valider', ['class' => 'btn btn-default', 'name' => 'add-etablissement-button']) ?>
  49. <?php ActiveForm::end(); ?>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="clr"></div>
  54. </div>
  55. <h2>Historique</h2>
  56. <?php if(count($commandes)): ?>
  57. <p>Retrouvez ici vos dernières commandes.</p>
  58. <table id="historique-commandes" class="table table-striped table-bordered">
  59. <thead>
  60. <tr>
  61. <th>Boulangerie</th>
  62. <th>Date livraison</th>
  63. <th>Résumé</th>
  64. <th>Lieu</th>
  65. <th class="montant">Montant</th>
  66. <th class="statut"></th>
  67. </tr>
  68. </thead>
  69. <tbody>
  70. <?php foreach($commandes as $c): ?>
  71. <tr>
  72. <td><?= Html::encode($c->production->etablissement->nom) ?></td>
  73. <td><?php echo date('d/m/Y',strtotime($c->production->date)); ?></td>
  74. <td class="resume"><?php
  75. $count = count($c->commandeProduits);
  76. $i = 0;
  77. foreach($c->commandeProduits as $p): ?>
  78. <?php if(isset($p->produit)): ?>
  79. <?php if($p->produit->vrac): ?>
  80. <?php echo $p->quantite; ?>g de <?php echo Html::encode($p->produit->nom) ; ?><?php if(++$i != $count): ?>, <?php endif; ?>
  81. <?php else: ?>
  82. <?php echo $p->quantite; ?> x <?php echo Html::encode($p->produit->nom) ; ?><?php if(++$i != $count): ?>, <?php endif; ?>
  83. <?php endif; ?>
  84. <?php endif; ?>
  85. <?php endforeach; ?></td>
  86. <td><?php echo '<span class="nom-point-vente">'.Html::encode($c->pointVente->nom) .'</span><br /><span class="localite">'.Html::encode($c->pointVente->localite).'</span>' ; ?></td>
  87. <td class="montant">
  88. <?php echo number_format($c->montant,2) ; ?> €<br />
  89. <?php if($c->montant_paye): ?>
  90. <?php if($c->statutPaiement() == Commande::STATUT_PAYEE): ?>
  91. <span class="label label-success">Payée</span>
  92. <?php elseif($c->statutPaiement() == Commande::STATUT_IMPAYEE): ?>
  93. <span class="label label-danger">Non payée</span><br />
  94. Reste <strong><?= $c->getMontantRestant(true); ?></strong> à payer
  95. <?php elseif($c->statutPaiement() == Commande::STATUT_SURPLUS): ?>
  96. <span class="label label-success">Payée</span>
  97. <?php endif; ?>
  98. <?php else: ?>
  99. <span class="label label-default">À régler sur place</span>
  100. <?php endif; ?>
  101. </td>
  102. <td class="statut">
  103. <?php
  104. if(date('H') > 20) {
  105. $date_limite = date('Y-m-d',strtotime(date('Y-m-d')) + 60*60*24) ;
  106. }
  107. else {
  108. $date_limite = date('Y-m-d') ;
  109. }
  110. ?>
  111. <?php if($c->production->date < date('Y-m-d') || ($c->production->date == date('Y-m-d') && date('H') > 13)): ?>Livrée
  112. <?php elseif($c->production->date <= $date_limite): ?>En cours de préparation
  113. <?php else: ?>
  114. <div class="btn-group">
  115. <a href="<?php echo Yii::$app->urlManager->createUrl(['commande/update','id'=>$c->id, 'id_etablissement'=>$c->production->etablissement->id]) ; ?>" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
  116. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
  117. <span class="caret"></span>
  118. <span class="sr-only">Toggle Dropdown</span>
  119. </button>
  120. <ul class="dropdown-menu" role="menu">
  121. <li><a href="<?php echo Yii::$app->urlManager->createUrl(['commande/annuler','id'=>$c->id]) ; ?>"><span class="glyphicon glyphicon-trash"></span> Annuler la commande</a></li>
  122. </ul>
  123. </div>
  124. <?php endif; ?>
  125. </td>
  126. </tr>
  127. <?php endforeach; ?>
  128. </tbody>
  129. </table>
  130. <?php else: ?>
  131. <div class="alert alert-info">Vous n'avez pas encore passé de commandes</div>
  132. <?php endif; ?>
  133. </div>