Browse Source

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

feature/rotating_product
Guillaume Bourgeois 5 months ago
parent
commit
0a0a3f9e4a
4 changed files with 40 additions and 6 deletions
  1. +9
    -0
      backend/views/delivery-note/index.php
  2. +1
    -2
      backend/views/invoice/index.php
  3. +26
    -1
      domain/Document/DeliveryNote/DeliveryNoteSearch.php
  4. +4
    -3
      domain/Document/Invoice/InvoiceSearch.php

+ 9
- 0
backend/views/delivery-note/index.php View File

} }
], ],
[ [
'attribute' => 'with_invoice',
'header' => 'Facture', 'header' => 'Facture',
'filter' => [
0 => 'Non',
1 => 'Oui',
],
'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'],
[ [
'attribute' => 'is_sent', 'attribute' => 'is_sent',
'header' => 'Envoyé', 'header' => 'Envoyé',
'filter' => [
0 => 'Non',
1 => 'Oui',
],
'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'],

+ 1
- 2
backend/views/invoice/index.php View File

'filterOptions' => ['class' => 'column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'], 'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($invoice) use ( $invoiceModule) { 'value' => function ($invoice) use ( $invoiceModule) {
$amountWithTax = $invoiceModule->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL);
if($amountWithTax && $invoiceModule->isInvoicePaid($invoice)) {
if($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>';

+ 26
- 1
domain/Document/DeliveryNote/DeliveryNoteSearch.php View File



class DeliveryNoteSearch extends DeliveryNote class DeliveryNoteSearch extends DeliveryNote
{ {
public $with_invoice;
public $id_point_sale; public $id_point_sale;
public $date_distribution; public $date_distribution;


{ {
return [ return [
[[], 'safe'], [[], 'safe'],
[['is_sent', 'with_invoice'], 'boolean'],
[['comment', 'address', 'status', 'date_distribution'], 'string'], [['comment', 'address', 'status', 'date_distribution'], 'string'],
[['id_user', 'id_point_sale'], 'integer'], [['id_user', 'id_point_sale'], 'integer'],
[['name', 'reference'], 'string', 'max' => 255], [['name', 'reference'], 'string', 'max' => 255],


public function search($params) public function search($params)
{ {
$deliveryNoteRepository = DeliveryNoteRepository::getInstance();
$deliveryNoteModule = DeliveryNoteModule::getInstance();
$deliveryNoteRepository = $deliveryNoteModule->getRepository();
$optionsSearch = $deliveryNoteRepository->getDefaultOptionsSearch(); $optionsSearch = $deliveryNoteRepository->getDefaultOptionsSearch();


if(isset($params['DeliveryNoteSearch']['id_point_sale'])) { if(isset($params['DeliveryNoteSearch']['id_point_sale'])) {
$query->andWhere(['order.id_point_sale' => $this->id_point_sale]); $query->andWhere(['order.id_point_sale' => $this->id_point_sale]);
} }


if(!is_null($this->is_sent) && is_numeric($this->is_sent)) {
if($this->is_sent) {
$query->andWhere(['delivery_note.is_sent' => 1]);
}
else {
$query->andWhere('delivery_note.is_sent IS NULL OR delivery_note.is_sent = 0');
}
}

if ($this->date_distribution && strlen($this->date_distribution)) { if ($this->date_distribution && strlen($this->date_distribution)) {
$query->andFilterWhere(['like', 'distribution.date', date('Y-m-d', strtotime(str_replace('/', '-', $this->date_distribution)))]); $query->andFilterWhere(['like', 'distribution.date', date('Y-m-d', strtotime(str_replace('/', '-', $this->date_distribution)))]);
} }


// filtre facture (oui / non)
$models = $dataProvider->getModels();
foreach($models as $index => $deliveryNote) {
if(!is_null($this->with_invoice) && is_numeric($this->with_invoice)) {
$invoice = $deliveryNoteModule->getSolver()->getInvoice($deliveryNote);
if(($this->with_invoice && !$invoice) || (!$this->with_invoice && $invoice)) {
unset($models[$index]);
}
}
}
$dataProvider->setModels($models);


return $dataProvider; return $dataProvider;
} }
} }

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

$query->andFilterWhere(['like', 'invoice.date', date('Y-m-d', strtotime(str_replace('/', '-', $this->date)))]); $query->andFilterWhere(['like', 'invoice.date', date('Y-m-d', strtotime(str_replace('/', '-', $this->date)))]);
} }


// filtre envoyé
if(!is_null($this->is_sent) && is_numeric($this->is_sent)) { if(!is_null($this->is_sent) && is_numeric($this->is_sent)) {
if($this->is_sent) { if($this->is_sent) {
$query->andWhere(['invoice.is_sent' => 1]); $query->andWhere(['invoice.is_sent' => 1]);
// filter payé / non payé // filter payé / non payé
// @TODO : comprendre pourquoi la pagination ne suit pas // @TODO : comprendre pourquoi la pagination ne suit pas
$models = $dataProvider->getModels(); $models = $dataProvider->getModels();
foreach($models as $index => $product) {
foreach($models as $index => $invoice) {
if(!is_null($this->paid) && is_numeric($this->paid)) { if(!is_null($this->paid) && is_numeric($this->paid)) {
$isInvoicePaid = $invoiceModule->getSolver()->isInvoicePaid($product);
if(($this->paid && !$isInvoicePaid) || (!$this->paid && $isInvoicePaid)) {
$isInvoicePaid = $invoiceModule->getSolver()->isInvoicePaid($invoice);
if(($this->paid && !$isInvoicePaid) || (!$this->paid && $isInvoicePaid)) {
unset($models[$index]); unset($models[$index]);
} }
} }

Loading…
Cancel
Save