diff --git a/app/Filters/RecurringInvoiceFilters.php b/app/Filters/RecurringInvoiceFilters.php index 4917a12a1f10..b9124c9168cb 100644 --- a/app/Filters/RecurringInvoiceFilters.php +++ b/app/Filters/RecurringInvoiceFilters.php @@ -133,6 +133,10 @@ class RecurringInvoiceFilters extends QueryFilters 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); } diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index e9e733191d5e..b8ba7573ad79 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -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) { if ($user->can('edit', $client)) { $this->client_repo->{$action}($client); diff --git a/app/Http/Requests/Client/BulkClientRequest.php b/app/Http/Requests/Client/BulkClientRequest.php index 1d61c0ddc7ae..b16fec93abb4 100644 --- a/app/Http/Requests/Client/BulkClientRequest.php +++ b/app/Http/Requests/Client/BulkClientRequest.php @@ -19,6 +19,17 @@ class BulkClientRequest extends Request { 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. * @@ -35,12 +46,14 @@ class BulkClientRequest extends Request $user = auth()->user(); 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)], 'template' => '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)], - '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'], ]; } diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index be0bfbf31b2a..ff2c6e1f8816 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -379,4 +379,9 @@ class BaseRepository return $model->fresh(); } + + public function bulkUpdate(\Illuminate\Database\Eloquent\Builder $model, string $column, mixed $new_value) :void + { + $model->update([$column => $new_value]); + } } diff --git a/lang/bg/texts.php b/lang/bg/texts.php index 602ace3c55e0..af87cbbca4f4 100644 --- a/lang/bg/texts.php +++ b/lang/bg/texts.php @@ -5296,6 +5296,8 @@ $lang = array( 'flutter_web_warning' => 'We recommend using the new web app or the desktop app for the best performance', 'rappen_rounding' => 'Rappen Rounding', '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;