Team 2 (Lung Care Programme) First code
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m28s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m28s
Details
This commit is contained in:
parent
f9621601b5
commit
2f4e1a50a4
|
|
@ -7,45 +7,37 @@
|
||||||
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
||||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
/* =========================
|
/* =========================
|
||||||
SELECT2 CUSTOM HIGHLIGHT
|
SELECT2 CUSTOM HIGHLIGHT
|
||||||
========================= */
|
========================= */
|
||||||
|
|
||||||
.select2-container .select2-selection--single{
|
.select2-container .select2-selection--single{
|
||||||
height: 38px !important;
|
height: 38px !important;
|
||||||
border: 1px solid #ced4da !important;
|
border: 1px solid #ced4da !important;
|
||||||
border-radius: 6px !important;
|
border-radius: 6px !important;
|
||||||
padding-top: 4px !important;
|
padding-top: 4px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||||
line-height: 28px !important;
|
line-height: 28px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||||
height: 36px !important;
|
height: 36px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dropdown option hover */
|
/* Dropdown option hover */
|
||||||
.select2-results__option--highlighted{
|
.select2-results__option--highlighted{
|
||||||
background-color: #0d6efd !important;
|
background-color: #0d6efd !important;
|
||||||
color: white !important;
|
color: white !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Selected option */
|
/* Selected option */
|
||||||
.select2-results__option[aria-selected=true]{
|
.select2-results__option[aria-selected=true]{
|
||||||
background-color: #dbe9ff !important;
|
background-color: #dbe9ff !important;
|
||||||
color: black !important;
|
color: black !important;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search box */
|
/* Search box */
|
||||||
.select2-search__field{
|
.select2-search__field{
|
||||||
border-radius: 5px !important;
|
border-radius: 5px !important;
|
||||||
padding: 6px !important;
|
padding: 6px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<div id="pageloader">
|
<div id="pageloader">
|
||||||
|
|
@ -68,8 +60,7 @@
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<h4 class="page-title">{{$form->title}}</h4>
|
<h4 class="page-title">{{$form->title}}</h4>
|
||||||
</div>
|
</div>
|
||||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||||
) )
|
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
@if($form->link_type == 'form')
|
@if($form->link_type == 'form')
|
||||||
<a href="/form/history" class="float-end pt-1">View History</a>
|
<a href="/form/history" class="float-end pt-1">View History</a>
|
||||||
|
|
@ -86,9 +77,7 @@
|
||||||
|
|
||||||
@php
|
@php
|
||||||
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||||
$submissions = $submissions->data->submissions;
|
$submissions = isset($submissions->data->submissions) ? $submissions->data->submissions : [];
|
||||||
|
|
||||||
|
|
||||||
@endphp
|
@endphp
|
||||||
@if(count($submissions)===0 || $id)
|
@if(count($submissions)===0 || $id)
|
||||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||||
|
|
@ -110,8 +99,7 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@foreach($questions as $question)
|
@foreach($questions as $question)
|
||||||
@if( !in_array($question->code,
|
@if( !in_array($question->code, ["record_date","select_rxber_type"] ) )
|
||||||
["record_date","select_rxber_type"] ) )
|
|
||||||
@continue;
|
@continue;
|
||||||
@endif
|
@endif
|
||||||
<div class="col-md-12 mb-2">
|
<div class="col-md-12 mb-2">
|
||||||
|
|
@ -146,14 +134,13 @@
|
||||||
@break
|
@break
|
||||||
@case('dropdown')
|
@case('dropdown')
|
||||||
<select class="form-control" id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
<select class="form-control" id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||||
<option value=""> -- Select -- </option>
|
<option value=""> -- Select -- </option>
|
||||||
@foreach ($question->options as $option)
|
@foreach ($question->options as $option)
|
||||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }} {{ $question->code == 'doctor_name' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'msl_code= ' . ($option->contact->msl_code ?? '') . ' ' : '' }} {{ $question->code == 'doctor_name' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||||
{{ $option->display }}
|
{{ $option->display }}
|
||||||
</option>
|
</option>
|
||||||
|
@endforeach
|
||||||
@endforeach
|
</select>
|
||||||
</select>
|
|
||||||
@break
|
@break
|
||||||
@endswitch
|
@endswitch
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -161,8 +148,7 @@
|
||||||
<div class="doctor-wrapper">
|
<div class="doctor-wrapper">
|
||||||
|
|
||||||
@foreach($questions as $question)
|
@foreach($questions as $question)
|
||||||
@if( in_array($question->code,
|
@if( in_array($question->code, ["record_date","select_rxber_type"] ) )
|
||||||
["record_date","select_rxber_type"] ) )
|
|
||||||
@continue;
|
@continue;
|
||||||
@endif
|
@endif
|
||||||
<div class="col-md-12 mb-2">
|
<div class="col-md-12 mb-2">
|
||||||
|
|
@ -197,37 +183,33 @@
|
||||||
@break
|
@break
|
||||||
@case('dropdown')
|
@case('dropdown')
|
||||||
@if ($question->code == 'contact_id')
|
@if ($question->code == 'contact_id')
|
||||||
<select class="form-control" id="field-{{ $question->code }}"
|
<select class="form-control" id="field-{{ $question->code }}"
|
||||||
name="{{ $question->code }}[0]"
|
name="{{ $question->code }}[0]"
|
||||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
data-preselected="{{ isset($question->value) ? (string)$question->value : '' }}"
|
||||||
<option value=""> -- Select -- </option>
|
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||||
@foreach ($question->options as $option)
|
<option value=""> -- Select -- </option>
|
||||||
|
@foreach ($question->options as $option)
|
||||||
|
<option value="{{ $option->value }}"
|
||||||
<option value="{{ $option->value }}"
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
||||||
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||||
@if($question->code == 'contact_id')
|
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
>
|
||||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
{{ $option->display }}
|
||||||
@endif
|
</option>
|
||||||
>
|
@endforeach
|
||||||
{{ $option->display }}
|
</select>
|
||||||
</option>
|
|
||||||
|
|
||||||
@endforeach
|
|
||||||
</select>
|
|
||||||
@else
|
@else
|
||||||
<select class="form-control" id="execution-{{ $question->code }}"
|
<select class="form-control" id="execution-{{ $question->code }}"
|
||||||
name="{{ $question->code }}[0]"
|
name="{{ $question->code }}[0]"
|
||||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||||
<option value=""> -- Select -- </option>
|
<option value=""> -- Select -- </option>
|
||||||
@foreach ($question->options as $option)
|
@foreach ($question->options as $option)
|
||||||
<option value="{{ $option->value }}"
|
<option value="{{ $option->value }}"
|
||||||
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||||
{{ $option->display }}</option>
|
{{ $option->display }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
@endif
|
@endif
|
||||||
@break
|
@break
|
||||||
@case('checkbox')
|
@case('checkbox')
|
||||||
@foreach($question->options as $option)
|
@foreach($question->options as $option)
|
||||||
|
|
@ -235,7 +217,7 @@
|
||||||
<input class="form-check-input" type="checkbox"
|
<input class="form-check-input" type="checkbox"
|
||||||
id="field-{{$question->code}}-{{$option->value}}"
|
id="field-{{$question->code}}-{{$option->value}}"
|
||||||
name="{{$question->code}}[0]" value="{{$option->value}}"
|
name="{{$question->code}}[0]" value="{{$option->value}}"
|
||||||
{{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
{{isset($question->value) && $question->value != '' && in_array($option->value, (array)$question->value) ? 'checked':''}}>
|
||||||
<label class="form-check-label"
|
<label class="form-check-label"
|
||||||
for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -250,7 +232,6 @@
|
||||||
@elseif(isset($question->value))
|
@elseif(isset($question->value))
|
||||||
<img src="{{$question->value}}" class="img-fluid">
|
<img src="{{$question->value}}" class="img-fluid">
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@break
|
@break
|
||||||
@case('multitextbox')
|
@case('multitextbox')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
@ -271,8 +252,7 @@
|
||||||
<div id="doctor-group-wrapper">
|
<div id="doctor-group-wrapper">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval !=
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||||
'yes' ) )
|
|
||||||
<div class="text-center button-list">
|
<div class="text-center button-list">
|
||||||
@if(!$id)
|
@if(!$id)
|
||||||
<button class="btn btn-primary" type="button" id="adddoctor-btn"> Add Doctor </button>
|
<button class="btn btn-primary" type="button" id="adddoctor-btn"> Add Doctor </button>
|
||||||
|
|
@ -286,17 +266,11 @@
|
||||||
@endif
|
@endif
|
||||||
</div> <!-- end card-body -->
|
</div> <!-- end card-body -->
|
||||||
</div>
|
</div>
|
||||||
<!-- end card -->
|
|
||||||
|
|
||||||
<!-- end row -->
|
|
||||||
|
|
||||||
</div> <!-- end col -->
|
</div> <!-- end col -->
|
||||||
</div>
|
</div>
|
||||||
<!-- end row -->
|
|
||||||
</div>
|
</div>
|
||||||
<!-- end container -->
|
|
||||||
</div>
|
</div>
|
||||||
<!-- end page -->
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#pageloader {
|
#pageloader {
|
||||||
background: rgba(255, 255, 255, 0.8);
|
background: rgba(255, 255, 255, 0.8);
|
||||||
|
|
@ -306,7 +280,6 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pageloader img {
|
#pageloader img {
|
||||||
left: 50%;
|
left: 50%;
|
||||||
margin-left: -32px;
|
margin-left: -32px;
|
||||||
|
|
@ -314,7 +287,6 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doctor-wrapper {
|
.doctor-wrapper {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
|
@ -322,24 +294,20 @@
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@include('layouts.shared/footer-script')
|
@include('layouts.shared/footer-script')
|
||||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
|
|
||||||
$('#field-contact_id').on('change',function(){
|
var allContactsList = []; // सर्व डॉक्टर्स साठवण्यासाठी ग्लोबल अॅरे
|
||||||
$('#field-msl_code').val($(this).find(":selected").attr("msl_code"));
|
var doctor_count = 0;
|
||||||
})
|
let numberOfSubmission = 0;
|
||||||
|
|
||||||
$('#field-contact_id').on('change',function(){
|
$('#field-msl_code, #field-speciality').attr('readonly', true);
|
||||||
$('#field-speciality').val($(this).find(":selected").attr("speciality"));
|
|
||||||
})
|
|
||||||
|
|
||||||
$('#field-msl_code,#field-speciality').attr('readonly',true);
|
|
||||||
|
|
||||||
function initializeSelect2() {
|
function initializeSelect2() {
|
||||||
|
|
||||||
$('select[id^="field-contact_id"]').select2({
|
$('select[id^="field-contact_id"]').select2({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
placeholder: '-- Select Doctor --'
|
placeholder: '-- Select Doctor --'
|
||||||
|
|
@ -355,121 +323,38 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeSelect2();
|
// डुप्लिकेट डॉक्टर्स टाळण्यासाठी फंक्शन
|
||||||
preventDuplicateDoctors();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* function preventDuplicateDoctors() {
|
|
||||||
|
|
||||||
let selectedValues = [];
|
|
||||||
|
|
||||||
// Get all selected doctor values
|
|
||||||
$('select[id^="field-contact_id"]').each(function () {
|
|
||||||
|
|
||||||
let value = $(this).val();
|
|
||||||
|
|
||||||
if (value) {
|
|
||||||
selectedValues.push(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Apply duplicate prevention
|
|
||||||
$('select[id^="field-contact_id"]').each(function () {
|
|
||||||
|
|
||||||
let currentSelect = $(this);
|
|
||||||
let currentValue = currentSelect.val();
|
|
||||||
|
|
||||||
currentSelect.find('option').each(function () {
|
|
||||||
|
|
||||||
let option = $(this);
|
|
||||||
let optionValue = option.val();
|
|
||||||
|
|
||||||
if (!optionValue) return;
|
|
||||||
|
|
||||||
// Remove old text
|
|
||||||
let cleanText = option.text().replace(' (Already Added)', '');
|
|
||||||
|
|
||||||
if (
|
|
||||||
selectedValues.includes(optionValue) &&
|
|
||||||
optionValue !== currentValue
|
|
||||||
) {
|
|
||||||
|
|
||||||
option.prop('disabled', true);
|
|
||||||
option.text(cleanText + ' (Already Added)');
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
option.prop('disabled', false);
|
|
||||||
option.text(cleanText);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// 🔥 IMPORTANT
|
|
||||||
currentSelect.select2('destroy');
|
|
||||||
|
|
||||||
currentSelect.select2({
|
|
||||||
width: '100%',
|
|
||||||
placeholder: '-- Select Doctor --'
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
} */
|
|
||||||
|
|
||||||
function preventDuplicateDoctors() {
|
function preventDuplicateDoctors() {
|
||||||
|
|
||||||
let selectedValues = [];
|
let selectedValues = [];
|
||||||
|
|
||||||
// Collect selected values
|
|
||||||
$('select[id^="field-contact_id"]').each(function () {
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
|
||||||
let value = $(this).val();
|
let value = $(this).val();
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
selectedValues.push(value);
|
selectedValues.push(String(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('select[id^="field-contact_id"]').each(function () {
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
|
||||||
let currentSelect = $(this);
|
let currentSelect = $(this);
|
||||||
let currentValue = currentSelect.val();
|
let currentValue = currentSelect.val() ? String(currentSelect.val()) : '';
|
||||||
|
|
||||||
currentSelect.find('option').each(function () {
|
currentSelect.find('option').each(function () {
|
||||||
|
|
||||||
let option = $(this);
|
let option = $(this);
|
||||||
let optionValue = option.val();
|
let optionValue = option.val() ? String(option.val()) : '';
|
||||||
|
|
||||||
if (!optionValue) return;
|
if (!optionValue) return;
|
||||||
|
|
||||||
// remove previous label
|
|
||||||
let cleanText = option.text().replace(' (Already Added)', '');
|
let cleanText = option.text().replace(' (Already Added)', '');
|
||||||
|
|
||||||
// IMPORTANT:
|
if (selectedValues.includes(optionValue) && optionValue !== currentValue) {
|
||||||
// keep currently selected option enabled
|
|
||||||
if (
|
|
||||||
selectedValues.includes(optionValue) &&
|
|
||||||
optionValue !== currentValue
|
|
||||||
) {
|
|
||||||
|
|
||||||
option.prop('disabled', true);
|
option.prop('disabled', true);
|
||||||
option.text(cleanText + ' (Already Added)');
|
option.text(cleanText + ' (Already Added)');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
option.prop('disabled', false);
|
option.prop('disabled', false);
|
||||||
option.text(cleanText);
|
option.text(cleanText);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// refresh select2 safely
|
|
||||||
if (currentSelect.hasClass("select2-hidden-accessible")) {
|
if (currentSelect.hasClass("select2-hidden-accessible")) {
|
||||||
currentSelect.select2('destroy');
|
currentSelect.select2('destroy');
|
||||||
}
|
}
|
||||||
|
|
@ -479,219 +364,242 @@
|
||||||
placeholder: '-- Select Doctor --'
|
placeholder: '-- Select Doctor --'
|
||||||
});
|
});
|
||||||
|
|
||||||
// VERY IMPORTANT FOR EDIT MODE
|
|
||||||
currentSelect.val(currentValue).trigger('change.select2');
|
currentSelect.val(currentValue).trigger('change.select2');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// सर्व Wrappers मधील डॉक्टर ड्रॉपडाउन अपडेट करण्यासाठी फंक्शन
|
||||||
|
function populateAllDoctorDropdowns(contactsData) {
|
||||||
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
let select = $(this);
|
||||||
|
let preVal = select.attr('data-preselected') || select.val() || '';
|
||||||
|
|
||||||
|
select.empty();
|
||||||
|
select.append($("<option></option>").attr("value", '').text('-- Select --'));
|
||||||
|
|
||||||
|
contactsData.forEach(function (itm) {
|
||||||
|
let msl = (itm.contact && itm.contact.msl_code) ? itm.contact.msl_code : '';
|
||||||
|
let spec = (itm.contact && itm.contact.speciality) ? itm.contact.speciality : '';
|
||||||
|
|
||||||
|
let option = $("<option></option>")
|
||||||
|
.attr("value", itm.value)
|
||||||
|
.text(itm.display)
|
||||||
|
.attr("msl_code", msl)
|
||||||
|
.attr("speciality", spec);
|
||||||
|
|
||||||
|
if (preVal && String(preVal) === String(itm.value)) {
|
||||||
|
option.prop('selected', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
select.append(option);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Edit mode मध्ये असल्यास data-preselected एकदा वापरल्यावर क्लिअर करा
|
||||||
|
select.removeAttr('data-preselected');
|
||||||
|
});
|
||||||
|
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
|
||||||
|
// प्री-सिलेक्टेड डॉक्टर असल्यास MSL code आणि Speciality आपोआप भरा
|
||||||
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
if ($(this).val()) {
|
||||||
|
$(this).trigger('change');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeSelect2();
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
|
||||||
|
// ABM (Manager) साठी फॉर्म ओपन होताच सर्व TMs चे डॉक्टर्स लोड करणे
|
||||||
|
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||||
|
var hierarcies = [];
|
||||||
|
@foreach($form->users as $option)
|
||||||
|
@if(!empty($option->hierarchy_id))
|
||||||
|
hierarcies.push('{{$option->hierarchy_id}}');
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
if (hierarcies.length > 0) {
|
||||||
|
$("#pageloader").fadeIn();
|
||||||
|
let fetchedContacts = [];
|
||||||
|
|
||||||
|
Promise.all(
|
||||||
|
hierarcies.map(hierarchy => {
|
||||||
|
return $.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
||||||
|
processData: false,
|
||||||
|
contentType: false
|
||||||
|
}).then(data => {
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
fetchedContacts = fetchedContacts.concat(data);
|
||||||
|
}
|
||||||
|
}).catch(function(err) {
|
||||||
|
console.log("Error fetching doctors for hierarchy " + hierarchy, err);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
).then(function() {
|
||||||
|
// 'sample' काढून टाका आणि डुप्लिकेट डॉक्टर्स असल्यास युनिक करा
|
||||||
|
let uniqueMap = new Map();
|
||||||
|
fetchedContacts.forEach(itm => {
|
||||||
|
if (itm && itm.value && itm.value !== 'sample') {
|
||||||
|
uniqueMap.set(String(itm.value), itm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
allContactsList = Array.from(uniqueMap.values());
|
||||||
|
populateAllDoctorDropdowns(allContactsList);
|
||||||
|
$("#pageloader").fadeOut();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@endif
|
||||||
|
|
||||||
|
// जेव्हा User / Territory ड्रॉपडाउन बदलला जाईल तेव्हा सर्व Wrappers मधील डॉक्टर्स अपडेट करणे
|
||||||
|
$('#field-user_id').on('change', function(event) {
|
||||||
|
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||||
|
$('#field-hierarchy_id').val(hierarchy);
|
||||||
|
|
||||||
|
// जर User सिलेक्ट नसेल (रिकामे असेल), तर पुन्हा सर्व ABM चे डॉक्टर्स दाखवा
|
||||||
|
if (!hierarchy) {
|
||||||
|
if (allContactsList.length > 0) {
|
||||||
|
populateAllDoctorDropdowns(allContactsList);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#pageloader').fadeIn();
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function(data) {
|
||||||
|
$("#pageloader").fadeOut();
|
||||||
|
let filteredData = Array.isArray(data) ? data.filter(itm => itm && itm.value !== 'sample') : [];
|
||||||
|
|
||||||
|
// सर्व wrappers मधील MSL Code आणि Speciality रिसेट करा
|
||||||
|
$('input[id^="field-msl_code"]').val('');
|
||||||
|
$('input[id^="field-speciality"]').val('');
|
||||||
|
|
||||||
|
populateAllDoctorDropdowns(filteredData);
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
$("#pageloader").fadeOut();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// डॉक्टर बदलल्यावर MSL Code, Speciality भरणे आणि Duplicate तपासणे (पहिल्या व सर्व नवीन wrappers साठी)
|
||||||
$(document).on('change', 'select[id^="field-contact_id"]', function () {
|
$(document).on('change', 'select[id^="field-contact_id"]', function () {
|
||||||
|
|
||||||
let selectedOption = $(this).find(':selected');
|
let selectedOption = $(this).find(':selected');
|
||||||
|
let selectId = $(this).attr('id');
|
||||||
|
|
||||||
let id = $(this).attr('id').split('-').pop(); // get doctor_count dynamically
|
// पहिला बॉक्स असेल तर id = 'field-contact_id', नवीन असेल तर 'field-contact_id-1'
|
||||||
|
if (selectId === 'field-contact_id') {
|
||||||
$('#field-msl_code-' + id).val(selectedOption.attr('msl_code'));
|
$('#field-msl_code').val(selectedOption.attr('msl_code') || '');
|
||||||
$('#field-speciality-' + id).val(selectedOption.attr('speciality'));
|
$('#field-speciality').val(selectedOption.attr('speciality') || '');
|
||||||
|
} else {
|
||||||
|
let id = selectId.split('-').pop();
|
||||||
|
$('#field-msl_code-' + id).val(selectedOption.attr('msl_code') || '');
|
||||||
|
$('#field-speciality-' + id).val(selectedOption.attr('speciality') || '');
|
||||||
|
}
|
||||||
|
|
||||||
preventDuplicateDoctors();
|
preventDuplicateDoctors();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add Doctor बटण क्लिक केल्यावर नवीन Wrapper जोडणे
|
||||||
|
|
||||||
|
|
||||||
var doctor_count = 0
|
|
||||||
let numberOfSubmission=0;
|
|
||||||
console.log("Number of Submission : ",numberOfSubmission);
|
|
||||||
$('#adddoctor-btn').click(function() {
|
$('#adddoctor-btn').click(function() {
|
||||||
let doctorName=$('#field-contact_id').html();
|
// सध्या पहिल्या ड्रॉपडाउनमध्ये जे डॉक्टर्स लोड झाले आहेत तेच नवीन wrapper मध्ये कॉपी करा
|
||||||
|
let doctorOptionsHtml = '';
|
||||||
|
$('#field-contact_id option').each(function() {
|
||||||
|
let val = $(this).val();
|
||||||
|
let text = $(this).text().replace(' (Already Added)', '');
|
||||||
|
let msl = $(this).attr('msl_code') || '';
|
||||||
|
let spec = $(this).attr('speciality') || '';
|
||||||
|
doctorOptionsHtml += `<option value="${val}" msl_code="${msl}" speciality="${spec}">${text}</option>`;
|
||||||
|
});
|
||||||
|
|
||||||
console.log("Doctor Name : ",doctorName);
|
|
||||||
doctor_count++;
|
doctor_count++;
|
||||||
numberOfSubmission=numberOfSubmission+1;
|
numberOfSubmission = numberOfSubmission + 1;
|
||||||
console.log("Number of Submission : ",numberOfSubmission);
|
|
||||||
|
|
||||||
let empty_doctor = `
|
let empty_doctor = `
|
||||||
|
<div class="doctor-wrapper">
|
||||||
|
<button type="button" class="btn btn-danger btn-remove float-end" style="margin-top:-25px; margin-right:-25px"><i class="mdi mdi-close"></i></button>
|
||||||
|
@foreach($questions as $question)
|
||||||
|
@if( in_array($question->code, ["record_date","select_rxber_type"] ) )
|
||||||
|
@continue;
|
||||||
|
@endif
|
||||||
|
<div class="col-md-12 mb-2">
|
||||||
|
<label for="field-{{$question->code}}-${doctor_count}" 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}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
@break
|
||||||
|
@case('text')
|
||||||
|
@case('file')
|
||||||
|
@case('email')
|
||||||
|
@case('tel')
|
||||||
|
@case('date')
|
||||||
|
<input type="{{$question->type}}" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" 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}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
||||||
|
@break
|
||||||
|
@case('dropdown')
|
||||||
|
@if($question->code == 'contact_id')
|
||||||
|
<select class="form-control" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" {{$question->required == 'yes'?'required':'' }}>
|
||||||
|
${doctorOptionsHtml}
|
||||||
|
</select>
|
||||||
|
@else
|
||||||
|
<select class="form-control" id="execution-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" {{$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>
|
||||||
|
@endif
|
||||||
|
@break
|
||||||
|
@endswitch
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>`;
|
||||||
|
|
||||||
<div class="doctor-wrapper"><button type="button" class="btn btn-danger btn-remove float-end" style="margin-top:-25px; margin-right:-25px"><i class="mdi mdi-close"></i></button>
|
$('#doctor-group-wrapper').append(empty_doctor);
|
||||||
|
|
||||||
@foreach($questions as $question)
|
|
||||||
@if( in_array($question->code,
|
|
||||||
["record_date","select_rxber_type"] ) )
|
|
||||||
@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}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" value="{{isset($question->value)?$question->value:''}}">
|
|
||||||
@break
|
|
||||||
@case('text')
|
|
||||||
@case('file')
|
|
||||||
@case('email')
|
|
||||||
@case('tel')
|
|
||||||
@case('date')
|
|
||||||
<input type="{{$question->type}}" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" 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}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
|
||||||
@break
|
|
||||||
@case('dropdown')
|
|
||||||
<select class="form-control" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" {{$question->required == 'yes'?'required':'' }}>
|
|
||||||
@if($question->code=='contact_id')
|
|
||||||
${doctorName}
|
|
||||||
@else
|
|
||||||
<option value=""> -- Select -- </option>
|
|
||||||
@foreach($question->options as $option)
|
|
||||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
|
||||||
{{ $option->display }}
|
|
||||||
</option>
|
|
||||||
@endforeach
|
|
||||||
@endif
|
|
||||||
</select>
|
|
||||||
@break
|
|
||||||
@endswitch
|
|
||||||
</div>
|
|
||||||
@endforeach </div>`;
|
|
||||||
|
|
||||||
|
|
||||||
$('#doctor-group-wrapper').append(empty_doctor)
|
|
||||||
|
|
||||||
$('#field-contact_id-'+doctor_count).select2({
|
|
||||||
|
|
||||||
|
$('#field-contact_id-' + doctor_count).select2({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
placeholder: '-- Select Doctor --'
|
placeholder: '-- Select Doctor --'
|
||||||
});
|
});
|
||||||
preventDuplicateDoctors();
|
|
||||||
|
|
||||||
|
|
||||||
$('select[id^="execution-"]').select2({
|
$('select[id^="execution-"]').select2({
|
||||||
width: '100%'
|
width: '100%'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#field-msl_code-' + doctor_count).attr('readonly', true);
|
||||||
|
$('#field-speciality-' + doctor_count).attr('readonly', true);
|
||||||
|
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
$('#field-msl_code-'+doctor_count).attr('readonly',true);
|
|
||||||
$('#field-speciality-'+doctor_count).attr('readonly',true);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($('.doctor-wrapper').length >= 10) {
|
if ($('.doctor-wrapper').length >= 10) {
|
||||||
$('#adddoctor-btn').hide();
|
$('#adddoctor-btn').hide();
|
||||||
} else {
|
} else {
|
||||||
$('#adddoctor-btn').show();
|
$('#adddoctor-btn').show();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove Doctor बटण (Delegated event जेणेकरून सर्व wrappers वर नीट चालेल)
|
||||||
$('.btn-remove').unbind();
|
$(document).on('click', '.btn-remove', function() {
|
||||||
$('.btn-remove').click(function() {
|
$(this).closest('.doctor-wrapper').find('select').select2('destroy');
|
||||||
$(this).closest('.doctor-wrapper').find('select').select2('destroy');
|
$(this).closest('.doctor-wrapper').remove();
|
||||||
$(this).closest('.doctor-wrapper').remove();
|
numberOfSubmission--;
|
||||||
numberOfSubmission--;
|
preventDuplicateDoctors();
|
||||||
doctor_count--
|
$('#adddoctor-btn').show();
|
||||||
preventDuplicateDoctors();
|
|
||||||
console.log("New Number of Submission : ",numberOfSubmission);
|
|
||||||
console.log("Number of doctors : ",doctor_count);
|
|
||||||
$('#adddoctor-btn').show();
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#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();
|
|
||||||
$('#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).attr("msl_code", itm.contact.msl_code).attr("speciality", itm.contact.speciality));
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#field-contact_id').change(function() {
|
|
||||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
|
||||||
})
|
|
||||||
|
|
||||||
$('#field-contact_id').change(function() {
|
|
||||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
|
||||||
})
|
|
||||||
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(hierarchy)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
$('#report-form').on('submit', function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
let isEditMode = $('input[name="id[0]"]').length > 0 && $('input[name="id[0]"]').val() !== '';
|
|
||||||
|
|
||||||
if (!isEditMode && numberOfSubmission != 9) {
|
|
||||||
alert(`You must submit 10 Doctors , Current Doctors : ${numberOfSubmission+1}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$("#pageloader").fadeIn();
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: '/form/ajaxsubmitmultiple',
|
|
||||||
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'
|
|
||||||
}).then(() => {
|
|
||||||
location.reload(); // 🔥 page refresh here
|
|
||||||
});
|
|
||||||
$('#report-form').trigger("reset");
|
|
||||||
} else {
|
|
||||||
Swal.fire({
|
|
||||||
icon: 'error',
|
|
||||||
title: 'Data not submitted',
|
|
||||||
text: 'Something went wrong, please try again after some time!'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue