setTitle('Factures');
$this->addBreadcrumb($this->getTitle());
$this->addButton(['label' => 'Nouvelle facture ', 'url' => 'invoice/create', 'class' => 'btn btn-primary']);
?>
= GridView::widget([
'filterModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'status',
'label' => 'Statut',
'filter' => [
'draft' => 'Brouillon',
'valid' => 'Valide',
],
'format' => 'raw',
'value' => function($model) {
return $model->getHtmlLabel() ;
}
],
[
'attribute' => 'reference',
'value' => function($model) {
if(strlen($model->reference) > 0) {
return $model->reference ;
}
return '' ;
}
],
'name',
[
'attribute' => 'id_user',
'header' => 'Utilisateur',
'value' => function($model) {
return $model->user->getUsername() ;
}
],
[
'attribute' => 'date',
'header' => 'Date',
'value' => function($model) {
return date('d/m/Y',strtotime($model->date)) ;
}
],
[
'attribute' => 'amount',
'header' => 'Montant',
'value' => function($invoice) {
return $invoice->getAmountWithTax(Order::AMOUNT_TOTAL, true) ;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete} {download}',
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'download' => function($url, $model) {
return Html::a('', $url, [
'title' => Yii::t('app', 'Télécharger'), 'class' => 'btn btn-default'
]);
},
'update' => function ($url, $model) {
return ($model->isStatusDraft() ? Html::a('', $url, [
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
]) : '');
},
'delete' => function ($url, $model) {
return ($model->isStatusDraft() ? Html::a('', $url, [
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
]) : '');
}
],
],
],
]); ?>