Rapport-Laravel/resources/views/form/rapport-team4/1724835609-b6bf631f-3458-4d...

778 lines
47 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" />
<link href="{{asset('assets/libs/flatpickr/flatpickr.min.css')}}" rel="stylesheet" type="text/css" />
<style>
.search-container {
position: relative;
}
.search-container i {
position: absolute;
right: 20px;
top: 8px;
font-size: 18px;
}
.form-group .form-control {
font-size: 16px;
}
.form-group .form-control:focus {
border-color: var(--bs-primary);
}
.quick-action-form-card .form-control:disabled,
.quick-action-form-card .form-control[readonly] {
background-color: var(--bs-light);
}
.quick-action-form-card .form-control.flatpickr-input[readonly] {
background-color: #fff;
}
.table-theme.table > :not(caption) > * > * {
padding: 0.65rem;
}
#table-wrapper { margin-top: 1rem;}
#table-wrapper #custom-datatable_filter { text-align: right !important; }
#table-wrapper table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td:first-child:before,
#table-wrapper table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th:first-child:before{
top: 50%;
}
#table-wrapper table.dataTable > tbody > tr.child ul.dtr-details {
width: 100%;
}
.quick-action-form-card #add-camp-btn i {
font-size: 18px;
line-height: 1.2;
vertical-align: middle;
}
.btn.edit-icon-btn {
background-color: transparent;
border: 0px solid;
color: var(--bs-secondary);
padding: 0;
line-height: 1.1;
}
.btn.edit-icon-btn.edit-execution-btn {
color: var(--bs-success);
}
.btn.edit-icon-btn > i { font-size: 1.5rem;}
/* #table-wrapper .dataTables_wrapper .row > .col-sm-12 { width: 50%; max-width: 50%;} */
</style>
</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 quick-action-form-card">
<div class="card-body p-3 pt-2 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">Activation Plan</h4>
</div>
@if (!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval !=
'yes'))
<div class="col-4 text-end">
@if ($form->link_type == 'form')
<!-- <a href="/form/history" class="float-end pt-1">View History</a> -->
<button type="button" class="btn btn-primary btn-sm" id="add-camp-btn"><i class="mdi mdi-plus"></i> Add
Plan</button>
<button type="button" class="btn btn-secondary btn-sm" id="go-back-btn">Back
</button>
@else
<a href="{{ url()->previous() }}" class="float-end pt-1">Back</a>
@endif
</div>
<!-- <div class="mb-2 search-container form-group">
<input type="text" id="search" class="form-control">
<i class="mdi mdi-magnify"></i>
</div> -->
@endif
@php
$history = Formhelper::getMultiformData($form->partition, $form->form_id, $form->user_id);
$planfields = ['camp_type','number_of_patient_screened' ,'patients_diagnosed_with_ar','rxn_of_montair_lc_adult','rxn_of_montair_lc_kid_tab','rxn_of_montair_lc_kid_syrup','rxn_of_furamist','rn_of_furamist_az','execution_date'];
@endphp
<div class="col-12" id="table-wrapper" class="custom-table-wrapper">
<!-- <div class="table-responsive"> dt-responsive -->
<table id="custom-datatable" class="table table-theme nowrap w-100">
<thead class="table-light">
<tr>
<th>#</th>
<th>Camp Date</th>
<!-- <th>Execution Done</th> -->
<th>Doctor Name</th>
<th>Camp Time</th>
<th>TM Name</th>
<th>OPD Timing</th>
<th>Camp Execution Date</th>
<th>Speciality</th>
<th>Legacy Code</th>
<th>Camp Type</th>
<th>Number of Patient Screened</th>
<th>Patients Diagnosed with AR</th>
<th>Rxn of Montair LC Adult</th>
<th>Rxn of Montair LC Kid Tab</th>
<th>Rxn of Montair LC Kid Syrup</th>
<th>Rxn of Furamist</th>
<th>Rn of Furamist AZ</th>
<th>No of Strips left with FSO</th>
</tr>
</thead>
<tbody>
@foreach ($history->data->submissions as $sub)
@php
$sub->formdata->id = $sub->id;
@endphp
<tr
class="{{(isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'yes') ? 'bg-soft-success' : ''}}"
>
<td>
@if (isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'yes')
<button type="button" class="btn btn-xs btn-primary edit-btn edit-icon-btn rounded-pill"
plan_details="{{ json_encode($sub->formdata) }}">
<i class="mdi mdi-pencil-circle"></i>
</button>
<!-- <i class="mdi mdi-check-circle" style="color:var(--bs-success); font-size: 20px;"></i> -->
<!-- <button type="button" class="btn btn-xs btn-primary edit-btn"
plan_details="{{ json_encode($sub->formdata) }}">Edit</button> -->
@else
<button type="button" class="btn btn-xs btn-primary edit-btn edit-icon-btn edit-execution-btn rounded-pill"
plan_details="{{ json_encode($sub->formdata) }}"><i class="mdi mdi-plus-circle"></i>
<!-- Edit -->
</button>
@endif
</td>
<td>{{ $sub->formdata->plan_date }}</td>
<!-- <td>{{ isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'yes' ? 'Yes' : 'No' }}
</td> -->
<td>{{isset($sub->formdata->name_of_doctor) ? $sub->formdata->name_of_doctor : '' }}
</td>
<td>{{isset($sub->formdata->camp_time) ? $sub->formdata->camp_time : '' }}
</td>
<td>{{isset($sub->user_info->name) ? $sub->user_info->name : '' }}
</td>
<td>{{isset($sub->formdata->opd_timing) ? $sub->formdata->opd_timing: ''}}
</td>
<td>{{$sub->formdata->execution_date}}</td>
<td>{{isset($sub->formdata->speciality ) ? $sub->formdata->speciality : ''}}
</td>
<td>{{isset($sub->formdata->legacy_code) ? $sub->formdata->legacy_code : '' }}
</td>
<td>{{isset($sub->formdata->camp_type) ? $sub->formdata->camp_type: ''}}</td>
<td>{{isset($sub->formdata->number_of_patient_screened) ? $sub->formdata->number_of_patient_screened: ''}}</td>
<td>{{isset($sub->formdata->patients_diagnosed_with_ar) ? $sub->formdata->patients_diagnosed_with_ar: ''}}</td>
<td>{{isset($sub->formdata->rxn_of_montair_lc_adult) ? $sub->formdata->rxn_of_montair_lc_adult: ''}}</td>
<td>{{isset($sub->formdata->rxn_of_montair_lc_kid_tab) ? $sub->formdata->rxn_of_montair_lc_kid_tab: ''}}</td>
<td>{{isset($sub->formdata->rxn_of_montair_lc_kid_syrup) ? $sub->formdata->rxn_of_montair_lc_kid_syrup: ''}}</td>
<td>{{isset($sub->formdata->rxn_of_furamist) ? $sub->formdata->rxn_of_furamist: ''}}</td>
<td>{{isset($sub->formdata->rn_of_furamist_az) ? $sub->formdata->rn_of_furamist_az: ''}}</td>
<td>{{isset($sub->formdata->rn_of_furamist_az) ? $sub->formdata->rn_of_furamist_az: ''}}</td>
</tr>
@endforeach
</tbody>
</table>
<!-- </div> -->
</div>
<div id="form-wrapper">
<form method="POST" action="/form/submit" id="report-form"
enctype="multipart/form-data" class="parsley-examples">
<input type="hidden" name="form_id" value="{{ $form_id }}">
@csrf
@if ($id)
<input type="hidden" name="id" value="{{ $id }}">
@endif
@foreach ($questions as $question)
@if (in_array($question->code, $planfields))
@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)
@if ($question->code == 'contact_id')
@if (!isset($option->contact->type) || $option->contact->type != 'Chemist')
<option value="{{ $option->value }}"
speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}"
legacy_code="{{isset($option->contact->legacy_code)?$option->contact->legacy_code:''}}"
name="{{isset($option->contact->name)?$option->contact->name:''}}"
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
{{ $option->display }}
</option>
@endif
@else
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
@endif
@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 id="execution-form-wrapper">
<form method="POST" action="/form/submit" id="execution-form"
enctype="multipart/form-data" class="parsley-examples">
<input type="hidden" name="form_id" value="{{ $form_id }}">
@csrf
<input type="hidden" name="id" value="" id="execution-id">
<input type="hidden" name="execution_done" value="yes">
<div id="accordion" class="mb-3 custom-accordion-outer">
<div class="card mb-1">
<div class="card-header" id="heading-planned">
<h5 class="m-0">
<a class="text-dar" data-bs-toggle="collapse" href="#collapse-planned" aria-expanded="true">
Plan Details <i class="mdi mdi-chevron-down accordion-arrow"></i>
</a>
</h5>
</div>
<div id="collapse-planned" class="collapse" aria-labelledby="heading-planned" data-bs-parent="#accordion">
<div class="card-body pt-1">
<div class="accordion custom-accordion custom-accordion-inner" id="custom-accordion-planned">
<div class="row">
@foreach ($questions as $question)
@if(!in_array($question->code, $planfields))
<div class="col-md-12 mb-2">
<label for="execution-{{ $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="execution-{{ $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="execution-{{ $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="execution-{{ $question->code }}" name="{{ $question->code }}"
class="form-control" {{ $question->required == 'yes' ? 'required' : '' }}
value="{{ isset($question->value) ? $question->value : 0 }}">
@break
@case('textarea')
<textarea id="execution-{{ $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="execution-{{ $question->code }}"
name="{{ $question->code }}"
{{ $question->required == 'yes' ? 'required' : '' }}>
<option value=""> -- Select -- </option>
@foreach ($question->options as $option)
@if ($question->code == 'contact_id')
@if (!isset($option->contact->type) || $option->contact->type != 'Chemist')
<option value="{{ $option->value }}"
speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}"
legacy_code="{{isset($option->contact->legacy_code)?$option->contact->legacy_code:''}}"
name="{{isset($option->contact->name)?$option->contact->name:''}}"
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
{{ $option->display }}
</option>
@endif
@else
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
@endif
@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="execution-{{ $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="execution-{{ $question->code }}-{{ $option->value }}">{{ $option->display }}</label>
</div>
@endforeach
@break
@case('file')
<input type="file" id="execution-{{ $question->code }}"
name="{{ $question->code }}" class="form-control" value=""
accept="image/jpg, image/jpeg, image/png">
@break
@endswitch
</div>
@endif
@endforeach
</div>
</div>
</div>
</div>
</div>
</div>
@foreach ($questions as $question)
@if(!in_array($question->code, $planfields))
@continue
@endif
<div class="col-md-12 mb-2">
<label for="execution-{{ $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="execution-{{ $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="execution-{{ $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="execution-{{ $question->code }}" name="{{ $question->code }}"
class="form-control" {{ $question->required == 'yes' ? 'required' : '' }}
value="{{ isset($question->value) ? $question->value : 0 }}">
@break
@case('textarea')
<textarea id="execution-{{ $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="execution-{{ $question->code }}"
name="{{ $question->code }}"
{{ $question->required == 'yes' ? 'required' : '' }}>
<option value=""> -- Select -- </option>
@foreach ($question->options as $option)
@if ($question->code == 'contact_id')
@if (!isset($option->contact->type) || $option->contact->type != 'Chemist')
<option value="{{ $option->value }}"
speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}"
legacy_code="{{isset($option->contact->legacy_code)?$option->contact->legacy_code:''}}"
name="{{isset($option->contact->name)?$option->contact->name:''}}"
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
{{ $option->display }}
</option>
@endif
@else
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
@endif
@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="execution-{{ $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="execution-{{ $question->code }}-{{ $option->value }}">{{ $option->display }}</label>
</div>
@endforeach
@break
@case('file')
<input type="file" id="execution-{{ $question->code }}"
name="{{ $question->code }}" class="form-control" value=""
accept="image/jpg, image/jpeg, image/png">
@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 src="{{asset('assets/libs/parsleyjs/parsleyjs.min.js')}}"></script>
<script src="{{asset('assets/libs/flatpickr/flatpickr.min.js')}}"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
//data tables search alignment
// $('##custom-datatable_filter').css({'textAlign', 'right'});
$('#form-wrapper').hide()
$('#execution-form-wrapper').hide()
$('#go-back-btn').hide();
//call validation
$('.parsley-examples').parsley();
//Add Other option to doctor list (contact_id)
$('#field-contact_id')
.append($("<option></option>")
.attr("value", 'other')
.text("Other"));
//data table call
$('#custom-datatable').DataTable({
"scrollX": true,
"lengthChange": false,
"pageLength": 50,
"language": {
"paginate": {
"previous": "<i class='mdi mdi-chevron-left'>",
"next": "<i class='mdi mdi-chevron-right'>"
}
},
"drawCallback": function () {
$('.dataTables_paginate > .pagination').addClass('pagination-rounded');
}
});
//Time Picker
$('#field-camp_time').flatpickr({
enableTime: true,
noCalendar: true,
dateFormat: "H:i",
defaultDate: "10:30"
});
$('#add-camp-btn').click(function() {
$('#form-wrapper').show()
$('#table-wrapper').hide()
$(this).hide();
$('#go-back-btn').show();
})
$('#go-back-btn').click(function() {
$('#form-wrapper').hide()
$('#table-wrapper').show()
$(this).hide();
$('#add-camp-btn').show();
})
$('.edit-btn').click(function() {
$('#execution-form-wrapper').show()
$('#table-wrapper').hide()
$('#add-camp-btn').hide();
// $('#go-back-btn').show();
//$('#execution-contact_id').prop('disabled', true)
// $('#execution-contact_id').prop('readonly', true)
// $('#execution-activity_type').prop('readonly', true)
// $('#execution-speciality').prop('readonly', true)
// $('#execution-plan_date').prop('readonly', true)
//$('#execution-time').prop('disabled', true)
//Make several fields as read only
$('#execution-contact_id').attr('readonly', true)
$('#execution-name_of_doctor').attr('readonly', true);
$('#execution-speciality').attr('readonly', true);
$('#execution-legacy_code').attr('readonly', true);
$('#execution-plan_date').attr('readonly', true)
$('#execution-camp_time').attr('readonly', true)
$('#execution-opd_timing').attr('readonly', true)
let selected = JSON.parse($(this).attr('plan_details'))
for (let k of Object.keys(selected)) {
if (selected[k] != '') {
if (k == 'contact_id') {
//$("#execution-contact_id option:contains(" + selected[k] + ")").prop('selected', true)
// console.log($("#execution-contact_id option:contains(" + selected[k] + ")").attr('value'))
$('#execution-contact_id').val($("#execution-contact_id option:contains(" +
selected[k] + ")").attr('value'));
} else
$('#execution-' + k).val(selected[k]);
}
// if(selected[k] != '')
// $('#execution-'+k).val(selected[k]);
}
let docid = $('#execution-contact_id option').map(function() {
if ($(this).text().trim() == selected['contact_id']) return this;
}).attr('value')
$('#execution-contact_id').val(docid)
$('#execution-id').val(selected['id'])
if($('#execution-camp_type').val() === "Camp with Sample") {
$("#execution-number_of_patient_screened").parent().find('label').hide();
$('#execution-number_of_patient_screened').hide()
$('#execution-patients_diagnosed_with_ar').parent().find('label').hide()
$('#execution-patients_diagnosed_with_ar').hide()
}
$('#execution-camp_type').on('change', function (e) {
console.log('Value = ', e.target.value)
const selectedVal = e.target.value;
console.log("selectedVal = ",selectedVal)
if(selectedVal !== "") {
if(selectedVal === "Camp with Sample") {
$("#execution-number_of_patient_screened").parent().find('label').hide();
$('#execution-number_of_patient_screened').hide()
$('#execution-patients_diagnosed_with_ar').parent().find('label').hide()
$('#execution-patients_diagnosed_with_ar').hide()
} else {
$('#execution-number_of_patient_screened').show()
$("#execution-number_of_patient_screened").parent().find('label').show();
$('#execution-patients_diagnosed_with_ar').show()
$('#execution-patients_diagnosed_with_ar').parent().find('label').show()
}
}
})
})
$('#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'
})
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!'
})
}
},
});
});
$('#execution-form').on('submit', function(event) {
event.preventDefault();
$("#pageloader").fadeIn();
$.ajax({
type: "POST",
url: '/form/ajaxsubmit',
data: new FormData($('#execution-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!'
})
}
},
});
});
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 recordDateField = document.getElementById('field-plan_date');
recordDateField.setAttribute('min', today);
var executionDateField = document.getElementById('execution-plan_date');
// executionDateField.setAttribute('min', today);
$('.edit-btn').click(function() {
var executionexeField = document.getElementById('execution-record_date');
executionexeField.setAttribute('min', executionDateField.value);
});
executionDateField.addEventListener('change', function() {
console.log('gg');
var executionexeField = document.getElementById('execution-record_date');
executionexeField.setAttribute('min', executionDateField.value);
});
//Contact_id i.e. doctor list on change make some fields readonly
$('#field-contact_id').on('change', function (e) {
const selectedVal = e.target.value;
$('#field-name_of_doctor').val($('option:selected', this).attr('name'))
$('#field-legacy_code').val($('option:selected', this).attr('legacy_code'))
$('#field-speciality').val($('option:selected', this).attr('speciality'))
let legacyCode = $('#field-legacy_code').val();
let speciality = $('#field-speciality').val();
if(selectedVal !== "" && selectedVal !== "other") {
$('#field-name_of_doctor').attr('readonly', true);
if (speciality != "") {
$('#field-speciality').attr('readonly', true);
}
if (legacyCode != "") {
$('#field-legacy_code').attr('readonly', true);
}
}
})
});
</script>
</body>
</html>