Team 2 (Purview Doctor Tagging ) ABM Code
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m46s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m46s
Details
This commit is contained in:
parent
d6a1c07f6b
commit
0f5a74dd03
|
|
@ -45,8 +45,9 @@
|
||||||
$submissions = $submissions->data->submissions;
|
$submissions = $submissions->data->submissions;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@endphp
|
@endphp
|
||||||
@if(count($submissions) === 0 || !empty($id))
|
@if(count($submissions) ==0)
|
||||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||||
|
|
@ -93,10 +94,6 @@
|
||||||
$isContact = str_starts_with($question->code, 'contact_id');
|
$isContact = str_starts_with($question->code, 'contact_id');
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select class="form-control" {!!($isContact)?'data-toggle="select2"':'' !!} id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
<select class="form-control" {!!($isContact)?'data-toggle="select2"':'' !!} id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||||
<option value=""> -- Select -- </option>
|
<option value=""> -- Select -- </option>
|
||||||
@foreach ($question->options as $option)
|
@foreach ($question->options as $option)
|
||||||
|
|
@ -166,10 +163,11 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</form>
|
</form>
|
||||||
@else
|
|
||||||
<h4 class="text-center" >You have submitted the Doctors</h4>
|
|
||||||
|
|
||||||
|
@else
|
||||||
|
<h4 class="text-center" >You have submitted the doctor tagging. Please Edit through View History option if any changes are to be done.</h4>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</div> <!-- end card-body -->
|
</div> <!-- end card-body -->
|
||||||
</div>
|
</div>
|
||||||
<!-- end card -->
|
<!-- end card -->
|
||||||
|
|
@ -207,167 +205,227 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(document).ready(function($){
|
jQuery(document).ready(function($){
|
||||||
$('[data-toggle="select2"]').select2();
|
$('[data-toggle="select2"]').select2();
|
||||||
$('#field-user_id').change(function(){
|
var hierarcies = [];
|
||||||
let hierarchy = $('option:selected', this).attr('hierarchy');
|
var contacts = [];
|
||||||
$('#field-hierarchy_id').val(hierarchy)
|
|
||||||
event.preventDefault();
|
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||||
|
@foreach($form->users as $option)
|
||||||
|
hierarcies.push('{{$option->hierarchy_id}}');
|
||||||
|
@endforeach
|
||||||
$("#pageloader").fadeIn();
|
$("#pageloader").fadeIn();
|
||||||
$.ajax({
|
Promise.all(
|
||||||
type: "GET",
|
hierarcies.map(hierarchy => {
|
||||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
return $.ajax({
|
||||||
processData: false,
|
type: "GET",
|
||||||
contentType: false,
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
||||||
success: function( data ) {
|
processData: false,
|
||||||
$("#pageloader").fadeOut();
|
contentType: false
|
||||||
$('#field-contact_id').html('')
|
}).then(data => {
|
||||||
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
console.log(data);
|
||||||
for (let itm of data) {
|
contacts = contacts.concat(data);
|
||||||
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display).attr("msl_code", itm.contact.msl_code).attr('speciality',itm.contact.speciality));
|
}).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);
|
||||||
|
|
||||||
$('#field-contact_id').change(function() {
|
// Loop through contacts and append options to select elements whose id starts with 'field-contact_id'
|
||||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
// 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 () {
|
||||||
$('#field-contact_id').change(function() {
|
var select = $(this);
|
||||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
// Avoid re-initializing select2
|
||||||
})
|
if (select.data("select2")) return;
|
||||||
},
|
select.select2({
|
||||||
});
|
width: "100%",
|
||||||
|
placeholder: "-- Select --",
|
||||||
console.log(hierarchy)
|
allowClear: true
|
||||||
})
|
});
|
||||||
|
});
|
||||||
$('#field-contact_id').change(function() {
|
|
||||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
|
||||||
})
|
|
||||||
|
|
||||||
$('#field-contact_id').change(function() {
|
|
||||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
$('input[id^="field-msl_code"], input[id^="field-speciality"]').prop('readonly', true);
|
|
||||||
|
|
||||||
|
|
||||||
$(document).on('change', 'select[id^="field-contact_id"]', function() {
|
|
||||||
let suffix = this.id.replace('field-contact_id', ''); // e.g. "", "_1", "_2", etc.
|
|
||||||
let msl = $('option:selected', this).attr('msl_code') || '';
|
|
||||||
let speciality = $('option:selected', this).attr('speciality') || '';
|
|
||||||
|
|
||||||
|
|
||||||
if ($('#field-msl_code' + suffix).length) {
|
|
||||||
$('#field-msl_code' + suffix).val(msl);
|
|
||||||
} else {
|
|
||||||
$('#field-msl_code').val(msl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($('#field-speciality' + suffix).length) {
|
|
||||||
$('#field-speciality' + suffix).val(speciality);
|
|
||||||
} else {
|
|
||||||
$('#field-speciality').val(speciality);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('select[id^="field-contact_id"]').trigger('change');
|
|
||||||
|
|
||||||
|
|
||||||
function syncSelectedDoctors() {
|
|
||||||
let selectedValues = [];
|
|
||||||
|
|
||||||
// check all selected values in the dropdowns and store them in an array
|
|
||||||
$('select[id^="field-contact_id"]').each(function() {
|
|
||||||
let val = $(this).val();
|
|
||||||
if (val && val !== '') {
|
|
||||||
selectedValues.push(val);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// disable options in all dropdowns based on the selected values
|
function enforceUniqueDoctorSelections() {
|
||||||
$('select[id^="field-contact_id"]').each(function() {
|
var selectedValues = [];
|
||||||
let currentSelect = $(this);
|
|
||||||
let currentVal = currentSelect.val();
|
|
||||||
|
|
||||||
currentSelect.find('option').each(function() {
|
// Collect selected values (ignore empty)
|
||||||
let optVal = $(this).val();
|
$("[id^='field-contact_id']").each(function () {
|
||||||
if (optVal && optVal !== '') {
|
var v = $(this).val();
|
||||||
// disable the option if it's selected in another dropdown and not the current one
|
if (v) selectedValues.push(String(v));
|
||||||
if (selectedValues.includes(optVal) && optVal !== currentVal) {
|
});
|
||||||
$(this).prop('disabled', true);
|
|
||||||
} else {
|
// Reset all option disabled states, then disable duplicates across selects
|
||||||
$(this).prop('disabled', false);
|
$("[id^='field-contact_id']").each(function () {
|
||||||
|
var currentSelect = $(this);
|
||||||
|
var currentVal = currentSelect.val() ? String(currentSelect.val()) : "";
|
||||||
|
|
||||||
|
currentSelect.find("option").prop("disabled", false);
|
||||||
|
|
||||||
|
// Disable values selected in OTHER selects (keep current selection enabled)
|
||||||
|
selectedValues.forEach(function (v) {
|
||||||
|
if (v && v !== currentVal) {
|
||||||
|
currentSelect
|
||||||
|
.find("option[value=\"" + v.replace(/"/g, '\\"') + "\"]")
|
||||||
|
.prop("disabled", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Refresh select2 UI if present
|
||||||
|
if (currentSelect.data("select2")) {
|
||||||
|
currentSelect.trigger("change.select2");
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$("[id^='field-contact_id']").each(function() {
|
||||||
|
var select = $(this);
|
||||||
|
// Clear previous options
|
||||||
|
select.html('');
|
||||||
|
// Add a default 'Select' option
|
||||||
|
select.append(
|
||||||
|
$("<option></option>")
|
||||||
|
.attr("value", '')
|
||||||
|
.text('-- Select --')
|
||||||
|
);
|
||||||
|
// Append options from contacts
|
||||||
|
contacts.forEach(function(itm) {
|
||||||
|
var option = $("<option></option>")
|
||||||
|
.attr("value", itm.value)
|
||||||
|
.text(itm.display);
|
||||||
|
// If doctor options have extra attributes
|
||||||
|
if (itm.contact && itm.contact.msl_code) {
|
||||||
|
option.attr("msl_code", itm.contact.msl_code);
|
||||||
|
}
|
||||||
|
if (itm.contact && itm.contact.speciality) {
|
||||||
|
option.attr("speciality", itm.contact.speciality);
|
||||||
|
}
|
||||||
|
select.append(option);
|
||||||
|
});
|
||||||
|
|
||||||
|
// For each select element, add a change event handler to populate `msl_code` and `speciality`
|
||||||
|
// We assume dropdowns and targets follow the pattern:
|
||||||
|
// - select: field-contact_id_1, field-contact_id_2, ..., field-contact_id
|
||||||
|
// - result: field-msl_code_1, field-speciality_1, etc.
|
||||||
|
|
||||||
|
// Remove any old event handlers first to prevent duplicate bindings
|
||||||
|
select.off('change').on('change', function () {
|
||||||
|
var selected = $(this).find(':selected');
|
||||||
|
|
||||||
|
var selectId = $(this).attr('id'); // e.g., field-contact_id_1
|
||||||
|
// Extract the suffix (e.g., _1 or empty)
|
||||||
|
var match = selectId.match(/^field-contact_id(_\d+)?$/);
|
||||||
|
var suffix = match && match[1] ? match[1] : '';
|
||||||
|
|
||||||
|
// Build the target msl_code and speciality field ids
|
||||||
|
var mslCodeField = $('#field-msl_code' + suffix);
|
||||||
|
var specialityField = $('#field-speciality' + suffix);
|
||||||
|
|
||||||
|
if (mslCodeField.length) {
|
||||||
|
mslCodeField.val(selected.attr('msl_code') || '');
|
||||||
|
}
|
||||||
|
if (specialityField.length) {
|
||||||
|
specialityField.val(selected.attr('speciality') || '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent selecting the same doctor across multiple dropdowns
|
||||||
|
enforceUniqueDoctorSelections();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure unique selection is enforced after initial render
|
||||||
|
enforceUniqueDoctorSelections();
|
||||||
});
|
});
|
||||||
|
|
||||||
// select2 needs to be re-initialized after changing the disabled state of options)
|
// Enable search on doctor dropdowns
|
||||||
if (currentSelect.hasClass('select2-hidden-accessible')) {
|
applySelect2ToDoctorDropdowns();
|
||||||
currentSelect.select2();
|
$("#pageloader").fadeOut();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
@endif
|
||||||
|
|
||||||
|
|
||||||
$(document).on('change', 'select[id^="field-contact_id"]', function() {
|
// Loop through hierarcies and fetch contacts for each hierarchy, store in contacts variable
|
||||||
let currentSelect = $(this);
|
|
||||||
let selectedVal = currentSelect.val();
|
|
||||||
let currentId = currentSelect.attr('id');
|
|
||||||
let suffix = currentId.replace('field-contact_id', '');
|
|
||||||
|
|
||||||
// duplicate check: Check if the selected value is already chosen in any other dropdown
|
// $('#field-user_id').change(function(){
|
||||||
if (selectedVal && selectedVal !== '') {
|
// let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||||
let isDuplicate = false;
|
// $('#field-hierarchy_id').val(hierarchy)
|
||||||
$('select[id^="field-contact_id"]').each(function() {
|
// event.preventDefault();
|
||||||
if ($(this).attr('id') !== currentId && $(this).val() === selectedVal) {
|
// $("#pageloader").fadeIn();
|
||||||
isDuplicate = true;
|
// $.ajax({
|
||||||
return false; // loop break
|
// type: "GET",
|
||||||
}
|
// url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
||||||
});
|
// processData: false,
|
||||||
|
// contentType: false,
|
||||||
|
// success: function( data ) {
|
||||||
|
// $("#pageloader").fadeOut();
|
||||||
|
// for (let i = 1; i <= 10; i++) {
|
||||||
|
|
||||||
if (isDuplicate) {
|
// let contactField = $('#field-contact_id_' + i);
|
||||||
Swal.fire({
|
|
||||||
icon: 'warning',
|
|
||||||
title: 'Duplicate Doctor!',
|
|
||||||
text: 'This doctor has already been selected in another dropdown. Please choose a different doctor.',
|
|
||||||
confirmButtonColor: '#3085d6'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Reset the current select to empty
|
// // Skip if field does not exist
|
||||||
currentSelect.val('').trigger('change.select2');
|
// if (!contactField.length) continue;
|
||||||
|
|
||||||
// empty msl_code and speciality fields for the current suffix
|
// contactField.html('');
|
||||||
if ($('#field-msl_code' + suffix).length) $('#field-msl_code' + suffix).val('');
|
// contactField.append(
|
||||||
if ($('#field-speciality' + suffix).length) $('#field-speciality' + suffix).val('');
|
// $("<option></option>")
|
||||||
return;
|
// .attr("value", '')
|
||||||
}
|
// .text('-- Select --')
|
||||||
}
|
// );
|
||||||
|
|
||||||
// If no duplicate, update msl_code and speciality fields
|
// for (let itm of data) {
|
||||||
let msl = $('option:selected', this).attr('msl_code') || '';
|
// contactField.append(
|
||||||
let speciality = $('option:selected', this).attr('speciality') || '';
|
// $("<option></option>")
|
||||||
|
// .attr("value", itm.value)
|
||||||
|
// .text(itm.display)
|
||||||
|
// .attr("msl_code", itm.contact.msl_code)
|
||||||
|
// .attr("speciality", itm.contact.speciality)
|
||||||
|
|
||||||
if ($('#field-msl_code' + suffix).length) {
|
// );
|
||||||
$('#field-msl_code' + suffix).val(msl);
|
// }
|
||||||
} else {
|
|
||||||
$('#field-msl_code').val(msl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($('#field-speciality' + suffix).length) {
|
|
||||||
$('#field-speciality' + suffix).val(speciality);
|
|
||||||
} else {
|
|
||||||
$('#field-speciality').val(speciality);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sink all options in all dropdowns (disable/enable)
|
|
||||||
syncSelectedDoctors();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // Remove old change events before binding again
|
||||||
|
|
||||||
|
|
||||||
|
// contactField.off('change').on('change', function () {
|
||||||
|
|
||||||
|
// let selected = $(this).find(':selected');
|
||||||
|
|
||||||
|
// $('#field-msl_code_' + i).val(selected.attr('msl_code') || '');
|
||||||
|
|
||||||
|
// $('#field-speciality_' + i).val(selected.attr('speciality') || '');
|
||||||
|
|
||||||
|
// console.log(selected.text()); // selected doctor name
|
||||||
|
// });
|
||||||
|
|
||||||
|
// contactField.select2({
|
||||||
|
// placeholder: "-- Select --",
|
||||||
|
// allowClear: true,
|
||||||
|
// width: '100%'
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// console.log(hierarchy)
|
||||||
|
// })
|
||||||
|
|
||||||
|
// for (let i = 1; i <= 10; i++) {
|
||||||
|
|
||||||
|
// $('#field-msl_code_' + i).attr('readonly',true);
|
||||||
|
// $('#field-speciality_' + i).attr('readonly',true);
|
||||||
|
// }
|
||||||
|
|
||||||
$('#report-form').on('submit', function(event){
|
$('#report-form').on('submit', function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const formData = new FormData($('#report-form')[0]);
|
const formData = new FormData($('#report-form')[0]);
|
||||||
|
|
@ -412,14 +470,13 @@
|
||||||
|
|
||||||
var plandateField = document.getElementById('field-record_date');
|
var plandateField = document.getElementById('field-record_date');
|
||||||
|
|
||||||
plandateField.setAttribute('min', "2026-10-09");
|
plandateField.setAttribute('max', today);
|
||||||
plandateField.setAttribute('max', "2026-10-09");
|
|
||||||
|
|
||||||
plandateField.value="2026-10-09";
|
|
||||||
|
|
||||||
$('#field-record_date').prop('readonly', true);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue