diff --git a/app/Filters/QuoteFilters.php b/app/Filters/QuoteFilters.php index f619559b621c..9942ee909c29 100644 --- a/app/Filters/QuoteFilters.php +++ b/app/Filters/QuoteFilters.php @@ -11,6 +11,7 @@ namespace App\Filters; +use App\Models\Quote; use App\Models\User; use Illuminate\Database\Eloquent\Builder; @@ -41,6 +42,51 @@ class QuoteFilters extends QueryFilters }); } + /** + * Filter based on client status. + * + * Statuses we need to handle + * - all + * - active + * - paused + * - completed + * + * @param string client_status The invoice status as seen by the client + * @return Builder + */ + public function client_status(string $value = '') :Builder + { + if (strlen($value) == 0) { + return $this->builder; + } + + $status_parameters = explode(',', $value); + + if (in_array('all', $status_parameters)) { + return $this->builder; + } + + if (in_array('draft', $status_parameters)) { + $this->builder->where('status_id', Quote::STATUS_DRAFT); + } + + if (in_array('sent', $status_parameters)) { + $this->builder->where('status_id', Quote::STATUS_SENT); + } + + if (in_array('approved', $status_parameters)) { + $this->builder->where('status_id', Quote::STATUS_APPROVED); + } + + if (in_array('expired', $status_parameters)) { + $this->builder->where('status_id', Quote::STATUS_SENT) + ->where('due_date', '<=', now()->toDateString()); + } + + return $this->builder; + } + + /** * Filters the list based on the status * archived, active, deleted. diff --git a/app/Filters/RecurringInvoiceFilters.php b/app/Filters/RecurringInvoiceFilters.php index 39f0bcaa0de7..541f24c03617 100644 --- a/app/Filters/RecurringInvoiceFilters.php +++ b/app/Filters/RecurringInvoiceFilters.php @@ -11,6 +11,7 @@ namespace App\Filters; +use App\Models\RecurringInvoice; use App\Models\User; use Illuminate\Database\Eloquent\Builder; @@ -40,6 +41,46 @@ class RecurringInvoiceFilters extends QueryFilters }); } + /** + * Filter based on client status. + * + * Statuses we need to handle + * - all + * - active + * - paused + * - completed + * + * @param string client_status The invoice status as seen by the client + * @return Builder + */ + public function client_status(string $value = '') :Builder + { + if (strlen($value) == 0) { + return $this->builder; + } + + $status_parameters = explode(',', $value); + + if (in_array('all', $status_parameters)) { + return $this->builder; + } + + if (in_array('active', $status_parameters)) { + $this->builder->where('status_id', RecurringInvoice::STATUS_ACTIVE); + } + + if (in_array('paused', $status_parameters)) { + $this->builder->where('status_id', RecurringInvoice::STATUS_PAUSED); + } + + if (in_array('completed', $status_parameters)) { + $this->builder->where('status_id', RecurringInvoice::STATUS_COMPLETED); + } + + return $this->builder; + } + + /** * Filters the list based on the status * archived, active, deleted. diff --git a/lang/en/texts.php b/lang/en/texts.php index fe2e75ac1590..3817b0d65129 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -4839,6 +4839,10 @@ $LANG = array( 'show_tasks_in_client_portal' => 'Show Tasks in Client Portal', 'notification_quote_expired_subject' => 'Quote :invoice has expired for :client', 'notification_quote_expired' => 'The following Quote :invoice for client :client and :amount has now expired.', + 'auto_sync' => 'Auto Sync', + 'refresh_accounts' => 'Refresh Accounts', + 'upgrade_to_connect_bank_account' => 'Upgrade to Enterprise to connect your bank account', + 'click_here_to_connect_bank_account' => 'Click here to connect your bank account', ); return $LANG;