Team 3 (Levoswitch Enrollment)
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m23s Details

This commit is contained in:
zeeshan 2026-11-05 13:19:33 +05:30
parent fd76dcda75
commit a2feb275b6
1 changed files with 52 additions and 41 deletions

View File

@ -366,9 +366,8 @@
$('#field-msl_code,#field-pcode,#field-speciality').attr('readonly',true);
/* $('#field-brand_name').on('input', function () {
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
}); */
var isEditMode = @json((bool)$id);
$(document).on('input', 'input[id^="field-brand_name"]', function () {
@ -392,6 +391,7 @@
});
}
initializeSelect2();
preventDuplicateDoctors();
@ -466,42 +466,52 @@
} */
function preventDuplicateDoctors() {
let selectedValues = [];
let selectedDoctorIds = [];
// Collect all selected doctor IDs (ignoring empty selections)
// Step 1: Collect all currently selected doctor values
$('select[id^="field-contact_id"]').each(function () {
let val = $(this).val();
if (val) {
selectedValues.push(val);
if (val && val !== '') {
selectedDoctorIds.push(String(val));
}
});
// Update options for each select
// Step 2: Traverse each doctor select element and update option states
$('select[id^="field-contact_id"]').each(function () {
let currentSelect = $(this);
let currentValue = currentSelect.val();
let $currentSelect = $(this);
let currentVal = String($currentSelect.val() || '');
currentSelect.find('option').each(function () {
let option = $(this);
let optionValue = option.val();
$currentSelect.find('option').each(function () {
let $option = $(this);
let optionVal = String($option.val() || '');
if (!optionValue) return;
// Skip the default placeholder option
if (!optionVal) return;
// Clean previously appended text
let originalText = option.text().replace(' (Already Added)', '').trim();
// Clean any previously appended '(Already Added)' tags
let rawText = $option.text().replace(/\s*\(Already Added\)/g, '').trim();
// If selected in another dropdown, disable it and add indicator
if (selectedValues.includes(optionValue) && optionValue !== currentValue) {
option.prop('disabled', true);
option.text(originalText + ' (Already Added)');
// If selected in another dropdown, disable and tag it
if (selectedDoctorIds.includes(optionVal) && optionVal !== currentVal) {
$option.prop('disabled', true);
$option.text(rawText + ' (Already Added)');
} else {
option.prop('disabled', false);
option.text(originalText);
$option.prop('disabled', false);
$option.text(rawText);
}
});
// Trigger change to update Select2 without destroying entire DOM binding
currentSelect.trigger('change.select2');
// Step 3: Refresh Select2 cleanly to render updated disabled states
if ($currentSelect.hasClass("select2-hidden-accessible")) {
$currentSelect.select2('destroy');
}
$currentSelect.select2({
width: '100%',
placeholder: '-- Select Doctor --'
});
// Preserve the selected value
$currentSelect.val(currentVal);
});
}
@ -510,7 +520,8 @@
let selectedOption = $(this).find(':selected');
let id = $(this).attr('id').split('-').pop(); // get doctor_count dynamically
let id = $(this).attr('id').split('-'); // get doctor_count dynamically
let suffix = idParts.length > 2 ? '-' + idParts[2] : '';
$('#field-msl_code-' + id).val(selectedOption.attr('msl_code'));
$('#field-pcode-' + id).val(selectedOption.attr('pcode'));
@ -702,7 +713,7 @@
console.log(hierarchy)
})
var isEditMode = @json((bool)$id);
$('#report-form').on('submit', function(event) {
event.preventDefault();
/* if (numberOfSubmission !=9) {