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-msl_code,#field-pcode,#field-speciality').attr('readonly',true);
/* $('#field-brand_name').on('input', function () { var isEditMode = @json((bool)$id);
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
}); */
$(document).on('input', 'input[id^="field-brand_name"]', function () { $(document).on('input', 'input[id^="field-brand_name"]', function () {
@ -392,6 +391,7 @@
}); });
} }
initializeSelect2(); initializeSelect2();
preventDuplicateDoctors(); preventDuplicateDoctors();
@ -466,51 +466,62 @@
} */ } */
function preventDuplicateDoctors() { 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 () { $('select[id^="field-contact_id"]').each(function () {
let val = $(this).val(); let val = $(this).val();
if (val) { if (val && val !== '') {
selectedValues.push(val); selectedDoctorIds.push(String(val));
}
});
// Step 2: Traverse each doctor select element and update option states
$('select[id^="field-contact_id"]').each(function () {
let $currentSelect = $(this);
let currentVal = String($currentSelect.val() || '');
$currentSelect.find('option').each(function () {
let $option = $(this);
let optionVal = String($option.val() || '');
// Skip the default placeholder option
if (!optionVal) return;
// Clean any previously appended '(Already Added)' tags
let rawText = $option.text().replace(/\s*\(Already Added\)/g, '').trim();
// 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(rawText);
}
});
// 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);
});
} }
});
// Update options for each select
$('select[id^="field-contact_id"]').each(function () {
let currentSelect = $(this);
let currentValue = currentSelect.val();
currentSelect.find('option').each(function () {
let option = $(this);
let optionValue = option.val();
if (!optionValue) return;
// Clean previously appended text
let originalText = option.text().replace(' (Already Added)', '').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)');
} else {
option.prop('disabled', false);
option.text(originalText);
}
});
// Trigger change to update Select2 without destroying entire DOM binding
currentSelect.trigger('change.select2');
});
}
$(document).on('change', 'select[id^="field-contact_id"]', function () { $(document).on('change', 'select[id^="field-contact_id"]', function () {
let selectedOption = $(this).find(':selected'); 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-msl_code-' + id).val(selectedOption.attr('msl_code'));
$('#field-pcode-' + id).val(selectedOption.attr('pcode')); $('#field-pcode-' + id).val(selectedOption.attr('pcode'));
@ -702,7 +713,7 @@
console.log(hierarchy) console.log(hierarchy)
}) })
var isEditMode = @json((bool)$id);
$('#report-form').on('submit', function(event) { $('#report-form').on('submit', function(event) {
event.preventDefault(); event.preventDefault();
/* if (numberOfSubmission !=9) { /* if (numberOfSubmission !=9) {