344 lines
22 KiB
PHP
344 lines
22 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/datatables/datatables.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">
|
|
<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-6">
|
|
<h4 class="page-title">{{$form->title}}</h4>
|
|
</div>
|
|
<div class="col-6">
|
|
@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>
|
|
@php
|
|
$doctors = DB::table('team3_nebyatra_doctors as nb')->leftjoin('team3_nebyatra_tm_edm_map as map', 'nb.user_id', '=', 'map.tm_user_id')->where('map.tm_user_id', $form->user_id )->whereNotNull('nb.doctor_name')->select('nb.*', 'map.tm_user_name', 'map.tm_user_id', 'map.edm_user_name', 'map.edm_user_id')->orderBy('date_added', 'desc')->get();
|
|
$tms = [];
|
|
$edms = [];
|
|
foreach($doctors as $doctor) {
|
|
$tms[$doctor->tm_user_name] = $doctor->tm_user_name;
|
|
$edms[$doctor->edm_user_id] = $doctor->edm_user_name;
|
|
}
|
|
@endphp
|
|
<div class="col-md-12" id="table-wrapper">
|
|
<div class="card">
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-borderless table-nowrap table-hover m-0" id="list-page-datatable">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Action</th>
|
|
<th>Doctor Name</th>
|
|
<th>Execution Date</th>
|
|
<th>No of Followups</th>
|
|
<th>Last Followup</th>
|
|
<th>Mobile Number</th>
|
|
<th>Speciality</th>
|
|
<th>Location</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($doctors as $doc)
|
|
<tr class="{{ $doc->tm_no_of_followups < 5 && strtotime($doc->tm_last_followup_date) < strtotime('-7 days') ? 'table-danger' : 'table-success' }}">
|
|
<td><button type="button" class="btn btn-xs btn-info edit-btn" plan_details="{{ json_encode($doc) }}"><i class="mdi mdi-pencil"></i> Visit</button></td>
|
|
<td>{{ $doc->doctor_name }}</td>
|
|
<td>{{ date("Y-m-d", strtotime($doc->date_added)) }}</td>
|
|
<td>{{ $doc->tm_no_of_followups }}</td>
|
|
<td>{{ date("Y-m-d", strtotime($doc->tm_last_followup_date)) }}</td>
|
|
<td>{{ $doc->mobile_number }}</td>
|
|
<td>{{ $doc->speciality }}</td>
|
|
<td>{{ $doc->location }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="form-wrapper">
|
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
|
|
|
@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="doctor_name" id="field-doctor_name" value="{{isset($form->formdata)&&isset($form->formdata->doctor_name)?$form->formdata->doctor_name:''}}">
|
|
<input type="hidden" name="doctor_execution_date" id="field-doctor_execution_date" value="{{isset($form->formdata)&&isset($form->formdata->doctor_execution_date)?$form->formdata->doctor_execution_date:''}}">
|
|
<input type="hidden" name="doctor_mobile" id="field-doctor_mobile" value="{{isset($form->formdata)&&isset($form->formdata->doctor_mobile)?$form->formdata->doctor_mobile:''}}">
|
|
<input type="hidden" name="doctor_speciality" id="field-doctor_speciality" value="{{isset($form->formdata)&&isset($form->formdata->doctor_speciality)?$form->formdata->doctor_speciality:''}}">
|
|
<input type="hidden" name="doctor_location" id="field-doctor_location" value="{{isset($form->formdata)&&isset($form->formdata->doctor_location)?$form->formdata->doctor_location:''}}">
|
|
<input type="hidden" name="doctor_district" id="field-doctor_district" value="{{isset($form->formdata)&&isset($form->formdata->doctor_district)?$form->formdata->doctor_district:''}}">
|
|
<input type="hidden" name="doctor_state" id="field-doctor_state" value="{{isset($form->formdata)&&isset($form->formdata->doctor_state)?$form->formdata->doctor_state:''}}">
|
|
<input type="hidden" name="doctor_id" id="field-doctor_id" value="{{isset($form->formdata)&&isset($form->formdata->doctor_id)?$form->formdata->doctor_id:''}}">
|
|
<input type="hidden" name="tm_user_name" id="field-tm_user_name" value="{{isset($form->formdata)&&isset($form->formdata->tm_user_name)?$form->formdata->tm_user_name:''}}">
|
|
<input type="hidden" name="tm_user_id" id="field-tm_user_id" value="{{isset($form->formdata)&&isset($form->formdata->tm_user_id)?$form->formdata->tm_user_id:''}}">
|
|
<input type="hidden" name="execution_id" id="field-execution_id" value="{{isset($form->formdata)&&isset($form->formdata->execution_id)?$form->formdata->execution_id:''}}">
|
|
<input type="hidden" name="plan_date" id="field-plan_date" value="{{isset($form->formdata)&&isset($form->formdata->plan_date)?$form->formdata->plan_date:''}}">
|
|
@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>
|
|
@if($question->code == 'educator_name')
|
|
@foreach($edms as $edm)
|
|
<option value="{{$edm}}" {{isset($question->value) && $question->value == $edm ? 'selected':''}}>{{ $edm }}</option>
|
|
@endforeach
|
|
<option value="Executed without Educator"> Executed without Educator </option>
|
|
@elseif($question->code == 'edu_dr_contact_exchange')
|
|
@foreach($tms as $tm)
|
|
<option value="{{$tm}}" {{isset($question->value) && $question->value == $tm ? 'selected':''}}>{{$tm}}</option>
|
|
@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
|
|
@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">
|
|
@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>
|
|
</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/datatables/datatables.min.js')}}"></script>
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function($){
|
|
|
|
$('#list-page-datatable').DataTable({
|
|
stateSave: true,
|
|
pageLength: 500,
|
|
"paging": false,
|
|
"scrollX": true,
|
|
"language": {
|
|
"paginate": {
|
|
"previous": "<i class='mdi mdi-chevron-left'>",
|
|
"next": "<i class='mdi mdi-chevron-right'>"
|
|
}
|
|
},
|
|
"drawCallback": function () {
|
|
$('.dataTables_paginate > .pagination').addClass('pagination-rounded');
|
|
}
|
|
});
|
|
|
|
|
|
$('#field-user_id').change(function(){
|
|
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 ) {
|
|
$("#pageloader").fadeOut();
|
|
$('#field-contact_id').html('')
|
|
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
|
for(let itm of data) {
|
|
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display));
|
|
}
|
|
},
|
|
});
|
|
|
|
console.log(hierarchy)
|
|
})
|
|
|
|
$('#form-wrapper').hide()
|
|
@if($id)
|
|
$('#form-wrapper').show()
|
|
$('#table-wrapper').hide()
|
|
@endif
|
|
$('.edit-btn').click(function(){
|
|
let selected = JSON.parse($(this).attr('plan_details'))
|
|
$('#field-doctor_execution_date').val(selected.date_added);
|
|
$('#field-doctor_name').val(selected.doctor_name);
|
|
$('#field-doctor_mobile').val(selected.mobile_number);
|
|
$('#field-doctor_speciality').val(selected.speciality);
|
|
$('#field-doctor_location').val(selected.location);
|
|
$('#field-doctor_district').val(selected.district);
|
|
$('#field-doctor_state').val(selected.state);
|
|
$('#field-doctor_id').val(selected.id);
|
|
|
|
$('#field-tm_user_name').val(selected.tm_user_name);
|
|
$('#field-tm_user_id').val(selected.tm_user_id);
|
|
$('#field-edu_dr_contact_exchange').val(selected.tm_user_name);
|
|
$('#field-execution_id').val(selected.execution_id);
|
|
$('#field-plan_date').val(selected.date_added);
|
|
|
|
let ex_date = new Date(selected.date_added)
|
|
console.log(ex_date)
|
|
$('#field-execution_date').val(ex_date.toISOString().split('T')[0]);
|
|
|
|
|
|
$('#form-wrapper').show()
|
|
$('#table-wrapper').hide()
|
|
})
|
|
|
|
$('#field-total_value').prop('readOnly',true);
|
|
$('#field-budecort,#field-duolin,#field-levolin,#field-hyperneb').on('input',function(){
|
|
let a=parseInt($('#field-budecort').val()) * 17.3 ||0;
|
|
let b=parseInt($('#field-duolin').val()) * 11.9 ||0;
|
|
let c=parseInt($('#field-levolin').val()) * 4.6 ||0;
|
|
let d=parseInt($('#field-hyperneb').val()) * 14 ||0;
|
|
let f=a+b+c+d;
|
|
$("#field-total_value").val( parseInt(f*100)/100 );
|
|
})
|
|
|
|
$('#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");
|
|
$('#form-wrapper').hide()
|
|
$('#table-wrapper').show()
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: data.hasOwnProperty('message') && data.message!='' ? data.message : '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> |