diff --git a/resources/views/form/rapport-team4/1781090899-2cedf382-9fbb-45ac-896b-94de9104a11b.blade.php b/resources/views/form/rapport-team4/1781090899-2cedf382-9fbb-45ac-896b-94de9104a11b.blade.php index e18a0ad8..99d7561e 100644 --- a/resources/views/form/rapport-team4/1781090899-2cedf382-9fbb-45ac-896b-94de9104a11b.blade.php +++ b/resources/views/form/rapport-team4/1781090899-2cedf382-9fbb-45ac-896b-94de9104a11b.blade.php @@ -339,7 +339,12 @@
-
{{ ucwords($categoryLabel) }}
+ {{--
{{ ucwords($categoryLabel) }}
--}} +
+ {{ $categoryLabel == 'nac + acebrophylline' + ? 'NAC + Acebrophylline' + : ucwords($categoryLabel) }} +
@@ -539,7 +544,7 @@ select option:disabled { }); } - function updateDoctorDropdowns($tbody) { + /* function updateDoctorDropdowns($tbody) { let selectedDoctors = []; $tbody.find('.doctor-select').each(function() { @@ -574,7 +579,47 @@ select option:disabled { }); }); } + */ + function updateDoctorDropdowns() { + let selectedDoctors = []; + + $('.doctor-select').each(function() { + let value = $(this).val(); + + if (value) { + selectedDoctors.push(value); + } + }); + + $('.doctor-select').each(function() { + + let currentDropdown = $(this); + let currentValue = currentDropdown.val(); + + currentDropdown.find('option').each(function() { + + let option = $(this); + let originalText = option.data('original-text') || option.text(); + + option.data('original-text', originalText); + option.text(originalText); + option.prop('disabled', false); + + let optionValue = option.val(); + + if ( + optionValue && + optionValue !== currentValue && + selectedDoctors.includes(optionValue) + ) { + option.prop('disabled', true); + option.text(originalText + ' (Already Added)'); + } + }); + + }); + } function updateOtherMoleculeDropdowns($tbody) { let sectionMolecule = $tbody.data('molecule-use'); @@ -663,8 +708,11 @@ select option:disabled { return fd; } - $(document).on('change', '.doctor-select', function() { + /*$(document).on('change', '.doctor-select', function() { updateDoctorDropdowns($(this).closest('.doctor-table-body')); + });*/ + $(document).on('change', '.doctor-select', function() { + updateDoctorDropdowns(); }); $('.doctor-select').select2({ @@ -675,12 +723,18 @@ select option:disabled { prefillAllDoctorTables(); - $('.doctor-table-body').each(function() { + /* $('.doctor-table-body').each(function() { let $tbody = $(this); updateOtherMoleculeDropdowns($tbody); updateDoctorDropdowns($tbody); + }); */ + $('.doctor-table-body').each(function() { + let $tbody = $(this); + updateOtherMoleculeDropdowns($tbody); }); + updateDoctorDropdowns(); + $('#report-form').on('submit', function(event) { event.preventDefault();