289 lines
16 KiB
PHP
289 lines
16 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" />
|
|
</head>
|
|
<div id="pageloader">
|
|
<img src="/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">
|
|
<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
|
|
|
|
@php
|
|
$start = $month = strtotime('2023-01-01');
|
|
$end = strtotime('now');
|
|
$months = [];
|
|
while($month < $end)
|
|
{
|
|
$months[date('Y-m', $month)] = date('F Y', $month);
|
|
$month = strtotime("+1 month", $month);
|
|
}
|
|
krsort($months);
|
|
|
|
if( request()->get('month') ) {
|
|
$target = strtotime(request()->get('month').'-01');
|
|
} else {
|
|
$target = strtotime("now");
|
|
}
|
|
$history = Formhelper::getMultiformData($form->partition, $form->form_id, $form->user_id, date("m-01-Y", $target) , date("m-t-Y", $target) );
|
|
|
|
$conts = [];
|
|
$contacts = [];
|
|
foreach($questions as $question) {
|
|
if($question->code == 'contact_id') {
|
|
$conts = $question->options;
|
|
}
|
|
}
|
|
|
|
foreach($conts as $contact) {
|
|
$contact->duolin_rx = 0;
|
|
$contact->glycohale_fb_rx = 0;
|
|
$contact->maxiflo_rx = 0;
|
|
$contact->maxiflo_sb_rx = 0;
|
|
$contact->glycohale_f_rx = 0;
|
|
$contact->asthalin_rx = 0;
|
|
|
|
if(sizeof($history->data->submissions) > 0) {
|
|
foreach($history->data->submissions as $sub){
|
|
if($contact->display == $sub->formdata->contact_id) {
|
|
$contact->duolin_rx += (int)$sub->formdata->duolin_rx;
|
|
$contact->glycohale_fb_rx += (int)$sub->formdata->glycohale_fb_rx;
|
|
$contact->maxiflo_rx += (int)$sub->formdata->maxiflo_rx;
|
|
$contact->maxiflo_sb_rx += (int)$sub->formdata->maxiflo_sb_rx;
|
|
$contact->glycohale_f_rx += (int)$sub->formdata->glycohale_f_rx;
|
|
$contact->asthalin_rx += (int)$sub->formdata->asthalin_rx;
|
|
}
|
|
}
|
|
}
|
|
$contacts[] = $contact;
|
|
}
|
|
//echo '<pre>'; print_r($contacts); exit;
|
|
@endphp
|
|
|
|
<div class="col-12">
|
|
<div class="row mb-3">
|
|
<label for="inputEmail3" class="col-4 col-xl-3 col-form-label">Selected Month</label>
|
|
<div class="col-8 col-xl-9">
|
|
<select class="form-control" id="month-selector">
|
|
@foreach($months as $k => $v)
|
|
<option value="{{$k}}" {{ $k==app('request')->input('month', '')?'selected':'' }} >{{$v}}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="col-12" id="table-wrapper">
|
|
|
|
|
|
<div class="table-responsive">
|
|
<table class="table table-borderless table-nowrap table-hover table-centered m-0">
|
|
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Action</th>
|
|
<th>Doctor</th>
|
|
<th>Powerof5 ?</th>
|
|
<th>Duolin Rx</th>
|
|
<th>Glycohale F Rx</th>
|
|
<th>Glycohale FB Rx</th>
|
|
<th>Maxiflo Rx</th>
|
|
<th>Maxiflo SB Rx</th>
|
|
<th>Asthalin Rx</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($contacts as $contact)
|
|
<tr>
|
|
<td>
|
|
<button type="button" class="btn btn-xs btn-info add-btn" doc_id="{{$contact->contact->id}}"><i class="mdi mdi-pencil"></i> Add</button>
|
|
</td>
|
|
<td><h5 class="m-0 fw-normal">{{$contact->display}}</h5></td>
|
|
<td>{{isset($contact->contact->powerof5) ? $contact->contact->powerof5 : 'No'}}</td>
|
|
<td>{{isset($contact->duolin_rx) ? $contact->duolin_rx : '0'}}</td>
|
|
<td>{{isset($contact->glycohale_f_rx) ? $contact->glycohale_f_rx : '0'}}</td>
|
|
<td>{{isset($contact->glycohale_fb_rx) ? $contact->glycohale_fb_rx : '0'}}</td>
|
|
<td>{{isset($contact->maxiflo_rx) ? $contact->maxiflo_rx : '0'}}</td>
|
|
<td>{{isset($contact->maxiflo_sb_rx) ? $contact->maxiflo_sb_rx : '0'}}</td>
|
|
<td>{{isset($contact->asthalin_rx) ? $contact->asthalin_rx : '0'}}</td>
|
|
</tr>
|
|
@endforeach
|
|
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="form-wrapper">
|
|
<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
|
|
@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" {{$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
|
|
@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')
|
|
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="" accept="image/jpg, image/jpeg, image/png" required>
|
|
@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>
|
|
|
|
</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 type="text/javascript">
|
|
jQuery(document).ready(function($){
|
|
let powerof5 = {}
|
|
@foreach($contacts as $contact)
|
|
powerof5['{{$contact->value}}'] = '{{isset($contact->contact->powerof5) ? $contact->contact->powerof5 : 'No'}}'
|
|
@endforeach
|
|
$('#form-wrapper').hide()
|
|
$('.add-btn').click(function(){
|
|
$('#field-contact_id').val( $(this).attr('doc_id') )
|
|
$('#form-wrapper').show()
|
|
$('#table-wrapper').hide()
|
|
})
|
|
|
|
console.log(document.location.href)
|
|
$('#month-selector').change(function() {
|
|
$("#pageloader").fadeIn();
|
|
let href = new URL(document.location.href);
|
|
console.log(href)
|
|
href.searchParams.set('month', $('#month-selector').val() );
|
|
window.location.href = href.toString()
|
|
});
|
|
|
|
$('#report-form').on('submit', function(event){
|
|
event.preventDefault();
|
|
$("#pageloader").fadeIn();
|
|
$('#report-form').append('<input type="hidden" name="powerof5" value="'+powerof5[$('#field-contact_id').val()]+'">')
|
|
$.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'
|
|
})
|
|
window.location.reload();
|
|
//$('#report-form').trigger("reset");
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: 'Something went wrong, please try again after some time!'
|
|
})
|
|
}
|
|
},
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |