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
|
|
@ -44,9 +44,10 @@
|
|||
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||
$submissions = $submissions->data->submissions;
|
||||
|
||||
|
||||
|
||||
@endphp
|
||||
@if(count($submissions) === 0 || !empty($id))
|
||||
@if(count($submissions) ==0)
|
||||
<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="user_id" value="{{$form->user_id}}">
|
||||
|
|
@ -93,10 +94,6 @@
|
|||
$isContact = str_starts_with($question->code, 'contact_id');
|
||||
@endphp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<select class="form-control" {!!($isContact)?'data-toggle="select2"':'' !!} id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
|
|
@ -166,10 +163,11 @@
|
|||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
@else
|
||||
<h4 class="text-center" >You have submitted the Doctors</h4>
|
||||
|
||||
<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
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
|
@ -207,167 +205,227 @@
|
|||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('[data-toggle="select2"]').select2();
|
||||
$('#field-user_id').change(function(){
|
||||
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||
$('#field-hierarchy_id').val(hierarchy)
|
||||
event.preventDefault();
|
||||
var hierarcies = [];
|
||||
var contacts = [];
|
||||
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
@foreach($form->users as $option)
|
||||
hierarcies.push('{{$option->hierarchy_id}}');
|
||||
@endforeach
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
$('#field-contact_id').html('')
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
||||
for (let itm of 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));
|
||||
}
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
console.log(hierarchy)
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
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);
|
||||
|
||||
$('#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);
|
||||
// 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);
|
||||
// Avoid re-initializing select2
|
||||
if (select.data("select2")) return;
|
||||
select.select2({
|
||||
width: "100%",
|
||||
placeholder: "-- Select --",
|
||||
allowClear: true
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// disable options in all dropdowns based on the selected values
|
||||
$('select[id^="field-contact_id"]').each(function() {
|
||||
let currentSelect = $(this);
|
||||
let currentVal = currentSelect.val();
|
||||
function enforceUniqueDoctorSelections() {
|
||||
var selectedValues = [];
|
||||
|
||||
currentSelect.find('option').each(function() {
|
||||
let optVal = $(this).val();
|
||||
if (optVal && optVal !== '') {
|
||||
// disable the option if it's selected in another dropdown and not the current one
|
||||
if (selectedValues.includes(optVal) && optVal !== currentVal) {
|
||||
$(this).prop('disabled', true);
|
||||
} else {
|
||||
$(this).prop('disabled', false);
|
||||
// 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);
|
||||
|
||||
// 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)
|
||||
if (currentSelect.hasClass('select2-hidden-accessible')) {
|
||||
currentSelect.select2();
|
||||
}
|
||||
// Enable search on doctor dropdowns
|
||||
applySelect2ToDoctorDropdowns();
|
||||
$("#pageloader").fadeOut();
|
||||
});
|
||||
}
|
||||
@endif
|
||||
|
||||
|
||||
// Loop through hierarcies and fetch contacts for each hierarchy, store in contacts variable
|
||||
|
||||
// $('#field-user_id').change(function(){
|
||||
// let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||
// $('#field-hierarchy_id').val(hierarchy)
|
||||
// event.preventDefault();
|
||||
// $("#pageloader").fadeIn();
|
||||
// $.ajax({
|
||||
// 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++) {
|
||||
|
||||
$(document).on('change', 'select[id^="field-contact_id"]', function() {
|
||||
let currentSelect = $(this);
|
||||
let selectedVal = currentSelect.val();
|
||||
let currentId = currentSelect.attr('id');
|
||||
let suffix = currentId.replace('field-contact_id', '');
|
||||
// let contactField = $('#field-contact_id_' + i);
|
||||
|
||||
// duplicate check: Check if the selected value is already chosen in any other dropdown
|
||||
if (selectedVal && selectedVal !== '') {
|
||||
let isDuplicate = false;
|
||||
$('select[id^="field-contact_id"]').each(function() {
|
||||
if ($(this).attr('id') !== currentId && $(this).val() === selectedVal) {
|
||||
isDuplicate = true;
|
||||
return false; // loop break
|
||||
}
|
||||
});
|
||||
// // Skip if field does not exist
|
||||
// if (!contactField.length) continue;
|
||||
|
||||
if (isDuplicate) {
|
||||
Swal.fire({
|
||||
icon: 'warning',
|
||||
title: 'Duplicate Doctor!',
|
||||
text: 'This doctor has already been selected in another dropdown. Please choose a different doctor.',
|
||||
confirmButtonColor: '#3085d6'
|
||||
});
|
||||
// contactField.html('');
|
||||
// contactField.append(
|
||||
// $("<option></option>")
|
||||
// .attr("value", '')
|
||||
// .text('-- Select --')
|
||||
// );
|
||||
|
||||
// Reset the current select to empty
|
||||
currentSelect.val('').trigger('change.select2');
|
||||
|
||||
// empty msl_code and speciality fields for the current suffix
|
||||
if ($('#field-msl_code' + suffix).length) $('#field-msl_code' + suffix).val('');
|
||||
if ($('#field-speciality' + suffix).length) $('#field-speciality' + suffix).val('');
|
||||
return;
|
||||
}
|
||||
}
|
||||
// for (let itm of data) {
|
||||
// contactField.append(
|
||||
// $("<option></option>")
|
||||
// .attr("value", itm.value)
|
||||
// .text(itm.display)
|
||||
// .attr("msl_code", itm.contact.msl_code)
|
||||
// .attr("speciality", itm.contact.speciality)
|
||||
|
||||
// );
|
||||
// }
|
||||
|
||||
// If no duplicate, update msl_code and speciality fields
|
||||
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);
|
||||
}
|
||||
// // Remove old change events before binding again
|
||||
|
||||
|
||||
if ($('#field-speciality' + suffix).length) {
|
||||
$('#field-speciality' + suffix).val(speciality);
|
||||
} else {
|
||||
$('#field-speciality').val(speciality);
|
||||
}
|
||||
// contactField.off('change').on('change', function () {
|
||||
|
||||
// Sink all options in all dropdowns (disable/enable)
|
||||
syncSelectedDoctors();
|
||||
});
|
||||
// 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){
|
||||
event.preventDefault();
|
||||
const formData = new FormData($('#report-form')[0]);
|
||||
|
|
@ -412,14 +470,13 @@
|
|||
|
||||
var plandateField = document.getElementById('field-record_date');
|
||||
|
||||
plandateField.setAttribute('min', "2026-10-09");
|
||||
plandateField.setAttribute('max', "2026-10-09");
|
||||
|
||||
plandateField.value="2026-10-09";
|
||||
|
||||
$('#field-record_date').prop('readonly', true);
|
||||
plandateField.setAttribute('max', today);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue