mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-05 11:24:35 -04:00
Merge branch 'v5-develop' into issue-templat
This commit is contained in:
commit
d8c592e700
4
.github/ISSUE_TEMPLATE/bug_report.md
vendored
4
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -15,7 +15,7 @@ https://invoiceninja.github.io/docs/self-host-troubleshooting/ -->
|
|||||||
- Environment: <!-- Docker/Shared Hosting/ZIP/Other -->
|
- Environment: <!-- Docker/Shared Hosting/ZIP/Other -->
|
||||||
|
|
||||||
## Checklist
|
## Checklist
|
||||||
- Can you replicate the issue on our v5 demo site https://demo.invoiceninja.com?
|
- Can you replicate the issue on our v5 demo site https://demo.invoiceninja.com pr https://react.invoicing.co/demo?
|
||||||
- Have you searched existing issues?
|
- Have you searched existing issues?
|
||||||
- Have you reported this to Slack/forum before posting?
|
- Have you reported this to Slack/forum before posting?
|
||||||
|
|
||||||
@ -38,4 +38,4 @@ https://invoiceninja.github.io/docs/self-host-troubleshooting/ -->
|
|||||||
<!-- Please check the log files (storage/logs/) and provide redacted output -->
|
<!-- Please check the log files (storage/logs/) and provide redacted output -->
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
@ -68,28 +68,22 @@ class BankIntegrationFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = 'bank_integrations';
|
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
return $this->builder->where(function ($query) use ($filters) {
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
$query->orWhereNull('deleted_at');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
||||||
$query->orWhere(function ($query) use ($table) {
|
$query->orWhere(function ($query) {
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
$query->whereNotNull('deleted_at');
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
if (in_array(parent::STATUS_DELETED, $filters)) {
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
$query->orWhere('is_deleted', 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -107,19 +101,6 @@ class BankIntegrationFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -134,14 +134,12 @@ class BankTransactionFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = 'bank_transactions';
|
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
return $this->builder->where(function ($query) use ($filters) {
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
$query->orWhereNull('deleted_at');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
||||||
|
@ -55,45 +55,6 @@ class BankTransactionRuleFilters extends QueryFilters
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'bank_transaction_rules';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
|
@ -122,45 +122,6 @@ class ClientFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'clients';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -176,59 +137,7 @@ class ClientFilters extends QueryFilters
|
|||||||
|
|
||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
$query = DB::table('clients')
|
|
||||||
->join('companies', 'companies.id', '=', 'clients.company_id')
|
|
||||||
->join('client_contacts', 'client_contacts.client_id', '=', 'clients.id')
|
|
||||||
->where('clients.company_id', '=', $company_id)
|
|
||||||
->where('client_contacts.is_primary', '=', true)
|
|
||||||
->where('client_contacts.deleted_at', '=', null)
|
|
||||||
->select(
|
|
||||||
DB::raw('COALESCE(clients.country_id, companies.country_id) country_id'),
|
|
||||||
DB::raw("CONCAT(COALESCE(client_contacts.first_name, ''), ' ', COALESCE(client_contacts.last_name, '')) contact"),
|
|
||||||
'clients.id',
|
|
||||||
'clients.name',
|
|
||||||
'clients.private_notes',
|
|
||||||
'client_contacts.first_name',
|
|
||||||
'client_contacts.last_name',
|
|
||||||
'clients.custom_value1',
|
|
||||||
'clients.custom_value2',
|
|
||||||
'clients.custom_value3',
|
|
||||||
'clients.custom_value4',
|
|
||||||
'clients.balance',
|
|
||||||
'clients.last_login',
|
|
||||||
'clients.created_at',
|
|
||||||
'clients.created_at as client_created_at',
|
|
||||||
'client_contacts.phone',
|
|
||||||
'client_contacts.email',
|
|
||||||
'clients.deleted_at',
|
|
||||||
'clients.is_deleted',
|
|
||||||
'clients.user_id',
|
|
||||||
'clients.id_number',
|
|
||||||
'clients.settings'
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user does not have permissions to view all invoices
|
|
||||||
* limit the user to only the invoices they have created
|
|
||||||
*/
|
|
||||||
if (Gate::denies('view-list', Client::class)) {
|
|
||||||
$query->where('clients.user_id', '=', $user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -37,45 +37,6 @@ class CompanyGatewayFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'company_gateways';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -89,19 +50,6 @@ class CompanyGatewayFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -88,45 +88,6 @@ class CreditFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted - legacy from V1.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'credits';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -140,19 +101,6 @@ class CreditFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
// ..
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -40,45 +40,6 @@ class DesignFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'designs';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
|
@ -64,19 +64,6 @@ class DocumentFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -35,49 +35,10 @@ class ExpenseCategoryFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->builder->where('expense_categories.name', 'like', '%'.$filter.'%');
|
return $this->builder->where('name', 'like', '%'.$filter.'%');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'expense_categories';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -95,21 +56,6 @@ class ExpenseCategoryFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
|
|
||||||
return $this->builder;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -69,14 +69,15 @@ class ExpenseFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->builder->whereNested(function ($query) use($status_parameters){
|
$this->builder->where(function ($query) use($status_parameters){
|
||||||
|
|
||||||
if (in_array('logged', $status_parameters)) {
|
if (in_array('logged', $status_parameters)) {
|
||||||
|
|
||||||
$query->orWhere(function ($query){
|
$query->orWhere(function ($query){
|
||||||
$query->where('amount', '>', 0)
|
$query->where('amount', '>', 0)
|
||||||
->whereNull('invoice_id')
|
->whereNull('invoice_id')
|
||||||
->whereNull('payment_date');
|
->whereNull('payment_date')
|
||||||
|
->where('should_be_invoiced',false);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -135,46 +136,6 @@ class ExpenseFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'expenses';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -192,46 +153,6 @@ class ExpenseFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
$query = DB::table('expenses')
|
|
||||||
->join('companies', 'companies.id', '=', 'expenses.company_id')
|
|
||||||
->where('expenses.company_id', '=', $company_id)
|
|
||||||
->select(
|
|
||||||
DB::raw('COALESCE(expenses.country_id, companies.country_id) country_id'),
|
|
||||||
DB::raw("CONCAT(COALESCE(expense_contacts.first_name, ''), ' ', COALESCE(expense_contacts.last_name, '')) contact"),
|
|
||||||
'expenses.id',
|
|
||||||
'expenses.private_notes',
|
|
||||||
'expenses.custom_value1',
|
|
||||||
'expenses.custom_value2',
|
|
||||||
'expenses.custom_value3',
|
|
||||||
'expenses.custom_value4',
|
|
||||||
'expenses.created_at',
|
|
||||||
'expenses.created_at as expense_created_at',
|
|
||||||
'expenses.deleted_at',
|
|
||||||
'expenses.is_deleted',
|
|
||||||
'expenses.user_id',
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user does not have permissions to view all invoices
|
|
||||||
* limit the user to only the invoices they have created
|
|
||||||
*/
|
|
||||||
if (Gate::denies('view-list', Expense::class)) {
|
|
||||||
$query->where('expenses.user_id', '=', $user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -47,30 +47,33 @@ class InvoiceFilters extends QueryFilters
|
|||||||
|
|
||||||
$status_parameters = explode(',', $value);
|
$status_parameters = explode(',', $value);
|
||||||
|
|
||||||
$invoice_filters = [];
|
|
||||||
|
|
||||||
if (in_array('all', $status_parameters)) {
|
if (in_array('all', $status_parameters)) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('paid', $status_parameters)) {
|
$this->builder->where(function ($query) use($status_parameters){
|
||||||
$invoice_filters[] = Invoice::STATUS_PAID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array('unpaid', $status_parameters)) {
|
$invoice_filters = [];
|
||||||
$invoice_filters[] = Invoice::STATUS_SENT;
|
|
||||||
$invoice_filters[] = Invoice::STATUS_PARTIAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($invoice_filters) >0){
|
if (in_array('paid', $status_parameters)) {
|
||||||
$this->builder->whereIn('status_id', $invoice_filters);
|
$invoice_filters[] = Invoice::STATUS_PAID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('overdue', $status_parameters)) {
|
if (in_array('unpaid', $status_parameters)) {
|
||||||
$this->builder->orWhereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
$invoice_filters[] = Invoice::STATUS_SENT;
|
||||||
->where('due_date', '<', Carbon::now())
|
$invoice_filters[] = Invoice::STATUS_PARTIAL;
|
||||||
->orWhere('partial_due_date', '<', Carbon::now());
|
}
|
||||||
}
|
|
||||||
|
if(count($invoice_filters) >0){
|
||||||
|
$query->whereIn('status_id', $invoice_filters);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('overdue', $status_parameters)) {
|
||||||
|
$query->orWhereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||||
|
->where('due_date', '<', Carbon::now())
|
||||||
|
->orWhere('partial_due_date', '<', Carbon::now());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
@ -106,45 +109,6 @@ class InvoiceFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted - legacy from V1.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'invoices';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Builder
|
* @return Builder
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
@ -221,18 +185,6 @@ class InvoiceFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -42,45 +42,6 @@ class PaymentFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'payments';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of payments that can be matched to bank transactions
|
* Returns a list of payments that can be matched to bank transactions
|
||||||
*/
|
*/
|
||||||
@ -92,7 +53,8 @@ class PaymentFilters extends QueryFilters
|
|||||||
->where('is_deleted',0)
|
->where('is_deleted',0)
|
||||||
->where(function ($query){
|
->where(function ($query){
|
||||||
$query->whereNull('transaction_id')
|
$query->whereNull('transaction_id')
|
||||||
->orWhere("transaction_id","");
|
->orWhere("transaction_id","")
|
||||||
|
->company();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -118,18 +80,6 @@ class PaymentFilters extends QueryFilters
|
|||||||
return $this->builder->where('number', $number);
|
return $this->builder->where('number', $number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -40,45 +40,6 @@ class PaymentTermFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'payment_terms';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -92,19 +53,6 @@ class PaymentTermFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -53,45 +53,6 @@ class ProductFilters extends QueryFilters
|
|||||||
return $this->builder->where('product_key', $filter);
|
return $this->builder->where('product_key', $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'products';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -108,18 +69,6 @@ class ProductFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -42,45 +42,6 @@ class ProjectFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'projects';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -94,43 +55,6 @@ class ProjectFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
$query = DB::table('projects')
|
|
||||||
->join('companies', 'companies.id', '=', 'projects.company_id')
|
|
||||||
->where('projects.company_id', '=', $company_id)
|
|
||||||
->select(
|
|
||||||
'projects.id',
|
|
||||||
'projects.name',
|
|
||||||
'projects.public_notes',
|
|
||||||
'projects.private_notes',
|
|
||||||
'projects.created_at',
|
|
||||||
'projects.created_at as project_created_at',
|
|
||||||
'projects.deleted_at',
|
|
||||||
'projects.is_deleted',
|
|
||||||
'projects.user_id',
|
|
||||||
'projects.assigned_user_id',
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user does not have permissions to view all invoices
|
|
||||||
* limit the user to only the invoices they have created
|
|
||||||
*/
|
|
||||||
if (Gate::denies('view-list', Project::class)) {
|
|
||||||
$query->where('projects.user_id', '=', $user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
@ -138,8 +62,6 @@ class ProjectFilters extends QueryFilters
|
|||||||
*/
|
*/
|
||||||
public function entityFilter()
|
public function entityFilter()
|
||||||
{
|
{
|
||||||
//return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
|
||||||
// return $this->builder->whereCompanyId(auth()->user()->company()->id)->orWhere('company_id', null);
|
|
||||||
return $this->builder->company();
|
return $this->builder->company();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
@ -93,45 +101,6 @@ class PurchaseOrderFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted - legacy from V1.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'purchase_orders';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -145,19 +114,6 @@ class PurchaseOrderFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
// ..
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -129,6 +129,38 @@ abstract class QueryFilters
|
|||||||
return $parts;
|
return $parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the list based on the status
|
||||||
|
* archived, active, deleted.
|
||||||
|
*
|
||||||
|
* @param string filter
|
||||||
|
* @return Builder
|
||||||
|
*/
|
||||||
|
public function status(string $filter = '') : Builder
|
||||||
|
{
|
||||||
|
if (strlen($filter) == 0) {
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
$filters = explode(',', $filter);
|
||||||
|
|
||||||
|
return $this->builder->where(function ($query) use ($filters) {
|
||||||
|
if (in_array(self::STATUS_ACTIVE, $filters)) {
|
||||||
|
$query->orWhereNull('deleted_at');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array(self::STATUS_ARCHIVED, $filters)) {
|
||||||
|
$query->orWhere(function ($query) {
|
||||||
|
$query->whereNotNull('deleted_at')->where('is_deleted',0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array(self::STATUS_DELETED, $filters)) {
|
||||||
|
$query->orWhere('is_deleted', 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String to operator convertor.
|
* String to operator convertor.
|
||||||
*
|
*
|
||||||
|
@ -66,85 +66,52 @@ class QuoteFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
$quote_filters = [];
|
$this->builder->where(function ($query) use ($status_parameters){
|
||||||
|
|
||||||
if (in_array('draft', $status_parameters)) {
|
if (in_array('sent', $status_parameters)) {
|
||||||
$quote_filters[] = Quote::STATUS_DRAFT;
|
$query->orWhere(function ($q){
|
||||||
}
|
$q->where('status_id', Quote::STATUS_SENT)
|
||||||
|
->whereNull('due_date')
|
||||||
|
->orWhere('due_date', '>=', now()->toDateString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$quote_filters = [];
|
||||||
|
|
||||||
if (in_array('sent', $status_parameters)) {
|
if (in_array('draft', $status_parameters)) {
|
||||||
$quote_filters[] = Quote::STATUS_SENT;
|
$quote_filters[] = Quote::STATUS_DRAFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('approved', $status_parameters)) {
|
|
||||||
$quote_filters[] = Quote::STATUS_APPROVED;
|
if (in_array('approved', $status_parameters)) {
|
||||||
}
|
$quote_filters[] = Quote::STATUS_APPROVED;
|
||||||
|
}
|
||||||
|
|
||||||
if(count($quote_filters) >=1){
|
if(count($quote_filters) >0){
|
||||||
$this->builder->whereIn('status_id', $quote_filters);
|
$query->orWhereIn('status_id', $quote_filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('expired', $status_parameters)) {
|
if (in_array('expired', $status_parameters)) {
|
||||||
$this->builder->orWhere(function ($query){
|
$query->orWhere(function ($q){
|
||||||
$query->where('status_id', Quote::STATUS_SENT)
|
$q->where('status_id', Quote::STATUS_SENT)
|
||||||
->company()
|
->whereNotNull('due_date')
|
||||||
->whereNotNull('due_date')
|
->where('due_date', '<=', now()->toDateString());
|
||||||
->where('due_date', '<=', now()->toDateString());
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array('upcoming', $status_parameters)) {
|
if (in_array('upcoming', $status_parameters)) {
|
||||||
$this->builder->orWhere(function ($query){
|
$query->orWhere(function ($q){
|
||||||
$query->where('status_id', Quote::STATUS_SENT)
|
$q->where('status_id', Quote::STATUS_SENT)
|
||||||
->company()
|
->where('due_date', '>=', now()->toDateString())
|
||||||
->where('due_date', '>=', now()->toDateString())
|
->orderBy('due_date', 'DESC');
|
||||||
->orderBy('due_date', 'DESC');
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
});
|
||||||
|
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'quotes';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function number($number = '')
|
public function number($number = '')
|
||||||
{
|
{
|
||||||
return $this->builder->where('number', 'like', '%'.$number.'%');
|
return $this->builder->where('number', 'like', '%'.$number.'%');
|
||||||
@ -166,18 +133,6 @@ class QuoteFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -45,45 +45,6 @@ class RecurringExpenseFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'recurring_expenses';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -97,45 +58,6 @@ class RecurringExpenseFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
$query = DB::table('recurring_expenses')
|
|
||||||
->join('companies', 'companies.id', '=', 'recurring_expenses.company_id')
|
|
||||||
->where('recurring_expenses.company_id', '=', $company_id)
|
|
||||||
->select(
|
|
||||||
DB::raw('COALESCE(recurring_expenses.country_id, companies.country_id) country_id'),
|
|
||||||
'recurring_expenses.id',
|
|
||||||
'recurring_expenses.private_notes',
|
|
||||||
'recurring_expenses.custom_value1',
|
|
||||||
'recurring_expenses.custom_value2',
|
|
||||||
'recurring_expenses.custom_value3',
|
|
||||||
'recurring_expenses.custom_value4',
|
|
||||||
'recurring_expenses.created_at',
|
|
||||||
'recurring_expenses.created_at as expense_created_at',
|
|
||||||
'recurring_expenses.deleted_at',
|
|
||||||
'recurring_expenses.is_deleted',
|
|
||||||
'recurring_expenses.user_id',
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user does not have permissions to view all invoices
|
|
||||||
* limit the user to only the invoices they have created
|
|
||||||
*/
|
|
||||||
if (Gate::denies('view-list', RecurringExpense::class)) {
|
|
||||||
$query->where('recurring_expenses.user_id', '=', $user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -65,59 +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))
|
||||||
* Filters the list based on the status
|
$recurring_filters[] = RecurringInvoice::STATUS_PAUSED;
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'recurring_invoices';
|
if (in_array('completed', $status_parameters))
|
||||||
$filters = explode(',', $filter);
|
$recurring_filters[] = RecurringInvoice::STATUS_COMPLETED;
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
return $this->builder->whereIn('status_id', $recurring_filters);
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,18 +94,6 @@ class RecurringInvoiceFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -40,45 +40,6 @@ class RecurringQuoteFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'recurring_';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -92,18 +53,6 @@ class RecurringQuoteFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -40,45 +40,6 @@ class SubscriptionFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'subscriptions';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -92,31 +53,6 @@ class SubscriptionFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
$query = DB::table('subscriptions')
|
|
||||||
->join('companies', 'companies.id', '=', 'subscriptions.company_id')
|
|
||||||
->where('subscriptions.company_id', '=', $company_id);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user does not have permissions to view all invoices
|
|
||||||
* limit the user to only the invoices they have created
|
|
||||||
*/
|
|
||||||
if (Gate::denies('view-list', Webhook::class)) {
|
|
||||||
$query->where('subscriptions.user_id', '=', $user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -63,18 +63,6 @@ class SystemLogFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -74,46 +74,6 @@ class TaskFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'tasks';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function project_tasks($project)
|
public function project_tasks($project)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -137,18 +97,6 @@ class TaskFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -37,45 +37,6 @@ class TaskStatusFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'task_statuses';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -89,19 +50,6 @@ class TaskStatusFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -37,45 +37,6 @@ class TaxRateFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'tax_rates';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -89,19 +50,6 @@ class TaxRateFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -39,45 +39,6 @@ class TokenFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'company_tokens';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -90,42 +51,7 @@ class TokenFilters extends QueryFilters
|
|||||||
|
|
||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
$query = DB::table('company_tokens')
|
|
||||||
->join('companies', 'companies.id', '=', 'company_tokens.company_id')
|
|
||||||
->where('company_tokens.company_id', '=', $company_id)
|
|
||||||
->select(
|
|
||||||
'company_tokens.id',
|
|
||||||
'company_tokens.name',
|
|
||||||
'company_tokens.token',
|
|
||||||
'company_tokens.created_at',
|
|
||||||
'company_tokens.created_at as token_created_at',
|
|
||||||
'company_tokens.deleted_at',
|
|
||||||
'company_tokens.is_deleted',
|
|
||||||
'company_tokens.user_id',
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user does not have permissions to view all invoices
|
|
||||||
* limit the user to only the invoices they have created
|
|
||||||
*/
|
|
||||||
if (Gate::denies('view-list', CompanyToken::class)) {
|
|
||||||
$query->where('company_tokens.user_id', '=', $user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -40,44 +40,6 @@ class UserFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'users';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
@ -92,18 +54,6 @@ class UserFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -50,45 +50,6 @@ class VendorFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'vendors';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -102,59 +63,6 @@ class VendorFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
$query = DB::table('vendors')
|
|
||||||
->join('companies', 'companies.id', '=', 'vendors.company_id')
|
|
||||||
->join('vendor_contacts', 'vendor_contacts.vendor_id', '=', 'vendors.id')
|
|
||||||
->where('vendors.company_id', '=', $company_id)
|
|
||||||
->where('vendor_contacts.is_primary', '=', true)
|
|
||||||
->where('vendor_contacts.deleted_at', '=', null)
|
|
||||||
->select(
|
|
||||||
// DB::raw('COALESCE(vendors.currency_id, companies.currency_id) currency_id'),
|
|
||||||
DB::raw('COALESCE(vendors.country_id, companies.country_id) country_id'),
|
|
||||||
DB::raw("CONCAT(COALESCE(vendor_contacts.first_name, ''), ' ', COALESCE(vendor_contacts.last_name, '')) contact"),
|
|
||||||
'vendors.id',
|
|
||||||
'vendors.name',
|
|
||||||
'vendors.private_notes',
|
|
||||||
'vendor_contacts.first_name',
|
|
||||||
'vendor_contacts.last_name',
|
|
||||||
'vendors.custom_value1',
|
|
||||||
'vendors.custom_value2',
|
|
||||||
'vendors.custom_value3',
|
|
||||||
'vendors.custom_value4',
|
|
||||||
'vendors.balance',
|
|
||||||
'vendors.last_login',
|
|
||||||
'vendors.created_at',
|
|
||||||
'vendors.created_at as vendor_created_at',
|
|
||||||
'vendor_contacts.phone',
|
|
||||||
'vendor_contacts.email',
|
|
||||||
'vendors.deleted_at',
|
|
||||||
'vendors.is_deleted',
|
|
||||||
'vendors.user_id',
|
|
||||||
'vendors.id_number',
|
|
||||||
'vendors.settings'
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user does not have permissions to view all invoices
|
|
||||||
* limit the user to only the invoices they have created
|
|
||||||
*/
|
|
||||||
if (Gate::denies('view-list', Vendor::class)) {
|
|
||||||
$query->where('vendors.user_id', '=', $user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -40,45 +40,6 @@ class WebhookFilters extends QueryFilters
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the list based on the status
|
|
||||||
* archived, active, deleted.
|
|
||||||
*
|
|
||||||
* @param string filter
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function status(string $filter = '') : Builder
|
|
||||||
{
|
|
||||||
if (strlen($filter) == 0) {
|
|
||||||
return $this->builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table = 'webhooks';
|
|
||||||
$filters = explode(',', $filter);
|
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filters, $table) {
|
|
||||||
$query->whereNull($table.'.id');
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ACTIVE, $filters)) {
|
|
||||||
$query->orWhereNull($table.'.deleted_at');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_ARCHIVED, $filters)) {
|
|
||||||
$query->orWhere(function ($query) use ($table) {
|
|
||||||
$query->whereNotNull($table.'.deleted_at');
|
|
||||||
|
|
||||||
if (! in_array($table, ['users'])) {
|
|
||||||
$query->where($table.'.is_deleted', '=', 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(parent::STATUS_DELETED, $filters)) {
|
|
||||||
$query->orWhere($table.'.is_deleted', '=', 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
*
|
*
|
||||||
@ -92,41 +53,6 @@ class WebhookFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base query.
|
|
||||||
*
|
|
||||||
* @param int company_id
|
|
||||||
* @param User $user
|
|
||||||
* @return Builder
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
|
||||||
{
|
|
||||||
$query = DB::table('webhooks')
|
|
||||||
->join('companies', 'companies.id', '=', 'webhooks.company_id')
|
|
||||||
->where('webhooks.company_id', '=', $company_id)
|
|
||||||
->select(
|
|
||||||
'webhooks.id',
|
|
||||||
'webhooks.target_url',
|
|
||||||
'webhooks.event_id',
|
|
||||||
'webhooks.created_at',
|
|
||||||
'webhooks.created_at as token_created_at',
|
|
||||||
'webhooks.deleted_at',
|
|
||||||
'webhooks.format',
|
|
||||||
'webhooks.user_id',
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user does not have permissions to view all invoices
|
|
||||||
* limit the user to only the invoices they have created
|
|
||||||
*/
|
|
||||||
if (Gate::denies('view-list', Webhook::class)) {
|
|
||||||
$query->where('webhooks.user_id', '=', $user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -65,8 +65,20 @@ class GmailTransport extends AbstractTransport
|
|||||||
|
|
||||||
$body->setRaw($this->base64_encode($bcc_list.$message->toString()));
|
$body->setRaw($this->base64_encode($bcc_list.$message->toString()));
|
||||||
|
|
||||||
$service->users_messages->send('me', $body, []);
|
try{
|
||||||
|
$service->users_messages->send('me', $body, []);
|
||||||
|
}
|
||||||
|
catch(Google\Service\Exception $e) {
|
||||||
|
|
||||||
|
/* Need to slow down */
|
||||||
|
if($e->getCode() == '429') {
|
||||||
|
|
||||||
|
sleep(5);
|
||||||
|
$service->users_messages->send('me', $body, []);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function base64_encode($data)
|
private function base64_encode($data)
|
||||||
|
@ -30,7 +30,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
class BankMatchingService implements ShouldQueue, ShouldBeUnique
|
class BankMatchingService implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
@ -60,13 +60,12 @@ trait GeneratesCounter
|
|||||||
|
|
||||||
$counter_entity = $client;
|
$counter_entity = $client;
|
||||||
} elseif ((strpos($pattern, 'groupCounter') !== false) || (strpos($pattern, 'group_counter') !== false)) {
|
} elseif ((strpos($pattern, 'groupCounter') !== false) || (strpos($pattern, 'group_counter') !== false)) {
|
||||||
if (property_exists($client, 'group_settings') && property_exists($client->group_settings, $counter_string)) {
|
if ($client->group_settings()->exists() && property_exists($client->group_settings?->settings, $counter_string)) {
|
||||||
$counter = $client->group_settings->{$counter_string};
|
$counter = $client->group_settings?->settings?->{$counter_string};
|
||||||
} else {
|
} else {
|
||||||
$counter = 1;
|
$counter = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $counter_entity = $client->group_settings;
|
|
||||||
$counter_entity = $client->group_settings ?: $client->company;
|
$counter_entity = $client->group_settings ?: $client->company;
|
||||||
} else {
|
} else {
|
||||||
$counter = $client->company->settings->{$counter_string};
|
$counter = $client->company->settings->{$counter_string};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user