team4 changes
This commit is contained in:
parent
963e1e0b3e
commit
3df1e8bf74
|
|
@ -60,7 +60,7 @@
|
|||
<th>Camp Plan Date</th>
|
||||
<th>Execution Done</th>
|
||||
<th>Doctor Name</th>
|
||||
<th>Other Doctor Name</th>
|
||||
{{-- <th>Other Doctor Name</th> --}}
|
||||
<th>Camp Execution Date</th>
|
||||
|
||||
<th>Reporting Date</th>
|
||||
|
|
@ -110,19 +110,19 @@
|
|||
$today=date('d',strtotime("-1 months"));
|
||||
|
||||
?>
|
||||
@if($sub->workflow_status == 'approved')
|
||||
|
||||
@if ( $planDate && $planDate->between($startOfCurrentMonth, $fifthOfNextMonth) && $now->greaterThanOrEqualTo($planDate))
|
||||
<button type="button" class="btn btn-xs btn-info edit-btn"
|
||||
plan_details="{{ json_encode($sub->formdata) }}"><i
|
||||
class="mdi mdi-pencil"></i> Edit</button>
|
||||
|
||||
@endif
|
||||
@elseif ($sub->workflow_status == 'rejected' ||
|
||||
|
||||
{{-- @elseif ($sub->workflow_status == 'rejected' ||
|
||||
(isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'no'))
|
||||
<button type="button" class="btn btn-xs btn-info edit-plan-btn"
|
||||
plan_details="{{ json_encode($sub->formdata) }}">
|
||||
<i class="mdi mdi-pencil"></i> Edit Plan
|
||||
</button>
|
||||
</button> --}}
|
||||
@endif
|
||||
|
||||
</td>
|
||||
|
|
@ -142,17 +142,18 @@
|
|||
{{ '' }}
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
|
||||
{{-- <td>
|
||||
@if (isset($sub->formdata->contact_id_2) && $sub->formdata->contact_id_2
|
||||
!== '')
|
||||
{{ $sub->formdata->contact_id_2 }}
|
||||
@elseif (isset($sub->formdata->doctor_name))
|
||||
{{ $sub->formdata->doctor_name }}
|
||||
@else
|
||||
{{-- Default value or empty string, adjust as needed --}}
|
||||
|
||||
{{ '' }}
|
||||
@endif
|
||||
</td>
|
||||
</td> --}}
|
||||
<td>{{$sub->formdata->execution_date}}</td>
|
||||
<td>{{isset($sub->formdata->record_date ) ? $sub->formdata->record_date : ''}}
|
||||
</td>
|
||||
|
|
@ -247,16 +248,20 @@
|
|||
<option value=""> -- Select -- </option>
|
||||
@if ($question->code == 'contact_id')
|
||||
@foreach ($question->options as $option)
|
||||
@if( isset($option->contact->ardc_camp_doctor_octnov) && $option->contact->ardc_camp_doctor_octnov == 'Yes' )
|
||||
<option value="{{ $option->value }}" legacy_code="{{isset($option->contact->legacy_code)?$option->contact->legacy_code:''}}" speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||
|
||||
<option value="{{ $option->value }}"
|
||||
legacy_code="{{isset($option->contact->legacy_code)?$option->contact->legacy_code:''}}"
|
||||
speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
||||
ardc_css_restricted_drs="{{isset($option->contact->ardc_css_restricted_drs)?$option->contact->ardc_css_restricted_drs:''}}"
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
|
||||
|
||||
@endforeach
|
||||
<option value="others" {{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>
|
||||
{{-- <option value="others" {{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>
|
||||
others
|
||||
</option>
|
||||
</option> --}}
|
||||
@elseif($question->code=='contact_id_2')
|
||||
@foreach ($question->options as $option)
|
||||
|
||||
|
|
@ -534,7 +539,7 @@
|
|||
});
|
||||
|
||||
$('#execution-total_rxns').prop({"readonly":true});
|
||||
$('#execution-executed_as_per_plan').prop("disabled",true);
|
||||
//$('#execution-executed_as_per_plan').prop("disabled",true);
|
||||
|
||||
// $('#execution-patients_diagnosed').on('change',function(){
|
||||
// let a=document.getElementById('execution-patients_diagnosed');
|
||||
|
|
@ -572,10 +577,10 @@
|
|||
e.preventDefault();
|
||||
})
|
||||
|
||||
let contact2 = document.getElementById('execution-contact_id_2');
|
||||
/* let contact2 = document.getElementById('execution-contact_id_2');
|
||||
contact2.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
}) */
|
||||
|
||||
|
||||
let camp_planned_start = document.getElementById('execution-camp_planned_start_time');
|
||||
|
|
@ -666,6 +671,8 @@
|
|||
$('#execution-form').append('<input type="hidden" name="execution_done" value="yes">');
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
$('.edit-plan-btn').click(function() {
|
||||
$('#execution-form-wrapper').show(100, () => {
|
||||
$('#add-camp-btn').hide(0);
|
||||
|
|
@ -772,6 +779,10 @@
|
|||
}
|
||||
|
||||
})
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
|
|
@ -819,12 +830,30 @@
|
|||
|
||||
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
/*$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('legacy_code'))
|
||||
})*/
|
||||
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
$('#field-msl_code').val($('option:selected', this).attr('legacy_code'))
|
||||
let restricted=$(this).find(":selected").attr('ardc_css_restricted_drs');
|
||||
console.log("restricted:",restricted);
|
||||
if (restricted === 'Yes') {
|
||||
|
||||
alert('Planning with these Doctors not allowed');
|
||||
|
||||
// Deselect current option
|
||||
$(this).val('').trigger('change');
|
||||
|
||||
// Clear msl code as well
|
||||
$('#field-msl_code').val('');
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
|
@ -974,6 +1003,95 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
// Existing submissions
|
||||
let submissions = @json($history->data->submissions);
|
||||
|
||||
function markMonthlyAddedDoctors() {
|
||||
|
||||
// Current month & year
|
||||
let today = new Date();
|
||||
|
||||
let currentMonth = today.getMonth();
|
||||
let currentYear = today.getFullYear();
|
||||
|
||||
// Store doctors already added this month
|
||||
let addedDoctors = [];
|
||||
|
||||
submissions.forEach(function(submission){
|
||||
|
||||
let doctorName = submission.formdata?.contact_id ?? '';
|
||||
let planDate = submission.formdata?.plan_date ?? '';
|
||||
|
||||
if (!doctorName || !planDate) return;
|
||||
|
||||
let existingDate = new Date(planDate);
|
||||
|
||||
let existingMonth = existingDate.getMonth();
|
||||
let existingYear = existingDate.getFullYear();
|
||||
|
||||
// Same current month + year
|
||||
if (
|
||||
existingMonth === currentMonth &&
|
||||
existingYear === currentYear
|
||||
) {
|
||||
addedDoctors.push(doctorName.trim());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Update dropdown options
|
||||
$('#field-contact_id option').each(function(){
|
||||
|
||||
let optionText = $(this).text().replace(' (Already added)', '').trim();
|
||||
|
||||
// Reset old text
|
||||
$(this).text(optionText);
|
||||
|
||||
// Skip placeholder
|
||||
if ($(this).val() === '') return;
|
||||
|
||||
// If doctor already added this month
|
||||
if (addedDoctors.includes(optionText)) {
|
||||
|
||||
$(this).text(optionText + ' (Already added)');
|
||||
$(this).attr('data-added', 'yes');
|
||||
|
||||
} else {
|
||||
|
||||
$(this).removeAttr('data-added');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Run initially
|
||||
markMonthlyAddedDoctors();
|
||||
|
||||
// Prevent selection
|
||||
$('#field-contact_id').change(function () {
|
||||
|
||||
let selectedOption = $(this).find(':selected');
|
||||
|
||||
let alreadyAdded = selectedOption.attr('data-added');
|
||||
|
||||
if (alreadyAdded === 'yes') {
|
||||
|
||||
alert('Doctor already added in this month');
|
||||
|
||||
$(this).val('').trigger('change');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -71,6 +71,14 @@ if (!empty($history->data->submissions)) {
|
|||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
echo "<div class='container'>";
|
||||
echo "<pre>";
|
||||
print_r($history->data->submissions);
|
||||
echo "</pre>";
|
||||
|
||||
echo "</div>";
|
||||
*/
|
||||
@endphp
|
||||
|
||||
|
||||
|
|
@ -128,7 +136,7 @@ if (!empty($history->data->submissions)) {
|
|||
<th>Camp Plan Date</th>
|
||||
<th>Execution Done</th>
|
||||
<th>Doctor Name</th>
|
||||
<th>Other Doctor Name</th>
|
||||
{{-- <th>Other Doctor Name</th> --}}
|
||||
<th>Camp Execution Date</th>
|
||||
<th>Legacy Code</th>
|
||||
<th>Speciality</th>
|
||||
|
|
@ -172,19 +180,19 @@ if (!empty($history->data->submissions)) {
|
|||
|
||||
<tr>
|
||||
<td>
|
||||
@if($sub->workflow_status == 'approved')
|
||||
|
||||
@if ( $planDate && $planDate->between($startOfCurrentMonth, $fifthOfNextMonth) && $now->greaterThanOrEqualTo($planDate))
|
||||
<button type="button" class="btn btn-xs btn-info edit-btn"
|
||||
plan_details="{{ json_encode($sub->formdata) }}"><i
|
||||
class="mdi mdi-pencil"></i> Edit</button>
|
||||
|
||||
@endif
|
||||
@elseif ($sub->workflow_status == 'rejected' ||
|
||||
|
||||
{{-- @elseif ($sub->workflow_status == 'rejected' ||
|
||||
(isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'no'))
|
||||
<button type="button" class="btn btn-xs btn-info edit-plan-btn"
|
||||
plan_details="{{ json_encode($sub->formdata) }}">
|
||||
<i class="mdi mdi-pencil"></i> Edit Plan
|
||||
</button>
|
||||
</button> --}}
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $sub->formdata->plan_date }}</td>
|
||||
|
|
@ -202,17 +210,17 @@ if (!empty($history->data->submissions)) {
|
|||
{{ '' }}
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
{{-- <td>
|
||||
@if (isset($sub->formdata->contact_id_2) && $sub->formdata->contact_id_2
|
||||
!== '')
|
||||
{{ $sub->formdata->contact_id_2 }}
|
||||
@elseif (isset($sub->formdata->doctor_name))
|
||||
{{ $sub->formdata->doctor_name }}
|
||||
@else
|
||||
{{-- Default value or empty string, adjust as needed --}}
|
||||
|
||||
{{ '' }}
|
||||
@endif
|
||||
</td>
|
||||
</td> --}}
|
||||
<td>{{$sub->formdata->execution_date}}</td>
|
||||
<td>{{isset($sub->formdata->msl_code) ? $sub->formdata->msl_code : '' }}
|
||||
</td>
|
||||
|
|
@ -304,16 +312,21 @@ if (!empty($history->data->submissions)) {
|
|||
<option value=""> -- Select -- </option>
|
||||
@if ($question->code == 'contact_id')
|
||||
@foreach ($question->options as $option)
|
||||
@if( isset($option->contact->css_camp_doctor_octnov) && $option->contact->css_camp_doctor_octnov == 'Yes' )
|
||||
<option value="{{ $option->value }}" msl_code="{{isset($option->contact->legacy_code)?$option->contact->legacy_code:''}}" speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||
@if ($option->contact->type == 'doctor')
|
||||
<option value="{{ $option->value }}"
|
||||
msl_code="{{isset($option->contact->legacy_code)?$option->contact->legacy_code:''}}"
|
||||
speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
||||
ardc_css_restricted_drs="{{isset($option->contact->ardc_css_restricted_drs)?$option->contact->ardc_css_restricted_drs:''}}"
|
||||
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
<option value="others" {{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>
|
||||
{{-- <option value="others" {{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>
|
||||
others
|
||||
</option>
|
||||
</option> --}}
|
||||
@elseif($question->code=='contact_id_2')
|
||||
@foreach ($question->options as $option)
|
||||
|
||||
|
|
@ -424,9 +437,9 @@ if (!empty($history->data->submissions)) {
|
|||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
<option value="others"{{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>
|
||||
{{-- <option value="others"{{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>
|
||||
others
|
||||
</option>
|
||||
</option> --}}
|
||||
|
||||
</select>
|
||||
|
||||
|
|
@ -599,10 +612,10 @@ if (!empty($history->data->submissions)) {
|
|||
e.preventDefault();
|
||||
})
|
||||
|
||||
let contact2 = document.getElementById('execution-contact_id_2');
|
||||
/* let contact2 = document.getElementById('execution-contact_id_2');
|
||||
contact2.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
}) */
|
||||
|
||||
// let typeOfDr = document.getElementById('execution-type_of_dr');
|
||||
// typeOfDr.addEventListener('mousedown', function(e) {
|
||||
|
|
@ -696,6 +709,7 @@ if (!empty($history->data->submissions)) {
|
|||
})
|
||||
|
||||
|
||||
/*
|
||||
$('.edit-plan-btn').click(function() {
|
||||
$('#execution-form-wrapper').show(100, () => {
|
||||
$('#add-camp-btn').hide(0);
|
||||
|
|
@ -801,6 +815,9 @@ if (!empty($history->data->submissions)) {
|
|||
$typeDr.on('change', toggleFlutter);
|
||||
})
|
||||
|
||||
*/
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
|
@ -832,28 +849,28 @@ if (!empty($history->data->submissions)) {
|
|||
});
|
||||
});
|
||||
|
||||
// $('#execution-sitazit_d_rx').attr({
|
||||
// "min":0,
|
||||
// "max":50
|
||||
// });
|
||||
// $('#execution-sitazit_dm_rx').attr({
|
||||
// "min":0,
|
||||
// "max":50
|
||||
// });
|
||||
// $('#execution-ziten_m_rx').attr({
|
||||
// "min":0,
|
||||
// "max":50
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr(
|
||||
'speciality'))
|
||||
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
let restricted=$(this).find(":selected").attr('ardc_css_restricted_drs');
|
||||
console.log("restricted:",restricted);
|
||||
if (restricted === 'Yes') {
|
||||
|
||||
alert('Planning with these Doctors not allowed');
|
||||
|
||||
// Deselect current option
|
||||
$(this).val('').trigger('change');
|
||||
|
||||
// Clear msl code as well
|
||||
$('#field-msl_code').val('');
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
|
@ -883,6 +900,7 @@ if (!empty($history->data->submissions)) {
|
|||
|
||||
$('#field-contact_id_2').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
|
||||
})
|
||||
|
||||
$('#execution-form').on('submit', function(event) {
|
||||
|
|
@ -1246,8 +1264,92 @@ $(document).ready(function () {
|
|||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
// Existing submissions
|
||||
let submissions = @json($history->data->submissions);
|
||||
|
||||
function markMonthlyAddedDoctors() {
|
||||
|
||||
// Current month & year
|
||||
let today = new Date();
|
||||
|
||||
let currentMonth = today.getMonth();
|
||||
let currentYear = today.getFullYear();
|
||||
|
||||
// Store doctors already added this month
|
||||
let addedDoctors = [];
|
||||
|
||||
submissions.forEach(function(submission){
|
||||
|
||||
let doctorName = submission.formdata?.contact_id ?? '';
|
||||
let planDate = submission.formdata?.plan_date ?? '';
|
||||
|
||||
if (!doctorName || !planDate) return;
|
||||
|
||||
let existingDate = new Date(planDate);
|
||||
|
||||
let existingMonth = existingDate.getMonth();
|
||||
let existingYear = existingDate.getFullYear();
|
||||
|
||||
// Same current month + year
|
||||
if (
|
||||
existingMonth === currentMonth &&
|
||||
existingYear === currentYear
|
||||
) {
|
||||
addedDoctors.push(doctorName.trim());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Update dropdown options
|
||||
$('#field-contact_id option').each(function(){
|
||||
|
||||
let optionText = $(this).text().replace(' (Already added)', '').trim();
|
||||
|
||||
// Reset old text
|
||||
$(this).text(optionText);
|
||||
|
||||
// Skip placeholder
|
||||
if ($(this).val() === '') return;
|
||||
|
||||
// If doctor already added this month
|
||||
if (addedDoctors.includes(optionText)) {
|
||||
|
||||
$(this).text(optionText + ' (Already added)');
|
||||
$(this).attr('data-added', 'yes');
|
||||
|
||||
} else {
|
||||
|
||||
$(this).removeAttr('data-added');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Run initially
|
||||
markMonthlyAddedDoctors();
|
||||
|
||||
// Prevent selection
|
||||
$('#field-contact_id').change(function () {
|
||||
|
||||
let selectedOption = $(this).find(':selected');
|
||||
|
||||
let alreadyAdded = selectedOption.attr('data-added');
|
||||
|
||||
if (alreadyAdded === 'yes') {
|
||||
|
||||
alert('Doctor already added in this month');
|
||||
|
||||
$(this).val('').trigger('change');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,57 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
@include('layouts.shared/title-meta', ['title' => "Form"])
|
||||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
||||
<link href="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">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</div>
|
||||
|
||||
<body class="loading">
|
||||
<div class="account-pages">
|
||||
<div class="container">
|
||||
|
|
@ -24,7 +68,8 @@
|
|||
<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>
|
||||
|
|
@ -38,11 +83,19 @@
|
|||
<h6>Submitted By: {{$form->user_info->name}}</h6>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@php
|
||||
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||
$submissions = $submissions->data->submissions;
|
||||
|
||||
|
||||
@endphp
|
||||
@if(count($submissions)===0 || $id)
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
<input type="hidden" name="id[0]" value="{{$id}}">
|
||||
@endif
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
<div class="col-md-12 mb-2">
|
||||
|
|
@ -56,83 +109,181 @@
|
|||
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@foreach($questions as $question)
|
||||
<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>
|
||||
@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}}"
|
||||
name="{{$question->code}}"
|
||||
value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('text')
|
||||
@case('email')
|
||||
@case('tel')
|
||||
@case('date')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||
name="{{$question->code}}" 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}}" name="{{$question->code}}" class="form-control"
|
||||
{{$question->required == 'yes'?'required':'' }}
|
||||
value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
@case('textarea')
|
||||
<textarea id="field-{{$question->code}}" name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@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>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="doctor-wrapper">
|
||||
|
||||
@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}}" name="{{$question->code}}" value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||
name="{{$question->code}}[0]"
|
||||
value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('text')
|
||||
@case('email')
|
||||
@case('tel')
|
||||
@case('date')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||
name="{{$question->code}}[0]" 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}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
<input type="{{$question->type}}" min="0" max="9999999999" step="1"
|
||||
id="field-{{$question->code}}" name="{{$question->code}}[0]"
|
||||
class="form-control" {{$question->required == 'yes'?'required':'' }}
|
||||
value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
@case('textarea')
|
||||
<textarea id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@break
|
||||
<textarea id="field-{{$question->code}}" name="{{$question->code}}[0]"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@break
|
||||
@case('dropdown')
|
||||
<select class="form-control" id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@if ($question->code == 'contact_id')
|
||||
@foreach ($question->options as $option)
|
||||
@if( isset($option->contact->montair_lc_kid_non_rxber_survey) && $option->contact->montair_lc_kid_non_rxber_survey == 'Yes' )
|
||||
<option value="{{ $option->value }}" speciality="{{isset($option->contact->speciality)?$option->contact->speciality:''}}" msl_code="{{isset($option->contact->msl_code)?$option->contact->msl_code:''}}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
@else
|
||||
@foreach ($question->options as $option)
|
||||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
@endforeach
|
||||
@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>
|
||||
@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>
|
||||
@break
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<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':''}}>
|
||||
<label class="form-check-label"
|
||||
for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) &&
|
||||
$form->is_approval != 'yes' ) )
|
||||
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}"
|
||||
class="form-control" value=""
|
||||
{{$question->required == 'yes'?'required':'' }}>
|
||||
@elseif(isset($question->value))
|
||||
<img src="{{$question->value}}" class="img-fluid">
|
||||
@endif
|
||||
|
||||
@break
|
||||
@case('multitextbox')
|
||||
<div class="row">
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
<div class="col-6">{{$option->display}}</div>
|
||||
<div class="col-6 mb-1">
|
||||
<input type="number" id="field-{{$option->value}}"
|
||||
name="{{$option->value}}" class="form-control" required
|
||||
value="{{isset($option->val)?$option->val:0}}">
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="" {{$question->required == 'yes'?'required':'' }}>
|
||||
@elseif(isset($question->value))
|
||||
<img src="{{$question->value}}" class="img-fluid">
|
||||
@endif
|
||||
|
||||
@break
|
||||
@case('multitextbox')
|
||||
<div class="row">
|
||||
@foreach($question->options as $option)
|
||||
<div class="col-6">{{$option->display}}</div>
|
||||
<div class="col-6 mb-1">
|
||||
<input type="number" id="field-{{$option->value}}" name="{{$option->value}}" class="form-control" required value="{{isset($option->val)?$option->val:0}}">
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
@endforeach
|
||||
</div>
|
||||
<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">
|
||||
@if(!$id)
|
||||
<button class="btn btn-primary" type="button" id="adddoctor-btn"> Add Doctor </button>
|
||||
@endif
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
@elseif(!$id)
|
||||
<h4>You have submitted 10 doctors</h4>
|
||||
@endif
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
|
@ -146,37 +297,415 @@
|
|||
<!-- end container -->
|
||||
</div>
|
||||
<!-- end page -->
|
||||
<style type="text/css">
|
||||
#pageloader {
|
||||
background: rgba( 255, 255, 255, 0.8 );
|
||||
display: none;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
<style type="text/css">
|
||||
#pageloader {
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
display: none;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
margin-top: -32px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
.anti-heading{
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
}
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
margin-top: -32px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.doctor-wrapper {
|
||||
border: 1px solid #ccc;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
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"));
|
||||
})
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
$('#field-speciality').val($(this).find(":selected").attr("speciality"));
|
||||
})
|
||||
|
||||
$('#field-msl_code,#field-speciality').attr('readonly',true);
|
||||
|
||||
function initializeSelect2() {
|
||||
|
||||
$('select[id^="field-contact_id"]').select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
$('#field-user_id').select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select User / Territory --'
|
||||
});
|
||||
|
||||
$('select[id^="execution-"]').select2({
|
||||
width: '100%'
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('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 previous label
|
||||
let cleanText = option.text().replace(' (Already Added)', '');
|
||||
|
||||
// IMPORTANT:
|
||||
// keep currently selected option enabled
|
||||
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');
|
||||
}
|
||||
|
||||
currentSelect.select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
// VERY IMPORTANT FOR EDIT MODE
|
||||
currentSelect.val(currentValue).trigger('change.select2');
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(document).on('change', 'select[id^="field-contact_id"]', function () {
|
||||
|
||||
let selectedOption = $(this).find(':selected');
|
||||
|
||||
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'));
|
||||
$('#field-msl_code-'+id).attr('readonly',true);
|
||||
$('#field-speciality-'+id).attr('readonly',true);
|
||||
|
||||
preventDuplicateDoctors();
|
||||
});
|
||||
|
||||
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').parent().hide();
|
||||
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').attr('required',false);
|
||||
|
||||
$('#execution-prescriber').on('change',function(){
|
||||
let value=$(this).val();
|
||||
console.log("Prescriber : ",value);
|
||||
if(value==='Yes'){
|
||||
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').parent().show();
|
||||
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').attr('required',true);
|
||||
|
||||
}
|
||||
else{
|
||||
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').parent().hide();
|
||||
$('#field-monthly_prescription_value,#field-potential_prescription_value,#field-current_prescription_value').attr('required',false);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
var doctor_count = 0
|
||||
let numberOfSubmission=0;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
$('#adddoctor-btn').click(function() {
|
||||
let doctorName=$('#field-contact_id').html();
|
||||
|
||||
console.log("Doctor Name : ",doctorName);
|
||||
doctor_count++;
|
||||
numberOfSubmission=numberOfSubmission+1;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
|
||||
let empty_doctor = `
|
||||
|
||||
<div class="doctor-wrapper">
|
||||
@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({
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
|
||||
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();
|
||||
}) */
|
||||
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
|
||||
$('#field-monthly_prescription_value-' + i).closest('.col-md-12').hide();
|
||||
$('#field-potential_prescription_value-' + i).closest('.col-md-12').hide();
|
||||
$('#field-current_prescription_value-' + i).closest('.col-md-12').hide();
|
||||
|
||||
$('#field-monthly_prescription_value-' + i).prop('required',false);
|
||||
$('#field-potential_prescription_value-' + i).prop('required',false);
|
||||
$('#field-current_prescription_value-' + i).prop('required',false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Show/Hide fields based on Prescriber dropdown
|
||||
$(document).on('change', 'select[id^="field-prescriber-"]', function () {
|
||||
|
||||
let id = $(this).attr('id').split('-').pop();
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if (value === 'Yes') {
|
||||
|
||||
$('#field-monthly_prescription_value-' + id)
|
||||
.closest('.col-md-12')
|
||||
.show();
|
||||
|
||||
$('#field-potential_prescription_value-' + id)
|
||||
.closest('.col-md-12')
|
||||
.show();
|
||||
|
||||
$('#field-current_prescription_value-' + id)
|
||||
.closest('.col-md-12')
|
||||
.show();
|
||||
|
||||
$('#field-monthly_prescription_value-' + id).prop('required',true);
|
||||
$('#field-potential_prescription_value-' + id).prop('required',true);
|
||||
$('#field-current_prescription_value-' + id).prop('required',true);
|
||||
|
||||
} else {
|
||||
|
||||
$('#field-monthly_prescription_value-' + id)
|
||||
.closest('.col-md-12')
|
||||
.hide();
|
||||
|
||||
$('#field-potential_prescription_value-' + id)
|
||||
.closest('.col-md-12')
|
||||
.hide();
|
||||
|
||||
$('#field-current_prescription_value-' + id)
|
||||
.closest('.col-md-12')
|
||||
.hide();
|
||||
|
||||
$('#field-monthly_prescription_value-' + id).prop('required',false);
|
||||
$('#field-potential_prescription_value-' + id).prop('required',false);
|
||||
$('#field-current_prescription_value-' + id).prop('required',false);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Trigger once on page load (important for edit mode)
|
||||
$('select[id^="field-prescriber-"]').trigger('change');
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
for (let i = 0; i < 9; i++) {
|
||||
$('#adddoctor-btn').trigger('click');
|
||||
}
|
||||
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#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,
|
||||
|
|
@ -186,157 +715,48 @@
|
|||
$("#pageloader").fadeOut();
|
||||
$('#field-contact_id').html('')
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
||||
for(let itm of data) {
|
||||
if(itm.contact.hasOwnProperty('montair_lc_kid_non_rxber_survey') && itm.contact.montair_lc_kid_non_rxber_survey.toLowerCase() == 'yes') {
|
||||
console.log(itm)
|
||||
$('#field-contact_id').append($("<option></option>").attr("msl_code", itm.contact.msl_code).attr("value", itm.value).text(itm.display));
|
||||
}
|
||||
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').unbind()
|
||||
$('#field-contact_id').change(function(){
|
||||
$('#field-msl_code').val( $('option:selected', this).attr('sbu_code') );
|
||||
})
|
||||
|
||||
$('#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)
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-speciality').val($('option:selected', this).attr(
|
||||
'speciality'))
|
||||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||
})
|
||||
|
||||
$('#field-msl_code,#field-speciality').attr('readonly',true);
|
||||
|
||||
//$('label[for="field-cough"]').html("<h4>In What % of patients do you prescribe ANTI HISTAMINE? </h4>Cough")
|
||||
$('label[for="field-seasonal_ar"]').html("<h5>4) Duration of Treatment : </h5>A) Seasonal AR <span class='text-danger'>*</span>");
|
||||
$('label[for="field-perrenial_ar"]').html("B) PERRENIAL AR <span class='text-danger'>*</span>");
|
||||
|
||||
$('label[for="field-in_what_conditions_do_you_prescribe_anti_histamine-Asthma"]').after('<h5 class="anti-heading">2)In what % of patients do you prescribe ANTI HISTAMINE?</h5>');
|
||||
|
||||
$('label[for="field-in_what_conditions_do_you_prescribe_anti_histamine"]').html('1) In what conditions do you prescribe ANTI HISTAMINE ?<span class="text-danger">*</span>')
|
||||
|
||||
$('label[for="field-which_is_your_preferred_anti_histamine"]').html("3)Which is your preferred ANTI HISTAMINE ? <span class='text-danger'>*</span>")
|
||||
|
||||
$('label[for="field-reason_to_prefer_a_brand"]').html('5) Reason to prefer a brand <span class="text-danger">*</span>');
|
||||
$('label[for="field-reasons_to_not_prescribe_montair_lc_kid"]').html('6) Reasons to NOT PRESCRIBE MONTAIR LC KID <span class="text-danger">*</span>')
|
||||
|
||||
$('label[for="field-cough"]').html('Cough<span class="text-danger">*</span>');
|
||||
$('label[for="field-cold"]').html('Cold<span class="text-danger">*</span>');
|
||||
$('label[for="field-fever"]').html('Fever<span class="text-danger">*</span>');
|
||||
$('label[for="field-sore_throat"]').html('Sore Throat<span class="text-danger">*</span>');
|
||||
$('label[for="field-seasonal_and_perennial_allergic_rhinitis"]').html('Seasonal & Perennial Allergic Rhinitis<span class="text-danger">*</span>');
|
||||
$('label[for="field-asthma"]').html('Asthma<span class="text-danger">*</span>');
|
||||
|
||||
|
||||
$('.col-md-12').has('select').has('select:not(#field-contact_id)').not(':has(.anti-heading)').each(function () {
|
||||
$(this).css({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '15px'
|
||||
});
|
||||
|
||||
$(this).find('label').css({
|
||||
width: '50%',
|
||||
marginBottom: '0'
|
||||
});
|
||||
|
||||
$(this).find('select').css({
|
||||
width: '50%'
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(document).on('click', 'input[name="seasonal_ar[]"]', function () {
|
||||
$('input[name="seasonal_ar[]"]').not(this).prop('checked', false);
|
||||
$(this).prop('checked', true);
|
||||
});
|
||||
|
||||
$(document).on('click', 'input[name="perrenial_ar[]"]', function () {
|
||||
$('input[name="perrenial_ar[]"]').not(this).prop('checked', false);
|
||||
$(this).prop('checked', true);
|
||||
});
|
||||
|
||||
$("#report-form").on("submit", function (e) {
|
||||
|
||||
$('#report-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
|
||||
let checkedCount = $('input[name="which_is_your_preferred_anti_histamine[]"]:checked').length;
|
||||
console.log("checkedCount : ",checkedCount);
|
||||
if (checkedCount === 0) {
|
||||
alert("Please select at least one option from your preferred ANTI HISTAMINE.");
|
||||
event.preventDefault(); // stop form submission
|
||||
return false;
|
||||
}
|
||||
|
||||
let checkedCount2 = $('input[name="in_what_conditions_do_you_prescribe_anti_histamine[]"]:checked').length;
|
||||
console.log("checkedCount 2 : ",checkedCount2);
|
||||
if (checkedCount2 === 0) {
|
||||
alert("Please select at least one option from what conditions do you prescribe ANTI HISTAMINE.");
|
||||
event.preventDefault(); // stop form submission
|
||||
return false;
|
||||
}
|
||||
|
||||
let checkedCount3 = $('input[name="seasonal_ar[]"]:checked').length;
|
||||
console.log("checkedCount 3 : ",checkedCount3);
|
||||
if (checkedCount3 === 0) {
|
||||
alert("Please select at least one option from Seasonal AR");
|
||||
event.preventDefault(); // stop form submission
|
||||
return false;
|
||||
}
|
||||
|
||||
let checkedCount4 = $('input[name="perrenial_ar[]"]:checked').length;
|
||||
console.log("checkedCount 4 : ",checkedCount4);
|
||||
if (checkedCount4 === 0) {
|
||||
alert("Please select at least one option from PERRENIAL AR");
|
||||
event.preventDefault(); // stop form submission
|
||||
return false;
|
||||
}
|
||||
|
||||
let checkedCount5 = $('input[name="reason_to_prefer_a_brand[]"]:checked').length;
|
||||
console.log("checkedCount 5 : ",checkedCount5);
|
||||
if (checkedCount5 === 0) {
|
||||
alert("Please select at least one option from Reason to prefer a brand");
|
||||
event.preventDefault(); // stop form submission
|
||||
return false;
|
||||
}
|
||||
|
||||
let checkedCount6 = $('input[name="reasons_to_not_prescribe_montair_lc_kid[]"]:checked').length;
|
||||
console.log("checkedCount 6 : ",checkedCount6);
|
||||
if (checkedCount6 === 0) {
|
||||
alert("Please select at least one option from Reasons to NOT PRESCRIBE MONTAIR LC KID");
|
||||
event.preventDefault(); // stop form submission
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
url: '/form/ajaxsubmitmultiple',
|
||||
data: new FormData($('#report-form')[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
success: function(data) {
|
||||
$("#pageloader").fadeOut();
|
||||
if(data.status == 'success') {
|
||||
if (data.status == 'success') {
|
||||
Swal.fire({
|
||||
title: 'Great!',
|
||||
text: 'Your data is successfully submitted!',
|
||||
icon: 'success'
|
||||
})
|
||||
title: 'Great!',
|
||||
text: 'Your data is successfully submitted!',
|
||||
icon: 'success'
|
||||
}).then(() => {
|
||||
location.reload(); // 🔥 page refresh here
|
||||
});
|
||||
$('#report-form').trigger("reset");
|
||||
} else {
|
||||
Swal.fire({
|
||||
|
|
@ -349,17 +769,8 @@
|
|||
});
|
||||
});
|
||||
|
||||
var today = new Date();
|
||||
var dd = String(today.getDate()).padStart(2, '0');
|
||||
var mm = String(today.getMonth() + 1).padStart(2, '0');
|
||||
var yyyy = today.getFullYear();
|
||||
today = yyyy + '-' + mm + '-' + dd;
|
||||
|
||||
var plandateField = document.getElementById('field-record_date');
|
||||
|
||||
//plandateField.setAttribute('max', today);
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -81,16 +81,16 @@
|
|||
</div>
|
||||
@endif
|
||||
|
||||
<!-- <div class="col-12 mb-2">
|
||||
|
||||
</div> -->
|
||||
{{-- <div class="col-12 mb-2">
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" id="add-doctor-btn">Add Doctor</button>
|
||||
</div> --}}
|
||||
|
||||
<div class="col-12" id="doctor-cards">
|
||||
<div class="card doctor-card border border-2 mb-3">
|
||||
<div class="card-body p-2">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<div class="fw-bold">Doctor</div>
|
||||
<button type="button" class="btn btn-outline-danger btn-sm remove-doctor-btn d-none">Remove</button>
|
||||
<div class="d-flex align-items-end mb-2">
|
||||
{{-- <div class="fw-bold">Doctor</div> --}}
|
||||
<button type="button" class="btn btn-outline-danger btn-sm remove-doctor-btn d-none ms-auto">Remove</button>
|
||||
</div>
|
||||
|
||||
@foreach($doctorQuestions as $question)
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
<input type="{{$question->type}}" name="{{$question->code}}[]" data-code="{{$question->code}}" 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" name="{{$question->code}}[]" data-code="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
||||
<input type="{{$question->type}}" min="0" max="9999999999" step="1" name="{{$question->code}}[]" data-code="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
@case('textarea')
|
||||
<textarea name="{{$question->code}}[]" data-code="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
|
|
@ -166,16 +166,12 @@
|
|||
</div>
|
||||
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6 text-center d-grid mt-3" >
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
<div class="col-6 text-center d-grid mt-3">
|
||||
<button type="button" class="btn btn-warning btn-sm" id="add-doctor-btn">Add Doctor</button>
|
||||
</div>
|
||||
<div class="d-grid mt-3">
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" id="add-doctor-btn">Add Doctor</button>
|
||||
</div>
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
</form>
|
||||
|
||||
|
|
@ -362,6 +358,189 @@
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// Define doctor dropdown
|
||||
let $doctorSelect = $('.js-contact-id');
|
||||
|
||||
// Store original options
|
||||
let originalOptions = $doctorSelect.find('option').clone();
|
||||
|
||||
$(document).on('change', '.js-campaign-type', function () {
|
||||
|
||||
/* let selectedCampaign = $(this).html(); */
|
||||
let selectedCampaign = ($(this).val() || '').trim();
|
||||
|
||||
selectedCampaign = selectedCampaign.replace(/@/g, '').replace(/\s+/g, ' ').trim();
|
||||
|
||||
|
||||
/* if (selectedCampaign === '7 PM Conversion Campaign') {
|
||||
console.log("Selected 7 PM");
|
||||
$('[data-code="rxs_given_for_montair_lc_adult"]')
|
||||
.attr('min', 15);
|
||||
|
||||
} else if (selectedCampaign === 'MLC A Pedia Campaign') {
|
||||
console.log("Selected MLC A");
|
||||
$('[data-code="rxs_given_for_montair_lc_adult"]')
|
||||
.attr('min', 8);
|
||||
|
||||
} */
|
||||
|
||||
|
||||
let $wrapper2 = $(this).closest('.doctor-card');
|
||||
|
||||
let $rxField = $wrapper2.find('[data-code="rxs_given_for_montair_lc_adult"]');
|
||||
|
||||
if (selectedCampaign === '7 PM Conversion Campaign') {
|
||||
console.log("Selected 7 PM");
|
||||
|
||||
$rxField.attr('min', 15);
|
||||
|
||||
} else if (selectedCampaign === 'MLC A Pedia Campaign') {
|
||||
console.log("Selected MLC A");
|
||||
|
||||
$rxField.attr('min', 8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
console.log("Selected Campaign:", selectedCampaign);
|
||||
|
||||
let $wrapper = $(this).closest('.doctor-card');
|
||||
|
||||
// Doctor dropdown ONLY inside current wrapper
|
||||
$doctorSelect = $wrapper.find('.js-contact-id');
|
||||
|
||||
// Destroy select2 temporarily
|
||||
$doctorSelect.select2('destroy');
|
||||
|
||||
// Empty dropdown
|
||||
$doctorSelect.empty();
|
||||
|
||||
// Array to collect pediatrician doctors
|
||||
let pediatricianDoctors = [];
|
||||
|
||||
// Loop through original options
|
||||
originalOptions.each(function () {
|
||||
|
||||
let $option = $(this).clone();
|
||||
/* console.log($option); */
|
||||
|
||||
let speciality = ($option.attr('speciality') || '').trim();
|
||||
|
||||
|
||||
/* console.log("Speciality:", speciality); */
|
||||
|
||||
// Keep default option
|
||||
if ($option.val() === '') {
|
||||
console.log("Doctor:",$option.val());
|
||||
$doctorSelect.append($option);
|
||||
return;
|
||||
}
|
||||
|
||||
// Show all doctors
|
||||
if (selectedCampaign === '7 PM Conversion Campaign') {
|
||||
console.log("7PM");
|
||||
$doctorSelect.append($option);
|
||||
}else if (selectedCampaign === 'MLC A Pedia Campaign') {
|
||||
console.log("*",selectedCampaign);
|
||||
|
||||
|
||||
if (speciality === 'PAEDIATRICIAN' || speciality === 'Paediatrician' ||speciality === 'paediatrician' ) {
|
||||
|
||||
pediatricianDoctors.push($option)
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
// Append pediatrician doctors
|
||||
if (selectedCampaign === 'MLC A Pedia Campaign') {
|
||||
|
||||
pediatricianDoctors.forEach(function ($doctor) {
|
||||
|
||||
$doctorSelect.append($doctor);
|
||||
});
|
||||
}
|
||||
|
||||
// Reinitialize select2
|
||||
$doctorSelect.select2();
|
||||
|
||||
// Reset selection
|
||||
$doctorSelect.val('').trigger('change');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#field-record_date').closest('.col-md-12').before(`
|
||||
<div class="col-md-12 mb-3">
|
||||
<div class="p-3 rounded shadow-sm border"
|
||||
style="background: #fff8e1; border-left: 5px solid #ff9800;">
|
||||
|
||||
<h5 class="fw-bold text-dark mb-3 text-center">
|
||||
Campaign Guidelines
|
||||
</h5>
|
||||
|
||||
<div class="mb-3">
|
||||
<h6 class="fw-bold text-primary">
|
||||
7PM Conversion Campaign
|
||||
</h6>
|
||||
|
||||
<p class="mb-1">
|
||||
<strong>Target Drs :</strong>
|
||||
25 Drs Mont+Fexo & Mont+Bila Drs
|
||||
</p>
|
||||
|
||||
<p class="mb-1">
|
||||
<strong>Conversion :</strong>
|
||||
5 Conversions for Montair LC Adult
|
||||
</p>
|
||||
|
||||
<p class="mb-1">
|
||||
<strong> Goal : </strong>
|
||||
Each conversion with 15 Rxs Montair LC Adult
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div>
|
||||
<h6 class="fw-bold text-primary">
|
||||
MLC Adult @Pedia
|
||||
</h6>
|
||||
|
||||
<p class="mb-1">
|
||||
<strong>Target Drs :</strong>
|
||||
10 Drs Mont+Fexo & Mont+Bila Drs
|
||||
</p>
|
||||
|
||||
<p class="mb-1">
|
||||
<strong>Conversion :</strong>
|
||||
5 Conversions for Montair LC Adult
|
||||
</p>
|
||||
|
||||
<p class="mb-1">
|
||||
<strong>Goal : </strong>
|
||||
Each conversion with 8 Rxs Montair LC Adult
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
|
|
|
|||
|
|
@ -328,7 +328,115 @@
|
|||
});
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* for (let i = 1; i <= 10; i++) {
|
||||
|
||||
$(`#field-email_id_${i}`).on('input', function () {
|
||||
|
||||
// Remove spaces
|
||||
this.value = this.value.replace(/\s/g, '');
|
||||
});
|
||||
|
||||
$(`#field-email_id_${i}`).on('blur', function () {
|
||||
|
||||
let email = $(this).val().trim();
|
||||
|
||||
let emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
|
||||
if (email !== '' && !emailPattern.test(email)) {
|
||||
alert('Please enter a valid email address');
|
||||
$(this).focus();
|
||||
}
|
||||
});
|
||||
|
||||
} */
|
||||
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
|
||||
$(`#field-email_id_${i}`).on('input', function () {
|
||||
|
||||
// Remove spaces
|
||||
this.value = this.value.replace(/\s/g, '');
|
||||
|
||||
});
|
||||
|
||||
$(`#field-email_id_${i}`).on('blur', function () {
|
||||
|
||||
let email = $(this).val().trim();
|
||||
|
||||
let emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
|
||||
// Remove old error
|
||||
$(this).next('.email-error').remove();
|
||||
|
||||
if (email !== '' && !emailPattern.test(email)) {
|
||||
|
||||
$(this).addClass('is-invalid');
|
||||
|
||||
$(this).after(`
|
||||
<small class="text-danger email-error">
|
||||
Please enter a valid email address
|
||||
</small>
|
||||
`);
|
||||
|
||||
} else {
|
||||
|
||||
$(this).removeClass('is-invalid');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
for(let i=1;i<=10;i++){
|
||||
$(`#field-msl_code_${i}`).prop('readonly',true);
|
||||
$(`#field-speciality_${i}`).prop('readonly',true);
|
||||
|
||||
}
|
||||
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
|
||||
$(`#field-mobile_number_${i}`).on('input', function () {
|
||||
|
||||
// Allow only numbers
|
||||
this.value = this.value.replace(/\D/g, '');
|
||||
|
||||
// Limit to 10 digits
|
||||
if (this.value.length > 10) {
|
||||
this.value = this.value.slice(0, 10);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Validation on form submit / field blur
|
||||
$(`#field-mobile_number_${i}`).on('blur', function () {
|
||||
|
||||
if (this.value.length !== 10) {
|
||||
$(this).addClass('is-invalid');
|
||||
|
||||
// Optional message
|
||||
if (!$(this).next('.error-msg').length) {
|
||||
$(this).after(
|
||||
`<small class="text-danger error-msg">
|
||||
Mobile number must be exactly 10 digits
|
||||
</small>`
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
$(this).removeClass('is-invalid');
|
||||
$(this).next('.error-msg').remove();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Loop through hierarcies and fetch contacts for each hierarchy, store in contacts variable
|
||||
|
||||
// $('#field-user_id').change(function(){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,798 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
@include('layouts.shared/title-meta', ['title' => "Form"])
|
||||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
||||
<link href="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">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</div>
|
||||
|
||||
<body class="loading">
|
||||
<div class="account-pages">
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8 col-lg-6 col-xl-5 p-0">
|
||||
<div class="card bg-pattern">
|
||||
<div class="card-body p-3 row">
|
||||
|
||||
@if(Session::has('error'))<div class="alert alert-danger">{{Session::get('error')}}</div>
|
||||
<br>@endif
|
||||
@if(session('success'))<div class=" alert alert-success">{{ session('success') }}
|
||||
</div>
|
||||
<br>@endif
|
||||
<div class="col-8">
|
||||
<h4 class="page-title">{{$form->title}}</h4>
|
||||
</div>
|
||||
@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>
|
||||
@else
|
||||
<a href="{{url()->previous()}}" class="float-end pt-1">Back</a>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
@if(isset($form->user_info))
|
||||
<div class="col-12">
|
||||
<h6>Submitted By: {{$form->user_info->name}}</h6>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@php
|
||||
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||
$submissions = $submissions->data->submissions;
|
||||
/*echo "<pre>";
|
||||
print_r($submissions);
|
||||
echo "</pre>";*/
|
||||
|
||||
$submissions = Formhelper::getMultiformData(
|
||||
$form->partition,
|
||||
$form_id,
|
||||
$form->user_id
|
||||
);
|
||||
|
||||
$submissions = $submissions->data->submissions;
|
||||
|
||||
$submittedDoctors = collect($submissions)->map(function ($item) {
|
||||
|
||||
return $item->formdata->cont_id ?? null;
|
||||
|
||||
})->filter()->unique()->values()->toArray();
|
||||
|
||||
/* echo "<pre>";
|
||||
print_r($submittedDoctors);
|
||||
echo "</pre>";
|
||||
*/
|
||||
|
||||
|
||||
@endphp
|
||||
{{-- @if(count($submissions)===0 || $id) --}}
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id[0]" value="{{$id}}">
|
||||
@endif
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-user_id" class="form-label"> Select User / Territory <span class="text-danger">*</span> </label>
|
||||
<select class="form-control" id="field-user_id" name="user_id" required>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($form->users as $option)
|
||||
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
||||
</div>
|
||||
@endif
|
||||
@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}}"
|
||||
name="{{$question->code}}"
|
||||
value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('text')
|
||||
@case('email')
|
||||
@case('tel')
|
||||
@case('date')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||
name="{{$question->code}}" 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}}" name="{{$question->code}}" class="form-control"
|
||||
{{$question->required == 'yes'?'required':'' }}
|
||||
value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
@case('textarea')
|
||||
<textarea id="field-{{$question->code}}" name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@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->legacy_code . ' ' : '' }} {{ $question->code == 'doctor_name' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="doctor-wrapper">
|
||||
|
||||
@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}}"
|
||||
name="{{$question->code}}[0]"
|
||||
value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('text')
|
||||
@case('email')
|
||||
@case('tel')
|
||||
@case('date')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||
name="{{$question->code}}[0]" 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}}" name="{{$question->code}}[0]"
|
||||
class="form-control" {{$question->required == 'yes'?'required':'' }}
|
||||
value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
@case('textarea')
|
||||
<textarea id="field-{{$question->code}}" name="{{$question->code}}[0]"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@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->legacy_code) ? $option->contact->legacy_code : '') }}"
|
||||
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||
@endif
|
||||
>
|
||||
{{ $option->display }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<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' : '' }}>
|
||||
{{ $option->display }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@endif
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<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':''}}>
|
||||
<label class="form-check-label"
|
||||
for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) &&
|
||||
$form->is_approval != 'yes' ) )
|
||||
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}"
|
||||
class="form-control" value=""
|
||||
{{$question->required == 'yes'?'required':'' }}>
|
||||
@elseif(isset($question->value))
|
||||
<img src="{{$question->value}}" class="img-fluid">
|
||||
@endif
|
||||
|
||||
@break
|
||||
@case('multitextbox')
|
||||
<div class="row">
|
||||
@foreach($question->options as $option)
|
||||
<div class="col-6">{{$option->display}}</div>
|
||||
<div class="col-6 mb-1">
|
||||
<input type="number" id="field-{{$option->value}}"
|
||||
name="{{$option->value}}" class="form-control" required
|
||||
value="{{isset($option->val)?$option->val:0}}">
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
<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">
|
||||
@if(!$id)
|
||||
<button class="btn btn-primary" type="button" id="adddoctor-btn"> Add Doctor </button>
|
||||
@endif
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
{{-- @elseif(!$id)
|
||||
<h4>You have submitted 10 doctors</h4>
|
||||
@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);
|
||||
display: none;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
margin-top: -32px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.doctor-wrapper {
|
||||
border: 1px solid #ccc;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
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"));
|
||||
})
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
$('#field-speciality').val($(this).find(":selected").attr("speciality"));
|
||||
})
|
||||
|
||||
$('#field-msl_code,#field-speciality').attr('readonly',true);
|
||||
|
||||
window.submittedDoctors = @json($submittedDoctors);
|
||||
|
||||
function initializeSelect2() {
|
||||
|
||||
$('select[id^="field-contact_id"]').select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
$('#field-user_id').select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select User / Territory --'
|
||||
});
|
||||
|
||||
$('select[id^="execution-"]').select2({
|
||||
width: '100%'
|
||||
});
|
||||
}
|
||||
|
||||
initializeSelect2();
|
||||
preventDuplicateDoctors(window.submittedDoctors);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*function preventDuplicateDoctors() {
|
||||
|
||||
let selectedValues = [];
|
||||
|
||||
// Collect selected values
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if (value) {
|
||||
selectedValues.push(value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('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 previous label
|
||||
let cleanText = option.text().replace(' (Already Added)', '');
|
||||
|
||||
// IMPORTANT:
|
||||
// keep currently selected option enabled
|
||||
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');
|
||||
}
|
||||
|
||||
currentSelect.select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
// VERY IMPORTANT FOR EDIT MODE
|
||||
currentSelect.val(currentValue).trigger('change.select2');
|
||||
|
||||
});
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
function preventDuplicateDoctors(submittedDoctors = []) {
|
||||
|
||||
let selectedDoctors = [];
|
||||
|
||||
// Get currently selected doctors from form
|
||||
$('select[id^="field-contact_id"]').each(function () {
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if (value) {
|
||||
selectedDoctors.push(value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Merge current + submitted doctors
|
||||
let blockedDoctors = [
|
||||
...new Set([
|
||||
...selectedDoctors,
|
||||
...submittedDoctors
|
||||
])
|
||||
];
|
||||
|
||||
$('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 labels
|
||||
let cleanText = option.text()
|
||||
.replace(' (Already Added)', '')
|
||||
.replace(' (Already Submitted)', '');
|
||||
|
||||
// Keep currently selected option enabled
|
||||
if (
|
||||
blockedDoctors.includes(optionValue) &&
|
||||
optionValue !== currentValue
|
||||
) {
|
||||
|
||||
option.prop('disabled', true);
|
||||
|
||||
if (submittedDoctors.includes(optionValue)) {
|
||||
|
||||
option.text(cleanText + ' (Already Submitted)');
|
||||
|
||||
} else {
|
||||
|
||||
option.text(cleanText + ' (Already Added)');
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
option.prop('disabled', false);
|
||||
option.text(cleanText);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Refresh Select2
|
||||
if (currentSelect.hasClass('select2-hidden-accessible')) {
|
||||
currentSelect.select2('destroy');
|
||||
}
|
||||
|
||||
currentSelect.select2({
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
|
||||
currentSelect.val(currentValue).trigger('change.select2');
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(document).on('change', 'select[id^="field-contact_id"]', function () {
|
||||
|
||||
let selectedOption = $(this).find(':selected');
|
||||
|
||||
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'));
|
||||
|
||||
preventDuplicateDoctors(window.submittedDoctors);
|
||||
});
|
||||
|
||||
|
||||
function createSlug2(value) {
|
||||
|
||||
return value
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/[^a-z0-9\s-]/g, '') // remove special chars
|
||||
.replace(/\s+/g, '_') // spaces to underscore
|
||||
.replace(/-+/g, '_'); // multiple hyphen to underscore
|
||||
}
|
||||
|
||||
|
||||
// Wrapper dropdowns
|
||||
$("#field-activity_type").on('change', function () {
|
||||
console.log("Selected");
|
||||
let fieldId = $(this).attr('id');
|
||||
|
||||
// Remove only current wrapper hidden input
|
||||
$('#report-form input[data-source="' + fieldId + '"]').remove();
|
||||
|
||||
let slug = createSlug2($(this).val());
|
||||
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="dynamic-hidden" data-source="' + fieldId + '" name="' + slug + '" value="1">'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
var doctor_count = 0
|
||||
let numberOfSubmission=0;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
$('#adddoctor-btn').click(function() {
|
||||
let doctorName=$('#field-contact_id').html();
|
||||
|
||||
console.log("Doctor Name : ",doctorName);
|
||||
doctor_count++;
|
||||
numberOfSubmission=numberOfSubmission+1;
|
||||
console.log("Number of Submission : ",numberOfSubmission);
|
||||
|
||||
let empty_doctor = `
|
||||
|
||||
<div class="doctor-wrapper">
|
||||
@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->legacy_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({
|
||||
|
||||
width: '100%',
|
||||
placeholder: '-- Select Doctor --'
|
||||
});
|
||||
preventDuplicateDoctors(window.submittedDoctors);
|
||||
|
||||
|
||||
$('select[id^="execution-"]').select2({
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
$('#field-msl_code-'+doctor_count).attr('readonly',true);
|
||||
$('#field-speciality-'+doctor_count).attr('readonly',true);
|
||||
|
||||
|
||||
}, 500);
|
||||
|
||||
|
||||
|
||||
|
||||
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();
|
||||
})
|
||||
|
||||
function createSlug(value) {
|
||||
|
||||
return value
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/[^a-z0-9\s-]/g, '') // remove special chars
|
||||
.replace(/\s+/g, '_') // spaces to underscore
|
||||
.replace(/-+/g, '_'); // multiple hyphen to underscore
|
||||
}
|
||||
|
||||
|
||||
// Wrapper dropdowns
|
||||
$('[id^="field-activity_type-"]').on('change', function () {
|
||||
console.log("Selected");
|
||||
let fieldId = $(this).attr('id');
|
||||
|
||||
// Remove only current wrapper hidden input
|
||||
$('#report-form input[data-source="' + fieldId + '"]').remove();
|
||||
|
||||
let slug = createSlug($(this).val());
|
||||
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="dynamic-hidden" data-source="' + fieldId + '" name="' + slug + '" value="1">'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
$('#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();
|
||||
// if (numberOfSubmission !=10) {
|
||||
// alert(`You must submit 10 Doctors for Ciphaler , 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>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue