Changes
Specific Folder FTP Upload / ftp-deploy (push) Successful in 5m4s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 5m4s
Details
This commit is contained in:
parent
a8bb633553
commit
fec6ff7177
|
|
@ -11578,6 +11578,29 @@ class FormController extends Controller
|
|||
return response()->json($docs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hierarchies below a given user (for RBM → ABM → TM doctor loading).
|
||||
*/
|
||||
public function hierarchyBelow(Request $request)
|
||||
{
|
||||
$partition = (string) $request->input('partition', '');
|
||||
$userId = (string) $request->input('user_id', '');
|
||||
if ($partition === '' || $userId === '') {
|
||||
return response()->json(['hierarchies' => []], 422);
|
||||
}
|
||||
$response = LambdaRequest::getrequest('ums', 'hierarchy/hierarchy_below_me', [
|
||||
'partition' => $partition,
|
||||
'user_id' => $userId,
|
||||
]);
|
||||
$hierarchies = [];
|
||||
if (isset($response->data->hierarchies) && is_array($response->data->hierarchies)) {
|
||||
$hierarchies = $response->data->hierarchies;
|
||||
} elseif (isset($response->data) && is_array($response->data)) {
|
||||
$hierarchies = $response->data;
|
||||
}
|
||||
return response()->json(['hierarchies' => $hierarchies]);
|
||||
}
|
||||
|
||||
public function surveyhandle($finfo, Request $request) {
|
||||
$request->session()->put('finfo', $finfo);
|
||||
$finfo = LambdaRequest::postrequest('form', 'survey/getforminfo', ['finfo' => $finfo]);
|
||||
|
|
|
|||
|
|
@ -159,13 +159,14 @@
|
|||
@endif
|
||||
|
||||
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
@php $managerEntryMode = $form->manager_entry_mode ?? 'abm'; @endphp
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true && $managerEntryMode === 'rbm')
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-user_id" class="form-label"> Select User / Territory <span class="text-danger">*</span> </label>
|
||||
<label for="field-user_id" class="form-label"> Select ABM <span class="text-danger">*</span> </label>
|
||||
<select class="form-control" id="field-user_id" name="user_id" required>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($form->users as $option)
|
||||
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}">{{$option->display}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
||||
|
|
@ -501,97 +502,72 @@
|
|||
}
|
||||
|
||||
$('[data-toggle="select2"]').select2();
|
||||
var hierarcies = [];
|
||||
var contacts = [];
|
||||
var managerEntryMode = @json($form->manager_entry_mode ?? 'abm');
|
||||
var managerUserHierarchies = [
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
@foreach(($form->users ?? []) as $option)
|
||||
'{{ $option->hierarchy_id }}',
|
||||
@endforeach
|
||||
@endif
|
||||
].filter(Boolean);
|
||||
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
@foreach($form->users as $option)
|
||||
hierarcies.push('{{$option->hierarchy_id}}');
|
||||
@endforeach
|
||||
$("#pageloader").fadeIn();
|
||||
Promise.all(
|
||||
hierarcies.map(hierarchy => {
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
||||
processData: false,
|
||||
contentType: false
|
||||
}).then(data => {
|
||||
console.log(data);
|
||||
contacts = contacts.concat(data);
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
})
|
||||
).then(function() {
|
||||
// All contacts loaded for each hierarchy
|
||||
// Example usage: console.log(contacts);
|
||||
// Filter out contacts where value == 'sample'
|
||||
contacts = contacts.filter(function(itm) { return itm.value !== 'sample'; });
|
||||
console.log(contacts);
|
||||
|
||||
// Loop through contacts and append options to select elements whose id starts with 'field-contact_id'
|
||||
// We assume contact_id fields may be suffixed, e.g. field-contact_id_1, field-contact_id, etc.
|
||||
function applySelect2ToDoctorDropdowns() {
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var select = $(this);
|
||||
if (select.data("select2")) return;
|
||||
select.select2({
|
||||
width: "100%",
|
||||
placeholder: "-- Select --",
|
||||
allowClear: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function enforceUniqueDoctorSelections() {
|
||||
var selectedValues = [];
|
||||
|
||||
// Collect selected values (ignore empty)
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var v = $(this).val();
|
||||
if (v) selectedValues.push(String(v));
|
||||
});
|
||||
|
||||
// Reset all option disabled states, then disable duplicates across selects
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var currentSelect = $(this);
|
||||
var currentVal = currentSelect.val() ? String(currentSelect.val()) : "";
|
||||
|
||||
currentSelect.find("option").prop("disabled", false);
|
||||
|
||||
selectedValues.forEach(function (v) {
|
||||
if (v && v !== currentVal) {
|
||||
currentSelect
|
||||
.find("option[value=\"" + v.replace(/"/g, '\\"') + "\"]")
|
||||
.prop("disabled", true);
|
||||
}
|
||||
});
|
||||
|
||||
if (currentSelect.data("select2")) {
|
||||
currentSelect.trigger("change.select2");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("[id^='field-contact_id']").each(function() {
|
||||
function applySelect2ToDoctorDropdowns() {
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var select = $(this);
|
||||
if (select.data("select2")) return;
|
||||
select.select2({
|
||||
width: "100%",
|
||||
placeholder: "-- Select --",
|
||||
allowClear: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var existingVal = select.attr('data-initial-value') || select.val();
|
||||
function enforceUniqueDoctorSelections() {
|
||||
var selectedValues = [];
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var v = $(this).val();
|
||||
if (v) selectedValues.push(String(v));
|
||||
});
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var currentSelect = $(this);
|
||||
var currentVal = currentSelect.val() ? String(currentSelect.val()) : "";
|
||||
currentSelect.find("option").prop("disabled", false);
|
||||
selectedValues.forEach(function (v) {
|
||||
if (v && v !== currentVal) {
|
||||
currentSelect
|
||||
.find("option[value=\"" + v.replace(/"/g, '\\"') + "\"]")
|
||||
.prop("disabled", true);
|
||||
}
|
||||
});
|
||||
if (currentSelect.data("select2")) {
|
||||
currentSelect.trigger("change.select2");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function clearDoctorDropdowns() {
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var select = $(this);
|
||||
select.empty();
|
||||
|
||||
// Default option
|
||||
select.append($("<option></option>").attr("value", '').text('-- Select --'));
|
||||
if (select.data("select2")) {
|
||||
select.trigger("change.select2");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
contacts.forEach(function(itm) {
|
||||
function fillDoctorDropdowns(contacts) {
|
||||
contacts = (contacts || []).filter(function (itm) { return itm.value !== 'sample'; });
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var select = $(this);
|
||||
var existingVal = select.attr('data-initial-value') || select.val();
|
||||
select.empty();
|
||||
select.append($("<option></option>").attr("value", '').text('-- Select --'));
|
||||
contacts.forEach(function (itm) {
|
||||
var option = $("<option></option>")
|
||||
.attr("value", itm.value)
|
||||
.text(itm.display);
|
||||
|
||||
if (itm.contact && itm.contact.legacy_code) {
|
||||
option.attr("msl_code", itm.contact.legacy_code);
|
||||
}
|
||||
|
|
@ -600,26 +576,17 @@
|
|||
}
|
||||
select.append(option);
|
||||
});
|
||||
|
||||
|
||||
if (existingVal) {
|
||||
select.val(String(existingVal));
|
||||
}
|
||||
|
||||
|
||||
select.off('change').on('change select2:select select2:clear', function () {
|
||||
handleDoctorChange($(this));
|
||||
enforceUniqueDoctorSelections();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
applySelect2ToDoctorDropdowns();
|
||||
|
||||
|
||||
$("[id^='field-msl_code'], [id^='field-speciality']").prop('readonly', true);
|
||||
|
||||
$("[id^='field-contact_id']").each(function() {
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var select = $(this);
|
||||
var existingVal = select.attr('data-initial-value');
|
||||
if (existingVal) {
|
||||
|
|
@ -629,15 +596,44 @@
|
|||
if ($('#field-replace_submission_id').length && $('#field-month').val()) {
|
||||
applyMonth(String($('#field-month').val()));
|
||||
}
|
||||
}
|
||||
|
||||
function loadDoctorsForHierarchies(hierarchyIds) {
|
||||
hierarchyIds = (hierarchyIds || []).filter(Boolean);
|
||||
if (!hierarchyIds.length) {
|
||||
clearDoctorDropdowns();
|
||||
$("#pageloader").fadeOut();
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
$("#pageloader").fadeIn();
|
||||
var contacts = [];
|
||||
return Promise.all(
|
||||
hierarchyIds.map(function (hierarchy) {
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
||||
processData: false,
|
||||
contentType: false
|
||||
}).then(function (data) {
|
||||
contacts = contacts.concat(data || []);
|
||||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
})
|
||||
).then(function () {
|
||||
fillDoctorDropdowns(contacts);
|
||||
$("#pageloader").fadeOut();
|
||||
return contacts;
|
||||
}).catch(function () {
|
||||
$("#pageloader").fadeOut();
|
||||
});
|
||||
}
|
||||
|
||||
$("[id^='field-city_']").on('input keyup paste', function() {
|
||||
|
||||
function bindCityPinHandlers() {
|
||||
$("[id^='field-city_']").on('input keyup paste', function () {
|
||||
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
||||
});
|
||||
|
||||
|
||||
$("[id^='field-city_']").on('keypress', function(e) {
|
||||
$("[id^='field-city_']").on('keypress', function (e) {
|
||||
var regex = new RegExp("^[a-zA-Z\\s]+$");
|
||||
var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
|
||||
if (!regex.test(str)) {
|
||||
|
|
@ -645,50 +641,60 @@
|
|||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$("[id^='field-pin_code_']").on('input keyup paste', function() {
|
||||
$("[id^='field-pin_code_']").on('input keyup paste', function () {
|
||||
var val = this.value;
|
||||
|
||||
|
||||
val = val.replace(/\D/g, '');
|
||||
|
||||
|
||||
val = val.replace(/^0+/, '');
|
||||
|
||||
|
||||
if (val.length > 6) {
|
||||
val = val.substring(0, 6);
|
||||
}
|
||||
|
||||
this.value = val;
|
||||
});
|
||||
|
||||
|
||||
$("[id^='field-pin_code_']").on('keypress', function(e) {
|
||||
$("[id^='field-pin_code_']").on('keypress', function (e) {
|
||||
var char = String.fromCharCode(e.which || e.keyCode);
|
||||
|
||||
|
||||
if (!/^\d$/.test(char)) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (this.value.length === 0 && char === '0') {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#pageloader").fadeOut();
|
||||
|
||||
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
bindCityPinHandlers();
|
||||
if (managerEntryMode === 'rbm') {
|
||||
$('#field-user_id').on('change', function () {
|
||||
var abmUserId = $(this).val() || '';
|
||||
var abmHierarchy = $('option:selected', this).attr('hierarchy') || '';
|
||||
$('#field-hierarchy_id').val(abmHierarchy);
|
||||
if (!abmUserId) {
|
||||
clearDoctorDropdowns();
|
||||
return;
|
||||
}
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/hierarchybelow?partition={{$form->partition}}&user_id=' + encodeURIComponent(abmUserId),
|
||||
success: function (data) {
|
||||
var hierarchies = (data && data.hierarchies) ? data.hierarchies : [];
|
||||
var tmIds = hierarchies
|
||||
.filter(function (h) { return h && h.type === 'Territory' && h.id; })
|
||||
.map(function (h) { return h.id; });
|
||||
loadDoctorsForHierarchies(tmIds);
|
||||
},
|
||||
error: function (err) {
|
||||
console.log(err);
|
||||
clearDoctorDropdowns();
|
||||
$("#pageloader").fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
} else {
|
||||
loadDoctorsForHierarchies(managerUserHierarchies);
|
||||
}
|
||||
@endif
|
||||
|
||||
$("[id^='field-contact_id_']").on('change', function () {
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ Route::post('/form/ajaxdoctortagging', [FormController::class, 'ajaxdoctortaggin
|
|||
Route::get('/form/pulmocarecoachingtool', [FormController::class, 'pulmocarecoachingtool']);
|
||||
|
||||
Route::get('/form/getdoctorlist', [FormController::class, 'getdoctorlist']);
|
||||
Route::get('/form/hierarchybelow', [FormController::class, 'hierarchyBelow']);
|
||||
Route::get('/form/preview', [FormController::class, 'preview']);
|
||||
Route::get('/form/history', [FormController::class, 'history']);
|
||||
Route::get('/form/show', [FormController::class, 'show']);
|
||||
|
|
|
|||
|
|
@ -313,6 +313,7 @@ Route::post('/form/ajaxdoctortagging', [FormController::class, 'ajaxdoctortaggin
|
|||
Route::get('/form/pulmocarecoachingtool', [FormController::class, 'pulmocarecoachingtool']);
|
||||
|
||||
Route::get('/form/getdoctorlist', [FormController::class, 'getdoctorlist']);
|
||||
Route::get('/form/hierarchybelow', [FormController::class, 'hierarchyBelow']);
|
||||
Route::get('/form/preview', [FormController::class, 'preview']);
|
||||
Route::get('/form/history', [FormController::class, 'history']);
|
||||
Route::get('/form/show', [FormController::class, 'show']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue