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);
|
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) {
|
public function surveyhandle($finfo, Request $request) {
|
||||||
$request->session()->put('finfo', $finfo);
|
$request->session()->put('finfo', $finfo);
|
||||||
$finfo = LambdaRequest::postrequest('form', 'survey/getforminfo', ['finfo' => $finfo]);
|
$finfo = LambdaRequest::postrequest('form', 'survey/getforminfo', ['finfo' => $finfo]);
|
||||||
|
|
|
||||||
|
|
@ -159,13 +159,14 @@
|
||||||
@endif
|
@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">
|
<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>
|
<select class="form-control" id="field-user_id" name="user_id" required>
|
||||||
<option value=""> -- Select -- </option>
|
<option value=""> -- Select -- </option>
|
||||||
@foreach($form->users as $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
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
||||||
|
|
@ -501,97 +502,72 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$('[data-toggle="select2"]').select2();
|
$('[data-toggle="select2"]').select2();
|
||||||
var hierarcies = [];
|
var managerEntryMode = @json($form->manager_entry_mode ?? 'abm');
|
||||||
var contacts = [];
|
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)
|
function applySelect2ToDoctorDropdowns() {
|
||||||
@foreach($form->users as $option)
|
$("[id^='field-contact_id']").each(function () {
|
||||||
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() {
|
|
||||||
var select = $(this);
|
var select = $(this);
|
||||||
|
if (select.data("select2")) return;
|
||||||
|
select.select2({
|
||||||
|
width: "100%",
|
||||||
|
placeholder: "-- Select --",
|
||||||
|
allowClear: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var existingVal = select.attr('data-initial-value') || select.val();
|
function clearDoctorDropdowns() {
|
||||||
|
$("[id^='field-contact_id']").each(function () {
|
||||||
|
var select = $(this);
|
||||||
select.empty();
|
select.empty();
|
||||||
|
|
||||||
// Default option
|
|
||||||
select.append($("<option></option>").attr("value", '').text('-- Select --'));
|
select.append($("<option></option>").attr("value", '').text('-- Select --'));
|
||||||
|
if (select.data("select2")) {
|
||||||
|
select.trigger("change.select2");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillDoctorDropdowns(contacts) {
|
||||||
contacts.forEach(function(itm) {
|
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>")
|
var option = $("<option></option>")
|
||||||
.attr("value", itm.value)
|
.attr("value", itm.value)
|
||||||
.text(itm.display);
|
.text(itm.display);
|
||||||
|
|
||||||
if (itm.contact && itm.contact.legacy_code) {
|
if (itm.contact && itm.contact.legacy_code) {
|
||||||
option.attr("msl_code", itm.contact.legacy_code);
|
option.attr("msl_code", itm.contact.legacy_code);
|
||||||
}
|
}
|
||||||
|
|
@ -600,26 +576,17 @@
|
||||||
}
|
}
|
||||||
select.append(option);
|
select.append(option);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (existingVal) {
|
if (existingVal) {
|
||||||
select.val(String(existingVal));
|
select.val(String(existingVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
select.off('change').on('change select2:select select2:clear', function () {
|
select.off('change').on('change select2:select select2:clear', function () {
|
||||||
handleDoctorChange($(this));
|
handleDoctorChange($(this));
|
||||||
enforceUniqueDoctorSelections();
|
enforceUniqueDoctorSelections();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
applySelect2ToDoctorDropdowns();
|
applySelect2ToDoctorDropdowns();
|
||||||
|
|
||||||
|
|
||||||
$("[id^='field-msl_code'], [id^='field-speciality']").prop('readonly', true);
|
$("[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 select = $(this);
|
||||||
var existingVal = select.attr('data-initial-value');
|
var existingVal = select.attr('data-initial-value');
|
||||||
if (existingVal) {
|
if (existingVal) {
|
||||||
|
|
@ -629,15 +596,44 @@
|
||||||
if ($('#field-replace_submission_id').length && $('#field-month').val()) {
|
if ($('#field-replace_submission_id').length && $('#field-month').val()) {
|
||||||
applyMonth(String($('#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, '');
|
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 regex = new RegExp("^[a-zA-Z\\s]+$");
|
||||||
var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
|
var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
|
||||||
if (!regex.test(str)) {
|
if (!regex.test(str)) {
|
||||||
|
|
@ -645,50 +641,60 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$("[id^='field-pin_code_']").on('input keyup paste', function () {
|
||||||
$("[id^='field-pin_code_']").on('input keyup paste', function() {
|
|
||||||
var val = this.value;
|
var val = this.value;
|
||||||
|
|
||||||
|
|
||||||
val = val.replace(/\D/g, '');
|
val = val.replace(/\D/g, '');
|
||||||
|
|
||||||
|
|
||||||
val = val.replace(/^0+/, '');
|
val = val.replace(/^0+/, '');
|
||||||
|
|
||||||
|
|
||||||
if (val.length > 6) {
|
if (val.length > 6) {
|
||||||
val = val.substring(0, 6);
|
val = val.substring(0, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.value = val;
|
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);
|
var char = String.fromCharCode(e.which || e.keyCode);
|
||||||
|
|
||||||
|
|
||||||
if (!/^\d$/.test(char)) {
|
if (!/^\d$/.test(char)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.value.length === 0 && char === '0') {
|
if (this.value.length === 0 && char === '0') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||||
|
bindCityPinHandlers();
|
||||||
$("#pageloader").fadeOut();
|
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
|
@endif
|
||||||
|
|
||||||
$("[id^='field-contact_id_']").on('change', function () {
|
$("[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/pulmocarecoachingtool', [FormController::class, 'pulmocarecoachingtool']);
|
||||||
|
|
||||||
Route::get('/form/getdoctorlist', [FormController::class, 'getdoctorlist']);
|
Route::get('/form/getdoctorlist', [FormController::class, 'getdoctorlist']);
|
||||||
|
Route::get('/form/hierarchybelow', [FormController::class, 'hierarchyBelow']);
|
||||||
Route::get('/form/preview', [FormController::class, 'preview']);
|
Route::get('/form/preview', [FormController::class, 'preview']);
|
||||||
Route::get('/form/history', [FormController::class, 'history']);
|
Route::get('/form/history', [FormController::class, 'history']);
|
||||||
Route::get('/form/show', [FormController::class, 'show']);
|
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/pulmocarecoachingtool', [FormController::class, 'pulmocarecoachingtool']);
|
||||||
|
|
||||||
Route::get('/form/getdoctorlist', [FormController::class, 'getdoctorlist']);
|
Route::get('/form/getdoctorlist', [FormController::class, 'getdoctorlist']);
|
||||||
|
Route::get('/form/hierarchybelow', [FormController::class, 'hierarchyBelow']);
|
||||||
Route::get('/form/preview', [FormController::class, 'preview']);
|
Route::get('/form/preview', [FormController::class, 'preview']);
|
||||||
Route::get('/form/history', [FormController::class, 'history']);
|
Route::get('/form/history', [FormController::class, 'history']);
|
||||||
Route::get('/form/show', [FormController::class, 'show']);
|
Route::get('/form/show', [FormController::class, 'show']);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue