getProducerManager();
$invoiceManager = $this->getInvoiceManager();
$userManager = $this->getUserManager();
$this->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 ($invoice) use ($invoiceManager) {
return $invoiceManager->getHtmlLabel($invoice);
}
],
[
'attribute' => 'reference',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($invoice) {
return (strlen($invoice->reference) > 0) ? $invoice->reference : '';
}
],
'name',
[
'attribute' => 'username',
'header' => 'Utilisateur',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($invoice) use ($userManager) {
return $userManager->getUsername($invoice->user);
}
],
[
'attribute' => 'date',
'header' => 'Date',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($invoice) {
return date('d/m/Y', strtotime($invoice->date));
}
],
[
'attribute' => 'amount',
'header' => 'Montant',
'value' => function ($invoice) use ($invoiceManager) {
return $invoiceManager->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL, true);
}
],
[
'attribute' => 'is_sent',
'header' => 'Envoyé',
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($model) {
if ($model->is_sent) {
return '
Oui';
} else {
return '
Non';
}
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{validate} {update} {delete} {send} {download} {export-csv-evoliz}',
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'validate' => function ($url, $invoice) use ($invoiceManager) {
return ($invoiceManager->isStatusDraft($invoice) ? Html::a('
', $url, [
'title' => 'Valider', 'class' => 'btn btn-default'
]) : '');
},
'send' => function ($url, $invoice) {
return ((isset($invoice->user) && strlen($invoice->user->email) > 0) ? Html::a('
', $url, [
'title' => 'Envoyer', 'class' => 'btn btn-default'
]) : '');
},
'download' => function ($url, $invoice) {
return Html::a('
', $url, [
'title' => 'Télécharger', 'class' => 'btn btn-default'
]);
},
'export-csv-evoliz' => function ($url, $invoice) use ($producerManager) {
if ($producerManager->getConfig('option_export_evoliz')) {
return Html::a('
Evoliz', $url, [
'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default'
]);
}
return '';
},
'update' => function ($url, $invoice) {
return Html::a('
', $url, [
'title' => 'Modifier', 'class' => 'btn btn-default'
]);
},
'delete' => function ($url, $invoice) use ($invoiceManager) {
return ($invoiceManager->isStatusDraft($invoice) ? Html::a('
', $url, [
'title' => 'Supprimer', 'class' => 'btn btn-default'
]) : '');
}
],
],
],
]); ?>
Aucune facture enregistrée