소스 검색

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

feature/rotating_product
Guillaume Bourgeois 4 달 전
부모
커밋
0a0a3f9e4a
4개의 변경된 파일40개의 추가작업 그리고 6개의 파일을 삭제
  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 파일 보기

@@ -118,7 +118,12 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl
}
],
[
'attribute' => 'with_invoice',
'header' => 'Facture',
'filter' => [
0 => 'Non',
1 => 'Oui',
],
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
@@ -134,6 +139,10 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl
[
'attribute' => 'is_sent',
'header' => 'Envoyé',
'filter' => [
0 => 'Non',
1 => 'Oui',
],
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],

+ 1
- 2
backend/views/invoice/index.php 파일 보기

@@ -126,8 +126,7 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'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-default">Non</span>';

+ 26
- 1
domain/Document/DeliveryNote/DeliveryNoteSearch.php 파일 보기

@@ -43,6 +43,7 @@ use yii\data\ActiveDataProvider;

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

@@ -50,6 +51,7 @@ class DeliveryNoteSearch extends DeliveryNote
{
return [
[[], 'safe'],
[['is_sent', 'with_invoice'], 'boolean'],
[['comment', 'address', 'status', 'date_distribution'], 'string'],
[['id_user', 'id_point_sale'], 'integer'],
[['name', 'reference'], 'string', 'max' => 255],
@@ -58,7 +60,8 @@ class DeliveryNoteSearch extends DeliveryNote

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

if(isset($params['DeliveryNoteSearch']['id_point_sale'])) {
@@ -93,10 +96,32 @@ class DeliveryNoteSearch extends DeliveryNote
$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)) {
$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;
}
}

+ 4
- 3
domain/Document/Invoice/InvoiceSearch.php 파일 보기

@@ -115,6 +115,7 @@ class InvoiceSearch extends Invoice
$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($this->is_sent) {
$query->andWhere(['invoice.is_sent' => 1]);
@@ -127,10 +128,10 @@ class InvoiceSearch extends Invoice
// filter payé / non payé
// @TODO : comprendre pourquoi la pagination ne suit pas
$models = $dataProvider->getModels();
foreach($models as $index => $product) {
foreach($models as $index => $invoice) {
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]);
}
}

Loading…
취소
저장