Team 3 (Levoswitch)
Specific Folder FTP Upload / ftp-deploy (push) Successful in 29s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 29s
Details
This commit is contained in:
parent
55e85b2f0f
commit
8516e19dae
|
|
@ -148,29 +148,13 @@
|
||||||
<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)
|
||||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
<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 }}"
|
{{ $option->display }}
|
||||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
</option>
|
||||||
@if($question->code == 'contact_id')
|
|
||||||
msl_code="{{ (isset($option->contact->legacy_code) ? $option->contact->legacy_code : '') }}"
|
|
||||||
pcode="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
|
||||||
|
|
||||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
|
||||||
@endif
|
|
||||||
>
|
|
||||||
{{ $option->display }}
|
|
||||||
</option>
|
|
||||||
@elseif($question->code != 'contact_id')
|
|
||||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
|
||||||
{{ $option->display }}
|
|
||||||
</option>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
@break
|
@break
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@endswitch
|
@endswitch
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
@ -220,23 +204,15 @@
|
||||||
@foreach ($question->options as $option)
|
@foreach ($question->options as $option)
|
||||||
|
|
||||||
|
|
||||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
<option value="{{ $option->value }}"
|
||||||
<option value="{{ $option->value }}"
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
||||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
@if($question->code == 'contact_id')
|
||||||
@if($question->code == 'contact_id')
|
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||||
msl_code="{{ (isset($option->contact->legacy_code) ? $option->contact->legacy_code : '') }}"
|
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||||
pcode="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
@endif
|
||||||
|
>
|
||||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
{{ $option->display }}
|
||||||
@endif
|
</option>
|
||||||
>
|
|
||||||
{{ $option->display }}
|
|
||||||
</option>
|
|
||||||
@elseif($question->code != 'contact_id')
|
|
||||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
|
||||||
{{ $option->display }}
|
|
||||||
</option>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
|
@ -349,30 +325,18 @@
|
||||||
@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(){
|
$('#field-contact_id').on('change',function(){
|
||||||
$('#field-msl_code').val($(this).find(":selected").attr("msl_code"));
|
$('#field-msl_code').val($(this).find(":selected").attr("msl_code"));
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#field-contact_id').on('change',function(){
|
|
||||||
$('#field-pcode').val($(this).find(":selected").attr("pcode"));
|
|
||||||
})
|
|
||||||
|
|
||||||
$('#field-contact_id').on('change',function(){
|
$('#field-contact_id').on('change',function(){
|
||||||
$('#field-speciality').val($(this).find(":selected").attr("speciality"));
|
$('#field-speciality').val($(this).find(":selected").attr("speciality"));
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#field-msl_code,#field-pcode,#field-speciality').attr('readonly',true);
|
$('#field-msl_code,#field-speciality').attr('readonly',true);
|
||||||
|
|
||||||
var isEditMode = @json((bool)$id);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).on('input', 'input[id^="field-brand_name"]', function () {
|
|
||||||
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
|
||||||
});
|
|
||||||
|
|
||||||
function initializeSelect2() {
|
function initializeSelect2() {
|
||||||
|
|
||||||
|
|
@ -391,18 +355,75 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
initializeSelect2();
|
initializeSelect2();
|
||||||
preventDuplicateDoctors();
|
preventDuplicateDoctors();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* function preventDuplicateDoctors() {
|
/* function preventDuplicateDoctors() {
|
||||||
|
|
||||||
let selectedValues = [];
|
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
|
// Collect selected values
|
||||||
$('select[id^="field-contact_id"]').each(function () {
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
|
||||||
|
|
@ -463,68 +484,17 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} */
|
|
||||||
|
|
||||||
function preventDuplicateDoctors() {
|
|
||||||
let selectedDoctorIds = [];
|
|
||||||
|
|
||||||
// Step 1: Collect all currently selected doctor values
|
|
||||||
$('select[id^="field-contact_id"]').each(function () {
|
|
||||||
let val = $(this).val();
|
|
||||||
if (val && val !== '') {
|
|
||||||
selectedDoctorIds.push(String(val));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Step 2: Traverse each doctor select element and update option states
|
|
||||||
$('select[id^="field-contact_id"]').each(function () {
|
|
||||||
let $currentSelect = $(this);
|
|
||||||
let currentVal = String($currentSelect.val() || '');
|
|
||||||
|
|
||||||
$currentSelect.find('option').each(function () {
|
|
||||||
let $option = $(this);
|
|
||||||
let optionVal = String($option.val() || '');
|
|
||||||
|
|
||||||
// Skip the default placeholder option
|
|
||||||
if (!optionVal) return;
|
|
||||||
|
|
||||||
// Clean any previously appended '(Already Added)' tags
|
|
||||||
let rawText = $option.text().replace(/\s*\(Already Added\)/g, '').trim();
|
|
||||||
|
|
||||||
// If selected in another dropdown, disable and tag it
|
|
||||||
if (selectedDoctorIds.includes(optionVal) && optionVal !== currentVal) {
|
|
||||||
$option.prop('disabled', true);
|
|
||||||
$option.text(rawText + ' (Already Added)');
|
|
||||||
} else {
|
|
||||||
$option.prop('disabled', false);
|
|
||||||
$option.text(rawText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Step 3: Refresh Select2 cleanly to render updated disabled states
|
|
||||||
if ($currentSelect.hasClass("select2-hidden-accessible")) {
|
|
||||||
$currentSelect.select2('destroy');
|
|
||||||
}
|
|
||||||
$currentSelect.select2({
|
|
||||||
width: '100%',
|
|
||||||
placeholder: '-- Select Doctor --'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Preserve the selected value
|
|
||||||
$currentSelect.val(currentVal);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(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 id = $(this).attr('id').split('-').prop(); // get doctor_count dynamically
|
let id = $(this).attr('id').split('-').pop(); // get doctor_count dynamically
|
||||||
|
|
||||||
|
|
||||||
$('#field-msl_code-' + id).val(selectedOption.attr('msl_code'));
|
$('#field-msl_code-' + id).val(selectedOption.attr('msl_code'));
|
||||||
$('#field-pcode-' + id).val(selectedOption.attr('pcode'));
|
|
||||||
$('#field-speciality-' + id).val(selectedOption.attr('speciality'));
|
$('#field-speciality-' + id).val(selectedOption.attr('speciality'));
|
||||||
|
|
||||||
preventDuplicateDoctors();
|
preventDuplicateDoctors();
|
||||||
|
|
@ -584,35 +554,6 @@
|
||||||
@endif
|
@endif
|
||||||
</select>
|
</select>
|
||||||
@break
|
@break
|
||||||
@case('checkbox')
|
|
||||||
<div class="checkbox-group">
|
|
||||||
@if(isset($question->options) && count($question->options) > 0)
|
|
||||||
@foreach($question->options as $option)
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input"
|
|
||||||
type="checkbox"
|
|
||||||
id="field-{{$question->code}}-${doctor_count}-{{ $loop->index }}"
|
|
||||||
name="{{$question->code}}[${doctor_count}][]"
|
|
||||||
value="{{ $option->value }}"
|
|
||||||
{{ isset($question->value) && (is_array($question->value) ? in_array($option->value, $question->value) : $question->value == $option->value) ? 'checked' : '' }}>
|
|
||||||
<label class="form-check-label" for="field-{{$question->code}}-${doctor_count}-{{ $loop->index }}">
|
|
||||||
{{ $option->display }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
@endforeach
|
|
||||||
@else
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input"
|
|
||||||
type="checkbox"
|
|
||||||
id="field-{{$question->code}}-${doctor_count}"
|
|
||||||
name="{{$question->code}}[${doctor_count}]"
|
|
||||||
value="1"
|
|
||||||
{{ isset($question->value) && $question->value ? 'checked' : '' }}>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
@break
|
|
||||||
|
|
||||||
@endswitch
|
@endswitch
|
||||||
</div>
|
</div>
|
||||||
@endforeach </div>`;
|
@endforeach </div>`;
|
||||||
|
|
@ -637,7 +578,6 @@
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$('#field-msl_code-'+doctor_count).attr('readonly',true);
|
$('#field-msl_code-'+doctor_count).attr('readonly',true);
|
||||||
$('#field-pcode-'+doctor_count).attr('readonly',true);
|
|
||||||
$('#field-speciality-'+doctor_count).attr('readonly',true);
|
$('#field-speciality-'+doctor_count).attr('readonly',true);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -697,11 +637,6 @@
|
||||||
$('#field-contact_id').change(function() {
|
$('#field-contact_id').change(function() {
|
||||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
$('#field-contact_id').change(function() {
|
|
||||||
$('#field-pcode').val($('option:selected', this).attr('pcode'))
|
|
||||||
})
|
|
||||||
|
|
||||||
$('#field-contact_id').change(function() {
|
$('#field-contact_id').change(function() {
|
||||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||||
|
|
@ -713,20 +648,12 @@
|
||||||
console.log(hierarchy)
|
console.log(hierarchy)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
$('#report-form').on('submit', function(event) {
|
$('#report-form').on('submit', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
/* if (numberOfSubmission !=9) {
|
if (numberOfSubmission !=10) {
|
||||||
alert(`You must submit 10 Doctors for Levoswitch , Current Doctors : ${numberOfSubmission+1}`);
|
alert(`You must submit 10 Doctors for Levoswitch , Current Doctors : ${numberOfSubmission+1}`);
|
||||||
return;
|
return;
|
||||||
} */
|
|
||||||
|
|
||||||
if (!isEditMode) {
|
|
||||||
let currentTotal = $('.doctor-wrapper').length;
|
|
||||||
if (currentTotal !== 10) {
|
|
||||||
alert(`You must submit 10 Doctors for Levoswitch, Current Doctors: ${currentTotal}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -760,6 +687,308 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script> --}}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
jQuery(document).ready(function($) {
|
||||||
|
|
||||||
|
// Check whether the form is loaded in Edit Mode
|
||||||
|
var isEditMode = @json((bool)$id);
|
||||||
|
|
||||||
|
// Auto-fill metadata fields (MSL Code, Pcode, Speciality) dynamically
|
||||||
|
$(document).on('change', 'select[id^="field-contact_id"]', function() {
|
||||||
|
let selectedOption = $(this).find(':selected');
|
||||||
|
let idParts = $(this).attr('id').split('-');
|
||||||
|
let suffix = idParts.length > 2 ? '-' + idParts[2] : '';
|
||||||
|
|
||||||
|
$('#field-msl_code' + suffix).val(selectedOption.attr('msl_code') || '');
|
||||||
|
$('#field-pcode' + suffix).val(selectedOption.attr('pcode') || '');
|
||||||
|
$('#field-speciality' + suffix).val(selectedOption.attr('speciality') || '');
|
||||||
|
|
||||||
|
// Refresh disabled options across all doctor dropdowns
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Restrict brand name inputs to letters and spaces only
|
||||||
|
$(document).on('input', 'input[id^="field-brand_name"]', function () {
|
||||||
|
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize Select2 elements helper
|
||||||
|
function initSelect2(selector, placeholderText) {
|
||||||
|
$(selector).each(function() {
|
||||||
|
if ($(this).hasClass("select2-hidden-accessible")) {
|
||||||
|
$(this).select2('destroy');
|
||||||
|
}
|
||||||
|
$(this).select2({
|
||||||
|
width: '100%',
|
||||||
|
placeholder: placeholderText || '-- Select --'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Core logic to disable already selected doctors in other dropdowns
|
||||||
|
function preventDuplicateDoctors() {
|
||||||
|
let selectedDoctorIds = [];
|
||||||
|
|
||||||
|
// Step 1: Collect all currently selected doctor values
|
||||||
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
let val = $(this).val();
|
||||||
|
if (val && val !== '') {
|
||||||
|
selectedDoctorIds.push(String(val));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Step 2: Traverse each doctor select element and update option states
|
||||||
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
let $currentSelect = $(this);
|
||||||
|
let currentVal = String($currentSelect.val() || '');
|
||||||
|
|
||||||
|
$currentSelect.find('option').each(function () {
|
||||||
|
let $option = $(this);
|
||||||
|
let optionVal = String($option.val() || '');
|
||||||
|
|
||||||
|
// Skip the default placeholder option
|
||||||
|
if (!optionVal) return;
|
||||||
|
|
||||||
|
// Clean any previously appended '(Already Added)' tags
|
||||||
|
let rawText = $option.text().replace(/\s*\(Already Added\)/g, '').trim();
|
||||||
|
|
||||||
|
// If selected in another dropdown, disable and tag it
|
||||||
|
if (selectedDoctorIds.includes(optionVal) && optionVal !== currentVal) {
|
||||||
|
$option.prop('disabled', true);
|
||||||
|
$option.text(rawText + ' (Already Added)');
|
||||||
|
} else {
|
||||||
|
$option.prop('disabled', false);
|
||||||
|
$option.text(rawText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Step 3: Refresh Select2 cleanly to render updated disabled states
|
||||||
|
if ($currentSelect.hasClass("select2-hidden-accessible")) {
|
||||||
|
$currentSelect.select2('destroy');
|
||||||
|
}
|
||||||
|
$currentSelect.select2({
|
||||||
|
width: '100%',
|
||||||
|
placeholder: '-- Select Doctor --'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Preserve the selected value
|
||||||
|
$currentSelect.val(currentVal);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial setup on page load
|
||||||
|
initSelect2('select[id^="field-contact_id"]', '-- Select Doctor --');
|
||||||
|
initSelect2('#field-user_id', '-- Select User / Territory --');
|
||||||
|
initSelect2('select[id^="execution-"]');
|
||||||
|
$('#field-msl_code,#field-pcode,#field-speciality').attr('readonly', true);
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
|
||||||
|
// Calculate doctor count based on existing elements
|
||||||
|
var doctor_count = $('.doctor-wrapper').length ? ($('.doctor-wrapper').length - 1) : 0;
|
||||||
|
|
||||||
|
// Add doctor row dynamically
|
||||||
|
$('#adddoctor-btn').click(function() {
|
||||||
|
if ($('.doctor-wrapper').length >= 10) {
|
||||||
|
alert('You can only add up to 10 doctors.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
doctor_count++;
|
||||||
|
|
||||||
|
// Clean clone of doctor options from the primary select element
|
||||||
|
let $temp = $('#field-contact_id').clone();
|
||||||
|
$temp.find('option').each(function() {
|
||||||
|
$(this).prop('disabled', false);
|
||||||
|
$(this).text($(this).text().replace(/\s*\(Already Added\)/g, '').trim());
|
||||||
|
});
|
||||||
|
let doctorName = $temp.html();
|
||||||
|
|
||||||
|
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')
|
||||||
|
<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' : '' }}>
|
||||||
|
{{ $option->display }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
</select>
|
||||||
|
@break
|
||||||
|
@case('checkbox')
|
||||||
|
<div class="checkbox-group">
|
||||||
|
@if(isset($question->options) && count($question->options) > 0)
|
||||||
|
@foreach($question->options as $option)
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-${doctor_count}-{{ $loop->index }}" name="{{$question->code}}[${doctor_count}][]" value="{{ $option->value }}">
|
||||||
|
<label class="form-check-label" for="field-{{$question->code}}-${doctor_count}-{{ $loop->index }}">
|
||||||
|
{{ $option->display }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@break
|
||||||
|
@endswitch
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
let $newRow = $(empty_doctor);
|
||||||
|
$('#doctor-group-wrapper').append($newRow);
|
||||||
|
|
||||||
|
// Initialize Select2 on the new elements
|
||||||
|
initSelect2('#field-contact_id-' + doctor_count, '-- Select Doctor --');
|
||||||
|
initSelect2($newRow.find('select[id^="execution-"]'));
|
||||||
|
|
||||||
|
// Set readonly attributes for metadata inputs in the new card
|
||||||
|
$('#field-msl_code-' + doctor_count).attr('readonly', true);
|
||||||
|
$('#field-pcode-' + doctor_count).attr('readonly', true);
|
||||||
|
$('#field-speciality-' + doctor_count).attr('readonly', true);
|
||||||
|
|
||||||
|
// Update duplicate validation state
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
|
||||||
|
// Toggle Add Button visibility
|
||||||
|
if ($('.doctor-wrapper').length >= 10) {
|
||||||
|
$('#adddoctor-btn').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove a doctor row
|
||||||
|
$(document).on('click', '.btn-remove', function() {
|
||||||
|
let $row = $(this).closest('.doctor-wrapper');
|
||||||
|
$row.find('select').each(function() {
|
||||||
|
if ($(this).hasClass("select2-hidden-accessible")) {
|
||||||
|
$(this).select2('destroy');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$row.remove();
|
||||||
|
|
||||||
|
// Re-enable options freed by removing this doctor
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
|
||||||
|
if ($('.doctor-wrapper').length < 10) {
|
||||||
|
$('#adddoctor-btn').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Territory / User dropdown dynamic change
|
||||||
|
$('#field-user_id').change(function(event){
|
||||||
|
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||||
|
$('#field-hierarchy_id').val(hierarchy);
|
||||||
|
$('#pageloader').fadeIn();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function(data) {
|
||||||
|
$("#pageloader").fadeOut();
|
||||||
|
let $contactSelect = $('#field-contact_id');
|
||||||
|
$contactSelect.empty().append($("<option></option>").attr("value", '').text('-- Select --'));
|
||||||
|
|
||||||
|
for (let itm of data) {
|
||||||
|
$contactSelect.append(
|
||||||
|
$("<option></option>")
|
||||||
|
.attr("value", itm.value)
|
||||||
|
.text(itm.display)
|
||||||
|
.attr("msl_code", itm.contact ? itm.contact.msl_code : '')
|
||||||
|
.attr("pcode", itm.contact ? itm.contact.pcode : '')
|
||||||
|
.attr("speciality", itm.contact ? itm.contact.speciality : '')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$contactSelect.val('').trigger('change.select2');
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Form submit handler
|
||||||
|
$('#report-form').on('submit', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
let currentTotal = $('.doctor-wrapper').length;
|
||||||
|
|
||||||
|
// Only enforce 10 submissions in Create Mode
|
||||||
|
if (!isEditMode && currentTotal !== 10) {
|
||||||
|
alert(`You must submit 10 Doctors for Levoswitch, Current Doctors: ${currentTotal}`);
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
$('#report-form').trigger("reset");
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Data not submitted',
|
||||||
|
text: data.message || 'Something went wrong, please try again after some time!'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
$("#pageloader").fadeOut();
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Server Error',
|
||||||
|
text: 'Something went wrong, please try again after some time!'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue