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
@if(count($submissions)===0 || $id)
{{-- @if(count($submissions)===0 || $id) --}}
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
<input type="hidden" name="form_id" value="{{$form_id}}">
@csrf
@ -203,7 +203,9 @@
<option value=""> -- Select -- </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 }}"
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
@if($question->code == 'contact_id')
@ -213,7 +215,7 @@
>
{{ $option->display }}
</option>
@endif
@endforeach
</select>
@else
@ -227,7 +229,7 @@
{{ $option->display }}</option>
@endforeach
</select>
@endif
@endif
@break
@case('checkbox')
@foreach($question->options as $option)
@ -281,9 +283,9 @@
</div>
@endif
</form>
@elseif(!$id)
{{-- @elseif(!$id)
<h4>You have submitted 10 doctors</h4>
@endif
@endif --}}
</div> <!-- end card-body -->
</div>
<!-- end card -->
@ -502,10 +504,10 @@
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').attr('required',false);
/* $('#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); */
$('#execution-prescriber').on('change',function(){
/* $('#execution-prescriber').on('change',function(){
let value=$(this).val();
console.log("Prescriber : ",value);
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').attr('required',false);
}
})
}) */
$('#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, ''));
@ -537,7 +539,7 @@
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)
@if( in_array($question->code,
["record_date","select_rxber_type"] ) )
@ -611,7 +613,7 @@
if ($('.doctor-wrapper').length >= 10) {
if ($('.doctor-wrapper').length >= 15) {
$('#adddoctor-btn').hide();
} else {
$('#adddoctor-btn').show();
@ -621,8 +623,9 @@
/* $('.btn-remove').unbind();
$('.btn-remove').click(function() {
/* $('.btn-remove').unbind(); */
/* $('.btn-remove').click(function() {
$(this).closest('.doctor-wrapper').find('select').select2('destroy');
$(this).closest('.doctor-wrapper').remove();
numberOfSubmission--;
@ -631,84 +634,45 @@
console.log("New Number of Submission : ",numberOfSubmission);
console.log("Number of doctors : ",doctor_count);
$('#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();
$('#field-potential_prescription_value-' + i).closest('.col-md-12').hide();
$('#field-current_prescription_value-' + i).closest('.col-md-12').hide();
let wrapper = $(this).closest('.doctor-wrapper');
$('#field-monthly_prescription_value-' + i).prop('required',false);
$('#field-potential_prescription_value-' + i).prop('required',false);
$('#field-current_prescription_value-' + i).prop('required',false);
}
wrapper.find('select').each(function () {
if ($(this).hasClass('select2-hidden-accessible')) {
$(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');
}
}*/
$('#field-user_id').change(function(){
let hierarchy = $('option:selected', this).attr('hierarchy');