Browse Source

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

feature/rotating_product
Guillaume Bourgeois 4 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

@@ -60,7 +60,7 @@ class InvoiceController extends DocumentController
public function actionAjaxDeleteDeliveryNote($idInvoice, $idDeliveryNote)
{
$orderModule = $this->getOrderModule();
$invoiceModule = $this-> getInvoiceModule();
$invoiceModule = $this-> getInvoiceModule();
$deliveryNoteModule = $this->getDeliveryNoteModule();
$invoice = $invoiceModule->findOneInvoiceById($idInvoice);
$deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById($idDeliveryNote);

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

@@ -52,7 +52,6 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
?>

<div class="invoice-index">

<?php if (Invoice::searchCount()): ?>
<?= GridView::widget([
'filterModel' => $searchModel,
@@ -82,7 +81,7 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
'name',
[
'attribute' => 'username',
'header' => 'Utilisateur',
'label' => 'Utilisateur',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
@@ -105,12 +104,17 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
'header' => 'Montant',
'format' => 'raw',
'value' => function ($invoice) use ( $invoiceModule) {
$amountWithTax = $invoiceModule->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL);
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',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
@@ -120,7 +124,6 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
if($amountWithTax && $invoiceModule->isInvoicePaid($invoice)) {
return '<span class="label label-success">Oui</span>';
}

return '<span class="label label-default">Non</span>';
}
],
@@ -166,7 +169,6 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default'
]);
}

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

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

@@ -40,17 +40,19 @@ namespace domain\Document\Invoice;

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

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

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

@@ -59,16 +61,34 @@ class InvoiceSearch extends Invoice
$invoiceRepository = InvoiceRepository::getInstance();
$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()
->with($optionsSearch['with'])
->joinWith($optionsSearch['join_with'])
->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');

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

Loading…
Cancel
Save