Team 4 Changes
This commit is contained in:
parent
223294c865
commit
966f5aee30
|
|
@ -23,8 +23,7 @@
|
||||||
<br>@endif
|
<br>@endif
|
||||||
<div class="col-9">
|
<div class="col-9">
|
||||||
<h4 class="page-title">{{$form->title}}</h4>
|
<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/>
|
<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>
|
||||||
Submission is only allowed for the same day.</h6>
|
|
||||||
</div>
|
</div>
|
||||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||||
<div class="col-3">
|
<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>
|
<h6>Submitted By: {{$form->user_info->name}}</h6>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@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">
|
<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
|
||||||
|
|
@ -246,17 +288,47 @@ Submission is only allowed for the same day.</h6>
|
||||||
$('#field-contact_id').append('<option value="others">Others</option>');
|
$('#field-contact_id').append('<option value="others">Others</option>');
|
||||||
$('label[for="field-brand"]').hide();
|
$('label[for="field-brand"]').hide();
|
||||||
let headerRow = `
|
let headerRow = `
|
||||||
<div class="row mb-1 fw-bold">
|
<div class="row mb-1 fw-bold">
|
||||||
<div class="col-6">Brand</div>
|
<div class="col-6">Brand</div>
|
||||||
<div class="col-6 text-center"> Rx Count</div>
|
<div class="col-6 text-center"> Rx Count</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
$('#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('');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#field-montair_lc_adult')
|
|
||||||
.closest('.row')
|
|
||||||
.prepend(headerRow);
|
|
||||||
|
|
||||||
$('#report-form').on('submit', function(event){
|
$('#report-form').on('submit', function(event){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$("#pageloader").fadeIn();
|
$("#pageloader").fadeIn();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue