Rapport-Laravel/resources/views/form/rapport-maxterneo/1744886368-a4db78a0-253f-44...

510 lines
28 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
@include('layouts.shared/title-meta', ['title' => "Form"])
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
<link href="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
</head>
<div id="pageloader">
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
</div>
@php
$brandData = [
['brand'=>'ZEFTABAC INJECTION (20ML)','size'=>'20 ML', 'slug'=>'zeftabac_injection_20ml_units'],
['brand'=>'BIASTRONG 300MG INJECTION','size'=>'1V', 'slug'=>'biastrong_300mg_injection_units'],
['brand'=>'CEFANTRAL 0.50G IP(10X1V) W/O WFI','size'=>'10x1 V', 'slug'=>'cefantral_050g_ip10x1v_wo_wfi_units'],
['brand'=>'CEFANTRAL 1.00G IP(10X1V) W/O WFI','size'=>'10x1 V', 'slug'=>'cefantral_100g_ip10x1v_wo_wfi_units'],
['brand'=>'CEFAXONE 0.25 GM (10X1V)','size'=>'10x1 V', 'slug'=>'cefaxone_025_gm_10x1v_units'],
['brand'=>'CEFAXONE 0.50 GM (10X1V)','size'=>'10 x 1 V', 'slug'=>'cefaxone_050_gm_10x1v_units'],
['brand'=>'CEFAXONE 1.00 GM (10X1V)','size'=>'10 x 1 V', 'slug'=>'cefaxone_100_gm_10x1v_units'],
['brand'=>'COMBITAZ-1GM INJ: 10X1V','size'=>'10 V + A', 'slug'=>'combitaz_1gm_inj_10x1v_units'],
['brand'=>'COMBITAZ-250 MG INJ:20X1V','size'=>'20 x 1 V', 'slug'=>'combitaz_250_mg_inj20x1v_units'],
['brand'=>'LUPINEM 500MG INJ','size'=>'1 V', 'slug'=>'lupinem_500mg_inj_units'],
['brand'=>"LUPIN'S LUPITUM INJ (1GM+125MG)10X1V",'size'=>'10 x 1 V', 'slug'=>'lupins_lupitum_inj_1gm125mg10x1v_units'],
['brand'=>"LUPIN'S TAZOX (1GX20)",'size'=>'20 x 1 V+A', 'slug'=>'lupins_tazox_1gx20_units'],
['brand'=>'MAGNOVA- 250 MG INJ: 10X1V','size'=>'10 x 1 V', 'slug'=>'magnova_250_mg_inj_10x1v_units'],
['brand'=>'MAGNOVA-0.500GM INJ: 10X1V','size'=>'10 X1 V+A', 'slug'=>'magnova_0500gm_inj_10x1v_units'],
['brand'=>'MAGNOVA-1GM INJ: 10X1V','size'=>'10 X 1V+A', 'slug'=>'magnova_1gm_inj_10x1v_units'],
['brand'=>'MEROTROL 0.25 GM 1 V','size'=>'1 Vial', 'slug'=>'merotrol_025_gm_1_v_units'],
['brand'=>'MEROTROL 0.5 GM 1 V','size'=>'1 Vial', 'slug'=>'merotrol_05_gm_1_v_units'],
['brand'=>'MEROTROL 1 GM 1 V','size'=>'1 Vial', 'slug'=>'merotrol_1_gm_1_v_units'],
['brand'=>'MEROTROL S 1.5 GM 1 V','size'=>'1 Vial', 'slug'=>'merotrol_s_15_gm_1_v_units'],
['brand'=>'NOVAPIME 0.25 GM (10X1V)','size'=>'10x1 V', 'slug'=>'novapime_025_gm_10x1v_units'],
['brand'=>'NOVAPIME 0.5 GM (10X1V)','size'=>'10x1 V', 'slug'=>'novapime_05_gm_10x1v_units'],
['brand'=>'NOVAPIME 1 GM (10X1V)','size'=>'10x1 V', 'slug'=>'novapime_1_gm_10x1v_units'],
['brand'=>'SUDOSTAR 1 MIU','size'=>'1 Vial', 'slug'=>'sudostar_1_miu_units'],
['brand'=>'SUDOSTAR 2 MIU','size'=>'Vial', 'slug'=>'sudostar_2_miu_units'],
['brand'=>'SUDOSTAR 3 MIU','size'=>'3 Million IU / Vial', 'slug'=>'sudostar_3_miu_units'],
['brand'=>'TAZAR INJ 1.125 GM (10X1V)','size'=>'10 x 1 Single', 'slug'=>'tazar_inj_1125_gm_10x1v_units'],
['brand'=>'TAZAR INJ 2.25 GM (5X1V)','size'=>'5x1 V', 'slug'=>'tazar_inj_225_gm_5x1v_units'],
['brand'=>'TAZAR INJ 4.5GM 5X1V','size'=>'5x1 V', 'slug'=>'tazar_inj_45gm_5x1v_units'],
['brand'=>'TICOGEM 400 INJ 1V','size'=>'1V', 'slug'=>'ticogem_400_inj_1v_units'],
['brand'=>'TIGEZ INJ 1V','size'=>'1V', 'slug'=>'tigez_inj_1v_units'],
['brand'=>'UPXIGA 100000 IU','size'=>'1 vial', 'slug'=>'upxiga_100000_iu_units'],
['brand'=>'VORITROL INJ 200MG','size'=>'1V', 'slug'=>'voritrol_inj_200mg_units'],
['brand'=>'VORITROL200 TAB (5X1 X 4T)','size'=>'5X1 X 4T', 'slug'=>'voritrol200_tab_5x1_x_4t_units'],
];
@endphp
<body class="loading">
<div class="account-pages">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-6 col-xl-5 p-0">
<div class="card bg-pattern">
<div class="card-body p-3 row">
@if(Session::has('error'))<div class="alert alert-danger">{{Session::get('error')}}</div>
<br>@endif
@if(session('success'))<div class=" alert alert-success">{{ session('success') }}
</div>
<br>@endif
<div class="col-8">
<h4 class="page-title">{{$form->title}}</h4>
</div>
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'
) )
<div class="col-4">
@if($form->link_type == 'form')
<a href="/form/history" class="float-end pt-1">View History</a>
@else
<a href="{{url()->previous()}}" class="float-end pt-1">Back</a>
@endif
</div>
@endif
@if(isset($form->user_info))
<div class="col-12">
<h6>Submitted By: {{$form->user_info->name}}</h6>
</div>
@endif
<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="record_date" value="" id="field-record_date">
@csrf
@if($id)
<input type="hidden" name="id" value="{{$id}}">
@endif
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
<div class="col-md-12 mb-2">
<label for="field-user_id" class="form-label"> Select User / Territory <span
class="text-danger">*</span> </label>
<select class="form-control" id="field-user_id" name="user_id" required>
<option value=""> -- Select -- </option>
@foreach($form->users as $option)
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}"
{{isset($question->value) && $question->value == $option->value ? 'selected':''}}>
{{$option->display}}
</option>
@endforeach
</select>
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
</div>
@endif
@foreach($questions as $question)
<div class="col-md-12 mb-2">
<label for="field-{{$question->code}}" class="form-label">{{$question->question}}
{!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!}
</label>
@switch($question->type)
@case('hidden')
<input type="{{$question->type}}" id="field-{{$question->code}}"
name="{{$question->code}}"
value="{{isset($question->value)?$question->value:''}}">
@break
@case('text')
@case('email')
@case('tel')
@case('date')
<input type="{{$question->type}}" id="field-{{$question->code}}"
name="{{$question->code}}" class="form-control"
{{$question->required == 'yes'?'required':'' }}
value="{{isset($question->value)?$question->value:''}}">
@break
@case('number')
<input type="{{$question->type}}" min="0" max="9999999999" step="1"
id="field-{{$question->code}}" name="{{$question->code}}" class="form-control"
step="0.01"
{{$question->required == 'yes'?'required':'' }}
value="{{isset($question->value)?$question->value:0}}">
@break
@case('textarea')
<textarea id="field-{{$question->code}}" name="{{$question->code}}"
class="form-control"
{{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
@break
@case('dropdown')
<select class="form-control" id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
<option value=""> -- Select -- </option>
@foreach ($question->options as $option)
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
{{ $option->display }}
</option>
@endforeach
</select>
@break
@case('checkbox')
@foreach($question->options as $option)
<div class="form-check mb-2 form-check-primary">
<input class="form-check-input" type="checkbox"
id="field-{{$question->code}}-{{$option->value}}"
name="{{$question->code}}[]" value="{{$option->value}}"
{{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
<label class="form-check-label"
for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
</div>
@endforeach
@break
@case('file')
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval
!= 'yes' ) )
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}"
class="form-control" value="" {{$question->required == 'yes'?'required':'' }}>
@elseif(isset($question->value))
<img src="{{$question->value}}" class="img-fluid">
@endif
@break
@case('multitextbox')
<div class="row">
<div style="width: auto; overflow-y: auto; overflow-x: auto;">
<table class="table tableclass">
<thead id="heading">
<tr>
<th>Brand</th>
<th>Size Pack</th>
<th>Units</th>
</tr>
</thead>
<tbody>
@foreach($brandData as $brand)
<tr>
<td>{{ $brand['brand'] }}</td>
<td>
{{$brand['size']}}
</td>
<td>
<input type="number" id="field-{{ $brand['slug'] }}"
name="{{ $brand['slug'] }}"
class="form-control form-control-large" value="{{ $id && isset($formdata) && isset($formdata->{$brand['pseudoId']}) ? $formdata->{$brand['pseudoId']} : 0 }}">
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<!-- @foreach($question->options as $option)
<div class="col-6">{{$option->display}}</div>
<div class="col-6 mb-1">
<input type="number" id="field-{{$option->value}}" name="{{$option->value}}" class="form-control" required value="{{isset($option->val)?$option->val:0}}">
</div>
@endforeach -->
</div>
@break
@endswitch
</div>
@endforeach
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval !=
'yes' ) )
<div class="text-center d-grid mt-3">
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
</div>
@endif
</form>
</div> <!-- end card-body -->
</div>
<!-- end card -->
<!-- end row -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
<style type="text/css">
#pageloader {
background: rgba(255, 255, 255, 0.8);
display: none;
height: 100%;
position: fixed;
width: 100%;
z-index: 9999;
}
#pageloader img {
left: 50%;
margin-left: -32px;
margin-top: -32px;
position: absolute;
top: 50%;
}
</style>
@include('layouts.shared/footer-script')
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('[data-toggle="select2"]').select2();
let selected_user_id = ''
$('#field-user_id').change(function() {
$("#pageloader").fadeIn();
selected_user_id = $(this).val()
hierarchy = $('option:selected', this).attr('hierarchy');
$('#field-hierarchy_id').val(hierarchy)
event.preventDefault();
$.ajax({
type: "GET",
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' +
hierarchy,
processData: false,
contentType: false,
success: function(data) {
$("#pageloader").fadeOut();
$('#field-contact_id').html('')
$('#field-contact_id').append($("<option></option>").attr("value", '')
.text('-- Select --'));
for (let itm of data) {
if(itm.contact.c2c == 'Yes') {
$('#field-contact_id').append($("<option></option>").attr("value",
itm.value).text(itm.display).attr("speciality", itm
.contact.speciality));
}
}
$('#field-contact_id').change(function() {
$('#field-speciality').val($('option:selected', this).attr(
'speciality'))
})
},
});
console.log(hierarchy)
})
$('#field-contact_id').change(function() {
$('#field-speciality').val($('option:selected', this).attr(
'speciality'))
})
$('#field-contact_id').change(function() {
$('#field-legacy_code').val($('option:selected', this).attr('msl_code'))
})
// $("#field-speciality").parent().hide();
// $("#field-speciality").prop({"required":false});
// $("#field-legacy_code").parent().hide();
// $("#field-legacy_code").prop({"required":false});
$('#field-total_units').prop({"readonly":true});
$('#field-total_value').prop({"readonly":true});
var input=document.querySelectorAll('input');
input.forEach(function(brands){
brands.addEventListener('keyup',function(){
console.log("We are inside of foreach loop");
let a=parseInt(document.getElementById('field-zeftabac_injection_20ml_units').value)||0;
let b=parseInt(document.getElementById('field-biastrong_300mg_injection_units').value)||0;
let c=parseInt(document.getElementById('field-cefantral_050g_ip10x1v_wo_wfi_units').value)||0;
let d=parseInt(document.getElementById('field-cefantral_100g_ip10x1v_wo_wfi_units').value)||0;
let e=parseInt(document.getElementById('field-cefaxone_025_gm_10x1v_units').value)||0;
let f=parseInt(document.getElementById('field-cefaxone_050_gm_10x1v_units').value)||0;
let g=parseInt(document.getElementById('field-cefaxone_100_gm_10x1v_units').value)||0;
let h=parseInt(document.getElementById('field-combitaz_1gm_inj_10x1v_units').value)||0;
let i=parseInt(document.getElementById('field-combitaz_250_mg_inj20x1v_units').value)||0;
let j=parseInt(document.getElementById('field-lupinem_500mg_inj_units').value)||0;
let k=parseInt(document.getElementById('field-lupins_lupitum_inj_1gm125mg10x1v_units').value)||0;
let l=parseInt(document.getElementById('field-lupins_tazox_1gx20_units').value)||0;
let m=parseInt(document.getElementById('field-magnova_250_mg_inj_10x1v_units').value)||0;
let n=parseInt(document.getElementById('field-magnova_0500gm_inj_10x1v_units').value)||0;
let o=parseInt(document.getElementById('field-magnova_1gm_inj_10x1v_units').value)||0;
let p=parseInt(document.getElementById('field-merotrol_025_gm_1_v_units').value)||0;
let q=parseInt(document.getElementById('field-merotrol_05_gm_1_v_units').value)||0;
let r=parseInt(document.getElementById('field-merotrol_1_gm_1_v_units').value)||0;
let s=parseInt(document.getElementById('field-merotrol_s_15_gm_1_v_units').value)||0;
let t=parseInt(document.getElementById('field-novapime_025_gm_10x1v_units').value)||0;
let u=parseInt(document.getElementById('field-novapime_05_gm_10x1v_units').value)||0;
let v=parseInt(document.getElementById('field-novapime_1_gm_10x1v_units').value)||0;
let w=parseInt(document.getElementById('field-sudostar_1_miu_units').value)||0;
let x=parseInt(document.getElementById('field-sudostar_2_miu_units').value)||0;
let y=parseInt(document.getElementById('field-sudostar_3_miu_units').value)||0;
let z=parseInt(document.getElementById('field-tazar_inj_1125_gm_10x1v_units').value)||0;
let aa=parseInt(document.getElementById('field-tazar_inj_225_gm_5x1v_units').value)||0;
let ab=parseInt(document.getElementById('field-tazar_inj_45gm_5x1v_units').value)||0;
let ac=parseInt(document.getElementById('field-ticogem_400_inj_1v_units').value)||0;
let ad=parseInt(document.getElementById('field-tigez_inj_1v_units').value)||0;
let ae=parseInt(document.getElementById('field-upxiga_100000_iu_units').value)||0;
let af=parseInt(document.getElementById('field-voritrol_inj_200mg_units').value)||0;
let ag=parseInt(document.getElementById('field-voritrol200_tab_5x1_x_4t_units').value)||0;
let priceOfA=4950;
let productOfA=a*priceOfA;
let priceOfB=2200;
let productOfB=b*priceOfB;
let priceOfC=272;
let productOfC=c*priceOfC;
let priceOfD=447;
let productOfD=d*priceOfD;
let priceOfE=306.50;
let productOfE=e*priceOfE;
let priceOfF=384.50;
let productOfF=f*priceOfF;
let priceOfG=464;
let productOfG=g*priceOfG;
let priceOfH=3459.50;
let productOfH=h*priceOfH;
let priceOfI=2250;
let productOfI=i*priceOfI;
let priceOfJ=1172.30;
let productOfJ=j*priceOfJ;
let priceOfK=3468.50;
let productOfK=k*priceOfK;
let priceOfL=4912;
let productOfL=l*priceOfL;
let priceOfM=1521.50;
let productOfM=m*priceOfM;
let priceOfN=3313.50;
let productOfN=n*priceOfN;
let priceOfO=6172;
let productOfO=o*priceOfO;
let priceOfP=292.50;
let productOfP=p*priceOfP;
let priceOfQ=652.80;
let productOfQ=q*priceOfQ;
let priceOfR=1067;
let productOfR=r*priceOfR;
let priceOfS=1624.55;
let productOfS=s*priceOfS;
let priceOfT=1599.50;
let productOfT=t*priceOfT;
let priceOfU=2509.00;
let productOfU=u*priceOfU;
let priceOfV=4609.50;
let productOfV=v*priceOfV;
let priceOfW=844.25;
let productOfW=w*priceOfW;
let priceOfX=1446.50;
let productOfX=x*priceOfX;
let priceOfY=2310.00;
let productOfY=y*priceOfY;
let priceOfZ=1115.50;
let productOfZ=z*priceOfZ;
let priceOfAA=1072.25;
let productOfAA=aa*priceOfAA;
let priceOfAB=1573.75;
let productOfAB=ab*priceOfAB;
let priceOfAC=1645.60;
let productOfAC=ac*priceOfAC;
let priceOfAD=3033.80;
let productOfAD=ad*priceOfAD;
let priceOfAE=4489.80;
let productOfAE=ae*priceOfAE;
let priceOfAF=3270.90;
let productOfAF=af*priceOfAF;
let priceOfAG=13965.50;
let productOfAG=ag*priceOfAG;
let total=(a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z+aa+ab+ac+ad+ae+af+ag);
let totalMoney=parseFloat(productOfA+productOfB+productOfC+productOfD+productOfE+productOfF+productOfG+productOfH+productOfI+productOfJ+productOfK+productOfL+productOfM+productOfN+productOfO+productOfP+productOfQ+productOfR+productOfS+productOfT+productOfU+productOfV+productOfW+productOfX+productOfY+productOfZ+productOfAA+productOfAB+productOfAB+productOfAC+productOfAD+productOfAE+productOfAF+productOfAG);
let total_Units=document.getElementById('field-total_units');
total_Units.value=total;
let total_money=document.getElementById('field-total_value');
total_money.value=totalMoney;
})
})
$('#report-form').on('submit', function(event) {
event.preventDefault();
$("#pageloader").fadeIn();
$.ajax({
type: "POST",
url: '/form/ajaxsubmit',
data: new FormData($('#report-form')[0]),
processData: false,
contentType: false,
success: function(data) {
$("#pageloader").fadeOut();
if (data.status == 'success') {
Swal.fire({
title: 'Great!',
text: 'Your data is successfully submitted!',
icon: 'success'
})
$('#report-form').trigger("reset");
$('#field-user_id').val(selected_user_id)
$('#field-user_id').trigger("change");
} else {
Swal.fire({
icon: 'error',
title: 'Data not submitted',
text: 'Something went wrong, please try again after some time!'
})
}
},
});
});
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0');
var yyyy = today.getFullYear();
today = yyyy + '-' + mm + '-' + dd;
var plandateField = document.getElementById('field-record_date');
plandateField.setAttribute('max', today);
});
</script>
</body>
</html>