mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -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;
|
||||
}
|
||||
|
||||
$po_status = [];
|
||||
$this->builder->where(function ($query) use ($status_parameters){
|
||||
|
||||
if (in_array('draft', $status_parameters)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_DRAFT;
|
||||
}
|
||||
$po_status = [];
|
||||
|
||||
if (in_array('sent', $status_parameters)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_SENT;
|
||||
}
|
||||
if (in_array('draft', $status_parameters)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_DRAFT;
|
||||
}
|
||||
|
||||
if (in_array('accepted', $status_parameters)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_ACCEPTED;
|
||||
}
|
||||
if (in_array('sent', $status_parameters)) {
|
||||
$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)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_CANCELLED;
|
||||
}
|
||||
if (in_array('accepted', $status_parameters)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_ACCEPTED;
|
||||
}
|
||||
|
||||
if(count($status_parameters) >=1) {
|
||||
$this->builder->whereIn('status_id', $status_parameters);
|
||||
}
|
||||
if (in_array('cancelled', $status_parameters)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if(count($status_parameters) >=1) {
|
||||
$query->whereIn('status_id', $status_parameters);
|
||||
}
|
||||
})
|
||||
|
||||
return $this->builder;
|
||||
}
|
||||
|
@ -65,19 +65,20 @@ class RecurringInvoiceFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
if (in_array('active', $status_parameters)) {
|
||||
$this->builder->where('status_id', RecurringInvoice::STATUS_ACTIVE);
|
||||
}
|
||||
$recurring_filters = [];
|
||||
|
||||
if (in_array('paused', $status_parameters)) {
|
||||
$this->builder->where('status_id', RecurringInvoice::STATUS_PAUSED);
|
||||
}
|
||||
if (in_array('active', $status_parameters))
|
||||
$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