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.

152 lines
6.9KB

  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. /* @var $this yii\web\View */
  8. /* @var $dataProvider yii\data\ActiveDataProvider */
  9. $this->title = 'Développement';
  10. $this->params['breadcrumbs'][] = $this->title;
  11. ?>
  12. <div class="developpement-index">
  13. <h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>
  14. <?php
  15. foreach (Yii::$app->session->getAllFlashes() as $key => $message) {
  16. echo '<div class="alert alert-' . $key . '">' . $message . '</div>';
  17. }
  18. ?>
  19. <?php
  20. $columns = [
  21. [
  22. 'header' => '#',
  23. 'value' => function($model) {
  24. return '#'.$model->id ;
  25. }
  26. ],
  27. [
  28. 'attribute' => 'type',
  29. 'header' => 'Type',
  30. 'format' => 'raw',
  31. 'value' => function($model) {
  32. if($model->type == Developpement::TYPE_EVOLUTION) {
  33. return '<span class="label label-success">Évolution</span>' ;
  34. }
  35. else {
  36. return '<span class="label label-danger">Anomalie</span>' ;
  37. }
  38. }
  39. ],
  40. [ 'attribute' => 'sujet',
  41. 'format' => 'raw',
  42. 'value' => function($model) {
  43. $html = '<strong>'.Html::encode($model->objet).'</strong>' ;
  44. if(strlen($model->description))
  45. $html .= '<br />'.Html::encode($model->description) ;
  46. return $html ;
  47. }],
  48. [ 'attribute' => 'estimation_temps',
  49. 'header' => 'Estimation',
  50. 'format' => 'raw',
  51. 'value' => function($model) {
  52. return intval($model->estimation_temps).' h' ;
  53. }],
  54. [ 'attribute' => 'avancement',
  55. 'format' => 'raw',
  56. 'value' => function($model) {
  57. if($model->avancement)
  58. return '<div class="progress">
  59. <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).'%;">
  60. <span class="sr-only">'.intval($model->avancement).'% effectué</span>
  61. </div>
  62. </div> ' ;
  63. else
  64. return '' ;
  65. }],
  66. [ 'attribute' => 'date_livraison',
  67. 'format' => 'raw',
  68. 'value' => function($model) {
  69. if(strlen($model->date_livraison))
  70. return date('d/m/Y',strtotime($model->date_livraison)) ;
  71. else
  72. return '' ;
  73. }],
  74. ] ;
  75. if(Yii::$app->user->identity->status == USER::STATUS_ADMIN
  76. || Yii::$app->user->identity->status == USER::STATUS_BOULANGER) {
  77. $columns[] = [
  78. 'header' => 'Priorité',
  79. 'format' => 'raw',
  80. 'value' => function($model) {
  81. $current_priorite = (isset($model->developpementPrioriteCurrentEtablissement)) ? $model->developpementPrioriteCurrentEtablissement->getStrPriorite() : 'Non' ;
  82. $style_bouton = (isset($model->developpementPrioriteCurrentEtablissement)) ? $model->developpementPrioriteCurrentEtablissement->getClassCssStyleBouton() : 'default' ;
  83. $html = '<div class="btn-group btn-group-priorite">
  84. <button type="button" class="btn btn-priorite btn-sm btn-'.$style_bouton.' dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  85. '.$current_priorite.' <span class="caret"></span>
  86. </button>
  87. <ul class="dropdown-menu">
  88. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id]).'">Non</a></li>
  89. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id, 'priorite' => DeveloppementPriorite::PRIORITE_BASSE]).'">Basse</a></li>
  90. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id, 'priorite' => DeveloppementPriorite::PRIORITE_NORMALE]).'">Normale</a></li>
  91. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id, 'priorite' => DeveloppementPriorite::PRIORITE_HAUTE]).'">Haute</a></li>
  92. </ul>
  93. </div><br />' ;
  94. if(isset($model->developpementPriorite) && count($model->developpementPriorite)) {
  95. foreach($model->developpementPriorite as $developpement_priorite) {
  96. if($developpement_priorite->id_etablissement != Yii::$app->user->identity->id_etablissement)
  97. $html .= '<div class="label label-priorite label-sm label-'.$developpement_priorite->getClassCssStyleBouton().'">'.Html::encode($developpement_priorite->etablissement->nom).'</div> ' ;
  98. }
  99. }
  100. return $html ;
  101. }
  102. ] ;
  103. }
  104. if(Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
  105. $columns[] = [
  106. 'class' => 'yii\grid\ActionColumn',
  107. 'template' => '{update}',
  108. 'headerOptions' => ['class' => 'actions'],
  109. 'buttons' => [
  110. 'update' => function ($url, $model) {
  111. return '<div class="btn-group">
  112. <a href="'.$url.'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
  113. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  114. <span class="caret"></span>
  115. <span class="sr-only">Toggle Dropdown</span>
  116. </button>
  117. <ul class="dropdown-menu">
  118. <li><a href="'.Yii::$app->urlManager->createUrl(['developpement/delete','id' => $model->id]).'" class=""><span class="glyphicon glyphicon-trash"></span> Supprimer</a></li>
  119. </ul>
  120. </div>' ;
  121. },
  122. ],
  123. ] ;
  124. }
  125. ?>
  126. <?=
  127. GridView::widget([
  128. 'id' => 'tab-developpements',
  129. 'dataProvider' => $dataProvider,
  130. 'columns' => $columns
  131. ]);
  132. ?>
  133. </div>