filter for recurring invoice filters

This commit is contained in:
David Bomba 2024-04-25 06:50:55 +10:00
parent b43a4ec866
commit 4dedfd616b
5 changed files with 36 additions and 2 deletions

View File

@ -133,6 +133,10 @@ class RecurringInvoiceFilters extends QueryFilters
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir); return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
} }
if($sort_col[0] == 'next_send_datetime'){
$sort_col[0] = 'next_send_date';
}
return $this->builder->orderBy($sort_col[0], $dir); return $this->builder->orderBy($sort_col[0], $dir);
} }

View File

@ -258,6 +258,16 @@ class ClientController extends BaseController
} }
if($action == 'bulk_update' && $user->can('edit', $clients->first())){
$clients = Client::withTrashed()
->company()
->whereIn('id', $request->ids);
$this->client_repo->bulkUpdate($clients, $request->column, $request->new_value);
}
$clients->each(function ($client) use ($action, $user) { $clients->each(function ($client) use ($action, $user) {
if ($user->can('edit', $client)) { if ($user->can('edit', $client)) {
$this->client_repo->{$action}($client); $this->client_repo->{$action}($client);

View File

@ -19,6 +19,17 @@ class BulkClientRequest extends Request
{ {
use MakesHash; use MakesHash;
private array $bulk_update_columns = [
'public_notes',
'industry_id',
'size_id',
'country_id',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4',
];
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
@ -35,12 +46,14 @@ class BulkClientRequest extends Request
$user = auth()->user(); $user = auth()->user();
return [ return [
'action' => 'required|string|in:archive,restore,delete,template,assign_group', 'action' => 'required|string|in:archive,restore,delete,template,assign_group,bulk_update',
'ids' => ['required','bail','array',Rule::exists('clients', 'id')->where('company_id', $user->company()->id)], 'ids' => ['required','bail','array',Rule::exists('clients', 'id')->where('company_id', $user->company()->id)],
'template' => 'sometimes|string', 'template' => 'sometimes|string',
'template_id' => 'sometimes|string', 'template_id' => 'sometimes|string',
'group_settings_id' => ['required_if:action,assign_group',Rule::exists('group_settings', 'id')->where('company_id', $user->company()->id)], 'group_settings_id' => ['required_if:action,assign_group',Rule::exists('group_settings', 'id')->where('company_id', $user->company()->id)],
'send_email' => 'sometimes|bool' 'send_email' => 'sometimes|bool',
'column' => ['required_if:action,bulk_update','string', Rule::in($this->client_bulk_update_columns)],
'new_value' => ['required_id:action,bulk_update|string'],
]; ];
} }

View File

@ -379,4 +379,9 @@ class BaseRepository
return $model->fresh(); return $model->fresh();
} }
public function bulkUpdate(\Illuminate\Database\Eloquent\Builder $model, string $column, mixed $new_value) :void
{
$model->update([$column => $new_value]);
}
} }

View File

@ -5296,6 +5296,8 @@ $lang = array(
'flutter_web_warning' => 'We recommend using the new web app or the desktop app for the best performance', 'flutter_web_warning' => 'We recommend using the new web app or the desktop app for the best performance',
'rappen_rounding' => 'Rappen Rounding', 'rappen_rounding' => 'Rappen Rounding',
'rappen_rounding_help' => 'Round amount to 5 cents', 'rappen_rounding_help' => 'Round amount to 5 cents',
'always_show_required_fields' => 'Always display required fields',
'always_show_required_fields_help' => 'Will show the form regards if the fields are filled or not'
); );
return $lang; return $lang;