diff --git a/app/Http/Controllers/Common/BulkActions.php b/app/Http/Controllers/Common/BulkActions.php index e84694553..ef43531a8 100644 --- a/app/Http/Controllers/Common/BulkActions.php +++ b/app/Http/Controllers/Common/BulkActions.php @@ -6,9 +6,7 @@ use App\Abstracts\Http\Controller; use App\Http\Requests\Common\BulkAction as Request; use Illuminate\Support\Str; -class - -BulkActions extends Controller +class BulkActions extends Controller { /** diff --git a/app/View/Components/SearchString.php b/app/View/Components/SearchString.php new file mode 100644 index 000000000..d7969ad06 --- /dev/null +++ b/app/View/Components/SearchString.php @@ -0,0 +1,82 @@ +model = $model; + } + + /** + * Get the view / contents that represent the component. + * + * @return \Illuminate\Contracts\View\View|string + */ + public function render() + { + $searc_string = config('search-string'); + + $this->filters = false; + + if (!empty($searc_string[$this->model])) { + $columns = $searc_string[$this->model]['columns']; + + foreach ($columns as $column => $options) { + if (!empty($options['searchable'])) { + continue; + } + + if (!is_array($options)) { + $column = $options; + } + + $name = $this->getFilterName($column); + + $this->filters[] = [ + 'key' => $column, + 'value' => $name, + 'url' => !empty($options['route']) ? route($options['route'][0], $options['route'][1]) : '' + ]; + } + } + + return view('components.search-string'); + } + + protected function getFilterName($column) + { + if (strpos($column, '_id') !== false) { + $column = str_replace('_id', '', $column); + } + + $plural = Str::plural($column, 2); + + if (trans_choice('general.' . $plural, 1) !== 'general.' . $plural) { + return trans_choice('general.' . $plural, 1); + } elseif (trans_choice('search_string.colmuns.' . $plural, 1) !== 'search_string.colmuns.' . $plural) { + return trans_choice('search_string.colmuns.' . $plural, 1); + } + + $name = trans('general.' . $column); + + if ($name == 'general.' . $column) { + $name = trans('search_string.colmuns.' . $column); + } + + return $name; + } +} diff --git a/config/search-string.php b/config/search-string.php index 355e1a988..cf316c474 100644 --- a/config/search-string.php +++ b/config/search-string.php @@ -120,9 +120,9 @@ return [ 'name' => ['searchable' => true], 'description' => ['searchable' => true], 'enabled' => ['boolean' => true], - 'category_id' => ['key' => 'category_id'], - 'sale_price', - 'purchase_price', + 'category_id' => [ + 'route' => ['categories.index', 'search=type:item'] + ], ], ], diff --git a/resources/assets/js/components/AkauntingSearch.vue b/resources/assets/js/components/AkauntingSearch.vue index 639849c4a..238c34490 100644 --- a/resources/assets/js/components/AkauntingSearch.vue +++ b/resources/assets/js/components/AkauntingSearch.vue @@ -1,175 +1,466 @@ - - + + \ No newline at end of file diff --git a/resources/lang/en-GB/general.php b/resources/lang/en-GB/general.php index 7c3426789..86eb36c0e 100644 --- a/resources/lang/en-GB/general.php +++ b/resources/lang/en-GB/general.php @@ -105,7 +105,7 @@ return [ 'to' => 'To', 'print' => 'Print', 'search' => 'Search', - 'search_placeholder' => 'Type to search..', + 'search_placeholder' => 'Search or filter results..', 'filter' => 'Filter', 'help' => 'Help', 'all' => 'All', diff --git a/resources/views/auth/permissions/index.blade.php b/resources/views/auth/permissions/index.blade.php index 54d53b2e0..381594d41 100644 --- a/resources/views/auth/permissions/index.blade.php +++ b/resources/views/auth/permissions/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.permissions', $bulk_actions, ['group' => 'auth', 'type' => 'permissions']) }} diff --git a/resources/views/auth/roles/index.blade.php b/resources/views/auth/roles/index.blade.php index a24fcabd3..992b7ff9e 100644 --- a/resources/views/auth/roles/index.blade.php +++ b/resources/views/auth/roles/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.roles', $bulk_actions, ['group' => 'auth', 'type' => 'roles']) }} diff --git a/resources/views/auth/users/index.blade.php b/resources/views/auth/users/index.blade.php index 69e5cd50f..a5d283672 100644 --- a/resources/views/auth/users/index.blade.php +++ b/resources/views/auth/users/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.users', $bulk_actions, ['group' => 'auth', 'type' => 'users']) }} diff --git a/resources/views/banking/accounts/index.blade.php b/resources/views/banking/accounts/index.blade.php index 888ff8cc7..24df6f215 100644 --- a/resources/views/banking/accounts/index.blade.php +++ b/resources/views/banking/accounts/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.accounts', $bulk_actions, ['group' => 'banking', 'type' => 'accounts']) }} diff --git a/resources/views/banking/reconciliations/index.blade.php b/resources/views/banking/reconciliations/index.blade.php index 2c0a9b255..d5ceabef9 100644 --- a/resources/views/banking/reconciliations/index.blade.php +++ b/resources/views/banking/reconciliations/index.blade.php @@ -19,10 +19,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.reconciliations', $bulk_actions, ['group' => 'banking', 'type' => 'reconciliations']) }} diff --git a/resources/views/banking/transactions/index.blade.php b/resources/views/banking/transactions/index.blade.php index 58d9a3a95..6b16ba24a 100644 --- a/resources/views/banking/transactions/index.blade.php +++ b/resources/views/banking/transactions/index.blade.php @@ -22,10 +22,7 @@ 'role' => 'form', 'class' => 'mb-0' ]) !!} - + {!! Form::close() !!} diff --git a/resources/views/banking/transfers/index.blade.php b/resources/views/banking/transfers/index.blade.php index f2f3b08f0..3b13700ec 100644 --- a/resources/views/banking/transfers/index.blade.php +++ b/resources/views/banking/transfers/index.blade.php @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.transfers', $bulk_actions, ['group' => 'banking', 'type' => 'transfers']) }} diff --git a/resources/views/common/companies/index.blade.php b/resources/views/common/companies/index.blade.php index b4de518d9..40049bbe9 100644 --- a/resources/views/common/companies/index.blade.php +++ b/resources/views/common/companies/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.companies', $bulk_actions, ['group' => 'common', 'type' => 'companies']) }} diff --git a/resources/views/common/dashboards/index.blade.php b/resources/views/common/dashboards/index.blade.php index 06cc6964a..a7536c528 100644 --- a/resources/views/common/dashboards/index.blade.php +++ b/resources/views/common/dashboards/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.dashboards', $bulk_actions, ['group' => 'common', 'type' => 'dashboards']) }} diff --git a/resources/views/common/items/index.blade.php b/resources/views/common/items/index.blade.php index 6a7170a7f..9e6b48018 100644 --- a/resources/views/common/items/index.blade.php +++ b/resources/views/common/items/index.blade.php @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.items', $bulk_actions, ['group' => 'common', 'type' => 'items']) }} diff --git a/resources/views/components/search-string.blade.php b/resources/views/components/search-string.blade.php new file mode 100644 index 000000000..d655b6dc8 --- /dev/null +++ b/resources/views/components/search-string.blade.php @@ -0,0 +1,7 @@ + + diff --git a/resources/views/purchases/bills/index.blade.php b/resources/views/purchases/bills/index.blade.php index 97f715f75..540b72cc7 100644 --- a/resources/views/purchases/bills/index.blade.php +++ b/resources/views/purchases/bills/index.blade.php @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.bills', $bulk_actions, ['group' => 'purchases', 'type' => 'bills']) }} diff --git a/resources/views/purchases/payments/index.blade.php b/resources/views/purchases/payments/index.blade.php index 3c24e4cb6..7aa451d26 100644 --- a/resources/views/purchases/payments/index.blade.php +++ b/resources/views/purchases/payments/index.blade.php @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.payments', $bulk_actions, ['group' => 'purchases', 'type' => 'payments']) }} diff --git a/resources/views/purchases/vendors/index.blade.php b/resources/views/purchases/vendors/index.blade.php index 8d2f4501a..c1045e75b 100644 --- a/resources/views/purchases/vendors/index.blade.php +++ b/resources/views/purchases/vendors/index.blade.php @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.vendors', $bulk_actions, ['group' => 'purchases', 'type' => 'vendors']) }} diff --git a/resources/views/sales/customers/index.blade.php b/resources/views/sales/customers/index.blade.php index 0b067419d..824341b7a 100644 --- a/resources/views/sales/customers/index.blade.php +++ b/resources/views/sales/customers/index.blade.php @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.customers', $bulk_actions, ['group' => 'sales', 'type' => 'customers']) }} diff --git a/resources/views/sales/invoices/index.blade.php b/resources/views/sales/invoices/index.blade.php index ec9deea37..03649eb26 100644 --- a/resources/views/sales/invoices/index.blade.php +++ b/resources/views/sales/invoices/index.blade.php @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.invoices', $bulk_actions, ['group' => 'sales', 'type' => 'invoices']) }} diff --git a/resources/views/sales/revenues/index.blade.php b/resources/views/sales/revenues/index.blade.php index 75930749e..42f6cab05 100644 --- a/resources/views/sales/revenues/index.blade.php +++ b/resources/views/sales/revenues/index.blade.php @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.revenues', $bulk_actions, ['group' => 'sales', 'type' => 'revenues']) }} diff --git a/resources/views/settings/categories/index.blade.php b/resources/views/settings/categories/index.blade.php index 50d1a1ade..ac5b2a67f 100644 --- a/resources/views/settings/categories/index.blade.php +++ b/resources/views/settings/categories/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.categories', $bulk_actions, ['group' => 'settings', 'type' => 'categories']) }} diff --git a/resources/views/settings/currencies/index.blade.php b/resources/views/settings/currencies/index.blade.php index 3a22a21ba..259cbfd45 100644 --- a/resources/views/settings/currencies/index.blade.php +++ b/resources/views/settings/currencies/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.currencies', $bulk_actions, ['group' => 'settings', 'type' => 'currencies']) }} diff --git a/resources/views/settings/taxes/index.blade.php b/resources/views/settings/taxes/index.blade.php index fd22cde08..cbea11413 100644 --- a/resources/views/settings/taxes/index.blade.php +++ b/resources/views/settings/taxes/index.blade.php @@ -19,10 +19,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.taxes', $bulk_actions, ['group' => 'settings', 'type' => 'taxes']) }}