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.

124 line
4.8KB

  1. <?php
  2. /* @var $this yii\web\View */
  3. use yii\helpers\Html;
  4. use yii\bootstrap\ActiveForm;
  5. $this->title = 'Commande' ;
  6. ?>
  7. <div id="index-commande">
  8. <h1 class="title-systeme-commande"><span class="glyphicon glyphicon-th-list"></span> Tableau de bord</h1>
  9. <h2>Boulangeries</h2>
  10. <?php if($commande_ok): ?>
  11. <div class="alert alert-success">
  12. <div class="icon"></div>
  13. Votre commande a bien été prise en compte.
  14. </div>
  15. <?php endif; ?>
  16. <?php if($annule_ok): ?>
  17. <div class="alert alert-success"><div class="icon"></div>Votre commande a bien été annulée.</div>
  18. <?php endif; ?>
  19. <div id="liste-boulangeries">
  20. <?=
  21. $this->render('_liste_etablissements.php',[
  22. 'etablissements' => $etablissements,
  23. 'context' => 'index'
  24. ]) ;
  25. ?>
  26. <div class="col-md-6" id="bloc-add-etablissement">
  27. <div class="panel panel-default">
  28. <div class="panel-heading">
  29. <h3 class="panel-title"><span class="glyphicon glyphicon-plus"></span> Ajouter une boulangerie</h3>
  30. </div>
  31. <div class="panel-body">
  32. <?php $form = ActiveForm::begin(['id' => 'form-add-boulanger','enableClientValidation'=> false]); ?>
  33. <?= $form->field($model_form_etablissement, 'id_etablissement')->label('')->dropDownList($data_etablissements_dispos, ['prompt' => '--','encode' => false,'options' => $options_etablissements_dispos]) ?>
  34. <?= Html::submitButton('<span class="glyphicon glyphicon-plus"></span> Ajouter', ['class' => 'btn btn-default', 'name' => 'add-etablissement-button']) ?>
  35. <?php ActiveForm::end(); ?>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="clr"></div>
  40. </div>
  41. <h2>Historique</h2>
  42. <?php if(count($commandes)): ?>
  43. <p>Retrouvez ici vos dernières commandes.</p>
  44. <table id="historique-commandes" class="table table-striped table-bordered">
  45. <thead>
  46. <tr>
  47. <th>Boulangerie</th>
  48. <th>Date livraison</th>
  49. <th>Résumé</th>
  50. <th>Lieu</th>
  51. <th class="montant">Montant</th>
  52. <th class="statut"></th>
  53. </tr>
  54. </thead>
  55. <tbody>
  56. <?php foreach($commandes as $c): ?>
  57. <tr>
  58. <td><?= Html::encode($c->production->etablissement->nom) ?></td>
  59. <td><?php echo date('d/m/Y',strtotime($c->production->date)); ?></td>
  60. <td class="resume"><?php
  61. $count = count($c->commandeProduits);
  62. $i = 0;
  63. foreach($c->commandeProduits as $p): ?>
  64. <?php if(isset($p->produit)): ?>
  65. <?php if($p->produit->vrac): ?>
  66. <?php echo $p->quantite; ?>g de <?php echo Html::encode($p->produit->nom) ; ?><?php if(++$i != $count): ?>, <?php endif; ?>
  67. <?php else: ?>
  68. <?php echo $p->quantite; ?> x <?php echo Html::encode($p->produit->nom) ; ?><?php if(++$i != $count): ?>, <?php endif; ?>
  69. <?php endif; ?>
  70. <?php endif; ?>
  71. <?php endforeach; ?></td>
  72. <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>
  73. <td class="montant"><?php echo number_format($c->montant,2) ; ?> €</td>
  74. <td class="statut">
  75. <?php
  76. if(date('H') > 20) {
  77. $date_limite = date('Y-m-d',strtotime(date('Y-m-d')) + 60*60*24) ;
  78. }
  79. else {
  80. $date_limite = date('Y-m-d') ;
  81. }
  82. ?>
  83. <?php if($c->production->date < date('Y-m-d') || ($c->production->date == date('Y-m-d') && date('H') > 13)): ?>Livrée
  84. <?php elseif($c->production->date <= $date_limite): ?>En cours de préparation
  85. <?php else: ?>
  86. <div class="btn-group">
  87. <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>
  88. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
  89. <span class="caret"></span>
  90. <span class="sr-only">Toggle Dropdown</span>
  91. </button>
  92. <ul class="dropdown-menu" role="menu">
  93. <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>
  94. </ul>
  95. </div>
  96. <?php endif; ?>
  97. </td>
  98. </tr>
  99. <?php endforeach; ?>
  100. </tbody>
  101. </table>
  102. <?php else: ?>
  103. <div class="alert alert-info">Vous n'avez pas encore passé de commandes</div>
  104. <?php endif; ?>
  105. </div>