getProducerModule();
$invoiceModule = $this-> getInvoiceModule();
$userModule = $this->getUserModule();
$featureChecker = $this->getFeatureModule()->getChecker();
$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 ( $invoiceModule) {
return $invoiceModule->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',
'label' => 'Utilisateur',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($invoice) use ($userModule) {
return $userModule->getUsername($invoice->user);
}
],
[
'attribute' => 'date',
'header' => 'Date',
'filter' => \yii\jui\DatePicker::widget([
'language' => 'fr',
'dateFormat' => 'dd/MM/yyyy',
'model' => $searchModel,
'attribute' => 'date',
'options' => ['class' => 'form-control']
]),
'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',
'format' => 'raw',
'value' => function ($invoice) use ( $invoiceModule) {
return $invoiceModule->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL, true);
}
],
[
'attribute' => 'is_paid',
'label' => 'Payée',
'filter' => [
0 => 'Non',
1 => 'Oui',
],
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($invoice) use ($invoiceModule) {
if($invoiceModule->isInvoicePaid($invoice)) {
return '
Oui';
}
return '
Non';
}
],
[
'attribute' => 'is_sent',
'header' => 'Envoyée',
'filter' => [
0 => 'Non',
1 => 'Oui',
],
'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 ( $invoiceModule) {
return ( $invoiceModule->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 ($producerModule, $featureChecker) {
if($featureChecker->isEnabled(Feature::ALIAS_BRIDGE_EVOLIZ)
&& $producerModule->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 ( $invoiceModule) {
return ( $invoiceModule->isStatusDraft($invoice) ? Html::a('
', $url, [
'title' => 'Supprimer', 'class' => 'btn btn-default'
]) : '');
}
],
],
],
]); ?>
Aucune facture enregistrée