|
- <?php
-
- use yii\helpers\Html;
- use yii\grid\GridView;
- use common\models\Developpement;
- use common\models\User;
-
- /* @var $this yii\web\View */
- /* @var $dataProvider yii\data\ActiveDataProvider */
-
- $this->title = 'Développement';
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <div class="developpement-index">
-
- <h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>
-
- <?php
- foreach (Yii::$app->session->getAllFlashes() as $key => $message) {
- echo '<div class="alert alert-' . $key . '">' . $message . '</div>';
- }
- ?>
-
- <?php
-
- $columns = [
- ['class' => 'yii\grid\SerialColumn'],
- [
- 'attribute' => 'type',
- 'header' => 'Type',
- 'format' => 'raw',
- 'value' => function($model) {
- if($model->type == Developpement::TYPE_EVOLUTION) {
- return '<span class="label label-success">Évolution</span>' ;
- }
- else {
- return '<span class="label label-danger">Anomalie</span>' ;
- }
- }
- ],
- [ 'attribute' => 'sujet',
- 'format' => 'raw',
- 'value' => function($model) {
- $html = '<strong>'.Html::encode($model->objet).'</strong>' ;
- if(strlen($model->description))
- $html .= '<br />'.Html::encode($model->description) ;
- return $html ;
- }],
- [ 'attribute' => 'estimation_temps',
- 'header' => 'Estimation',
- 'format' => 'raw',
- 'value' => function($model) {
- return intval($model->estimation_temps).' h' ;
- }],
- [ 'attribute' => 'avancement',
- 'format' => 'raw',
- 'value' => function($model) {
- if($model->avancement)
- return '<div class="progress">
- <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).'%;">
- <span class="sr-only">'.intval($model->avancement).'% effectué</span>
- </div>
- </div> ' ;
- else
- return '' ;
- }],
- [ 'attribute' => 'date_livraison',
- 'format' => 'raw',
- 'value' => function($model) {
- if(strlen($model->date_livraison))
- return date('d/m/Y',strtotime($model->date_livraison)) ;
- else
- return '' ;
- }],
- ] ;
-
-
- if(Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
- $columns[] = [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{update} {delete}',
- 'headerOptions' => ['class' => 'actions'],
- 'buttons' => [
- 'update' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
- 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
- ]);
- },
- 'delete' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
- 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
- ]);
- }
- ],
- ] ;
- }
-
- ?>
-
- <?=
- GridView::widget([
- 'dataProvider' => $dataProvider,
- 'columns' => $columns
- ]);
- ?>
- </div>
|