mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 02:14:33 -04:00
Cleanup for filters
This commit is contained in:
parent
59faed5e59
commit
e822550c38
@ -42,27 +42,35 @@ class PurchaseOrderFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
$po_status = [];
|
$this->builder->where(function ($query) use ($status_parameters){
|
||||||
|
|
||||||
if (in_array('draft', $status_parameters)) {
|
$po_status = [];
|
||||||
$po_status[] = PurchaseOrder::STATUS_DRAFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array('sent', $status_parameters)) {
|
if (in_array('draft', $status_parameters)) {
|
||||||
$po_status[] = PurchaseOrder::STATUS_SENT;
|
$po_status[] = PurchaseOrder::STATUS_DRAFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('accepted', $status_parameters)) {
|
if (in_array('sent', $status_parameters)) {
|
||||||
$po_status[] = PurchaseOrder::STATUS_ACCEPTED;
|
$query->orWhere(function ($q){
|
||||||
}
|
$q->where('status_id', PurchaseOrder::STATUS_SENT)
|
||||||
|
->whereNull('due_date')
|
||||||
|
->orWhere('due_date', '>=', now()->toDateString());
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array('cancelled', $status_parameters)) {
|
if (in_array('accepted', $status_parameters)) {
|
||||||
$po_status[] = PurchaseOrder::STATUS_CANCELLED;
|
$po_status[] = PurchaseOrder::STATUS_ACCEPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($status_parameters) >=1) {
|
if (in_array('cancelled', $status_parameters)) {
|
||||||
$this->builder->whereIn('status_id', $status_parameters);
|
$po_status[] = PurchaseOrder::STATUS_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(count($status_parameters) >=1) {
|
||||||
|
$query->whereIn('status_id', $status_parameters);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
@ -65,19 +65,20 @@ class RecurringInvoiceFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('active', $status_parameters)) {
|
$recurring_filters = [];
|
||||||
$this->builder->where('status_id', RecurringInvoice::STATUS_ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array('paused', $status_parameters)) {
|
if (in_array('active', $status_parameters))
|
||||||
$this->builder->where('status_id', RecurringInvoice::STATUS_PAUSED);
|
$recurring_filters[] = RecurringInvoice::STATUS_ACTIVE;
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array('completed', $status_parameters)) {
|
|
||||||
$this->builder->where('status_id', RecurringInvoice::STATUS_COMPLETED);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->builder;
|
if (in_array('paused', $status_parameters))
|
||||||
|
$recurring_filters[] = RecurringInvoice::STATUS_PAUSED;
|
||||||
|
|
||||||
|
if (in_array('completed', $status_parameters))
|
||||||
|
$recurring_filters[] = RecurringInvoice::STATUS_COMPLETED;
|
||||||
|
|
||||||
|
return $this->builder->whereIn('status_id', $recurring_filters);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user