您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

107 行
3.9KB

  1. <?php
  2. use yii\helpers\Html;
  3. use yii\grid\GridView;
  4. use common\models\Developpement;
  5. use common\models\User;
  6. /* @var $this yii\web\View */
  7. /* @var $dataProvider yii\data\ActiveDataProvider */
  8. $this->title = 'Développement';
  9. $this->params['breadcrumbs'][] = $this->title;
  10. ?>
  11. <div class="developpement-index">
  12. <h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>
  13. <?php
  14. foreach (Yii::$app->session->getAllFlashes() as $key => $message) {
  15. echo '<div class="alert alert-' . $key . '">' . $message . '</div>';
  16. }
  17. ?>
  18. <?php
  19. $columns = [
  20. ['class' => 'yii\grid\SerialColumn'],
  21. [
  22. 'attribute' => 'type',
  23. 'header' => 'Type',
  24. 'format' => 'raw',
  25. 'value' => function($model) {
  26. if($model->type == Developpement::TYPE_EVOLUTION) {
  27. return '<span class="label label-success">Évolution</span>' ;
  28. }
  29. else {
  30. return '<span class="label label-danger">Anomalie</span>' ;
  31. }
  32. }
  33. ],
  34. [ 'attribute' => 'sujet',
  35. 'format' => 'raw',
  36. 'value' => function($model) {
  37. $html = '<strong>'.Html::encode($model->objet).'</strong>' ;
  38. if(strlen($model->description))
  39. $html .= '<br />'.Html::encode($model->description) ;
  40. return $html ;
  41. }],
  42. [ 'attribute' => 'estimation_temps',
  43. 'header' => 'Estimation',
  44. 'format' => 'raw',
  45. 'value' => function($model) {
  46. return intval($model->estimation_temps).' h' ;
  47. }],
  48. [ 'attribute' => 'avancement',
  49. 'format' => 'raw',
  50. 'value' => function($model) {
  51. if($model->avancement)
  52. return '<div class="progress">
  53. <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).'%;">
  54. <span class="sr-only">'.intval($model->avancement).'% effectué</span>
  55. </div>
  56. </div> ' ;
  57. else
  58. return '' ;
  59. }],
  60. [ 'attribute' => 'date_livraison',
  61. 'format' => 'raw',
  62. 'value' => function($model) {
  63. if(strlen($model->date_livraison))
  64. return date('d/m/Y',strtotime($model->date_livraison)) ;
  65. else
  66. return '' ;
  67. }],
  68. ] ;
  69. if(Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
  70. $columns[] = [
  71. 'class' => 'yii\grid\ActionColumn',
  72. 'template' => '{update} {delete}',
  73. 'headerOptions' => ['class' => 'actions'],
  74. 'buttons' => [
  75. 'update' => function ($url, $model) {
  76. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  77. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  78. ]);
  79. },
  80. 'delete' => function ($url, $model) {
  81. return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
  82. 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
  83. ]);
  84. }
  85. ],
  86. ] ;
  87. }
  88. ?>
  89. <?=
  90. GridView::widget([
  91. 'dataProvider' => $dataProvider,
  92. 'columns' => $columns
  93. ]);
  94. ?>
  95. </div>