From 966f5aee301be8741e58086f796eabe7949416fc Mon Sep 17 00:00:00 2001 From: zeeshan Date: Tue, 2 Jun 2026 17:58:08 +0530 Subject: [PATCH] Team 4 Changes --- ...e0eb-680e-4855-b4fd-4472099dfcd9.blade.php | 92 +++++++++++++++++-- 1 file changed, 82 insertions(+), 10 deletions(-) diff --git a/resources/views/form/rapport-team4/1774506455-f48ce0eb-680e-4855-b4fd-4472099dfcd9.blade.php b/resources/views/form/rapport-team4/1774506455-f48ce0eb-680e-4855-b4fd-4472099dfcd9.blade.php index 2e597f63..41234132 100644 --- a/resources/views/form/rapport-team4/1774506455-f48ce0eb-680e-4855-b4fd-4472099dfcd9.blade.php +++ b/resources/views/form/rapport-team4/1774506455-f48ce0eb-680e-4855-b4fd-4472099dfcd9.blade.php @@ -23,8 +23,7 @@
@endif

{{$form->title}}

-
No ROI & BF Drs to be part of O1 @ 9 AM Reporting.
-Submission is only allowed for the same day.
+
No ROI & BF Drs to be part of O1 @ 9 AM Reporting.
Submission is only allowed for the same day.
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
@@ -40,6 +39,49 @@ Submission is only allowed for the same day.
Submitted By: {{$form->user_info->name}}
@endif + + @php + $submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id); + $submissions = $submissions->data->submissions ?? []; + /* echo "
";
+                                print_r($submissions);
+                                echo "
"; */ + + $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 +
@csrf @@ -246,17 +288,47 @@ Submission is only allowed for the same day. $('#field-contact_id').append(''); $('label[for="field-brand"]').hide(); let headerRow = ` -
-
Brand
-
Rx Count
-
- `; +
+
Brand
+
Rx Count
+
+ `; - $('#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({