264 lines
13 KiB
PHP
264 lines
13 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-12">
|
|
<h4 class="page-title">{{ $form->title }}</h4>
|
|
</div>
|
|
@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
|
|
|
|
@php
|
|
$history2 = Formhelper::getMultiformData($form->partition, $form_id, $form->user_id);
|
|
$submissions2 = $history2->data->submissions;
|
|
$existing_submissions = [];
|
|
$existing_submission_ids = [];
|
|
|
|
foreach ($submissions2 as $entries) {
|
|
$existing_submissions[$entries->formdata->cont_id] = $entries->formdata->voltido_trio_patient;
|
|
$existing_submission_ids[$entries->formdata->cont_id] = $entries->id;
|
|
}
|
|
|
|
@endphp
|
|
|
|
<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="user_id" value="{{ $form->user_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
|
|
<div class="col-md-12 mb-2">
|
|
<div class="table-responsive sticky-table">
|
|
<table id="doctor_table"
|
|
class="table table-borderless table-hover table-nowrap table-centered m-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Doctor Name </th>
|
|
<th>Voltido Trio-Patient Assistance</th>
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@php
|
|
$doctors = [];
|
|
foreach ($questions as $question) {
|
|
if ($question->code == 'contact_id') {
|
|
$doctors = $question->options;
|
|
}
|
|
}
|
|
@endphp
|
|
|
|
@foreach ($doctors as $i => $doctor)
|
|
<tr>
|
|
<th>
|
|
{{ $doctor->display }}<br />
|
|
<small>MSL Code: {{ $doctor->contact->msl_code ?? '-' }}</small>
|
|
|
|
<input type="hidden" name="contact_id[{{ $doctor->contact->id }}]" value="{{ $doctor->contact->id }}">
|
|
|
|
@if (array_key_exists($doctor->contact->id, $existing_submission_ids))
|
|
<input
|
|
type="hidden"
|
|
name="id[{{ $doctor->contact->id }}]"
|
|
value="{{ $existing_submission_ids[$doctor->contact->id] }}"
|
|
>
|
|
@endif
|
|
</th>
|
|
|
|
<td>
|
|
<input
|
|
type="checkbox"
|
|
class="competition-check"
|
|
data-index="{{ $doctor->contact->id }}"
|
|
name="voltido_trio_patient[{{ $doctor->contact->id }}]"
|
|
value="Yes"
|
|
{{ isset($existing_submissions[$doctor->contact->id]) && $existing_submissions[$doctor->contact->id] == 'Yes' ? 'checked' : '' }} />
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@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> <!-- 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%;
|
|
}
|
|
|
|
small {
|
|
font-size: 10px;
|
|
}
|
|
|
|
div.sticky-table {
|
|
position: relative;
|
|
height: 100%;
|
|
max-height: 500px;
|
|
}
|
|
|
|
div.sticky-table table thead {
|
|
position: sticky;
|
|
top: 0;
|
|
}
|
|
</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 = [];
|
|
let inputs = document.querySelectorAll('input[type="checkbox"]');
|
|
console.log("inputs - ", inputs);
|
|
$('#report-form').on('submit', function(event) {
|
|
event.preventDefault();
|
|
let arrChecks = [];
|
|
let selectedvoltido_trio_patient = 0;
|
|
|
|
/** Counting namewise checked checkboxes count */
|
|
$('input[type="checkbox"]:checked').each(function(e) {
|
|
//alert(this.value);
|
|
arrChecks.push({
|
|
'name': this.name,
|
|
'val': this.value
|
|
})
|
|
})
|
|
console.log("arrChecks = ", arrChecks);
|
|
//return;
|
|
|
|
arrChecks.forEach((item, index) => {
|
|
if (item.name.includes('voltido_trio_patient')) {
|
|
selectedvoltido_trio_patient++;
|
|
}
|
|
})
|
|
|
|
if (selectedvoltido_trio_patient <= 0) {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: `You must at least select 1 Voltido Trio-Patient Assistance Program doctors! Current Selection: Voltido Trio-Patient Assistance Program doctors: ${selectedvoltido_trio_patient}.`,
|
|
})
|
|
return;
|
|
}
|
|
if (selectedvoltido_trio_patient > 8) {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: `You can at most select 8 Voltido Trio-Patient Assistance Program doctors! Current Selection: Voltido Trio-Patient Assistance Program doctors: ${selectedvoltido_trio_patient}.`,
|
|
})
|
|
return;
|
|
}
|
|
$("#pageloader").fadeIn();
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/form/ajaxsubmitmultiple',
|
|
data: new FormData($('#report-form')[0]),
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(data) {
|
|
console.log('data = ', data)
|
|
$("#pageloader").fadeOut();
|
|
if (data.status == 'success') {
|
|
Swal.fire({
|
|
title: 'Great!',
|
|
text: 'Your data is successfully submitted!',
|
|
icon: 'success'
|
|
})
|
|
// $('#report-form').trigger("reset");
|
|
// $('#doctor_table tbody').html('')
|
|
window.location.reload()
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: 'Something went wrong, please try again after some time!'
|
|
})
|
|
}
|
|
},
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|