982 lines
57 KiB
PHP
982 lines
57 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="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> -->
|
|
<button type="button" class="btn btn-primary btn-xs" id="add-camp-btn">Add
|
|
Plan</button>
|
|
@else
|
|
<a href="{{ url()->previous() }}" class="float-end pt-1">Back</a>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
|
|
@php
|
|
$submissions = [];
|
|
if (isset($form->manager_can_submit) && $form->manager_can_submit == true && isset($form->users) && count($form->users) > 0) {
|
|
foreach ($form->users as $option) {
|
|
$history = Formhelper::getMultiformData($form->partition, $form->form_id, $option->value);
|
|
if (isset($history->data->submissions) && is_array($history->data->submissions)) {
|
|
$submissions = array_merge($submissions, $history->data->submissions);
|
|
}
|
|
}
|
|
} else {
|
|
$history = Formhelper::getMultiformData($form->partition, $form->form_id, $form->user_id);
|
|
$submissions = $history->data->submissions ?? [];
|
|
}
|
|
@endphp
|
|
|
|
<!-- test -->
|
|
|
|
<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-striped table-hover table-nowrap table-centered m-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Action</th>
|
|
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
|
<th>User</th>
|
|
@endif
|
|
<th>Execution Done</th>
|
|
<th>Plan Date</th>
|
|
{{-- <th>Team Name</th> --}}
|
|
<th>Type of meeting</th>
|
|
<th>Execution Date</th>
|
|
<th>Name of speaker</th>
|
|
<th>MSL Code</th>
|
|
<th>Speciality</th>
|
|
<th>No. of Doctors/Paramedics attended</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($submissions as $sub)
|
|
@php
|
|
$sub->formdata->id = $sub->id;
|
|
if (isset($sub->user_info->id)) {
|
|
$sub->formdata->user_id = $sub->user_info->id;
|
|
}
|
|
if (isset($sub->hierarchy_id) && $sub->hierarchy_id != '') {
|
|
$sub->formdata->hierarchy_id = $sub->hierarchy_id;
|
|
} elseif (isset($form->users) && isset($sub->formdata->user_id)) {
|
|
foreach ($form->users as $option) {
|
|
if ($option->value == $sub->formdata->user_id && isset($option->hierarchy_id)) {
|
|
$sub->formdata->hierarchy_id = $option->hierarchy_id;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
@endphp
|
|
<tr>
|
|
<td>
|
|
|
|
@if($sub->workflow_status=='approved' || isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'Yes' )
|
|
<button type="button" class="btn btn-xs btn-info edit-btn"
|
|
plan_details="{{ json_encode($sub->formdata) }}"><i
|
|
class="mdi mdi-pencil"></i> Execute</button>
|
|
<button type="button" class="btn btn-danger btn-xs delete-btn" data-form-id="{{ $sub->formdata->form_id }}" data-id="{{ $sub->id }}">Delete</button>
|
|
|
|
|
|
|
|
@elseif($sub->workflow_status=='rejected')
|
|
<button type="button" class="btn btn-xs btn-info edit-plan-btn"
|
|
plan_details="{{ json_encode($sub->formdata) }}"><i
|
|
class="mdi mdi-pencil"></i> Edit Plan</button>
|
|
<button type="button" class="btn btn-danger btn-xs delete-btn" data-form-id="{{ $sub->formdata->form_id }}" data-id="{{ $sub->id }}">Delete</button>
|
|
|
|
@else
|
|
<button type="button" class="btn btn-danger btn-xs delete-btn" data-form-id="{{ $sub->formdata->form_id }}" data-id="{{ $sub->id }}">Delete</button>
|
|
|
|
|
|
@endif
|
|
<!-- <button type="button"
|
|
class="btn btn-xs btn-info edit-btn"
|
|
plan_details="{{ json_encode($sub->formdata) }}"><i
|
|
class="mdi mdi-pencil"></i> Execute</button>
|
|
<button type="button" class="btn btn-danger btn-xs delete-btn" data-form-id="{{ $sub->formdata->form_id }}" data-id="{{ $sub->id }}">Delete</button> -->
|
|
</td>
|
|
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
|
<td>{{ $sub->user_info->name ?? '' }}</td>
|
|
@endif
|
|
<td>{{ isset($sub->formdata->record_date) && $sub->formdata->record_date > 0 ? 'Yes' : 'No' }}
|
|
</td>
|
|
<td>{{ $sub->formdata->plan_date }}</td>
|
|
{{-- <td>{{ $sub->formdata->team_name }}</td> --}}
|
|
<td>{{ $sub->formdata->type_of_meeting }}</td>
|
|
<td>{{ $sub->formdata->record_date }}</td>
|
|
<!-- <td>{{$sub->formdata->name_of_the_speaker}}</td> -->
|
|
|
|
<!-- <td>{{ $sub->formdata->name_of_the_speaker ?? '' }}</td> -->
|
|
<td>
|
|
@if (isset($sub->formdata->name_of_the_speaker) && $sub->formdata->name_of_the_speaker !== '')
|
|
{{ $sub->formdata->name_of_the_speaker }}
|
|
@elseif (isset($sub->formdata->doctor_name))
|
|
{{ $sub->formdata->doctor_name }}
|
|
@else
|
|
{{ '' }}
|
|
@endif
|
|
</td>
|
|
<td>{{ $sub->formdata->msl_code }}</td>
|
|
<td>{{ $sub->formdata->speciality }}</td>
|
|
<td>{{ $sub->formdata->attendence }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="form-wrapper">
|
|
<form method="POST" action="/form/submit" id="report-form">
|
|
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
|
@csrf
|
|
@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, ['record_date', 'attendence','honorarium_amount','other_expenses','total_eas','no_of_patients_on_duolin','no_of_units_duolin_respules']))
|
|
@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>
|
|
@if ($question->code == 'name_of_the_speaker')
|
|
@foreach ($question->options as $option)
|
|
@if( isset($option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors) && $option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors == 'Yes' )
|
|
<option value="{{ $option->value }}" speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" msl_code="{{isset($option->contact->msl_code)?$option->contact->msl_code:''}}"
|
|
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
|
{{ $option->display }}
|
|
</option>
|
|
@endif
|
|
@endforeach
|
|
<option value="other" speciality="" msl_code="">Other</option>
|
|
|
|
@elseif ($question->code == 'other_speaker_name')
|
|
@foreach ($question->options as $option)
|
|
@if(!isset($option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors) ||
|
|
$option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors === null
|
|
)
|
|
<option value="{{ $option->value }}" speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" msl_code="{{isset($option->contact->msl_code)?$option->contact->msl_code:''}}"
|
|
|
|
{{ 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
|
|
|
|
@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
|
|
@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">
|
|
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
|
@csrf
|
|
<input type="hidden" name="id" value="" id="execution-id">
|
|
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
|
<input type="hidden" name="user_id" value="" id="execution-user_id">
|
|
<input type="hidden" name="hierarchy_id" value="" id="execution-hierarchy_id">
|
|
@endif
|
|
@foreach ($questions as $question)
|
|
<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>
|
|
@if ($question->code == 'name_of_the_speaker')
|
|
@foreach ($question->options as $option)
|
|
@if( isset($option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors) && $option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors == 'Yes' )
|
|
<option value="{{ $option->value }}" speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" msl_code="{{isset($option->contact->msl_code)?$option->contact->msl_code:''}}"
|
|
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
|
{{ $option->display }}
|
|
</option>
|
|
@endif
|
|
@endforeach
|
|
<option value="other" speciality="" msl_code="">Other</option>
|
|
|
|
@elseif ($question->code == 'other_speaker_name')
|
|
@foreach ($question->options as $option)
|
|
@if(!isset($option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors) ||
|
|
$option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors === null
|
|
)
|
|
<option value="{{ $option->value }}" speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" msl_code="{{isset($option->contact->msl_code)?$option->contact->msl_code:''}}"
|
|
|
|
{{ 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
|
|
|
|
@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>
|
|
$(document).on('click', '.delete-btn', function() {
|
|
var btn = $(this);
|
|
var formId = btn.data('form-id');
|
|
var id = btn.data('id');
|
|
Swal.fire({
|
|
title: 'Are you sure?',
|
|
text: "You want to delete this submission? This is not recoverable!",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#d33',
|
|
cancelButtonColor: '#3085d6',
|
|
confirmButtonText: 'Yes, delete it!'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$("#pageloader").fadeIn();
|
|
$.ajax({
|
|
url: '/form/delete',
|
|
type: 'GET',
|
|
data: {
|
|
form_id: formId,
|
|
id: id
|
|
},
|
|
success: function(response) {
|
|
$("#pageloader").fadeOut();
|
|
Swal.fire('Deleted!', 'Submission has been deleted.', 'success').then(() => {
|
|
location.reload();
|
|
});
|
|
},
|
|
error: function() {
|
|
$("#pageloader").fadeOut();
|
|
Swal.fire('Error', 'Failed to delete submission.', 'error');
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
const slugify = str =>
|
|
str
|
|
.toLowerCase()
|
|
.trim()
|
|
.replace(/[^\w\s-]/g, '')
|
|
.replace(/[\s_-]+/g, '-')
|
|
.replace(/^-+|-+$/g, '');
|
|
|
|
function fillSpeakerDropdown($select, data, includeOther) {
|
|
$select.html('');
|
|
$select.append($("<option></option>").attr("value", '').text('-- Select --'));
|
|
for (let itm of data) {
|
|
const activities = itm?.contact?.doctor_activities_for_neb_2_top_30_next_30_doctors;
|
|
if (typeof activities !== 'undefined' && activities !== null && activities !== 'Yes') continue;
|
|
$select.append(
|
|
$("<option></option>")
|
|
.attr("value", itm.value)
|
|
.text(itm.display)
|
|
.attr("msl_code", itm?.contact?.msl_code ?? '')
|
|
.attr('speciality', itm?.contact?.speciality ?? '')
|
|
);
|
|
}
|
|
if (includeOther) {
|
|
$select.append(
|
|
$("<option></option>")
|
|
.attr("value", 'other')
|
|
.text('Other')
|
|
.attr("msl_code", '')
|
|
.attr('speciality', '')
|
|
);
|
|
}
|
|
}
|
|
|
|
function fillOtherSpeakerDropdown($select, data) {
|
|
$select.html('');
|
|
$select.append($("<option></option>").attr("value", '').text('-- Select --'));
|
|
for (let itm of data) {
|
|
const activities = itm?.contact?.doctor_activities_for_neb_2_top_30_next_30_doctors;
|
|
if (typeof activities !== 'undefined' && activities !== null) continue;
|
|
$select.append(
|
|
$("<option></option>")
|
|
.attr("value", itm.value)
|
|
.text(itm.display)
|
|
.attr("msl_code", itm?.contact?.msl_code ?? '')
|
|
.attr('speciality', itm?.contact?.speciality ?? '')
|
|
);
|
|
}
|
|
}
|
|
|
|
function applySpeakerValue($select, savedValue) {
|
|
if (!savedValue) return;
|
|
$select.val(savedValue);
|
|
if ($select.val() !== savedValue) {
|
|
let match = $select.find('option').filter(function() {
|
|
return $(this).text().trim() == String(savedValue).trim();
|
|
}).attr('value');
|
|
if (match) {
|
|
$select.val(match);
|
|
}
|
|
}
|
|
$select.trigger('change');
|
|
}
|
|
|
|
$('#form-wrapper').hide()
|
|
$('#execution-form-wrapper').hide()
|
|
|
|
$('#add-camp-btn').click(function() {
|
|
$('#form-wrapper').show()
|
|
$('#table-wrapper').hide()
|
|
$('#execution-form-wrapper').hide()
|
|
})
|
|
|
|
|
|
$('#field-msl_code,#field-speciality,#field-other_msl_code,#field-other_speciality').attr('readonly',true);
|
|
|
|
$('#field-name_of_the_speaker').change(function() {
|
|
let value=$(this).val();
|
|
if(value==='other'){
|
|
$('#field-other_msl_code,#field-other_speciality,#field-other_speaker_name').parent().show();
|
|
$('#field-other_msl_code,#field-other_speciality,#field-other_speaker_name').attr('required',true);
|
|
|
|
$('#field-msl_code,#field-speciality').parent().hide();
|
|
$('#field-msl_code,#field-speciality').attr('required',false);
|
|
}
|
|
else{
|
|
$('#field-other_msl_code,#field-other_speciality,#field-other_speaker_name').parent().hide();
|
|
$('#field-other_msl_code,#field-other_speciality,#field-other_speaker_name').attr('required',false);
|
|
$('#field-msl_code,#field-speciality').parent().show();
|
|
$('#field-msl_code,#field-speciality').attr('required',true);
|
|
}
|
|
})
|
|
|
|
$('#field-other_msl_code,#field-other_speciality,#field-other_speaker_name,#field-other_type_of_meeting').parent().hide();
|
|
$('#field-other_msl_code,#field-other_speciality,#field-other_speaker_name,#field-other_type_of_meeting').attr('required',false);
|
|
|
|
$('#field-name_of_the_speaker').change(function() {
|
|
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
|
})
|
|
|
|
$('#field-name_of_the_speaker').change(function() {
|
|
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
|
})
|
|
|
|
$('#field-other_speaker_name').change(function() {
|
|
$('#field-other_msl_code').val($('option:selected', this).attr('msl_code'))
|
|
})
|
|
|
|
$('#field-other_speaker_name').change(function() {
|
|
$('#field-other_speciality').val($('option:selected', this).attr('speciality'))
|
|
})
|
|
|
|
|
|
$('#field-type_of_meeting').on('change',function(){
|
|
let type_of_meet=$('#field-type_of_meeting').val();
|
|
console.log("Type of Meet",type_of_meet);
|
|
|
|
if(type_of_meet==='Other'){
|
|
$('#field-other_type_of_meeting').parent().show();
|
|
$('#field-other_type_of_meeting').attr('required',true);
|
|
|
|
}
|
|
else{
|
|
$('#field-other_type_of_meeting').parent().hide();
|
|
$('#field-other_type_of_meeting').attr('required',false);
|
|
|
|
}
|
|
})
|
|
|
|
|
|
|
|
$('.edit-btn').click(function() {
|
|
let selected = JSON.parse($(this).attr('plan_details'))
|
|
let hierarchy = selected['hierarchy_id'] || '';
|
|
if (!hierarchy && selected['user_id']) {
|
|
hierarchy = $('#field-user_id option[value="' + selected['user_id'] + '"]').attr('hierarchy') || '';
|
|
}
|
|
|
|
for (let k of Object.keys(selected)) {
|
|
if (selected[k] != '') {
|
|
if (k == 'name_of_the_speaker' || k == 'other_speaker_name') {
|
|
continue;
|
|
} else {
|
|
$('#execution-' + k).val(selected[k]);
|
|
}
|
|
}
|
|
}
|
|
|
|
$('#execution-id').val(selected['id'])
|
|
if (selected['user_id'] && $('#execution-user_id').length) {
|
|
$('#execution-user_id').val(selected['user_id'])
|
|
}
|
|
if ($('#execution-hierarchy_id').length) {
|
|
$('#execution-hierarchy_id').val(hierarchy)
|
|
}
|
|
|
|
|
|
|
|
$('#execution-id').val(selected['id'])
|
|
$('#form-wrapper').hide()
|
|
$('#execution-form-wrapper').show()
|
|
$('#table-wrapper').hide()
|
|
$('#execution-no_of_patients_on_duolin').attr('max',10);
|
|
|
|
function setExecutionSpeakers(data) {
|
|
fillSpeakerDropdown($('#execution-name_of_the_speaker'), data, true);
|
|
if ($('#execution-other_speaker_name').length) {
|
|
fillOtherSpeakerDropdown($('#execution-other_speaker_name'), data);
|
|
}
|
|
applySpeakerValue($('#execution-name_of_the_speaker'), selected['name_of_the_speaker']);
|
|
applySpeakerValue($('#execution-other_speaker_name'), selected['other_speaker_name']);
|
|
}
|
|
|
|
if (hierarchy) {
|
|
$("#pageloader").fadeIn();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(data) {
|
|
$("#pageloader").fadeOut();
|
|
setExecutionSpeakers(data);
|
|
},
|
|
error: function() {
|
|
$("#pageloader").fadeOut();
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#execution-other_type_of_meeting').parent().hide();
|
|
$('#execution-other_type_of_meeting').attr('required',false);
|
|
|
|
$('#execution-type_of_meeting').on('change',function(){
|
|
let type_of_meet=$('#execution-type_of_meeting').val();
|
|
console.log("Type of Meet",type_of_meet);
|
|
|
|
if(type_of_meet==='GNP Camp'){
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().show();
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',true);
|
|
$('label[for="execution-name_of_the_speaker"]').html('Name of the Speaker (Pedia or GP only) ');
|
|
$('#execution-other_type_of_meeting').parent().hide();
|
|
$('#execution-other_type_of_meeting').attr('required',false);
|
|
}
|
|
|
|
else if(type_of_meet==='Other'){
|
|
$('#execution-other_type_of_meeting').parent().show();
|
|
$('#execution-other_type_of_meeting').attr('required',true);
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
|
$('label[for="execution-name_of_the_speaker"]').html('Name of the speaker');
|
|
$('#execution-other_type_of_meeting').parent().hide();
|
|
$('#execution-other_type_of_meeting').attr('required',false);
|
|
}
|
|
})
|
|
|
|
$('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').parent().hide();
|
|
$('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').attr('required',false);
|
|
|
|
|
|
let type_of_meet=$('#execution-type_of_meeting').val();
|
|
console.log("Type of Meet without change",type_of_meet);
|
|
|
|
if(type_of_meet==='GNP Camp'){
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().show();
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',true);
|
|
$('label[for="execution-name_of_the_speaker"]').html('Name of the Speaker (Pedia or GP only) ');
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
|
$('label[for="execution-name_of_the_speaker"]').html('Name of the speaker');
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
$('.edit-plan-btn').click(function() {
|
|
let selected = JSON.parse($(this).attr('plan_details'))
|
|
let hierarchy = selected['hierarchy_id'] || '';
|
|
if (!hierarchy && selected['user_id']) {
|
|
hierarchy = $('#field-user_id option[value="' + selected['user_id'] + '"]').attr('hierarchy') || '';
|
|
}
|
|
|
|
for (let k of Object.keys(selected)) {
|
|
if (selected[k] != '') {
|
|
if (k == 'name_of_the_speaker' || k == 'other_speaker_name') {
|
|
continue;
|
|
} else {
|
|
$('#execution-' + k).val(selected[k]);
|
|
}
|
|
}
|
|
}
|
|
|
|
$('#execution-id').val(selected['id'])
|
|
if (selected['user_id'] && $('#execution-user_id').length) {
|
|
$('#execution-user_id').val(selected['user_id'])
|
|
}
|
|
if ($('#execution-hierarchy_id').length) {
|
|
$('#execution-hierarchy_id').val(hierarchy)
|
|
}
|
|
|
|
|
|
|
|
$('#execution-id').val(selected['id'])
|
|
$('#form-wrapper').hide()
|
|
$('#execution-form-wrapper').show()
|
|
$('#table-wrapper').hide()
|
|
$('#execution-no_of_patients_on_duolin').attr('max',10);
|
|
|
|
function setExecutionSpeakers(data) {
|
|
fillSpeakerDropdown($('#execution-name_of_the_speaker'), data, true);
|
|
if ($('#execution-other_speaker_name').length) {
|
|
fillOtherSpeakerDropdown($('#execution-other_speaker_name'), data);
|
|
}
|
|
applySpeakerValue($('#execution-name_of_the_speaker'), selected['name_of_the_speaker']);
|
|
applySpeakerValue($('#execution-other_speaker_name'), selected['other_speaker_name']);
|
|
}
|
|
|
|
if (hierarchy) {
|
|
$("#pageloader").fadeIn();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(data) {
|
|
$("#pageloader").fadeOut();
|
|
setExecutionSpeakers(data);
|
|
},
|
|
error: function() {
|
|
$("#pageloader").fadeOut();
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#execution-other_type_of_meeting').parent().hide();
|
|
$('#execution-other_type_of_meeting').attr('required',false);
|
|
|
|
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
|
$('#execution-record_date,#execution-attendence,#execution-honorarium_amount,#execution-other_expenses,#execution-total_eas').parent().hide();
|
|
$('#execution-record_date,#execution-attendence,#execution-honorarium_amount,#execution-other_expenses,#execution-total_eas').attr('required',false);
|
|
|
|
|
|
$('#execution-type_of_meeting').on('change',function(){
|
|
let type_of_meet=$('#execution-type_of_meeting').val();
|
|
console.log("Type of Meet",type_of_meet);
|
|
|
|
if(type_of_meet==='GNP Camp'){
|
|
/*$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().show();
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',true);
|
|
$('label[for="execution-name_of_the_speaker"]').html('Name of the Speaker (Pedia or GP only) ');
|
|
$('#execution-other_type_of_meeting').parent().hide();
|
|
$('#execution-other_type_of_meeting').attr('required',false);*/
|
|
}
|
|
|
|
else if(type_of_meet==='Other'){
|
|
$('#execution-other_type_of_meeting').parent().show();
|
|
$('#execution-other_type_of_meeting').attr('required',true);
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
|
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
|
$('label[for="execution-name_of_the_speaker"]').html('Name of the speaker');
|
|
$('#execution-other_type_of_meeting').parent().hide();
|
|
$('#execution-other_type_of_meeting').attr('required',false);
|
|
}
|
|
})
|
|
|
|
$('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').parent().hide();
|
|
$('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').attr('required',false);
|
|
|
|
|
|
let type_of_meet=$('#execution-type_of_meeting').val();
|
|
console.log("Type of Meet without change",type_of_meet);
|
|
|
|
$('#execution-name_of_the_speaker').change(function() {
|
|
$('#execution-msl_code').val($('option:selected', this).attr('msl_code'))
|
|
})
|
|
|
|
$('#execution-name_of_the_speaker').change(function() {
|
|
$('#execution-speciality').val($('option:selected', this).attr('speciality'))
|
|
})
|
|
|
|
$('#execution-other_speaker_name').change(function() {
|
|
$('#execution-other_msl_code').val($('option:selected', this).attr('msl_code'))
|
|
})
|
|
|
|
$('#execution-other_speaker_name').change(function() {
|
|
$('#execution-other_speciality').val($('option:selected', this).attr('speciality'))
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$('#execution-msl_code,#execution-speciality,#execution-other_msl_code,#execution-other_speciality').attr('readonly',true);
|
|
|
|
$('#execution-name_of_the_speaker').change(function() {
|
|
let value=$(this).val();
|
|
if(value==='other'){
|
|
$('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').parent().show();
|
|
$('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').attr('required',true);
|
|
|
|
$('#execution-msl_code,#execution-speciality').parent().hide();
|
|
$('#execution-msl_code,#execution-speciality').attr('required',false);
|
|
}
|
|
else{
|
|
$('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').parent().hide();
|
|
$('#execution-other_msl_code,#execution-other_speciality,#execution-other_speaker_name').attr('required',false);
|
|
$('#execution-msl_code,#execution-speciality').parent().show();
|
|
$('#execution-msl_code,#execution-speciality').attr('required',true);
|
|
}
|
|
})
|
|
|
|
jQuery(document).ready(function($) {
|
|
$('#field-user_id').change(function(){
|
|
let hierarchy = $('option:selected', this).attr('hierarchy');
|
|
$('#field-hierarchy_id').val(hierarchy)
|
|
event.preventDefault();
|
|
$("#pageloader").fadeIn();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
|
processData: false,
|
|
contentType: false,
|
|
success: function( data ) {
|
|
$("#pageloader").fadeOut();
|
|
fillSpeakerDropdown($('#field-name_of_the_speaker'), data, true);
|
|
if ($('#field-other_speaker_name').length) {
|
|
fillOtherSpeakerDropdown($('#field-other_speaker_name'), data);
|
|
}
|
|
},
|
|
});
|
|
|
|
console.log(hierarchy)
|
|
})
|
|
|
|
|
|
|
|
|
|
$('#report-form').on('submit', function(event) {
|
|
event.preventDefault();
|
|
$("#pageloader").fadeIn();
|
|
//$('#report-form').append('<input type="hidden" name="' + slugify($('#field-type_of_meeting').val()) + '" value="1">')
|
|
|
|
$.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();
|
|
} 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();
|
|
$('#execution-form').append('<input type="hidden" name="' + slugify($('#execution-type_of_meeting').val()) + '" value="1">')
|
|
$.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('max', today);
|
|
});
|
|
|
|
/* executionDateField.addEventListener('change', function() {
|
|
console.log('gg');
|
|
var executionexeField = document.getElementById('execution-record_date');
|
|
executionexeField.setAttribute('min', executionDateField.value);
|
|
});
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|