Team 4 Changes

This commit is contained in:
zeeshan 2026-06-02 17:58:08 +05:30
parent 223294c865
commit 966f5aee30
1 changed files with 82 additions and 10 deletions

View File

@ -23,8 +23,7 @@
<br>@endif
<div class="col-9">
<h4 class="page-title">{{$form->title}}</h4>
<h6 style="font-size: 12.5px" class="text-danger">No ROI & BF Drs to be part of O1 @ 9 AM Reporting.<br/>
Submission is only allowed for the same day.</h6>
<h6 style="font-size: 12.5px" class="text-danger">No ROI & BF Drs to be part of O1 @ 9 AM Reporting.<br/>Submission is only allowed for the same day.</h6>
</div>
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
<div class="col-3">
@ -40,6 +39,49 @@ Submission is only allowed for the same day.</h6>
<h6>Submitted By: {{$form->user_info->name}}</h6>
</div>
@endif
@php
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
$submissions = $submissions->data->submissions ?? [];
/* echo "<pre>";
print_r($submissions);
echo "</pre>"; */
$brands = [
'montair_lc_adult',
'montair_lc_kid',
'erdostyne',
'nicogum_2_and_4',
'furamist_range',
'levolinplus_range'
];
$brandTotals = [];
foreach ($brands as $brand) {
$totalRx = 0;
foreach ($submissions as $submission) {
if (
isset($submission->formdata) &&
isset($submission->formdata->record_date) &&
$submission->formdata->record_date == date('Y-m-d')
) {
$totalRx += (int)($submission->formdata->$brand ?? 0);
}
}
$brandTotals[$brand] = $totalRx;
}
@endphp
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
<input type="hidden" name="form_id" value="{{$form_id}}">
@csrf
@ -246,17 +288,47 @@ Submission is only allowed for the same day.</h6>
$('#field-contact_id').append('<option value="others">Others</option>');
$('label[for="field-brand"]').hide();
let headerRow = `
<div class="row mb-1 fw-bold">
<div class="col-6">Brand</div>
<div class="col-6 text-center"> Rx Count</div>
</div>
`;
<div class="row mb-1 fw-bold">
<div class="col-6">Brand</div>
<div class="col-6 text-center"> Rx Count</div>
</div>
`;
$('#field-montair_lc_adult')
.closest('.row')
.prepend(headerRow);
$('#field-montair_lc_adult').closest('.row').prepend(headerRow);
const brandTotals = @json($brandTotals);
const DAILY_LIMIT = 30;
$('#field-montair_lc_adult,\
#field-montair_lc_kid,\
#field-erdostyne,\
#field-nicogum_2_and_4,\
#field-furamist_range,\
#field-levolinplus_range')
.on('input', function () {
let brand = $(this).attr('name');
let currentValue = parseInt($(this).val()) || 0;
let alreadySubmitted = parseInt(brandTotals[brand]) || 0;
if ((alreadySubmitted + currentValue) > DAILY_LIMIT) {
Swal.fire({
icon: 'warning',
title: 'Limit Exceeded',
text: `${brand.replaceAll('_',' ')} cannot exceed 30 Rx per day`
});
$(this).val('');
}
});
$('#report-form').on('submit', function(event){
event.preventDefault();
$("#pageloader").fadeIn();
$.ajax({