user roles, bug fixes
This commit is contained in:
@@ -149,7 +149,8 @@
|
||||
data-department_id="{{ $staff->department_id }}"
|
||||
data-location_country="{{ $staff->location_country }}"
|
||||
data-status="{{ $staff->status }}"
|
||||
data-pic="{{ $staff->profile_pic ? asset('public/storage/' . $staff->profile_pic) : '' }}">
|
||||
data-pic="{{ $staff->profile_pic ? asset('public/storage/' . $staff->profile_pic) : '' }}"
|
||||
data-roles="{{ $staff->roles->pluck('id')->toJson() }}">
|
||||
<i class="bi bi-pencil me-1"></i> Edit
|
||||
</button>
|
||||
|
||||
@@ -258,6 +259,16 @@
|
||||
<option value="INACTIVE">Inactive</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Insert this directly after the Status col-md-4 block -->
|
||||
<div class="col-12 mt-3 pt-3 border-top">
|
||||
<label class="form-label text-secondary fw-semibold small">System Roles & Permissions</label>
|
||||
<select class="form-select" id="staffRoles" name="roles[]" multiple="multiple">
|
||||
@foreach($systemRoles as $role)
|
||||
<option value="{{ $role->id }}">{{ $role->label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<div class="form-text text-muted" style="font-size: 0.75rem;">Leave blank for standard employee access.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-light">
|
||||
@@ -318,6 +329,19 @@
|
||||
<div class="text-secondary small fw-semibold">ANNUAL LEAVE BALANCE</div>
|
||||
<div class="fw-medium text-dark small"><span id="viewStaffLeaveBalance">0</span> Days</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="text-secondary small fw-semibold">ANNUAL LEAVE BALANCE</div>
|
||||
<div class="fw-medium text-dark small"><span id="viewStaffLeaveBalance">0</span> Days</div>
|
||||
</div>
|
||||
|
||||
<!-- NEW ROLES SECTION -->
|
||||
<div class="col-12 mt-3 pt-3 border-top">
|
||||
<div class="text-secondary small fw-semibold mb-2">SYSTEM ROLES</div>
|
||||
<div id="viewStaffRoles" class="d-flex flex-wrap gap-1">
|
||||
<span class="text-muted small">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END ROLES SECTION -->
|
||||
</div>
|
||||
|
||||
<!-- Emergency Contacts Table Section -->
|
||||
@@ -423,6 +447,12 @@
|
||||
width: '100%',
|
||||
dropdownParent: $('#staffModal')
|
||||
});
|
||||
$('#staffRoles').select2({
|
||||
placeholder: "Select applicable roles...",
|
||||
allowClear: true,
|
||||
width: '100%',
|
||||
dropdownParent: $('#staffModal')
|
||||
});
|
||||
|
||||
// Handle Photo Preview
|
||||
$('#staffPhoto').on('change', function(e) {
|
||||
@@ -441,7 +471,7 @@
|
||||
$('#staffId').val('');
|
||||
$('#avatarPreview').html('<i class="bi bi-person text-secondary"></i>');
|
||||
$('#staffCountry').val(null).trigger('change');
|
||||
|
||||
$('#staffRoles').val(null).trigger('change');
|
||||
$('#staffModalTitle').text('Add New Employee');
|
||||
$('#btnSubmitStaff').html('<i class="bi bi-save me-2"></i>Save Employee');
|
||||
staffModal.show();
|
||||
@@ -460,6 +490,7 @@
|
||||
$('#staffPhone').val(data.phone);
|
||||
$('#staffDept').val(data.department_id);
|
||||
$('#staffCountry').val(data.location_country).trigger('change');
|
||||
$('#staffRoles').val(data.roles).trigger('change');
|
||||
$('#staffStatus').val(data.status);
|
||||
|
||||
if (data.pic) {
|
||||
@@ -559,7 +590,7 @@
|
||||
$('#viewStaffLocation').text('');
|
||||
$('#viewStaffLeaveBalance').text('');
|
||||
$('#viewStaffDependentsList').html('<tr><td colspan="4" class="text-center text-secondary py-3">Loading...</td></tr>');
|
||||
|
||||
$('#viewStaffRoles').html('<span class="text-muted small">Loading...</span>');
|
||||
viewModal.show();
|
||||
|
||||
// Fetch staff details via AJAX
|
||||
@@ -590,6 +621,15 @@
|
||||
let initials = staff.name.split(' ').map(n => n[0]).join('').substring(0, 2).toUpperCase();
|
||||
$('#viewStaffAvatarContainer').html(`<div class="rounded-circle bg-light text-primary fw-bold d-flex align-items-center justify-content-center border" style="width: 70px; height: 70px; font-size: 1.5rem;">${initials}</div>`);
|
||||
}
|
||||
let rolesHtml = '';
|
||||
if (staff.roles && staff.roles.length > 0) {
|
||||
staff.roles.forEach(role => {
|
||||
rolesHtml += `<span class="badge bg-primary bg-opacity-10 text-primary border border-primary-subtle px-2 py-1">${role.label}</span>`;
|
||||
});
|
||||
} else {
|
||||
rolesHtml = `<span class="text-muted small fst-italic">Standard Employee Access</span>`;
|
||||
}
|
||||
$('#viewStaffRoles').html(rolesHtml);
|
||||
|
||||
// Dependents Table population
|
||||
let dependentsHtml = '';
|
||||
|
||||
Reference in New Issue
Block a user