Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2023-08-18 15:32:33 +01:00
commit 384428148b
4 changed files with 55 additions and 8 deletions

View file

@ -234,17 +234,39 @@ class LdapSync extends Command
$item['createorupdate'] = 'created'; $item['createorupdate'] = 'created';
} }
$user->first_name = $item['firstname']; //If a sync option is not filled in on the LDAP settings don't populate the user field
$user->last_name = $item['lastname']; if($ldap_result_username != null){
$user->username = $item['username']; $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']); $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']; $user->phone = $item['telephone'];
}
if($ldap_result_jobtitle != null){
$user->jobtitle = $item['jobtitle']; $user->jobtitle = $item['jobtitle'];
}
if($ldap_result_country != null){
$user->country = $item['country']; $user->country = $item['country'];
}
if($ldap_result_dept != null){
$user->department_id = $department->id; $user->department_id = $department->id;
}
if($ldap_result_location != null){
$user->location_id = $location ? $location->id : null; $user->location_id = $location ? $location->id : null;
}
if($ldap_result_manager != null){
if($item['manager'] != null) { if($item['manager'] != null) {
// Check Cache first // Check Cache first
if (isset($manager_cache[$item['manager']])) { if (isset($manager_cache[$item['manager']])) {
@ -284,6 +306,7 @@ class LdapSync extends Command
} }
} }
}
// Sync activated state for Active Directory. // Sync activated state for Active Directory.
if ( !empty($ldap_result_active_flag)) { // IF we have an 'active' flag set.... if ( !empty($ldap_result_active_flag)) { // IF we have an 'active' flag set....

View file

@ -13,6 +13,7 @@ use App\Events\CheckoutableCheckedIn;
use App\Events\ComponentCheckedIn; use App\Events\ComponentCheckedIn;
use App\Models\Asset; use App\Models\Asset;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Database\Query\Builder;
class ComponentsController extends Controller class ComponentsController extends Controller
{ {
@ -203,12 +204,29 @@ class ComponentsController extends Controller
$this->authorize('view', \App\Models\Asset::class); $this->authorize('view', \App\Models\Asset::class);
$component = Component::findOrFail($id); $component = Component::findOrFail($id);
$assets = $component->assets();
$offset = request('offset', 0); $offset = request('offset', 0);
$limit = $request->input('limit', 50); $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); return (new ComponentsTransformer)->transformCheckedoutComponents($assets, $total);
} }

View file

@ -41,7 +41,7 @@ class SuppliersController extends Controller
]; ];
$suppliers = Supplier::select( $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('assets as assets_count')
->withCount('licenses as licenses_count') ->withCount('licenses as licenses_count')
->withCount('accessories as accessories_count') ->withCount('accessories as accessories_count')

View file

@ -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') { if ($fieldname =='assigned_to') {
$query->whereHasMorph('assignedTo', [User::class], function ($query) use ($search_val) { $query->whereHasMorph('assignedTo', [User::class], function ($query) use ($search_val) {
$query->where(function ($query) use ($search_val) { $query->where(function ($query) use ($search_val) {