A free open source IT asset/license management system
Normalize advanced search
snipeb7193a06fdf9
diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.phpindex 7933b19057..3a198f1dd3 100644--- a/app/Http/Controllers/Api/AccessoriesController.php+++ b/app/Http/Controllers/Api/AccessoriesController.php@@ -54,6 +54,15 @@ class AccessoriesController extends Controller'notes','checkouts_count','qty',+ // These are *relationships* so we wouldn't normally include them in this array,+ // since they would normally create a `column not found` error,+ // BUT we account for them in the ordering switch down at the end of this method+ // DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!+ 'company',+ 'location',+ 'category',+ 'supplier',+ 'manufacturer',];@@ -61,10 +70,23 @@ class AccessoriesController extends Controller->with('category', 'company', 'manufacturer', 'checkouts', 'location', 'supplier', 'adminuser')->withCount('checkouts as checkouts_count');- if ($request->filled('search')) {- $accessories = $accessories->TextSearch($request->input('search'));+ $filter = [];++ if ($request->filled('filter')) {+ $filter = json_decode($request->input('filter'), true);+ $filter = array_filter($filter, function ($key) use ($allowed_columns) {+ return in_array($key, $allowed_columns);+ }, ARRAY_FILTER_USE_KEY);+}+ if ((! is_null($filter)) && (count($filter)) > 0) {+ $accessories->ByFilter($filter);+ } elseif ($request->filled('search')) {+ $accessories->TextSearch($request->input('search'));+ }++if ($request->filled('company_id')) {$accessories->where('accessories.company_id', '=', $request->input('company_id'));}diff --git a/app/Http/Controllers/Api/AssetModelsController.php b/app/Http/Controllers/Api/AssetModelsController.phpindex 601d92e861..d0a6ceba5b 100644--- a/app/Http/Controllers/Api/AssetModelsController.php+++ b/app/Http/Controllers/Api/AssetModelsController.php@@ -54,6 +54,12 @@ class AssetModelsController extends Controller'deleted_at','updated_at','require_serial',+ // These are *relationships* so we wouldn't normally include them in this array,+ // since they would normally create a `column not found` error,+ // BUT we account for them in the ordering switch down at the end of this method+ // DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!+ 'manufacturer',+ 'category',];$assetmodels = AssetModel::select([@@ -81,6 +87,24 @@ class AssetModelsController extends Controller->withCount('assignedAssets as assets_assigned_count')->withCount('archivedAssets as assets_archived_count');+ $filter = [];++ if ($request->filled('filter')) {+ $filter = json_decode($request->input('filter'), true);++ $filter = array_filter($filter, function ($key) use ($allowed_columns) {+ return in_array($key, $allowed_columns);+ }, ARRAY_FILTER_USE_KEY);++ }++ if ((! is_null($filter)) && (count($filter)) > 0) {+ $assetmodels->ByFilter($filter);+ } elseif ($request->filled('search')) {+ $assetmodels->TextSearch($request->input('search'));+ }++if ($request->input('status')=='deleted') {$assetmodels->onlyTrashed();}diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.phpindex 78bb2d2ee1..de923e3c88 100644--- a/app/Http/Controllers/Api/CategoriesController.php+++ b/app/Http/Controllers/Api/CategoriesController.php@@ -61,6 +61,23 @@ class CategoriesController extends Controller->withCount('accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count', 'models as models_count');+ $filter = [];++ if ($request->filled('filter')) {+ $filter = json_decode($request->input('filter'), true);++ $filter = array_filter($filter, function ($key) use ($allowed_columns) {+ return in_array($key, $allowed_columns);+ }, ARRAY_FILTER_USE_KEY);++ }++ if ((! is_null($filter)) && (count($filter)) > 0) {+ $categories->ByFilter($filter);+ } elseif ($request->filled('search')) {+ $categories->TextSearch($request->input('search'));+ }+/** This checks to see if we should override the Admin Setting to show archived assets in list.* We don't currently use it within the Snipe-IT GUI, but will be useful for API integrations where they@@ -74,10 +91,6 @@ class CategoriesController extends Controller$categories = $categories->withCount('showableAssets as assets_count');}- if ($request->filled('search')) {- $categories = $categories->TextSearch($request->input('search'));- }-if ($request->filled('name')) {$categories->where('name', '=', $request->input('name'));}diff --git a/app/Http/Controllers/Api/ComponentsController.php b/app/Http/Controllers/Api/ComponentsController.phpindex 8881628b39..57bd6fe589 100644--- a/app/Http/Controllers/Api/ComponentsController.php+++ b/app/Http/Controllers/Api/ComponentsController.php@@ -45,16 +45,40 @@ class ComponentsController extends Controller'qty','image','notes',+ // These are *relationships* so we wouldn't normally include them in this array,+ // since they would normally create a `column not found` error,+ // BUT we account for them in the ordering switch down at the end of this method+ // DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!+ 'company',+ 'location',+ 'category',+ 'manufacturer',+ 'supplier',+];$components = Component::select('components.*')->with('company', 'location', 'category', 'assets', 'supplier', 'adminuser', 'manufacturer', 'uncontrainedAssets')->withSum('uncontrainedAssets', 'components_assets.assigned_qty');- if ($request->filled('search')) {- $components = $components->TextSearch($request->input('search'));+ $filter = [];++ if ($request->filled('filter')) {+ $filter = json_decode($request->input('filter'), true);++ $filter = array_filter($filter, function ($key) use ($allowed_columns) {+ return in_array($key, $allowed_columns);+ }, ARRAY_FILTER_USE_KEY);++ }++ if ((! is_null($filter)) && (count($filter)) > 0) {+ $components->ByFilter($filter);+ } elseif ($request->filled('search')) {+ $components->TextSearch($request->input('search'));}+if ($request->filled('name')) {$components->where('name', '=', $request->input('name'));}diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.phpindex e163f080aa..7191b0b94a 100644--- a/app/Http/Controllers/Api/ConsumablesController.php+++ b/app/Http/Controllers/Api/ConsumablesController.php@@ -31,10 +31,53 @@ class ConsumablesController extends Controller$consumables = Consumable::with('company', 'location', 'category', 'supplier', 'manufacturer')->withCount('users as consumables_users_count');- if ($request->filled('search')) {- $consumables = $consumables->TextSearch(e($request->input('search')));+ // This array is what determines which fields should be allowed to be sorted on ON the table itself.+ // These must match a column on the consumables table directly.+ $allowed_columns = [+ 'id',+ 'name',+ 'order_number',+ 'min_amt',+ 'purchase_date',+ 'purchase_cost',+ 'company',+ 'category',+ 'model_number',+ 'item_no',+ 'manufacturer',+ 'location',+ 'qty',+ 'image',+ // These are *relationships* so we wouldn't normally include them in this array,+ // since they would normally create a `column not found` error,+ // BUT we account for them in the ordering switch down at the end of this method+ // DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!+ 'company',+ 'location',+ 'category',+ 'supplier',+ 'manufacturer',+ ];+++ $filter = [];++ if ($request->filled('filter')) {+ $filter = json_decode($request->input('filter'), true);++ $filter = array_filter($filter, function ($key) use ($allowed_columns) {+ return in_array($key, $allowed_columns);+ }, ARRAY_FILTER_USE_KEY);++ }++ if ((! is_null($filter)) && (count($filter)) > 0) {+ $consumables->ByFilter($filter);+ } elseif ($request->filled('search')) {+ $consumables->TextSearch($request->input('search'));}+if ($request->filled('name')) {$consumables->where('name', '=', $request->input('name'));}@@ -96,25 +139,6 @@ class ConsumablesController extends Controller$consumables = $consumables->OrderByCreatedBy($order);break;default:- // This array is what determines which fields should be allowed to be sorted on ON the table itself.- // These must match a column on the consumables table directly.- $allowed_columns = [- 'id',- 'name',- 'order_number',- 'min_amt',- 'purchase_date',- 'purchase_cost',- 'company',- 'category',- 'model_number',- 'item_no',- 'manufacturer',- 'location',- 'qty',- 'image'- ];-$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';$consumables = $consumables->orderBy($sort, $order);break;diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.phpindex 1b06f5364f..e7896eeeb3 100644--- a/app/Http/Controllers/Api/UsersController.php+++ b/app/Http/Controllers/Api/UsersController.php@@ -103,9 +103,75 @@ class UsersController extends Controller'managedLocations as manages_locations_count']);-- if ($request->filled('search') != '') {- $users = $users->TextSearch($request->input('search'));+ $allowed_columns =+ [+ 'last_name',+ 'first_name',+ 'display_name',+ 'email',+ 'jobtitle',+ 'username',+ 'employee_num',+ 'groups',+ 'activated',+ 'created_at',+ 'updated_at',+ 'two_factor_enrolled',+ 'two_factor_optin',+ 'last_login',+ 'assets_count',+ 'licenses_count',+ 'consumables_count',+ 'accessories_count',+ 'manages_users_count',+ 'manages_locations_count',+ 'phone',+ 'mobile',+ 'address',+ 'city',+ 'state',+ 'country',+ 'zip',+ 'id',+ 'ldap_import',+ 'two_factor_optin',+ 'two_factor_enrolled',+ 'remote',+ 'vip',+ 'start_date',+ 'end_date',+ 'autoassign_licenses',+ 'website',+ 'locale',+ 'notes',+ 'employee_num',++ // These are *relationships* so we wouldn't normally include them in this array,+ // since they would normally create a `column not found` error,+ // BUT we account for them in the ordering switch down at the end of this method+ // DO NOT ADD ANYTHING TO THIS LIST WITHOUT CHECKING THE ORDERING SWITCH BELOW!+ 'company',+ 'location',+ 'department',+ 'manager',+ 'created_by',++ ];++ $filter = [];++ if ($request->filled('filter')) {+ $filter = json_decode($request->input('filter'), true);+ $filter = array_filter($filter, function ($key) use ($allowed_columns) {+ return in_array($key, $allowed_columns);+ }, ARRAY_FILTER_USE_KEY);++ }++ if ((! is_null($filter)) && (count($filter)) > 0) {+ $users->ByFilter($filter);+ } elseif ($request->filled('search')) {+ $users->TextSearch($request->input('search'));}if ($request->filled('activated')) {@@ -286,49 +352,6 @@ class UsersController extends Controller$users->orderBy('first_name', $order);break;default:- $allowed_columns =- [- 'last_name',- 'first_name',- 'display_name',- 'email',- 'jobtitle',- 'username',- 'employee_num',- 'groups',- 'activated',- 'created_at',- 'updated_at',- 'two_factor_enrolled',- 'two_factor_optin',- 'last_login',- 'assets_count',- 'licenses_count',- 'consumables_count',- 'accessories_count',- 'manages_users_count',- 'manages_locations_count',- 'phone',- 'mobile',- 'address',- 'city',- 'state',- 'country',- 'zip',- 'id',- 'ldap_import',- 'two_factor_optin',- 'two_factor_enrolled',- 'remote',- 'vip',- 'start_date',- 'end_date',- 'autoassign_licenses',- 'website',- 'locale',- 'notes',- ];-$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'first_name';$users = $users->orderBy($sort, $order);break;diff --git a/app/Models/Accessory.php b/app/Models/Accessory.phpindex 8efd68ef7e..8b461900aa 100755--- a/app/Models/Accessory.php+++ b/app/Models/Accessory.php@@ -390,7 +390,91 @@ class Accessory extends SnipeModel* BEGIN QUERY SCOPES* -----------------------------------------------**/+ /**+ * Query builder scope to search on text filters for complex Bootstrap Tables API+ *+ * @param \Illuminate\Database\Query\Builder $query Query builder instance+ * @param text $filter JSON array of search keys and terms+ *+ * @return \Illuminate\Database\Query\Builder Modified query builder+ */+ public function scopeByFilter($query, $filter)+ {+ return $query->where(+ function ($query) use ($filter) {+ foreach ($filter as $fieldname => $search_val) {++ if ($fieldname == 'name') {+ $query->where('accessories.name', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'notes') {+ $query->where('accessories.notes', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'model_number') {+ $query->where('accessories.model_number', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'order_number') {+ $query->where('accessories.order_number', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'purchase_cost') {+ $query->where('accessories.purchase_cost', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'location') {+ $query->whereHas(+ 'location', function ($query) use ($search_val) {+ $query->where('locations.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++ if ($fieldname == 'manufacturer') {+ $query->whereHas(+ 'manufacturer', function ($query) use ($search_val) {+ $query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }+++ if ($fieldname == 'supplier') {+ $query->whereHas(+ 'supplier', function ($query) use ($search_val) {+ $query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }+++ if ($fieldname == 'category') {+ $query->whereHas(+ 'category', function ($query) use ($search_val) {+ $query->where('categories.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++ if ($fieldname == 'company') {+ $query->whereHas(+ 'company', function ($query) use ($search_val) {+ $query->where('companies.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++++ }+++ }+ );+ }/*** Query builder scope to order on created_by namediff --git a/app/Models/AssetModel.php b/app/Models/AssetModel.phpindex 81c9850b8c..0fe5160b39 100755--- a/app/Models/AssetModel.php+++ b/app/Models/AssetModel.php@@ -256,6 +256,57 @@ class AssetModel extends SnipeModel* -----------------------------------------------**/+ /**+ * Query builder scope to search on text filters for complex Bootstrap Tables API+ *+ * @param \Illuminate\Database\Query\Builder $query Query builder instance+ * @param text $filter JSON array of search keys and terms+ *+ * @return \Illuminate\Database\Query\Builder Modified query builder+ */+ public function scopeByFilter($query, $filter)+ {+ return $query->where(+ function ($query) use ($filter) {+ foreach ($filter as $fieldname => $search_val) {++ if ($fieldname == 'name') {+ $query->where('models.name', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'notes') {+ $query->where('models.notes', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'model_number') {+ $query->where('models.model_number', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'category') {+ $query->whereHas(+ 'category', function ($query) use ($search_val) {+ $query->where('categories.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++ if ($fieldname == 'manufacturer') {+ $query->whereHas(+ 'manufacturer', function ($query) use ($search_val) {+ $query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++++ }+++ }+ );+ }+/*** scopeInCategory* Get all models that are in the array of category idsdiff --git a/app/Models/Category.php b/app/Models/Category.phpindex 7d9d7a14ae..c3b6080c1e 100755--- a/app/Models/Category.php+++ b/app/Models/Category.php@@ -290,6 +290,35 @@ class Category extends SnipeModel* -----------------------------------------------**/+ /**+ * Query builder scope to search on text filters for complex Bootstrap Tables API+ *+ * @param \Illuminate\Database\Query\Builder $query Query builder instance+ * @param text $filter JSON array of search keys and terms+ *+ * @return \Illuminate\Database\Query\Builder Modified query builder+ */+ public function scopeByFilter($query, $filter)+ {+ return $query->where(+ function ($query) use ($filter) {+ foreach ($filter as $fieldname => $search_val) {++ if ($fieldname == 'name') {+ $query->where('categories.name', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'category_type') {+ $query->where('categories.category_type', 'LIKE', '%' . $search_val . '%');+ }++ }+++ }+ );+ }+/*** Query builder scope for whether or not the category requires acceptance*diff --git a/app/Models/Component.php b/app/Models/Component.phpindex 6352981418..fb62a872c2 100644--- a/app/Models/Component.php+++ b/app/Models/Component.php@@ -321,6 +321,97 @@ class Component extends SnipeModel* -----------------------------------------------**/+ /**+ * Query builder scope to search on text filters for complex Bootstrap Tables API+ *+ * @param \Illuminate\Database\Query\Builder $query Query builder instance+ * @param text $filter JSON array of search keys and terms+ *+ * @return \Illuminate\Database\Query\Builder Modified query builder+ */+ public function scopeByFilter($query, $filter)+ {+ return $query->where(+ function ($query) use ($filter) {+ foreach ($filter as $fieldname => $search_val) {++ if ($fieldname == 'name') {+ $query->where('components.name', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'notes') {+ $query->where('components.notes', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'model_number') {+ $query->where('components.model_number', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'order_number') {+ $query->where('components.order_number', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'serial') {+ $query->where('components.serial', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'serial') {+ $query->where('components.serial', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'purchase_cost') {+ $query->where('components.purchase_cost', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'location') {+ $query->whereHas(+ 'location', function ($query) use ($search_val) {+ $query->where('locations.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++ if ($fieldname == 'manufacturer') {+ $query->whereHas(+ 'manufacturer', function ($query) use ($search_val) {+ $query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }+++ if ($fieldname == 'supplier') {+ $query->whereHas(+ 'supplier', function ($query) use ($search_val) {+ $query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }+++ if ($fieldname == 'category') {+ $query->whereHas(+ 'category', function ($query) use ($search_val) {+ $query->where('categories.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++ if ($fieldname == 'company') {+ $query->whereHas(+ 'company', function ($query) use ($search_val) {+ $query->where('companies.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }+++ }+++ }+ );+ }/*** Query builder scope to order on companydiff --git a/app/Models/Consumable.php b/app/Models/Consumable.phpindex 806b10d317..339b88044e 100644--- a/app/Models/Consumable.php+++ b/app/Models/Consumable.php@@ -345,6 +345,99 @@ class Consumable extends SnipeModel* -----------------------------------------------**/+ /**+ * Query builder scope to search on text filters for complex Bootstrap Tables API+ *+ * @param \Illuminate\Database\Query\Builder $query Query builder instance+ * @param text $filter JSON array of search keys and terms+ *+ * @return \Illuminate\Database\Query\Builder Modified query builder+ */+ public function scopeByFilter($query, $filter)+ {+ return $query->where(+ function ($query) use ($filter) {+ foreach ($filter as $fieldname => $search_val) {++ if ($fieldname == 'name') {+ $query->where('consumables.name', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'notes') {+ $query->where('consumables.notes', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'model_number') {+ $query->where('consumables.model_number', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'order_number') {+ $query->where('consumables.order_number', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'item_no') {+ $query->where('consumables.item_no', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'serial') {+ $query->where('consumables.serial', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'purchase_cost') {+ $query->where('consumables.purchase_cost', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'location') {+ $query->whereHas(+ 'location', function ($query) use ($search_val) {+ $query->where('locations.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++ if ($fieldname == 'manufacturer') {+ $query->whereHas(+ 'manufacturer', function ($query) use ($search_val) {+ $query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }+++ if ($fieldname == 'supplier') {+ $query->whereHas(+ 'supplier', function ($query) use ($search_val) {+ $query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }+++ if ($fieldname == 'category') {+ $query->whereHas(+ 'category', function ($query) use ($search_val) {+ $query->where('categories.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++ if ($fieldname == 'company') {+ $query->whereHas(+ 'company', function ($query) use ($search_val) {+ $query->where('companies.name', 'LIKE', '%'.$search_val.'%');+ }+ );+ }++++ }+++ }+ );+ }+/*** Query builder scope to order on company*diff --git a/app/Models/User.php b/app/Models/User.phpindex dd3bbfec57..fda296ff91 100644--- a/app/Models/User.php+++ b/app/Models/User.php@@ -863,6 +863,141 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCoreturn new \stdClass;}++ /**+ * Query builder scope to search on text filters for complex Bootstrap Tables API+ *+ * @param \Illuminate\Database\Query\Builder $query Query builder instance+ * @param text $filter JSON array of search keys and terms+ *+ * @return \Illuminate\Database\Query\Builder Modified query builder+ */+ public function scopeByFilter($query, $filter)+ {+ return $query->where(+ function ($query) use ($filter) {+ foreach ($filter as $fieldname => $search_val) {++ if ($fieldname == 'first_name') {+ $query->where('users.first_name', 'LIKE', '%' . $search_val . '%');+ }+ if ($fieldname == 'last_name') {+ $query->where('users.last_name', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'display_name') {+ $query->where('users.display_name', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'name') {+ $query->where('users.last_name', 'LIKE', '%' . $search_val . '%')+ ->orWhere('users.first_name', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'username') {+ $query->where('users.username', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'email') {+ $query->where('users.email', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'phone') {+ $query->where('users.phone', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'mobile') {+ $query->where('users.mobile', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'phone') {+ $query->where('users.phone', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'jobtitle') {+ $query->where('users.jobtitle', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'created_at') {+ $query->where('users.created_at', '=', '%' . $search_val . '%');+ }++ if ($fieldname == 'updated_at') {+ $query->where('users.updated_at', '=', '%' . $search_val . '%');+ }++ if ($fieldname == 'start_date') {+ $query->where('users.start_date', '=', '%' . $search_val . '%');+ }++ if ($fieldname == 'end_date') {+ $query->where('users.end_date', '=', '%' . $search_val . '%');+ }++ if ($fieldname == 'employee_num') {+ $query->where('users.employee_num', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'locale') {+ $query->where('users.locale', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'address') {+ $query->where('users.address', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'state') {+ $query->where('users.state', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'zip') {+ $query->where('users.zip', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'country') {+ $query->where('users.country', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'vip') {+ $query->where('users.vip', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'remote') {+ $query->where('users.remote', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'start_date') {+ $query->where('users.purchase_date', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'notes') {+ $query->where('users.notes', 'LIKE', '%' . $search_val . '%');+ }++ if ($fieldname == 'location') {+ $query->whereHas(+ 'location', function ($query) use ($search_val) {+ $query->where('locations.name', 'LIKE', '%' . $search_val . '%');+ }+ );+ }++ if ($fieldname == 'company') {+ $query->whereHas(+ 'company', function ($query) use ($search_val) {+ $query->where('companies.name', 'LIKE', '%' . $search_val . '%');+ }+ );+ }+++ }+++ }+ );+ }+/*** Query builder scope to search user by name with spaces in it.* We don't use the advancedTextSearch() scope because that searchesdiff --git a/app/Presenters/AssetModelPresenter.php b/app/Presenters/AssetModelPresenter.phpindex c07a7fdf58..ac9aa5e661 100644--- a/app/Presenters/AssetModelPresenter.php+++ b/app/Presenters/AssetModelPresenter.php@@ -53,7 +53,7 @@ class AssetModelPresenter extends Presenter],['field' => 'manufacturer',- 'searchable' => false,+ 'searchable' => true,'sortable' => true,'switchable' => true,'title' => trans('general.manufacturer'),@@ -62,7 +62,7 @@ class AssetModelPresenter extends Presenter],['field' => 'model_number',- 'searchable' => false,+ 'searchable' => true,'sortable' => true,'switchable' => true,'title' => trans('admin/models/table.modelnumber'),@@ -130,7 +130,7 @@ class AssetModelPresenter extends Presenter],['field' => 'category',- 'searchable' => false,+ 'searchable' => true,'sortable' => true,'switchable' => true,'title' => trans('general.category'),diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.phpindex e7d31264e9..e09b1e4a61 100644--- a/app/Presenters/CategoryPresenter.php+++ b/app/Presenters/CategoryPresenter.php@@ -92,7 +92,7 @@ class CategoryPresenter extends Presenter'formatter' => 'usersLinkObjFormatter',], ['field' => 'created_at',- 'searchable' => true,+ 'searchable' => false,'sortable' => true,'switchable' => true,'title' => trans('general.created_at'),@@ -100,7 +100,7 @@ class CategoryPresenter extends Presenter'formatter' => 'dateDisplayFormatter',], ['field' => 'updated_at',- 'searchable' => true,+ 'searchable' => false,'sortable' => true,'switchable' => true,'title' => trans('general.updated_at'),diff --git a/app/Presenters/ComponentPresenter.php b/app/Presenters/ComponentPresenter.phpindex 5e33d72d1c..0b13ef159f 100644--- a/app/Presenters/ComponentPresenter.php+++ b/app/Presenters/ComponentPresenter.php@@ -131,7 +131,7 @@ class ComponentPresenter extends Presenter'class' => 'text-right',], ['field' => 'total_cost',- 'searchable' => true,+ 'searchable' => false,'sortable' => true,'title' => trans('general.total_cost'),'footerFormatter' => 'sumFormatterQuantity',diff --git a/resources/views/companies/index.blade.php b/resources/views/companies/index.blade.phpindex 35f8a5914c..ef085373a9 100644--- a/resources/views/companies/index.blade.php+++ b/resources/views/companies/index.blade.php@@ -18,6 +18,7 @@data-id-table="companiesTable"data-side-pagination="server"data-sort-order="asc"+ data-advanced-search="false"id="companiesTable"data-buttons="companyButtons"class="table table-striped snipe-table"diff --git a/resources/views/custom_fields/index.blade.php b/resources/views/custom_fields/index.blade.phpindex cf805e914e..32bfab3af1 100644--- a/resources/views/custom_fields/index.blade.php+++ b/resources/views/custom_fields/index.blade.php@@ -33,6 +33,7 @@data-side-pagination="client"data-sort-order="asc"data-sort-name="name"+ data-advanced-search="false"id="customFieldsetTable"data-buttons="customFieldsetButtons"class="table table-striped snipe-table"@@ -128,6 +129,7 @@data-sort-order="asc"data-sort-name="name"id="customFieldsTable"+ data-advanced-search="false"data-buttons="customFieldButtons"class="table table-striped snipe-table"data-export-options='{diff --git a/resources/views/departments/index.blade.php b/resources/views/departments/index.blade.phpindex 41101ada95..47cf29cd32 100644--- a/resources/views/departments/index.blade.php+++ b/resources/views/departments/index.blade.php@@ -18,6 +18,7 @@data-side-pagination="server"data-sort-order="asc"id="departmentsTable"+ data-advanced-search="false"data-buttons="departmentButtons"class="table table-striped snipe-table"data-url="{{ route('api.departments.index') }}"diff --git a/resources/views/depreciations/index.blade.php b/resources/views/depreciations/index.blade.phpindex e522468004..69d57e5a60 100755--- a/resources/views/depreciations/index.blade.php+++ b/resources/views/depreciations/index.blade.php@@ -20,6 +20,7 @@data-side-pagination="server"data-sort-order="asc"id="depreciationsTable"+ data-advanced-search="false"data-buttons="depreciationButtons"class="table table-striped snipe-table"data-url="{{ route('api.depreciations.index') }}"diff --git a/resources/views/locations/index.blade.php b/resources/views/locations/index.blade.phpindex 9ffaec7e41..5932e01359 100755--- a/resources/views/locations/index.blade.php+++ b/resources/views/locations/index.blade.php@@ -22,6 +22,7 @@data-bulk-button-id="#bulkLocationsEditButton"data-bulk-form-id="#locationsBulkForm"data-side-pagination="server"+ data-advanced-search="false"data-sort-order="asc"data-buttons="locationButtons"id="locationTable"diff --git a/resources/views/maintenances/index.blade.php b/resources/views/maintenances/index.blade.phpindex 1821f76352..118c7b7268 100644--- a/resources/views/maintenances/index.blade.php+++ b/resources/views/maintenances/index.blade.php@@ -20,6 +20,7 @@data-cookie-id-table="maintenancesTable"data-side-pagination="server"data-show-footer="true"+ data-advanced-search="false"id="maintenancesTable"data-buttons="maintenanceButtons"class="table table-striped snipe-table"diff --git a/resources/views/manufacturers/index.blade.php b/resources/views/manufacturers/index.blade.phpindex 654f206d50..c9aed9b2db 100755--- a/resources/views/manufacturers/index.blade.php+++ b/resources/views/manufacturers/index.blade.php@@ -36,6 +36,7 @@data-columns="{{ \App\Presenters\ManufacturerPresenter::dataTableLayout() }}"data-cookie-id-table="manufacturersTable"data-id-table="manufacturersTable"+ data-advanced-search="false"data-side-pagination="server"data-sort-order="asc"id="manufacturersTable"diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.phpindex 9562694b65..3584012cb4 100644--- a/resources/views/partials/bootstrap-table.blade.php+++ b/resources/views/partials/bootstrap-table.blade.php@@ -60,6 +60,7 @@}+$(this).bootstrapTable({ajaxOptions: {diff --git a/resources/views/reports/accessories.blade.php b/resources/views/reports/accessories.blade.phpindex 91972f42f1..8107d4951f 100644--- a/resources/views/reports/accessories.blade.php+++ b/resources/views/reports/accessories.blade.php@@ -19,6 +19,7 @@data-side-pagination="server"data-sort-order="asc"id="accessoriesReport"+ data-advanced-search="false"class="table table-striped snipe-table"data-url="{{ route('api.accessories.index') }}"data-export-options='{diff --git a/resources/views/reports/activity.blade.php b/resources/views/reports/activity.blade.phpindex 1cda649a1a..31360d4ccc 100644--- a/resources/views/reports/activity.blade.php+++ b/resources/views/reports/activity.blade.php@@ -29,6 +29,7 @@data-cookie-id-table="activityReport"data-id-table="activityReport"data-side-pagination="server"+ data-advanced-search="false"data-sort-order="desc"data-sort-name="created_at"id="activityReport"diff --git a/resources/views/reports/asset.blade.php b/resources/views/reports/asset.blade.phpindex a0a7d644d7..3d10987f4b 100644--- a/resources/views/reports/asset.blade.php+++ b/resources/views/reports/asset.blade.php@@ -23,6 +23,7 @@<tablename="assetsReport"class="table table-striped snipe-table"+ data-advanced-search="false"id="table"data-url="{{route('api.assets.index', array(''=>e(Request::get('status')),'order_number'=>e(Request::get('order_number')), 'status_id'=>e(Request::get('status_id')), 'report'=>'true'))}}"data-cookie="true"diff --git a/resources/views/reports/audit.blade.php b/resources/views/reports/audit.blade.phpindex f670128a1b..bbbf4a4784 100644--- a/resources/views/reports/audit.blade.php+++ b/resources/views/reports/audit.blade.php@@ -22,6 +22,7 @@id="auditReport"data-url="{{ route('api.activity.index', ['action_type' => 'audit']) }}"class="table table-striped snipe-table"+ data-advanced-search="false"data-export-options='{"fileName": "activity-report-{{ date('Y-m-d') }}","ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]diff --git a/resources/views/reports/depreciation.blade.php b/resources/views/reports/depreciation.blade.phpindex 0c93a021fd..c2d3788f3f 100644--- a/resources/views/reports/depreciation.blade.php+++ b/resources/views/reports/depreciation.blade.php@@ -24,6 +24,7 @@data-sort-name="created_at"data-show-footer="true"id="depreciationReport"+ data-advanced-search="false"data-url="{{ route('api.depreciation-report.index') }}"data-mobile-responsive="true"{{-- data-toggle="table" --}}diff --git a/resources/views/reports/licenses.blade.php b/resources/views/reports/licenses.blade.phpindex 8897bc0543..ddcd5ccac0 100644--- a/resources/views/reports/licenses.blade.php+++ b/resources/views/reports/licenses.blade.php@@ -18,6 +18,7 @@data-side-pagination="client"data-sort-order="asc"id="licensesReport"+ data-advanced-search="false"class="table table-striped snipe-table"data-export-options='{"fileName": "license-report-{{ date('Y-m-d') }}",@@ -54,8 +55,8 @@</td><td>{{ $license->seats }}</td><td>{{ $license->remaincount() }}</td>- <td>{{ $license->expiration_date }}</td>- <td>{{ $license->termination_date }}+ <td>{{ $license->expires_formatted_date }}</td>+ <td>{{ $license->terminates_formatted_date }}@if ($license->isTerminated())<span class="text-danger"><x-icon type="warning" class="text-warning" />diff --git a/resources/views/reports/maintenances.blade.php b/resources/views/reports/maintenances.blade.phpindex b641c0ca6c..a3dbfd2083 100644--- a/resources/views/reports/maintenances.blade.php+++ b/resources/views/reports/maintenances.blade.php@@ -19,6 +19,7 @@data-side-pagination="server"data-sort-order="asc"id="maintenancesReport"+ data-advanced-search="false"data-url="{{route('api.maintenances.index') }}"class="table table-striped snipe-table"data-export-options='{diff --git a/resources/views/reports/unaccepted_assets.blade.php b/resources/views/reports/unaccepted_assets.blade.phpindex f0d93c0bed..d4e259f02f 100644--- a/resources/views/reports/unaccepted_assets.blade.php+++ b/resources/views/reports/unaccepted_assets.blade.php@@ -40,6 +40,7 @@data-side-pagination="client"data-sort-order="asc"data-sort-name="created_at"+ data-advanced-search="false"id="unacceptedAssetsReport"class="table table-striped snipe-table"data-export-options='{diff --git a/resources/views/statuslabels/index.blade.php b/resources/views/statuslabels/index.blade.phpindex ce2a6f758b..84fcfcf283 100755--- a/resources/views/statuslabels/index.blade.php+++ b/resources/views/statuslabels/index.blade.php@@ -23,6 +23,7 @@data-sort-name="name"id="statuslabelsTable"data-buttons="statuslabelButtons"+ data-advanced-search="false"class="table table-striped snipe-table"data-url="{{ route('api.statuslabels.index') }}"data-export-options='{diff --git a/resources/views/suppliers/index.blade.php b/resources/views/suppliers/index.blade.phpindex 6e70a734c3..bbfe056e97 100755--- a/resources/views/suppliers/index.blade.php+++ b/resources/views/suppliers/index.blade.php@@ -21,6 +21,7 @@data-side-pagination="server"data-sort-order="asc"id="suppliersTable"+ data-advanced-search="false"data-buttons="supplierButtons"class="table table-striped snipe-table"data-url="{{ route('api.suppliers.index') }}"