Team 2 (Lung Care Programme) Second Code
Specific Folder FTP Upload / ftp-deploy (push) Successful in 2m53s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 2m53s
Details
This commit is contained in:
parent
2f4e1a50a4
commit
cc6b3bf57f
|
|
@ -86,10 +86,12 @@
|
|||
@if($id)
|
||||
<input type="hidden" name="id[0]" value="{{$id}}">
|
||||
@endif
|
||||
|
||||
{{-- 1) #field-user_id पूर्णपणे Hide केला आहे आणि required काढला आहे --}}
|
||||
@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>
|
||||
<div class="col-md-12 mb-2" style="display: none;">
|
||||
<label for="field-user_id" class="form-label"> Select User / Territory </label>
|
||||
<select class="form-control" id="field-user_id" name="user_id">
|
||||
<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>
|
||||
|
|
@ -98,6 +100,7 @@
|
|||
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@foreach($questions as $question)
|
||||
@if( !in_array($question->code, ["record_date","select_rxber_type"] ) )
|
||||
@continue;
|
||||
|
|
@ -145,8 +148,9 @@
|
|||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
{{-- पहिला Doctor Wrapper (Index 0) --}}
|
||||
<div class="doctor-wrapper">
|
||||
|
||||
@foreach($questions as $question)
|
||||
@if( in_array($question->code, ["record_date","select_rxber_type"] ) )
|
||||
@continue;
|
||||
|
|
@ -249,13 +253,17 @@
|
|||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
{{-- उर्वरित 4 Wrappers येथे आपोआप अॅड होतील --}}
|
||||
<div id="doctor-group-wrapper">
|
||||
|
||||
</div>
|
||||
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center button-list">
|
||||
{{-- 3) Add Doctor बटण Hide केले आहे --}}
|
||||
@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" style="display: none;"> Add Doctor </button>
|
||||
@endif
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
|
|
@ -301,9 +309,8 @@
|
|||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
var allContactsList = []; // सर्व डॉक्टर्स साठवण्यासाठी ग्लोबल अॅरे
|
||||
var allContactsList = [];
|
||||
var doctor_count = 0;
|
||||
let numberOfSubmission = 0;
|
||||
|
||||
$('#field-msl_code, #field-speciality').attr('readonly', true);
|
||||
|
||||
|
|
@ -313,17 +320,11 @@
|
|||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
$('#field-user_id').select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select User / Territory --'
|
||||
});
|
||||
|
||||
$('select[id^="execution-"]').select2({
|
||||
width: '100%'
|
||||
});
|
||||
}
|
||||
|
||||
// डुप्लिकेट डॉक्टर्स टाळण्यासाठी फंक्शन
|
||||
function preventDuplicateDoctors() {
|
||||
let selectedValues = [];
|
||||
|
||||
|
|
@ -368,7 +369,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
// सर्व Wrappers मधील डॉक्टर ड्रॉपडाउन अपडेट करण्यासाठी फंक्शन
|
||||
function populateAllDoctorDropdowns(contactsData) {
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
let select = $(this);
|
||||
|
|
@ -394,13 +394,11 @@
|
|||
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');
|
||||
|
|
@ -408,109 +406,8 @@
|
|||
});
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
// पहिला बॉक्स असेल तर 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();
|
||||
});
|
||||
|
||||
// Add Doctor बटण क्लिक केल्यावर नवीन Wrapper जोडणे
|
||||
$('#adddoctor-btn').click(function() {
|
||||
// सध्या पहिल्या ड्रॉपडाउनमध्ये जे डॉक्टर्स लोड झाले आहेत तेच नवीन wrapper मध्ये कॉपी करा
|
||||
|
||||
function addDoctorWrapper() {
|
||||
let doctorOptionsHtml = '';
|
||||
$('#field-contact_id option').each(function() {
|
||||
let val = $(this).val();
|
||||
|
|
@ -521,7 +418,6 @@
|
|||
});
|
||||
|
||||
doctor_count++;
|
||||
numberOfSubmission = numberOfSubmission + 1;
|
||||
|
||||
let empty_doctor = `
|
||||
<div class="doctor-wrapper">
|
||||
|
|
@ -580,23 +476,115 @@
|
|||
|
||||
$('#field-msl_code-' + doctor_count).attr('readonly', true);
|
||||
$('#field-speciality-' + doctor_count).attr('readonly', true);
|
||||
}
|
||||
|
||||
|
||||
@if(!$id)
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
addDoctorWrapper();
|
||||
}
|
||||
@endif
|
||||
|
||||
initializeSelect2();
|
||||
preventDuplicateDoctors();
|
||||
|
||||
|
||||
@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() {
|
||||
|
||||
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());
|
||||
|
||||
|
||||
allContactsList.sort(function(a, b) {
|
||||
let nameA = (a.display || '').trim().toLowerCase();
|
||||
let nameB = (b.display || '').trim().toLowerCase();
|
||||
return nameA.localeCompare(nameB);
|
||||
});
|
||||
|
||||
|
||||
populateAllDoctorDropdowns(allContactsList);
|
||||
$("#pageloader").fadeOut();
|
||||
});
|
||||
}
|
||||
@else
|
||||
|
||||
let initialOptions = [];
|
||||
$('#field-contact_id option').each(function() {
|
||||
let val = $(this).val();
|
||||
if (val && val !== 'sample') {
|
||||
initialOptions.push({
|
||||
value: val,
|
||||
display: $(this).text().trim(),
|
||||
contact: {
|
||||
msl_code: $(this).attr('msl_code') || '',
|
||||
speciality: $(this).attr('speciality') || ''
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
initialOptions.sort(function(a, b) {
|
||||
return a.display.toLowerCase().localeCompare(b.display.toLowerCase());
|
||||
});
|
||||
if (initialOptions.length > 0) {
|
||||
populateAllDoctorDropdowns(initialOptions);
|
||||
}
|
||||
@endif
|
||||
|
||||
|
||||
$(document).on('change', 'select[id^="field-contact_id"]', function () {
|
||||
let selectedOption = $(this).find(':selected');
|
||||
let selectId = $(this).attr('id');
|
||||
|
||||
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();
|
||||
|
||||
if ($('.doctor-wrapper').length >= 10) {
|
||||
$('#adddoctor-btn').hide();
|
||||
} else {
|
||||
$('#adddoctor-btn').show();
|
||||
}
|
||||
});
|
||||
|
||||
// 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();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue