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.

125 lines
5.0KB

  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. <?php //$form->field($model_form_etablissement, 'id_etablissement')->label('')->dropDownList($data_etablissements_dispos, ['prompt' => '--','encode' => false,'options' => $options_etablissements_dispos]) ?>
  34. <?= $form->field($model_form_etablissement, 'code')->label('Code')->hint('Renseignez-vous auprès de votre boulangerie pour qu\'elle vous fournisse un code d\'accès') ; ?>
  35. <?= Html::submitButton('<span class="glyphicon glyphicon-plus"></span> Valider', ['class' => 'btn btn-default', 'name' => 'add-etablissement-button']) ?>
  36. <?php ActiveForm::end(); ?>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="clr"></div>
  41. </div>
  42. <h2>Historique</h2>
  43. <?php if(count($commandes)): ?>
  44. <p>Retrouvez ici vos dernières commandes.</p>
  45. <table id="historique-commandes" class="table table-striped table-bordered">
  46. <thead>
  47. <tr>
  48. <th>Boulangerie</th>
  49. <th>Date livraison</th>
  50. <th>Résumé</th>
  51. <th>Lieu</th>
  52. <th class="montant">Montant</th>
  53. <th class="statut"></th>
  54. </tr>
  55. </thead>
  56. <tbody>
  57. <?php foreach($commandes as $c): ?>
  58. <tr>
  59. <td><?= Html::encode($c->production->etablissement->nom) ?></td>
  60. <td><?php echo date('d/m/Y',strtotime($c->production->date)); ?></td>
  61. <td class="resume"><?php
  62. $count = count($c->commandeProduits);
  63. $i = 0;
  64. foreach($c->commandeProduits as $p): ?>
  65. <?php if(isset($p->produit)): ?>
  66. <?php if($p->produit->vrac): ?>
  67. <?php echo $p->quantite; ?>g de <?php echo Html::encode($p->produit->nom) ; ?><?php if(++$i != $count): ?>, <?php endif; ?>
  68. <?php else: ?>
  69. <?php echo $p->quantite; ?> x <?php echo Html::encode($p->produit->nom) ; ?><?php if(++$i != $count): ?>, <?php endif; ?>
  70. <?php endif; ?>
  71. <?php endif; ?>
  72. <?php endforeach; ?></td>
  73. <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>
  74. <td class="montant"><?php echo number_format($c->montant,2) ; ?> €</td>
  75. <td class="statut">
  76. <?php
  77. if(date('H') > 20) {
  78. $date_limite = date('Y-m-d',strtotime(date('Y-m-d')) + 60*60*24) ;
  79. }
  80. else {
  81. $date_limite = date('Y-m-d') ;
  82. }
  83. ?>
  84. <?php if($c->production->date < date('Y-m-d') || ($c->production->date == date('Y-m-d') && date('H') > 13)): ?>Livrée
  85. <?php elseif($c->production->date <= $date_limite): ?>En cours de préparation
  86. <?php else: ?>
  87. <div class="btn-group">
  88. <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>
  89. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
  90. <span class="caret"></span>
  91. <span class="sr-only">Toggle Dropdown</span>
  92. </button>
  93. <ul class="dropdown-menu" role="menu">
  94. <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>
  95. </ul>
  96. </div>
  97. <?php endif; ?>
  98. </td>
  99. </tr>
  100. <?php endforeach; ?>
  101. </tbody>
  102. </table>
  103. <?php else: ?>
  104. <div class="alert alert-info">Vous n'avez pas encore passé de commandes</div>
  105. <?php endif; ?>
  106. </div>