@@ -475,7 +475,7 @@
$('.doctor-group-wrapper').show();
- // आधीचे सर्व जनरेट झालेले ग्रुप्स साफ करा
+
$('.execution-doctor-group-wrapper').empty();
if (attendees <= 0) {
@@ -502,6 +502,8 @@
'
' + doctor_html + '
'
);
+ updateDoctorOptions();
+
(function(c) {
$('#field-hcp_name_' + c).change(function() {
@@ -510,7 +512,7 @@
$('#field-pcode_of_wrapper_doctor_' + c).val(selectedOption.attr('msl_code'));
- // २. सर्वात महत्त्वाचे: या ड्रॉपडाउनची 'value' बदलून थेट डॉक्टरांचे 'नाव' सेट करा
+
let doctorName = selectedOption.text().trim();
if(doctorName !== "" && doctorName !== "-- Select --") {
selectedOption.val(doctorName);
@@ -521,6 +523,60 @@
});
+ function updateDoctorOptions() {
+
+ let selectedDoctors = [];
+
+ $('[id^="field-hcp_name"]').each(function () {
+ let val = $(this).val();
+ if (val) {
+ selectedDoctors.push(val);
+ }
+ });
+
+ $('[id^="field-hcp_name"]').each(function () {
+
+ let currentValue = $(this).val();
+
+ $(this).find('option').each(function () {
+
+ let optionValue = $(this).val();
+
+ if (
+ optionValue &&
+ optionValue !== currentValue &&
+ selectedDoctors.includes(optionValue)
+ ) {
+ $(this).prop('disabled', true);
+ } else {
+ $(this).prop('disabled', false);
+ }
+
+ });
+
+ });
+ }
+
+ $(document).on('change', '[id^="field-hcp_name"]', function () {
+
+ let currentVal = $(this).val();
+
+ let duplicate = false;
+
+ $('[id^="field-hcp_name"]').not(this).each(function () {
+ if ($(this).val() === currentVal && currentVal !== '') {
+ duplicate = true;
+ }
+ });
+
+ if (duplicate) {
+ alert('This doctor is already selected.');
+ $(this).val('');
+ }
+
+ updateDoctorOptions();
+ });
+
$('#field-hcp_name').change(function() {
$('#field-pcode_of_wrapper_doctor').val($('option:selected', this).attr('msl_code'))
})
@@ -562,6 +618,7 @@
$('#execution-plan_date').prop('readonly', true);
$('#execution-msl_code').prop('readonly',true);
$('#execution-expected_no_of_attendees').prop('readonly',true);
+ $('#execution-name_of_additional_speaker').prop('readonly',true);
let contacts = document.getElementById('execution-contact_id');
@@ -615,6 +672,10 @@
$('#execution-hcp_name,#execution-pcode_of_wrapper_doctor,#execution-speaker_name').parent().hide();
$('#execution-hcp_name,#execution-pcode_of_wrapper_doctor,#execution-speaker_name').attr('required',false);
+ document.querySelectorAll('[id^="field-pcode_of_wrapper_doctor"]')
+ .forEach(function(el) {
+ el.readOnly = true;
+ });
})