Browse Source

[Administration] Factures & bons de livraisons > Liste : amélioration des filtres de recherche

feature/rotating_product
Guillaume Bourgeois 5 months ago
parent
commit
ed796a2064
3 changed files with 33 additions and 11 deletions
  1. +1
    -1
      backend/controllers/InvoiceController.php
  2. +8
    -6
      backend/views/invoice/index.php
  3. +24
    -4
      domain/Document/Invoice/InvoiceSearch.php

+ 1
- 1
backend/controllers/InvoiceController.php View File

public function actionAjaxDeleteDeliveryNote($idInvoice, $idDeliveryNote) public function actionAjaxDeleteDeliveryNote($idInvoice, $idDeliveryNote)
{ {
$orderModule = $this->getOrderModule(); $orderModule = $this->getOrderModule();
$invoiceModule = $this-> getInvoiceModule();
$invoiceModule = $this-> getInvoiceModule();
$deliveryNoteModule = $this->getDeliveryNoteModule(); $deliveryNoteModule = $this->getDeliveryNoteModule();
$invoice = $invoiceModule->findOneInvoiceById($idInvoice); $invoice = $invoiceModule->findOneInvoiceById($idInvoice);
$deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById($idDeliveryNote); $deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById($idDeliveryNote);

+ 8
- 6
backend/views/invoice/index.php View File

?> ?>


<div class="invoice-index"> <div class="invoice-index">

<?php if (Invoice::searchCount()): ?> <?php if (Invoice::searchCount()): ?>
<?= GridView::widget([ <?= GridView::widget([
'filterModel' => $searchModel, 'filterModel' => $searchModel,
'name', 'name',
[ [
'attribute' => 'username', 'attribute' => 'username',
'header' => 'Utilisateur',
'label' => 'Utilisateur',
'headerOptions' => ['class' => 'column-hide-on-mobile'], 'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'], 'contentOptions' => ['class' => 'column-hide-on-mobile'],
'header' => 'Montant', 'header' => 'Montant',
'format' => 'raw', 'format' => 'raw',
'value' => function ($invoice) use ( $invoiceModule) { 'value' => function ($invoice) use ( $invoiceModule) {
$amountWithTax = $invoiceModule->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL);
return $invoiceModule->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL, true); return $invoiceModule->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL, true);
} }
], ],
[ [
'header' => 'Payée',
'attribute' => 'paid',
'label' => 'Payée',
/*'filter' => [
0 => 'Non',
1 => 'Oui',
],*/
'filter' => false,
'format' => 'raw', 'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'], 'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'],
if($amountWithTax && $invoiceModule->isInvoicePaid($invoice)) { if($amountWithTax && $invoiceModule->isInvoicePaid($invoice)) {
return '<span class="label label-success">Oui</span>'; return '<span class="label label-success">Oui</span>';
} }

return '<span class="label label-default">Non</span>'; return '<span class="label label-default">Non</span>';
} }
], ],
'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default' 'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default'
]); ]);
} }

return ''; return '';
}, },
'update' => function ($url, $invoice) { 'update' => function ($url, $invoice) {

+ 24
- 4
domain/Document/Invoice/InvoiceSearch.php View File



use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\data\Sort;


class InvoiceSearch extends Invoice class InvoiceSearch extends Invoice
{ {
var $paid;
var $username; var $username;


public function rules() public function rules()
{ {
return [ return [
[[], 'safe'],
[['paid'], 'safe'],
[['comment', 'address', 'status', 'username'], 'string'], [['comment', 'address', 'status', 'username'], 'string'],
[['name', 'reference'], 'string', 'max' => 255],
[['name', 'reference', 'username'], 'string', 'max' => 255],
]; ];
} }


$invoiceRepository = InvoiceRepository::getInstance(); $invoiceRepository = InvoiceRepository::getInstance();
$optionsSearch = $invoiceRepository->getDefaultOptionsSearch(); $optionsSearch = $invoiceRepository->getDefaultOptionsSearch();


$sort = new Sort([
'attributes' => [
'status',
'reference',
'name',
'date',
'username' => [
'asc' => ['user_invoice.lastname' => SORT_ASC, 'user_invoice.name' => SORT_ASC],
'desc' => ['user_invoice.lastname' => SORT_DESC, 'user_invoice.name' => SORT_DESC],
]
],
'defaultOrder' => [
'status' => SORT_ASC,
'reference' => SORT_DESC
]
]);

$query = Invoice::find() $query = Invoice::find()
->with($optionsSearch['with']) ->with($optionsSearch['with'])
->joinWith($optionsSearch['join_with']) ->joinWith($optionsSearch['join_with'])
->where(['invoice.id_producer' => GlobalParam::getCurrentProducerId()]) ->where(['invoice.id_producer' => GlobalParam::getCurrentProducerId()])
->orderBy('invoice.status ASC, invoice.reference DESC')
//->orderBy('invoice.status ASC, invoice.reference DESC')
->orderBy($sort->orders)
->groupBy('invoice.id'); ->groupBy('invoice.id');


$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => $query, 'query' => $query,
'sort' => ['attributes' => ['name', 'reference', 'date']],
'sort' => $sort,
'pagination' => [ 'pagination' => [
'pageSize' => 20, 'pageSize' => 20,
], ],

Loading…
Cancel
Save