diff --git a/resources/views/form/rapport-team2/1794811995-cd07ffaa-1b76-40c8-800b-6b2d3c801016.blade.php b/resources/views/form/rapport-team2/1794811995-cd07ffaa-1b76-40c8-800b-6b2d3c801016.blade.php index 39869f7f..c3387c46 100644 --- a/resources/views/form/rapport-team2/1794811995-cd07ffaa-1b76-40c8-800b-6b2d3c801016.blade.php +++ b/resources/views/form/rapport-team2/1794811995-cd07ffaa-1b76-40c8-800b-6b2d3c801016.blade.php @@ -327,6 +327,8 @@ const tmHierarchies = @json(isset($form->users) ? collect($form->users)->pluck('hierarchy_id')->filter()->unique()->values() : []); let doctor_count = 0; + let allDoctorsList = []; + function initializeSelect2(element) { const $element = $(element); @@ -559,6 +561,8 @@ return String(a.display || '').localeCompare(String(b.display || ''), 'en', { sensitivity: 'base' }); }); + allDoctorsList = allDoctors; + const $doctorSelect = $('#field-contact_id'); const preselectedDoctorId = String($doctorSelect.attr('data-preselected') || ''); @@ -606,7 +610,7 @@ loadAllTmDoctors(); // Add another doctor wrapper. The first wrapper is already present in the form. - $('#adddoctor-btn').on('click', function () { + /* $('#adddoctor-btn').on('click', function () { if ($('.doctor-wrapper').length >= 5) return; const doctorOptions = $('#field-contact_id').html(); @@ -679,11 +683,103 @@ initializeExecutionSelects(); preventDuplicateDoctors(); + if ($('.doctor-wrapper').length >= 5) { + $('#adddoctor-btn').hide(); + } + }); */ + + $('#adddoctor-btn').on('click', function () { + if ($('.doctor-wrapper').length >= 5) return; + + doctor_count++; + + + let doctorOptionsHtml = ''; + allDoctorsList.forEach(function (doctor) { + const contact = doctor.contact || {}; + const msl = contact.msl_code || contact.legacy_code || ''; + const spec = contact.speciality || ''; + doctorOptionsHtml += ``; + }); + + const empty_doctor = ` +