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="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<style>
|
||||
|
||||
/* =========================
|
||||
SELECT2 CUSTOM HIGHLIGHT
|
||||
========================= */
|
||||
|
||||
.select2-container .select2-selection--single{
|
||||
height: 38px !important;
|
||||
border: 1px solid #ced4da !important;
|
||||
border-radius: 6px !important;
|
||||
padding-top: 4px !important;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||
line-height: 28px !important;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||
height: 36px !important;
|
||||
}
|
||||
|
||||
/* Dropdown option hover */
|
||||
.select2-results__option--highlighted{
|
||||
background-color: #0d6efd !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
/* Selected option */
|
||||
.select2-results__option[aria-selected=true]{
|
||||
background-color: #dbe9ff !important;
|
||||
color: black !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Search box */
|
||||
.select2-search__field{
|
||||
border-radius: 5px !important;
|
||||
padding: 6px !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
|
|
@ -68,8 +60,7 @@
|
|||
<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'
|
||||
) )
|
||||
@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>
|
||||
|
|
@ -86,9 +77,7 @@
|
|||
|
||||
@php
|
||||
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||
$submissions = $submissions->data->submissions;
|
||||
|
||||
|
||||
$submissions = isset($submissions->data->submissions) ? $submissions->data->submissions : [];
|
||||
@endphp
|
||||
@if(count($submissions)===0 || $id)
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
|
|
@ -110,8 +99,7 @@
|
|||
</div>
|
||||
@endif
|
||||
@foreach($questions as $question)
|
||||
@if( !in_array($question->code,
|
||||
["record_date","select_rxber_type"] ) )
|
||||
@if( !in_array($question->code, ["record_date","select_rxber_type"] ) )
|
||||
@continue;
|
||||
@endif
|
||||
<div class="col-md-12 mb-2">
|
||||
|
|
@ -146,14 +134,13 @@
|
|||
@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)
|
||||
<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>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
<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 == 'doctor_name' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
|
|
@ -161,8 +148,7 @@
|
|||
<div class="doctor-wrapper">
|
||||
|
||||
@foreach($questions as $question)
|
||||
@if( in_array($question->code,
|
||||
["record_date","select_rxber_type"] ) )
|
||||
@if( in_array($question->code, ["record_date","select_rxber_type"] ) )
|
||||
@continue;
|
||||
@endif
|
||||
<div class="col-md-12 mb-2">
|
||||
|
|
@ -197,37 +183,33 @@
|
|||
@break
|
||||
@case('dropdown')
|
||||
@if ($question->code == 'contact_id')
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}[0]"
|
||||
{{ $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' : '' }}
|
||||
@if($question->code == 'contact_id')
|
||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}[0]"
|
||||
data-preselected="{{ isset($question->value) ? (string)$question->value : '' }}"
|
||||
{{ $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' : '' }}
|
||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<select class="form-control" id="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}[0]"
|
||||
{{ $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
|
||||
<select class="form-control" id="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}[0]"
|
||||
{{ $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
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
|
|
@ -235,7 +217,7 @@
|
|||
<input class="form-check-input" type="checkbox"
|
||||
id="field-{{$question->code}}-{{$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"
|
||||
for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
|
|
@ -250,7 +232,6 @@
|
|||
@elseif(isset($question->value))
|
||||
<img src="{{$question->value}}" class="img-fluid">
|
||||
@endif
|
||||
|
||||
@break
|
||||
@case('multitextbox')
|
||||
<div class="row">
|
||||
|
|
@ -271,8 +252,7 @@
|
|||
<div id="doctor-group-wrapper">
|
||||
|
||||
</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="text-center button-list">
|
||||
@if(!$id)
|
||||
<button class="btn btn-primary" type="button" id="adddoctor-btn"> Add Doctor </button>
|
||||
|
|
@ -286,17 +266,11 @@
|
|||
@endif
|
||||
</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);
|
||||
|
|
@ -306,7 +280,6 @@
|
|||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
|
|
@ -314,7 +287,6 @@
|
|||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.doctor-wrapper {
|
||||
border: 1px solid #ccc;
|
||||
padding: 20px;
|
||||
|
|
@ -322,24 +294,20 @@
|
|||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@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="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
$('#field-msl_code').val($(this).find(":selected").attr("msl_code"));
|
||||
})
|
||||
var allContactsList = []; // सर्व डॉक्टर्स साठवण्यासाठी ग्लोबल अॅरे
|
||||
var doctor_count = 0;
|
||||
let numberOfSubmission = 0;
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
$('#field-speciality').val($(this).find(":selected").attr("speciality"));
|
||||
})
|
||||
|
||||
$('#field-msl_code,#field-speciality').attr('readonly',true);
|
||||
$('#field-msl_code, #field-speciality').attr('readonly', true);
|
||||
|
||||
function initializeSelect2() {
|
||||
|
||||
$('select[id^="field-contact_id"]').select2({
|
||||
width: '100%',
|
||||
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() {
|
||||
|
||||
let selectedValues = [];
|
||||
|
||||
// Collect selected values
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if (value) {
|
||||
selectedValues.push(value);
|
||||
selectedValues.push(String(value));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let currentSelect = $(this);
|
||||
let currentValue = currentSelect.val();
|
||||
let currentValue = currentSelect.val() ? String(currentSelect.val()) : '';
|
||||
|
||||
currentSelect.find('option').each(function () {
|
||||
|
||||
let option = $(this);
|
||||
let optionValue = option.val();
|
||||
let optionValue = option.val() ? String(option.val()) : '';
|
||||
|
||||
if (!optionValue) return;
|
||||
|
||||
// remove previous label
|
||||
let cleanText = option.text().replace(' (Already Added)', '');
|
||||
|
||||
// IMPORTANT:
|
||||
// keep currently selected option enabled
|
||||
if (
|
||||
selectedValues.includes(optionValue) &&
|
||||
optionValue !== currentValue
|
||||
) {
|
||||
|
||||
if (selectedValues.includes(optionValue) && optionValue !== currentValue) {
|
||||
option.prop('disabled', true);
|
||||
option.text(cleanText + ' (Already Added)');
|
||||
|
||||
} else {
|
||||
|
||||
option.prop('disabled', false);
|
||||
option.text(cleanText);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// refresh select2 safely
|
||||
if (currentSelect.hasClass("select2-hidden-accessible")) {
|
||||
currentSelect.select2('destroy');
|
||||
}
|
||||
|
|
@ -479,219 +364,242 @@
|
|||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
// VERY IMPORTANT FOR EDIT MODE
|
||||
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 () {
|
||||
|
||||
let selectedOption = $(this).find(':selected');
|
||||
let selectId = $(this).attr('id');
|
||||
|
||||
let id = $(this).attr('id').split('-').pop(); // get doctor_count dynamically
|
||||
|
||||
$('#field-msl_code-' + id).val(selectedOption.attr('msl_code'));
|
||||
$('#field-speciality-' + id).val(selectedOption.attr('speciality'));
|
||||
// पहिला बॉक्स असेल तर id = 'field-contact_id', नवीन असेल तर 'field-contact_id-1'
|
||||
if (selectId === 'field-contact_id') {
|
||||
$('#field-msl_code').val(selectedOption.attr('msl_code') || '');
|
||||
$('#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();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var doctor_count = 0
|
||||
let numberOfSubmission=0;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
// Add Doctor बटण क्लिक केल्यावर नवीन Wrapper जोडणे
|
||||
$('#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++;
|
||||
numberOfSubmission=numberOfSubmission+1;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
numberOfSubmission = numberOfSubmission + 1;
|
||||
|
||||
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>
|
||||
<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>`;
|
||||
|
||||
@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);
|
||||
|
||||
|
||||
$('#doctor-group-wrapper').append(empty_doctor)
|
||||
|
||||
$('#field-contact_id-'+doctor_count).select2({
|
||||
|
||||
$('#field-contact_id-' + doctor_count).select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
preventDuplicateDoctors();
|
||||
|
||||
|
||||
$('select[id^="execution-"]').select2({
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
$('#field-msl_code-'+doctor_count).attr('readonly',true);
|
||||
$('#field-speciality-'+doctor_count).attr('readonly',true);
|
||||
|
||||
|
||||
|
||||
}, 500);
|
||||
$('#field-msl_code-' + doctor_count).attr('readonly', true);
|
||||
$('#field-speciality-' + doctor_count).attr('readonly', true);
|
||||
|
||||
|
||||
|
||||
preventDuplicateDoctors();
|
||||
|
||||
if ($('.doctor-wrapper').length >= 10) {
|
||||
$('#adddoctor-btn').hide();
|
||||
} else {
|
||||
$('#adddoctor-btn').show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('.btn-remove').unbind();
|
||||
$('.btn-remove').click(function() {
|
||||
$(this).closest('.doctor-wrapper').find('select').select2('destroy');
|
||||
$(this).closest('.doctor-wrapper').remove();
|
||||
numberOfSubmission--;
|
||||
doctor_count--
|
||||
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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
// Remove Doctor बटण (Delegated event जेणेकरून सर्व wrappers वर नीट चालेल)
|
||||
$(document).on('click', '.btn-remove', function() {
|
||||
$(this).closest('.doctor-wrapper').find('select').select2('destroy');
|
||||
$(this).closest('.doctor-wrapper').remove();
|
||||
numberOfSubmission--;
|
||||
preventDuplicateDoctors();
|
||||
$('#adddoctor-btn').show();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
Loading…
Reference in New Issue