Team 4 (Wrapper Changes)

This commit is contained in:
zeeshan 2026-06-05 11:45:14 +05:30
parent 14992927a9
commit ba9aa7bd04
1 changed files with 42 additions and 78 deletions

View File

@ -90,7 +90,7 @@
@endphp @endphp
@if(count($submissions)===0 || $id) {{-- @if(count($submissions)===0 || $id) --}}
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data"> <form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
<input type="hidden" name="form_id" value="{{$form_id}}"> <input type="hidden" name="form_id" value="{{$form_id}}">
@csrf @csrf
@ -203,7 +203,9 @@
<option value=""> -- Select -- </option> <option value=""> -- Select -- </option>
@foreach ($question->options as $option) @foreach ($question->options as $option)
@if(isset($option->contact->montair_lc_kid_non_rxber_survey)
&& $option->contact->montair_lc_kid_non_rxber_survey == 'Yes')
<option value="{{ $option->value }}" <option value="{{ $option->value }}"
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
@if($question->code == 'contact_id') @if($question->code == 'contact_id')
@ -213,7 +215,7 @@
> >
{{ $option->display }} {{ $option->display }}
</option> </option>
@endif
@endforeach @endforeach
</select> </select>
@else @else
@ -227,7 +229,7 @@
{{ $option->display }}</option> {{ $option->display }}</option>
@endforeach @endforeach
</select> </select>
@endif @endif
@break @break
@case('checkbox') @case('checkbox')
@foreach($question->options as $option) @foreach($question->options as $option)
@ -281,9 +283,9 @@
</div> </div>
@endif @endif
</form> </form>
@elseif(!$id) {{-- @elseif(!$id)
<h4>You have submitted 10 doctors</h4> <h4>You have submitted 10 doctors</h4>
@endif @endif --}}
</div> <!-- end card-body --> </div> <!-- end card-body -->
</div> </div>
<!-- end card --> <!-- end card -->
@ -502,10 +504,10 @@
preventDuplicateDoctors(); preventDuplicateDoctors();
}); });
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').parent().hide(); /* $('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').parent().hide();
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').attr('required',false); $('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').attr('required',false); */
$('#execution-prescriber').on('change',function(){ /* $('#execution-prescriber').on('change',function(){
let value=$(this).val(); let value=$(this).val();
console.log("Prescriber : ",value); console.log("Prescriber : ",value);
if(value==='Yes'){ if(value==='Yes'){
@ -517,7 +519,7 @@
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').parent().hide(); $('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').parent().hide();
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').attr('required',false); $('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').attr('required',false);
} }
}) }) */
$('#field-brand_1_name_pre, #field-brand_name_2_prescriber, #field-brand_name_3_prescriber').on('input', function () { $('#field-brand_1_name_pre, #field-brand_name_2_prescriber, #field-brand_name_3_prescriber').on('input', function () {
$(this).val($(this).val().replace(/[^a-zA-Z\s]/g, '')); $(this).val($(this).val().replace(/[^a-zA-Z\s]/g, ''));
@ -537,7 +539,7 @@
let empty_doctor = ` let empty_doctor = `
<div class="doctor-wrapper"> <div class="doctor-wrapper"><button type="button" class="btn btn-danger btn-remove float-end" style="margin-top:-25px; margin-right:-25px"><i class="mdi mdi-close"></i></button>
@foreach($questions as $question) @foreach($questions as $question)
@if( in_array($question->code, @if( in_array($question->code,
["record_date","select_rxber_type"] ) ) ["record_date","select_rxber_type"] ) )
@ -611,7 +613,7 @@
if ($('.doctor-wrapper').length >= 10) { if ($('.doctor-wrapper').length >= 15) {
$('#adddoctor-btn').hide(); $('#adddoctor-btn').hide();
} else { } else {
$('#adddoctor-btn').show(); $('#adddoctor-btn').show();
@ -621,8 +623,9 @@
/* $('.btn-remove').unbind(); /* $('.btn-remove').unbind(); */
$('.btn-remove').click(function() {
/* $('.btn-remove').click(function() {
$(this).closest('.doctor-wrapper').find('select').select2('destroy'); $(this).closest('.doctor-wrapper').find('select').select2('destroy');
$(this).closest('.doctor-wrapper').remove(); $(this).closest('.doctor-wrapper').remove();
numberOfSubmission--; numberOfSubmission--;
@ -631,84 +634,45 @@
console.log("New Number of Submission : ",numberOfSubmission); console.log("New Number of Submission : ",numberOfSubmission);
console.log("Number of doctors : ",doctor_count); console.log("Number of doctors : ",doctor_count);
$('#adddoctor-btn').show(); $('#adddoctor-btn').show();
}) */ }) */
for (let i = 1; i <= 10; i++) { $(document).on('click', '.btn-remove', function () {
$('#field-monthly_prescription_value-' + i).closest('.col-md-12').hide(); let wrapper = $(this).closest('.doctor-wrapper');
$('#field-potential_prescription_value-' + i).closest('.col-md-12').hide();
$('#field-current_prescription_value-' + i).closest('.col-md-12').hide();
$('#field-monthly_prescription_value-' + i).prop('required',false); wrapper.find('select').each(function () {
$('#field-potential_prescription_value-' + i).prop('required',false); if ($(this).hasClass('select2-hidden-accessible')) {
$('#field-current_prescription_value-' + i).prop('required',false); $(this).select2('destroy');
}
});
}
wrapper.remove();
numberOfSubmission--;
preventDuplicateDoctors();
console.log("New Number of Submission :", numberOfSubmission);
$('#adddoctor-btn').show();
});
// Show/Hide fields based on Prescriber dropdown
$(document).on('change', 'select[id^="field-prescriber-"]', function () {
let id = $(this).attr('id').split('-').pop();
let value = $(this).val();
if (value === 'Yes') {
$('#field-monthly_prescription_value-' + id)
.closest('.col-md-12')
.show();
$('#field-potential_prescription_value-' + id)
.closest('.col-md-12')
.show();
$('#field-current_prescription_value-' + id)
.closest('.col-md-12')
.show();
$('#field-monthly_prescription_value-' + id).prop('required',true);
$('#field-potential_prescription_value-' + id).prop('required',true);
$('#field-current_prescription_value-' + id).prop('required',true);
} else {
$('#field-monthly_prescription_value-' + id)
.closest('.col-md-12')
.hide();
$('#field-potential_prescription_value-' + id)
.closest('.col-md-12')
.hide();
$('#field-current_prescription_value-' + id)
.closest('.col-md-12')
.hide();
$('#field-monthly_prescription_value-' + id).prop('required',false);
$('#field-potential_prescription_value-' + id).prop('required',false);
$('#field-current_prescription_value-' + id).prop('required',false);
}
});
// Trigger once on page load (important for edit mode)
$('select[id^="field-prescriber-"]').trigger('change');
}) })
for (let i = 0; i < 9; i++) { /*for (let i = 0; i < 9; i++) {
$('#adddoctor-btn').trigger('click'); $('#adddoctor-btn').trigger('click');
} }*/
$('#field-user_id').change(function(){ $('#field-user_id').change(function(){
let hierarchy = $('option:selected', this).attr('hierarchy'); let hierarchy = $('option:selected', this).attr('hierarchy');