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.

158 line
7.4KB

  1. <?php
  2. use yii\helpers\Html;
  3. use yii\grid\GridView;
  4. use common\models\Developpement;
  5. use common\models\DeveloppementPriorite;
  6. use common\models\User;
  7. use common\helpers\Url;
  8. /* @var $this yii\web\View */
  9. /* @var $dataProvider yii\data\ActiveDataProvider */
  10. $this->title = 'Développement';
  11. $this->params['breadcrumbs'][] = $this->title;
  12. ?>
  13. <div class="developpement-index">
  14. <h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>
  15. <div class="well">
  16. Cette page liste les besoins recencés auprès des producteurs utilisant la plateforme. N'hésitez pas à me <a href="<?= Url::frontend('site/contact') ?>">contacter</a> pour la faire évoluer. Les remontées de bugs sont également bienvenues.<br />
  17. Afin d'orienter de manière pertinente le développement de la plateforme, je vous invite à définir la priorité des évolutions qui vous intéressent.
  18. </div>
  19. <?php
  20. foreach (Yii::$app->session->getAllFlashes() as $key => $message) {
  21. echo '<div class="alert alert-' . $key . '">' . $message . '</div>';
  22. }
  23. ?>
  24. <?php
  25. $columns = [
  26. [
  27. 'header' => '#',
  28. 'value' => function($model) {
  29. return '#'.$model->id ;
  30. }
  31. ],
  32. [
  33. 'attribute' => 'type',
  34. 'header' => 'Type',
  35. 'format' => 'raw',
  36. 'value' => function($model) {
  37. if($model->type == Developpement::TYPE_EVOLUTION) {
  38. return '<span class="label label-success">Évolution</span>' ;
  39. }
  40. else {
  41. return '<span class="label label-danger">Anomalie</span>' ;
  42. }
  43. }
  44. ],
  45. [ 'attribute' => 'sujet',
  46. 'format' => 'raw',
  47. 'value' => function($model) {
  48. $html = '<strong>'.Html::encode($model->objet).'</strong>' ;
  49. if(strlen($model->description))
  50. $html .= '<br />'.nl2br(Html::encode($model->description)) ;
  51. return $html ;
  52. }],
  53. [ 'attribute' => 'estimation_temps',
  54. 'header' => 'Estimation',
  55. 'format' => 'raw',
  56. 'value' => function($model) {
  57. return intval($model->estimation_temps).' h' ;
  58. }],
  59. [ 'attribute' => 'avancement',
  60. 'format' => 'raw',
  61. 'value' => function($model) {
  62. if($model->avancement)
  63. return '<div class="progress">
  64. <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="'.intval($model->avancement).'" aria-valuemin="0" aria-valuemax="100" style="width: '.intval($model->avancement).'%;">
  65. <span class="sr-only">'.intval($model->avancement).'% effectué</span>
  66. </div>
  67. </div> ' ;
  68. else
  69. return '' ;
  70. }],
  71. [ 'attribute' => 'date_livraison',
  72. 'format' => 'raw',
  73. 'value' => function($model) {
  74. if(strlen($model->date_livraison))
  75. return date('d/m/Y',strtotime($model->date_livraison)) ;
  76. else
  77. return '' ;
  78. }],
  79. ] ;
  80. if(Yii::$app->user->identity->status == USER::STATUS_ADMIN
  81. || Yii::$app->user->identity->status == USER::STATUS_BOULANGER) {
  82. $columns[] = [
  83. 'header' => 'Priorité',
  84. 'format' => 'raw',
  85. 'value' => function($model) {
  86. $current_priorite = (isset($model->developpementPrioriteCurrentEtablissement)) ? $model->developpementPrioriteCurrentEtablissement->getStrPriorite() : 'Non' ;
  87. $style_bouton = (isset($model->developpementPrioriteCurrentEtablissement)) ? $model->developpementPrioriteCurrentEtablissement->getClassCssStyleBouton() : 'default' ;
  88. $html = '<div class="btn-group btn-group-priorite">
  89. <button type="button" class="btn btn-priorite btn-sm btn-'.$style_bouton.' dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  90. '.$current_priorite.' <span class="caret"></span>
  91. </button>
  92. <ul class="dropdown-menu">
  93. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id]).'">Non</a></li>
  94. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id, 'priorite' => DeveloppementPriorite::PRIORITE_BASSE]).'">Basse</a></li>
  95. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id, 'priorite' => DeveloppementPriorite::PRIORITE_NORMALE]).'">Normale</a></li>
  96. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id, 'priorite' => DeveloppementPriorite::PRIORITE_HAUTE]).'">Haute</a></li>
  97. </ul>
  98. </div><br />' ;
  99. if(isset($model->developpementPriorite) && count($model->developpementPriorite)) {
  100. foreach($model->developpementPriorite as $developpement_priorite) {
  101. if($developpement_priorite->id_etablissement != Yii::$app->user->identity->id_etablissement)
  102. $html .= '<div class="label label-priorite label-sm label-'.$developpement_priorite->getClassCssStyleBouton().'">'.Html::encode($developpement_priorite->etablissement->nom).'</div> ' ;
  103. }
  104. }
  105. return $html ;
  106. }
  107. ] ;
  108. }
  109. if(Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
  110. $columns[] = [
  111. 'class' => 'yii\grid\ActionColumn',
  112. 'template' => '{update}',
  113. 'headerOptions' => ['class' => 'actions'],
  114. 'buttons' => [
  115. 'update' => function ($url, $model) {
  116. return '<div class="btn-group">
  117. <a href="'.$url.'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
  118. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  119. <span class="caret"></span>
  120. <span class="sr-only">Toggle Dropdown</span>
  121. </button>
  122. <ul class="dropdown-menu">
  123. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/delete','id' => $model->id]).'" class=""><span class="glyphicon glyphicon-trash"></span> Supprimer</a></li>
  124. </ul>
  125. </div>' ;
  126. },
  127. ],
  128. ] ;
  129. }
  130. ?>
  131. <?=
  132. GridView::widget([
  133. 'id' => 'tab-developpements',
  134. 'dataProvider' => $dataProvider,
  135. 'columns' => $columns
  136. ]);
  137. ?>
  138. </div>