From 622adecf6e8b4b982df5e310666d6de0a8e78faa Mon Sep 17 00:00:00 2001 From: zeeshan Date: Wed, 25 Nov 2026 16:51:11 +0530 Subject: [PATCH] Team 3 (Visit Form) Update MSL code --- ...5d7f-2410-4bae-89bc-ab3d9ea2a684.blade.php | 93 +++++++++++++------ 1 file changed, 64 insertions(+), 29 deletions(-) diff --git a/resources/views/form/rapport-team3/1795590118-9f6c5d7f-2410-4bae-89bc-ab3d9ea2a684.blade.php b/resources/views/form/rapport-team3/1795590118-9f6c5d7f-2410-4bae-89bc-ab3d9ea2a684.blade.php index 2cd7abff..69c71071 100644 --- a/resources/views/form/rapport-team3/1795590118-9f6c5d7f-2410-4bae-89bc-ab3d9ea2a684.blade.php +++ b/resources/views/form/rapport-team3/1795590118-9f6c5d7f-2410-4bae-89bc-ab3d9ea2a684.blade.php @@ -272,7 +272,7 @@ $('#field-contact_id,#field-chemist_name').attr('required',false); - $('#field-visit_type').on('change',function(){ + /* $('#field-visit_type').on('change',function(){ let type=$(this).val(); console.log("Value is : ",type); if(type==='Doctor'){ @@ -291,7 +291,69 @@ $('#field-contact_id,#field-chemist_name').parent().hide(); $('#field-contact_id,#field-chemist_name').attr('required',false); } - }) + }) */ + + +// MSL Code and Speciality update function +function updateDoctorDetails() { + + let visitType = $('#field-visit_type').val(); + + let selectedOption; + + if (visitType === 'Doctor') { + selectedOption = $('#field-contact_id option:selected'); + } + else if (visitType === 'Chemist') { + selectedOption = $('#field-chemist_name option:selected'); + } + + if (selectedOption && selectedOption.val()) { + $('#field-msl_code').val(selectedOption.attr('msl_code') || ''); + $('#field-speciality').val(selectedOption.attr('speciality') || ''); + } +} + +// Doctor dropdown change +$('#field-contact_id').on('change', function () { + updateDoctorDetails(); +}); + +// Chemist dropdown change +$('#field-chemist_name').on('change', function () { + updateDoctorDetails(); +}); + +// Visit type change +$('#field-visit_type').on('change', function () { + + let type = $(this).val(); + + if (type === 'Doctor') { + $('#field-contact_id').parent().show(); + $('#field-contact_id').attr('required', true); + + $('#field-chemist_name').parent().hide(); + $('#field-chemist_name').attr('required', false); + } + else if (type === 'Chemist') { + $('#field-chemist_name').parent().show(); + $('#field-chemist_name').attr('required', true); + + $('#field-contact_id').parent().hide(); + $('#field-contact_id').attr('required', false); + } + else { + $('#field-contact_id, #field-chemist_name').parent().hide(); + $('#field-contact_id, #field-chemist_name').attr('required', false); + } + + updateDoctorDetails(); +}); + +// Initial load - Edit mode +updateDoctorDetails(); + @@ -354,34 +416,7 @@ // MSL Code and Speciality update function -function updateDoctorDetails() { - let visitType = $('#field-visit_type').val(); - - let selectedOption; - - if (visitType === 'Doctor') { - selectedOption = $('#field-contact_id option:selected'); - } - else if (visitType === 'Chemist') { - selectedOption = $('#field-chemist_name option:selected'); - } - - if (selectedOption && selectedOption.val()) { - $('#field-msl_code').val(selectedOption.attr('msl_code') || ''); - $('#field-speciality').val(selectedOption.attr('speciality') || ''); - } -} - -// Doctor dropdown change -$('#field-contact_id').on('change', function () { - updateDoctorDetails(); -}); - -// Chemist dropdown change -$('#field-chemist_name').on('change', function () { - updateDoctorDetails(); -}); // Visit type change $('#field-visit_type').on('change', function () {