diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index d92bc1023b..c72de8cb72 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -234,17 +234,39 @@ class LdapSync extends Command $item['createorupdate'] = 'created'; } - $user->first_name = $item['firstname']; - $user->last_name = $item['lastname']; + //If a sync option is not filled in on the LDAP settings don't populate the user field + if($ldap_result_username != null){ $user->username = $item['username']; - $user->email = $item['email']; + } + if($ldap_result_last_name != null){ + $user->last_name = $item['lastname']; + } + if($ldap_result_first_name != null){ + $user->first_name = $item['firstname']; + } + if($ldap_result_emp_num != null){ $user->employee_num = e($item['employee_number']); + } + if($ldap_result_email != null){ + $user->email = $item['email']; + } + if($ldap_result_phone != null){ $user->phone = $item['telephone']; + } + if($ldap_result_jobtitle != null){ $user->jobtitle = $item['jobtitle']; + } + if($ldap_result_country != null){ $user->country = $item['country']; + } + if($ldap_result_dept != null){ $user->department_id = $department->id; + } + if($ldap_result_location != null){ $user->location_id = $location ? $location->id : null; + } + if($ldap_result_manager != null){ if($item['manager'] != null) { // Check Cache first if (isset($manager_cache[$item['manager']])) { @@ -284,6 +306,7 @@ class LdapSync extends Command } } + } // Sync activated state for Active Directory. if ( !empty($ldap_result_active_flag)) { // IF we have an 'active' flag set.... diff --git a/app/Http/Controllers/Api/ComponentsController.php b/app/Http/Controllers/Api/ComponentsController.php index 4806caf8a3..a6e3e379e3 100644 --- a/app/Http/Controllers/Api/ComponentsController.php +++ b/app/Http/Controllers/Api/ComponentsController.php @@ -13,6 +13,7 @@ use App\Events\CheckoutableCheckedIn; use App\Events\ComponentCheckedIn; use App\Models\Asset; use Illuminate\Support\Facades\Validator; +use Illuminate\Database\Query\Builder; class ComponentsController extends Controller { @@ -203,12 +204,29 @@ class ComponentsController extends Controller $this->authorize('view', \App\Models\Asset::class); $component = Component::findOrFail($id); - $assets = $component->assets(); - + $offset = request('offset', 0); $limit = $request->input('limit', 50); - $total = $assets->count(); - $assets = $assets->skip($offset)->take($limit)->get(); + + if ($request->filled('search')) { + $assets = $component->assets() + ->where(function ($query) use ($request) { + $search_str = '%' . $request->input('search') . '%'; + $query->where('name', 'like', $search_str) + ->orWhereIn('model_id', function (Builder $query) use ($request) { + $search_str = '%' . $request->input('search') . '%'; + $query->selectRaw('id')->from('models')->where('name', 'like', $search_str); + }) + ->orWhere('asset_tag', 'like', $search_str); + }) + ->get(); + $total = $assets->count(); + } else { + $assets = $component->assets(); + + $total = $assets->count(); + $assets = $assets->skip($offset)->take($limit)->get(); + } return (new ComponentsTransformer)->transformCheckedoutComponents($assets, $total); } diff --git a/app/Http/Controllers/Api/SuppliersController.php b/app/Http/Controllers/Api/SuppliersController.php index a26c33b1f8..ad1227cc83 100644 --- a/app/Http/Controllers/Api/SuppliersController.php +++ b/app/Http/Controllers/Api/SuppliersController.php @@ -41,7 +41,7 @@ class SuppliersController extends Controller ]; $suppliers = Supplier::select( - ['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'updated_at', 'deleted_at', 'image', 'notes']) + ['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'updated_at', 'deleted_at', 'image', 'notes', 'url']) ->withCount('assets as assets_count') ->withCount('licenses as licenses_count') ->withCount('accessories as accessories_count') diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 95e1c3a166..6792cf2859 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -1433,6 +1433,12 @@ class Asset extends Depreciable }); } + if ($fieldname == 'rtd_location') { + $query->whereHas('defaultLoc', function ($query) use ($search_val) { + $query->where('locations.name', 'LIKE', '%'.$search_val.'%'); + }); + } + if ($fieldname =='assigned_to') { $query->whereHasMorph('assignedTo', [User::class], function ($query) use ($search_val) { $query->where(function ($query) use ($search_val) {