460 lines
26 KiB
PHP
460 lines
26 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>
|
|
|
|
<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}}">
|
|
@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)
|
|
@if( !in_array($question->code,
|
|
["select_month","record_date","select_emanzen_thursday_week"] ) )
|
|
@continue;
|
|
@endif
|
|
<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"
|
|
{{$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':''}}>
|
|
{{$option->display}}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@break
|
|
@endswitch
|
|
</div>
|
|
@endforeach
|
|
|
|
<div class="col-md-12" id="doctor-wrapper-group">
|
|
<div class="doctor-wrapper row mt-3">
|
|
@foreach($questions as $question)
|
|
@if(in_array($question->code,
|
|
["select_month","record_date","select_emanzen_thursday_week"] ) )
|
|
@continue;
|
|
@endif
|
|
<div class="col-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}}" name="{{$question->code}}[]"
|
|
value="{{isset($question->value)?$question->value:''}}">
|
|
@break
|
|
@case('text')
|
|
@case('email')
|
|
@case('tel')
|
|
@case('date')
|
|
<input type="{{$question->type}}" name="{{$question->code}}[]"
|
|
class="form-control {{$question->type}}_{{$question->code}}" {{$question->required == 'yes'?'required':'' }}
|
|
value="{{isset($question->value)?$question->value:''}}">
|
|
@break
|
|
@case('number')
|
|
<input type="{{$question->type}}" min="0" max="9999999999" step="any"
|
|
name="{{$question->code}}[]"
|
|
class="form-control number_{{$question->code}}"
|
|
{{$question->required == 'yes'?'required':'' }}
|
|
value="{{isset($question->value)?$question->value:0}}" >
|
|
@break
|
|
@case('dropdown')
|
|
<select class="form-control select_{{$question->code}}" id="field-{{ $question->code }}" name="{{ $question->code }}[]" {{ $question->required == 'yes' ? 'required' : '' }}>
|
|
<option value=""> -- Select -- </option>
|
|
@if ($question->code == 'contact_id')
|
|
@foreach ($question->options as $option)
|
|
@if( isset($option->contact->emanzen_thursday) && $option->contact->emanzen_thursday == 'Yes' )
|
|
<option value="{{ $option->value }}" msl_code="{{isset($option->contact->msl_code)?$option->contact->msl_code:''}}" speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
|
{{ $option->display }}
|
|
</option>
|
|
@endif
|
|
@endforeach
|
|
@else
|
|
@foreach ($question->options as $option)
|
|
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
|
{{ $option->display }}
|
|
</option>
|
|
@endforeach
|
|
@endif
|
|
</select>
|
|
@break
|
|
@endswitch
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
|
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval !=
|
|
'yes' ) )
|
|
<div class="text-center button-list row mt-3">
|
|
<div class="col-6 d-grid"><button class="btn btn-primary" type="submit"
|
|
id="submit-btn"> Submit </button></div>
|
|
<div class="col-6 d-grid"><button class="btn btn-warning" type="button"
|
|
id="adddoctor-btn"> Add Doctor </button></div>
|
|
</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%;
|
|
}
|
|
|
|
.doctor-wrapper {
|
|
border: 1px solid #ccc;
|
|
border-radius: 15px;
|
|
padding: 15px;
|
|
position: relative;
|
|
}
|
|
</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($) {
|
|
let doctors = [];
|
|
$('[data-toggle="select2"]').select2();
|
|
$('#field-user_id').change(function() {
|
|
$("#pageloader").fadeIn();
|
|
let 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) {
|
|
//doctors = data
|
|
$("#pageloader").fadeOut();
|
|
$('.select_contact_id').each(function(i, obj) {
|
|
$(this).html('')
|
|
$(this).append($("<option></option>").attr("value", '')
|
|
.text('-- Select --'));
|
|
for (let itm of data) {
|
|
if(itm.contact.emanzen_thursday == 'Yes') {
|
|
doctors.push(itm)
|
|
$(this).append($("<option></option>").attr("speciality", itm.contact.speciality).attr("value", itm.value).text(itm.display));
|
|
}
|
|
}
|
|
$('.select_contact_id').on('change', function() {
|
|
$(this).parent().parent().find('.text_speciality').val( $("option:selected" ,this).attr("speciality") )
|
|
})
|
|
});
|
|
},
|
|
});
|
|
|
|
console.log(hierarchy)
|
|
})
|
|
const temp_input = $('input[name^="speciality"]');
|
|
console.log('in --- ',temp_input);
|
|
|
|
$(temp_input).addClass('text_speciality');
|
|
|
|
|
|
$('.select_contact_id').on('change', function() {
|
|
$(this).parent().parent().find('.text_speciality').val( $("option:selected" ,this).attr("speciality") )
|
|
})
|
|
|
|
$('.number_total_emanzen_units,.number_total_emanzen_value,.text_speciality').prop('readonly', 'true');
|
|
|
|
$('.number_emanzen_d_pob_in_strips_units,.number_emanzen_dp_pob_in_strips_units,.number_emanzen_forte_10_mg_pob_in_strips,.number_emanzen_5_mg_pob_in_strips_units').on('keyup', function() {
|
|
let a=parseFloat($('.number_emanzen_d_pob_in_strips_units').val()||0);
|
|
let b=parseFloat($('.number_emanzen_dp_pob_in_strips_units').val()||0);
|
|
let c=parseFloat($('.number_emanzen_forte_10_mg_pob_in_strips').val()||0);
|
|
let d=parseFloat($('.number_emanzen_5_mg_pob_in_strips_units').val()||0);
|
|
|
|
|
|
let priceOfA=163.61;
|
|
let priceOfB=145.34;
|
|
let priceOfC=159.57;
|
|
let priceOfD=110.00;
|
|
|
|
let productOfA=a*priceOfA;
|
|
let productOfB=b*priceOfB;
|
|
let productOfC=c*priceOfC;
|
|
let productOfD=d*priceOfD;
|
|
|
|
let totalUnit=a+b+c+d;
|
|
|
|
let total=productOfA+productOfB+productOfC+productOfD;
|
|
$('.number_total_emanzen_units').val(totalUnit);
|
|
$('.number_total_emanzen_value').val(total.toFixed(2));
|
|
})
|
|
|
|
var doctorformhtml = `<div class="doctor-wrapper row mt-3">
|
|
<div class="col-12">
|
|
<button type="button" class="btn btn-danger btn-remove float-end" style="position:absolute; right:0px; top:0px;"><i class="mdi mdi-close"></i></button>
|
|
</div>
|
|
@foreach($questions as $question)
|
|
@if(in_array($question->code, ["select_month","record_date","select_emanzen_thursday_week"] ) )
|
|
@continue;
|
|
@endif
|
|
<div class="col-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}}" name="{{$question->code}}[]" value="{{isset($question->value)?$question->value:''}}">
|
|
@break
|
|
@case('text')
|
|
@case('email')
|
|
@case('tel')
|
|
@case('date')
|
|
<input class="form-control text_{{$question->code}}" type="{{$question->type}}" name="{{$question->code}}[]" class="form-control {{$question->type}}_{{$question->code}}" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}">
|
|
@break
|
|
@case('number')
|
|
<input class="form-control number_{{$question->code}}" type="{{$question->type}}" min="0" max="9999999999" step="any" name="{{$question->code}}[]" class="form-control number_{{$question->code}}" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
|
@break
|
|
@case('dropdown')
|
|
<select class="form-control select_{{$question->code}}" {!!($question->code == 'contact_id')?'data-toggle="select2"':'' !!} name="{{$question->code}}[]" {{$question->required == 'yes'?'required':'' }}>
|
|
<option value=""> -- Select -- </option>
|
|
@foreach($question->options as $option)
|
|
<option value="{{$option->value}}" speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
|
@endforeach
|
|
</select>
|
|
@break
|
|
@endswitch
|
|
</div>
|
|
@endforeach
|
|
</div>`
|
|
|
|
$('#adddoctor-btn').click(function() {
|
|
// console.log(doctorformhtml)
|
|
$('#doctor-wrapper-group').append(doctorformhtml)
|
|
$('.btn-remove').unbind()
|
|
$('.btn-remove').click(function() {
|
|
$(this).parent().parent().remove()
|
|
})
|
|
// $('[data-toggle="select2"]').unbind();
|
|
// $('[data-toggle="select2"]').select2();
|
|
|
|
$('#doctor-wrapper-group').children().last().find('.select_contact_id').html('')
|
|
$('#doctor-wrapper-group').children().last().find('.select_contact_id').append($("<option></option>").attr("value", '').text('-- Select --'));
|
|
for (let itm of doctors) {
|
|
$('#doctor-wrapper-group').children().last().find('.select_contact_id').append($(
|
|
"<option></option>").attr("speciality", itm.contact.speciality).attr("value", itm.value).text(itm.display));
|
|
}
|
|
|
|
|
|
|
|
|
|
//$('.select_contact_id').unbind()
|
|
$('.select_contact_id').on('change', function() {
|
|
console.log('changed');
|
|
$(this).parent().parent().find('.text_speciality').val( $("option:selected" ,this).attr("speciality") )
|
|
})
|
|
|
|
$('.number_emanzen_d_pob_in_strips_units,.number_emanzen_dp_pob_in_strips_units,.number_emanzen_forte_10_mg_pob_in_strips,.number_emanzen_5_mg_pob_in_strips_units,.number_total_emanzen_value').unbind();
|
|
$('.number_total_emanzen_units,.number_total_emanzen_value').unbind();
|
|
$('.number_total_emanzen_units,.number_total_emanzen_value,.text_speciality').prop('readonly', 'true');
|
|
|
|
|
|
|
|
|
|
$('.number_emanzen_d_pob_in_strips_units,\
|
|
.number_emanzen_dp_pob_in_strips_units,\
|
|
.number_emanzen_forte_10_mg_pob_in_strips,\
|
|
.number_emanzen_5_mg_pob_in_strips_units'
|
|
).on('change keyup', function () {
|
|
|
|
let $row = $(this).parent().parent(); // same pattern as proxym
|
|
|
|
let totalUnits =
|
|
(parseFloat($row.find('.number_emanzen_d_pob_in_strips_units').val()) || 0) +
|
|
(parseFloat($row.find('.number_emanzen_dp_pob_in_strips_units').val()) || 0) +
|
|
(parseFloat($row.find('.number_emanzen_forte_10_mg_pob_in_strips').val()) || 0) +
|
|
(parseFloat($row.find('.number_emanzen_5_mg_pob_in_strips_units').val()) || 0);
|
|
|
|
let totalValue=
|
|
(parseFloat($row.find('.number_emanzen_d_pob_in_strips_units').val()*163.61) || 0) +
|
|
(parseFloat($row.find('.number_emanzen_dp_pob_in_strips_units').val()*145.34) || 0) +
|
|
(parseFloat($row.find('.number_emanzen_forte_10_mg_pob_in_strips').val()*159.57) || 0) +
|
|
(parseFloat($row.find('.number_emanzen_5_mg_pob_in_strips_units').val()*110.00) || 0);
|
|
|
|
$row.find('.number_total_emanzen_units').val(totalUnits);
|
|
$row.find('.number_total_emanzen_value').val(totalValue.toFixed(2));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
// $('#field-total_pob_in_strips_units').prop('readonly', true);
|
|
// $('#field-no_of_proxym_rx_generated').on('input', function() {
|
|
// let proxym_rx_generated = parseInt($('#field-no_of_proxym_rx_generated').val()) || 0;
|
|
|
|
// $('#field-total_pob_in_strips_units').val(proxym_rx_generated);
|
|
// })
|
|
|
|
|
|
|
|
$('#report-form').on('submit', function(event) {
|
|
event.preventDefault();
|
|
$('.doctor-wrapper').each(function(index) {
|
|
for (let ques of ["record_date", "select_rehab_tuesday_week"]) {
|
|
$('#report-form').append('<input type="hidden" name="' + ques +
|
|
'[]" value="' + $('#field-' + ques).val() + '">')
|
|
}
|
|
});
|
|
|
|
$("#pageloader").fadeIn();
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/form/ajaxsubmitmultiple',
|
|
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");
|
|
} 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> |