Arise Changes
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m41s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m41s
Details
This commit is contained in:
parent
1f68ed2ae2
commit
89d21055de
|
|
@ -0,0 +1,713 @@
|
|||
<!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" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="/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">
|
||||
<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">(RA-2) Catch Up Camp</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> -->
|
||||
<button type="button" class="btn btn-primary btn-xs" id="add-camp-btn">Add
|
||||
Plan</button>
|
||||
@else
|
||||
<a href="{{ url()->previous() }}" class="float-end pt-1">Back</a>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@php
|
||||
$history = Formhelper::getMultiformData(
|
||||
$form->partition,
|
||||
$form->form_id,
|
||||
$form->user_id,
|
||||
);
|
||||
@endphp
|
||||
|
||||
|
||||
|
||||
<div class="col-12" id="table-wrapper">
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless table-nowrap table-hover table-centered m-0">
|
||||
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Action.</th>
|
||||
<th>Camp Plan Date</th>
|
||||
<th>Execution Completed</th>
|
||||
|
||||
<th>Doctor Name</th>
|
||||
|
||||
<th>MSL Code</th>
|
||||
<th>Speciality</th>
|
||||
<th>Type of camp</th>
|
||||
<th>Execution Done</th>
|
||||
<th>Reason For Not-Executing</th>
|
||||
<th>Patient Screened</th>
|
||||
<th>Patient Diagnosed</th>
|
||||
{{-- <th>Foracort Rx</th> --}}
|
||||
<th>Seroflo Rx</th>
|
||||
{{-- <th>Duolin Rx</th> --}}
|
||||
<th>Aerocort Rx</th>
|
||||
{{-- <th>Glycohale FB Rx</th> --}}
|
||||
<th>E-Voltido Rx</th>
|
||||
{{-- <th>E- Foracort G Rx</th> --}}
|
||||
<th>E-Synchrobreathe range Rx</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (collect($history->data->submissions)->sortByDesc('formdata.record_date') as $sub)
|
||||
@php
|
||||
$sub->formdata->id = $sub->id;
|
||||
|
||||
@endphp
|
||||
<tr>
|
||||
<td>
|
||||
<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>
|
||||
</td>
|
||||
<td>{{ $sub->formdata->plan_date }}</td>
|
||||
<td>{{ isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'yes' ? 'Yes' : 'No' }}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@if (isset($sub->formdata->contact_id) && $sub->formdata->contact_id !== '')
|
||||
{{ $sub->formdata->contact_id }}
|
||||
@elseif (isset($sub->formdata->doctor_name))
|
||||
{{ $sub->formdata->doctor_name }}
|
||||
@else
|
||||
{{-- Default value or empty string, adjust as needed --}}
|
||||
{{ '' }}
|
||||
@endif
|
||||
</td>
|
||||
|
||||
|
||||
<td>{{ isset($sub->formdata->msl_code) ? $sub->formdata->msl_code : '' }}
|
||||
</td>
|
||||
<td>{{ isset($sub->formdata->speciality) ? $sub->formdata->speciality : '' }}
|
||||
</td>
|
||||
<td>{{ isset($sub->formdata->type_of_camp) ? $sub->formdata->type_of_camp : '' }}
|
||||
</td>
|
||||
<td>{{ isset($sub->formdata->execution) ? $sub->formdata->execution : '' }}
|
||||
</td>
|
||||
<td>{{ isset($sub->formdata->reason) ? $sub->formdata->reason : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->patient_screened) ? $sub->formdata->patient_screened : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->patients_diagnosed) ? $sub->formdata->patients_diagnosed : '' }}</td>
|
||||
{{-- <td>{{ isset($sub->formdata->foracort_rx) ? $sub->formdata->foracort_rx : '' }}</td> --}}
|
||||
<td>{{ isset($sub->formdata->seroflo_rx) ? $sub->formdata->seroflo_rx : '' }}</td>
|
||||
{{-- <td>{{ isset($sub->formdata->duolin_rx) ? $sub->formdata->duolin_rx : '' }}</td> --}}
|
||||
<td>{{ isset($sub->formdata->aerocort_rx) ? $sub->formdata->aerocort_rx : '' }}</td>
|
||||
{{-- <td>{{ isset($sub->formdata->glycohale_fb_rx) ? $sub->formdata->glycohale_fb_rx : '' }}</td> --}}
|
||||
<td>{{ isset($sub->formdata->e_voltido_rx) ? $sub->formdata->e_voltido_rx : '' }}</td>
|
||||
{{-- <td>{{ isset($sub->formdata->e_foracort_g_rx) ? $sub->formdata->e_foracort_g_rx : '' }}</td> --}}
|
||||
<td>{{ isset($sub->formdata->e_synchrobreathe_range_rx) ? $sub->formdata->e_synchrobreathe_range_rx : '' }}</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="form-wrapper">
|
||||
<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 }}">
|
||||
@endif
|
||||
@foreach ($questions as $question)
|
||||
@if (in_array($question->code, [
|
||||
'execution_date',
|
||||
'execution',
|
||||
'reason',
|
||||
'patient_screened',
|
||||
'patients_diagnosed',
|
||||
'foracort_rx',
|
||||
'seroflo_rx',
|
||||
'duolin_rx',
|
||||
'aerocort_rx',
|
||||
'glycohale_fb_rx',
|
||||
'e_voltido_rx',
|
||||
'e_foracort_g_rx',
|
||||
'e_synchrobreathe_range_rx'
|
||||
]))
|
||||
@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)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type != 'Chemist' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@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>
|
||||
@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
|
||||
|
||||
</select>
|
||||
@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 }}[]" 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')
|
||||
<input type="file" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control" value=""
|
||||
accept="image/jpg, image/jpeg, image/png" required>
|
||||
@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">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="execution-form-wrapper">
|
||||
<form method="POST" action="/form/submit" id="execution-form"
|
||||
enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
||||
@csrf
|
||||
<input type="hidden" name="id" value="" id="execution-id">
|
||||
<input type="hidden" name="execution_done" value="yes">
|
||||
@foreach ($questions as $question)
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="execution-{{ $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="execution-{{ $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="execution-{{ $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="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}
|
||||
value="{{ isset($question->value) ? $question->value : 0 }}">
|
||||
@break
|
||||
|
||||
@case('textarea')
|
||||
<textarea id="execution-{{ $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="execution-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type != 'Chemist' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@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>
|
||||
@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
|
||||
|
||||
</select>
|
||||
@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="execution-{{ $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="execution-{{ $question->code }}-{{ $option->value }}">{{ $option->display }}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
|
||||
@case('file')
|
||||
<input type="file" id="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control" value=""
|
||||
accept="image/jpg, image/jpeg, image/png">
|
||||
@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">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</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%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{ asset('assets/libs/sweetalert2/sweetalert2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('#form-wrapper').hide()
|
||||
$('#execution-form-wrapper').hide()
|
||||
|
||||
// $('#add-camp-btn').click(function() {
|
||||
// $('#form-wrapper').show()
|
||||
// $('#table-wrapper').hide()
|
||||
// })
|
||||
|
||||
$('#add-camp-btn').click(function() {
|
||||
$('#table-wrapper').hide(0)
|
||||
$('#form-wrapper').show(100, () => {
|
||||
$('#add-camp-btn').hide(0);
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
$('.edit-btn').click(function() {
|
||||
$('#execution-form-wrapper').show(100, () => {
|
||||
$('#add-camp-btn').hide(0);
|
||||
})
|
||||
$('#table-wrapper').hide()
|
||||
let contacts = document.getElementById('execution-contact_id');
|
||||
contacts.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
let type = document.getElementById('execution-type_of_camp');
|
||||
type.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
$('#execution-msl_code,#execution-speciality,execution-plan_date').prop('readonly',true);
|
||||
|
||||
let selected = JSON.parse($(this).attr('plan_details'));
|
||||
console.log("Plan Detail : ", selected);
|
||||
if (selected['contact_id']) {
|
||||
selected['contact_id'] = selected['contact_id'].trim();
|
||||
}
|
||||
console.log("Selected Doctor:", selected['contact_id']);
|
||||
|
||||
|
||||
|
||||
for (let k of Object.keys(selected)) {
|
||||
//console.log("k",k);
|
||||
if (selected[k] != '') {
|
||||
if (k == 'contact_id') {
|
||||
//$("#execution-contact_id option:contains(" + selected[k] + ")").prop('selected', true)
|
||||
// console.log($("#execution-contact_id option:contains(" + selected[k] + ")").attr('value'))
|
||||
$('#execution-contact_id').val($("#execution-contact_id option:contains(" +
|
||||
selected[k] + ")").attr('value'));
|
||||
} else if (k == 'upload_photo_1' || k == 'upload_photo_2') {
|
||||
continue;
|
||||
} else {
|
||||
$('#execution-' + k).val(selected[k]);
|
||||
}
|
||||
}
|
||||
// if(selected[k] != '')
|
||||
// $('#execution-'+k).val(selected[k]);
|
||||
}
|
||||
|
||||
let docid = $('#execution-contact_id option').map(function() {
|
||||
if ($(this).text().trim() == selected['contact_id'] || $(this).val().trim() == selected['cont_id']) return this;
|
||||
}).attr('value')
|
||||
|
||||
$('#execution-contact_id').val(docid)
|
||||
$('#execution-id').val(selected['id'])
|
||||
|
||||
|
||||
|
||||
|
||||
$('#execution-reason').parent().hide();
|
||||
$('#execution-reason').prop('required',false);
|
||||
|
||||
/* $('#execution-execution_done').on('change',function(){
|
||||
let value=$(this).val();
|
||||
console.log("Value is ",value);
|
||||
|
||||
if(value==='Yes'){
|
||||
$('#execution-reason').parent().hide();
|
||||
$('#execution-reason').prop('required',false);
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="executed" value="1">');
|
||||
}
|
||||
else{
|
||||
$('#execution-reason').parent().show();
|
||||
$('#execution-reason').prop('required',true);
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="not_executed" value="0">');
|
||||
}
|
||||
}) */
|
||||
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').parent().hide();
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').attr('required',false);
|
||||
|
||||
$('#execution-execution').on('change',function(){
|
||||
let value=$('#execution-execution').val();
|
||||
if(value==='Yes'){
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').parent().show();
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').attr('required',true);
|
||||
$('#execution-reason').parent().hide();
|
||||
$('#execution-reason').prop('required',false);
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="executed" value="1">');
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').parent().hide();
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').attr('required',false);
|
||||
$('#execution-reason').parent().show();
|
||||
$('#execution-reason').prop('required',true);
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="not_executed" value="0">');
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#execution-execution').trigger('change');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
const screened = document.getElementById('execution-patient_screened');
|
||||
const diagnosed = document.getElementById('execution-patients_diagnosed');
|
||||
|
||||
function validatePatients() {
|
||||
let screenedVal = parseInt(screened.value) || 0;
|
||||
let diagnosedVal = parseInt(diagnosed.value) || 0;
|
||||
|
||||
if (diagnosedVal > screenedVal) {
|
||||
alert('Patients Diagnosed cannot be greater than Patients Screened');
|
||||
diagnosed.value = screenedVal; // reset to max allowed
|
||||
}
|
||||
}
|
||||
|
||||
diagnosed.addEventListener('input', validatePatients);
|
||||
screened.addEventListener('input', validatePatients);
|
||||
|
||||
$('#execution-execution').on('change', function () {
|
||||
let value=$(this).val();
|
||||
|
||||
// Remove old hidden inputs
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
|
||||
// Convert dropdown value into slug format
|
||||
let slugName = $(this).val()
|
||||
.toLowerCase() // lowercase
|
||||
.replace(/\s+/g, '_'); // spaces to underscore
|
||||
|
||||
// Append hidden input
|
||||
if(value==='Yes'){
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="' + slugName + '" value="1">');
|
||||
}
|
||||
});
|
||||
|
||||
let typeValue=$('#execution-type_of_camp').val();
|
||||
console.log("Type of Value : ",typeValue);
|
||||
if(typeValue==='In Clinic camp'){
|
||||
$('#execution-form').append('<input type="hidden" name="in_clinic_camp_exe" value="1">');
|
||||
|
||||
}
|
||||
else{
|
||||
$('#execution-form').append('<input type="hidden" name="outreach_camp_exe" value="1">');
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$('#report-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
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'
|
||||
})
|
||||
window.location.reload();
|
||||
//$('#report-form').trigger("reset");
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Data not submitted',
|
||||
text: 'Something went wrong, please try again after some time!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#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').prop('readonly', true);
|
||||
|
||||
//$('#field-contact_id').append('<option value="others">Others</option>');
|
||||
|
||||
|
||||
$('#field-type_of_camp').on('change', function () {
|
||||
|
||||
// Remove old hidden inputs
|
||||
$('#report-form input.dynamic-hidden').remove();
|
||||
|
||||
// Convert dropdown value into slug format
|
||||
let slugName = $(this).val()
|
||||
.toLowerCase() // lowercase
|
||||
.replace(/\s+/g, '_'); // spaces to underscore
|
||||
|
||||
// Append hidden input
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="dynamic-hidden" name="' + slugName + '" value="1">'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#execution-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
data: new FormData($('#execution-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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var today = new Date(); // keep as Date object
|
||||
|
||||
var dd = String(today.getDate()).padStart(2, '0');
|
||||
var mm = String(today.getMonth() + 1).padStart(2, '0');
|
||||
var yyyy = today.getFullYear();
|
||||
|
||||
// formatted string (only if needed)
|
||||
var todayFormatted = yyyy + '-' + mm + '-' + dd;
|
||||
|
||||
var recordDateField = document.getElementById('field-plan_date');
|
||||
|
||||
// 👉 First day of current month
|
||||
let minDateObj = new Date(today.getFullYear(), today.getMonth(), 1);
|
||||
|
||||
// 👉 Last day of (current month + 2 months)
|
||||
let maxDateObj = new Date(today.getFullYear(), today.getMonth() + 3, 0);
|
||||
|
||||
// Convert to YYYY-MM-DD
|
||||
let minDate = minDateObj.toISOString().split('T')[0];
|
||||
let maxDate = maxDateObj.toISOString().split('T')[0];
|
||||
|
||||
// Apply
|
||||
recordDateField.min = minDate;
|
||||
recordDateField.max = maxDate;
|
||||
|
||||
// (Optional) set default value = today
|
||||
recordDateField.value = todayFormatted;
|
||||
|
||||
var executionDateField = document.getElementById('execution-plan_date');
|
||||
//executionDateField.setAttribute('min', today);
|
||||
|
||||
// $('.edit-btn').click(function() {
|
||||
// var executionexeField = document.getElementById('execution-record_date');
|
||||
// executionexeField.setAttribute('min', executionDateField.value);
|
||||
// });
|
||||
|
||||
|
||||
|
||||
executionDateField.addEventListener('change', function() {
|
||||
console.log('gg');
|
||||
var executionexeField = document.getElementById('execution-record_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,309 @@
|
|||
<!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" />
|
||||
</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
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" 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)
|
||||
<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)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type != 'Chemist' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@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>
|
||||
@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
|
||||
{{-- @if($question->code=='contact_id')
|
||||
<option value="others" {{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>Others</option>
|
||||
@endif --}}
|
||||
</select>
|
||||
@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}}[]" 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
|
||||
|
||||
@case('time')
|
||||
<input type="time"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}">
|
||||
@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">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
</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%;
|
||||
}
|
||||
</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,
|
||||
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)
|
||||
})
|
||||
|
||||
// $('#field-select_brand').on('change',function(){
|
||||
// $('#report-form input.dynamic-hidden').remove();
|
||||
// $('#report-form').append('<input type="hidden" class="dynamic-hidden" name="'+ $('#field-select_brand').val() +'" value="1">')
|
||||
// })
|
||||
|
||||
$('#field-select_brand').on('change', function () {
|
||||
$('#report-form input.dynamic-hidden').remove();
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
// Convert to slug
|
||||
let slug = value
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/\s+/g, '_') // spaces → underscore
|
||||
.replace(/[^\w\-]+/g, ''); // remove special chars
|
||||
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="dynamic-hidden" name="' + slug + '" value="1">'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
$('#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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
const formData = new FormData($('#report-form')[0]);
|
||||
// Log form data to console
|
||||
for (let [key, value] of formData.entries()) {
|
||||
console.log(key, value);
|
||||
}
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
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>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,315 @@
|
|||
<!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" />
|
||||
</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
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" 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)
|
||||
<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)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@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>
|
||||
@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
|
||||
|
||||
</select>
|
||||
@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}}[]" 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
|
||||
|
||||
@case('time')
|
||||
<input type="time"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}">
|
||||
@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">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
</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%;
|
||||
}
|
||||
</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,
|
||||
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)
|
||||
})
|
||||
|
||||
$('#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);
|
||||
|
||||
|
||||
$('#field-pob_unit,#field-number_of_conversion,#field-rx,#field-brand_pob').parent().hide();
|
||||
$('#field-pob_unit,#field-number_of_conversion,#field-rx,#field-brand_pob').attr('required',false);
|
||||
|
||||
$('#field-type').on('change',function(){
|
||||
let value=$(this).val();
|
||||
console.log("Value is : ",value);
|
||||
if(value==='POB Details'){
|
||||
$('#field-pob_unit,#field-brand_pob').parent().show();
|
||||
$('#field-pob_unit,#field-brand_pob').attr('required',true);
|
||||
$('#field-number_of_conversion,#field-rx').parent().hide();
|
||||
$('#field-number_of_conversion,#field-rx').attr('required',false);
|
||||
}
|
||||
else if(value==='New Conversion'){
|
||||
$('#field-number_of_conversion,#field-brand_pob').parent().show();
|
||||
$('#field-number_of_conversion,#field-brand_pob').attr('required',true);
|
||||
$('#field-pob_unit,#field-rx').parent().hide();
|
||||
$('#field-pob_unit,#field-rx').attr('required',false);
|
||||
}
|
||||
else if(value==='Rx'){
|
||||
$('#field-rx,#field-brand_pob').parent().show();
|
||||
$('#field-rx,#field-brand_pob').attr('required',true);
|
||||
$('#field-number_of_conversion,#field-pob_unit').parent().hide();
|
||||
$('#field-number_of_conversion,#field-pob_unit').attr('required',false);
|
||||
}
|
||||
})
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#field-contact_id').trigger('change');
|
||||
$('#field-type').trigger('change');
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
const formData = new FormData($('#report-form')[0]);
|
||||
// Log form data to console
|
||||
for (let [key, value] of formData.entries()) {
|
||||
console.log(key, value);
|
||||
}
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
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>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,315 @@
|
|||
<!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" />
|
||||
</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
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" 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)
|
||||
<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)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@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>
|
||||
@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
|
||||
|
||||
</select>
|
||||
@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}}[]" 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
|
||||
|
||||
@case('time')
|
||||
<input type="time"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}">
|
||||
@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">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
</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%;
|
||||
}
|
||||
</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,
|
||||
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)
|
||||
})
|
||||
|
||||
$('#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);
|
||||
|
||||
|
||||
$('#field-pob_unit,#field-number_of_conversion,#field-rx,#field-brand_pob').parent().hide();
|
||||
$('#field-pob_unit,#field-number_of_conversion,#field-rx,#field-brand_pob').attr('required',false);
|
||||
|
||||
$('#field-type').on('change',function(){
|
||||
let value=$(this).val();
|
||||
console.log("Value is : ",value);
|
||||
if(value==='POB Details'){
|
||||
$('#field-pob_unit,#field-brand_pob').parent().show();
|
||||
$('#field-pob_unit,#field-brand_pob').attr('required',true);
|
||||
$('#field-number_of_conversion,#field-rx').parent().hide();
|
||||
$('#field-number_of_conversion,#field-rx').attr('required',false);
|
||||
}
|
||||
else if(value==='New Conversion'){
|
||||
$('#field-number_of_conversion,#field-brand_pob').parent().show();
|
||||
$('#field-number_of_conversion,#field-brand_pob').attr('required',true);
|
||||
$('#field-pob_unit,#field-rx').parent().hide();
|
||||
$('#field-pob_unit,#field-rx').attr('required',false);
|
||||
}
|
||||
else if(value==='Rx'){
|
||||
$('#field-rx,#field-brand_pob').parent().show();
|
||||
$('#field-rx,#field-brand_pob').attr('required',true);
|
||||
$('#field-number_of_conversion,#field-pob_unit').parent().hide();
|
||||
$('#field-number_of_conversion,#field-pob_unit').attr('required',false);
|
||||
}
|
||||
})
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#field-contact_id').trigger('change');
|
||||
$('#field-type').trigger('change');
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
const formData = new FormData($('#report-form')[0]);
|
||||
// Log form data to console
|
||||
for (let [key, value] of formData.entries()) {
|
||||
console.log(key, value);
|
||||
}
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
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>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,636 @@
|
|||
<!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" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="/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">
|
||||
<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">Dr Engagement Meet</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> -->
|
||||
<button type="button" class="btn btn-primary btn-xs" id="add-camp-btn">Add
|
||||
Plan</button>
|
||||
@else
|
||||
<a href="{{ url()->previous() }}" class="float-end pt-1">Back</a>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@php
|
||||
$history = Formhelper::getMultiformData(
|
||||
$form->partition,
|
||||
$form->form_id,
|
||||
$form->user_id,
|
||||
);
|
||||
@endphp
|
||||
|
||||
|
||||
|
||||
<div class="col-12" id="table-wrapper">
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless table-nowrap table-hover table-centered m-0">
|
||||
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Action.</th>
|
||||
<th>Plan Date</th>
|
||||
<th>Execution Done</th>
|
||||
|
||||
|
||||
<th>Camp Execution Date</th>
|
||||
<th>Type of meet</th>
|
||||
<th>Location</th>
|
||||
<th>Module Type</th>
|
||||
<th>Meeting Done</th>
|
||||
<th>Dr list submitted to HO</th>
|
||||
<th>No of Drs attended</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (collect($history->data->submissions)->sortByDesc('formdata.record_date') as $sub)
|
||||
@php
|
||||
$sub->formdata->id = $sub->id;
|
||||
|
||||
@endphp
|
||||
<tr>
|
||||
<td>
|
||||
<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>
|
||||
</td>
|
||||
<td>{{ $sub->formdata->plan_date }}</td>
|
||||
<td>{{ isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'yes' ? 'Yes' : 'No' }}
|
||||
</td>
|
||||
|
||||
|
||||
<td>{{ $sub->formdata->execution_date }}</td>
|
||||
|
||||
<td>{{ isset($sub->formdata->type_of_meet) ? $sub->formdata->type_of_meet : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->location) ? $sub->formdata->location : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->module_type) ? $sub->formdata->module_type : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->meeting_done) ? $sub->formdata->meeting_done : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->dr_list_submitted_to_ho) ? $sub->formdata->dr_list_submitted_to_ho : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->no_of_drs_attended) ? $sub->formdata->no_of_drs_attended : '' }}</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="form-wrapper">
|
||||
<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 }}">
|
||||
@endif
|
||||
@foreach ($questions as $question)
|
||||
@if (in_array($question->code, [
|
||||
'execution_date',
|
||||
'meeting_done',
|
||||
'dr_list_submitted_to_ho',
|
||||
'no_of_drs_attended'
|
||||
]))
|
||||
@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)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type != 'Chemist' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@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>
|
||||
@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
|
||||
@if($question->code=='contact_id')
|
||||
<option value="others" {{ isset($question->value) && $question->value == 'others' ? 'selected' : '' }}>Others</option>
|
||||
@endif
|
||||
</select>
|
||||
@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 }}[]" 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')
|
||||
<input type="file" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control" value=""
|
||||
accept="image/jpg, image/jpeg, image/png" required>
|
||||
@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">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="execution-form-wrapper">
|
||||
<form method="POST" action="/form/submit" id="execution-form"
|
||||
enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
||||
@csrf
|
||||
<input type="hidden" name="id" value="" id="execution-id">
|
||||
<input type="hidden" name="execution_done" value="yes">
|
||||
@foreach ($questions as $question)
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="execution-{{ $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="execution-{{ $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="execution-{{ $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="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}
|
||||
value="{{ isset($question->value) ? $question->value : 0 }}">
|
||||
@break
|
||||
|
||||
@case('textarea')
|
||||
<textarea id="execution-{{ $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="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type != 'Chemist' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@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>
|
||||
@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
|
||||
</select>
|
||||
@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="execution-{{ $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="execution-{{ $question->code }}-{{ $option->value }}">{{ $option->display }}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
|
||||
@case('file')
|
||||
<input type="file" id="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control" value=""
|
||||
accept="image/jpg, image/jpeg, image/png">
|
||||
@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">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</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%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{ asset('assets/libs/sweetalert2/sweetalert2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('#form-wrapper').hide()
|
||||
$('#execution-form-wrapper').hide()
|
||||
|
||||
|
||||
|
||||
$('#add-camp-btn').click(function() {
|
||||
$('#table-wrapper').hide(0)
|
||||
$('#form-wrapper').show(100, () => {
|
||||
$('#add-camp-btn').hide(0);
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
$('#field-module_type').parent().hide();
|
||||
$('#field-module_type').attr('required',false);
|
||||
|
||||
$('#field-type_of_meet').on('change',function(){
|
||||
let value=$('#field-type_of_meet').val();
|
||||
console.log("Value is : ",value);
|
||||
if(value==='Step Up'){
|
||||
$('#field-module_type').parent().show();
|
||||
$('#field-module_type').attr('required',true);
|
||||
}
|
||||
else{
|
||||
$('#field-module_type').parent().hide();
|
||||
$('#field-module_type').attr('required',false);
|
||||
}
|
||||
})
|
||||
|
||||
$('#field-type_of_meet').on('change', function () {
|
||||
$('#report-form input.dynamic-hidden').remove();
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
// Convert to slug
|
||||
let slug = value
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/\s+/g, '_') // spaces → underscore
|
||||
.replace(/[^\w\-]+/g, ''); // remove special chars
|
||||
console.log("Slug is ",slug);
|
||||
$('#report-form').append('<input type="hidden" class="dynamic-hidden" name="' + slug + '" value="1">');
|
||||
});
|
||||
|
||||
|
||||
$('.edit-btn').click(function() {
|
||||
$('#execution-form-wrapper').show(100, () => {
|
||||
$('#add-camp-btn').hide(0);
|
||||
})
|
||||
$('#table-wrapper').hide()
|
||||
let meeting_type = document.getElementById('execution-type_of_meet');
|
||||
meeting_type.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
let module_type = document.getElementById('execution-module_type');
|
||||
module_type.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
$('#execution-location').prop('readonly', true)
|
||||
$('#execution-plan_date').prop('readonly', true)
|
||||
$('#execution-uid').prop('readonly', true);
|
||||
//$('#execution-time').prop('disabled', true)
|
||||
|
||||
let selected = JSON.parse($(this).attr('plan_details'));
|
||||
console.log("Plan Detail : ", selected);
|
||||
|
||||
|
||||
|
||||
|
||||
for (let k of Object.keys(selected)) {
|
||||
//console.log("k",k);
|
||||
if (selected[k] != '') {
|
||||
if (k == 'contact_id') {
|
||||
//$("#execution-contact_id option:contains(" + selected[k] + ")").prop('selected', true)
|
||||
// console.log($("#execution-contact_id option:contains(" + selected[k] + ")").attr('value'))
|
||||
$('#execution-contact_id').val($("#execution-contact_id option:contains(" +
|
||||
selected[k] + ")").attr('value'));
|
||||
} else if (k == 'upload_photo_1' || k == 'upload_photo_2') {
|
||||
continue;
|
||||
} else {
|
||||
$('#execution-' + k).val(selected[k]);
|
||||
}
|
||||
}
|
||||
// if(selected[k] != '')
|
||||
// $('#execution-'+k).val(selected[k]);
|
||||
}
|
||||
|
||||
$('#execution-module_type').parent().hide();
|
||||
$('#execution-module_type').attr('required',false);
|
||||
|
||||
let meeting=$('#execution-type_of_meet').val();
|
||||
console.log("Type of Meeting : ",meeting);
|
||||
if(meeting==='Step Up'){
|
||||
$('#execution-module_type').parent().show();
|
||||
$('#execution-module_type').attr('required',true);
|
||||
}
|
||||
else{
|
||||
$('#execution-module_type').parent().hide();
|
||||
$('#execution-module_type').attr('required',false);
|
||||
}
|
||||
|
||||
$('#execution-execution_date,#execution-dr_list_submitted_to_ho,#execution-no_of_drs_attended').parent().hide();
|
||||
$('#execution-execution_date,#execution-dr_list_submitted_to_ho,#execution-no_of_drs_attended').attr('required',false);
|
||||
|
||||
$('#execution-meeting_done').on('change',function(){
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
let value=$('#execution-meeting_done').val();
|
||||
if(value==='Yes'){
|
||||
$('#execution-execution_date,#execution-dr_list_submitted_to_ho,#execution-no_of_drs_attended').parent().show();
|
||||
$('#execution-execution_date,#execution-dr_list_submitted_to_ho,#execution-no_of_drs_attended').attr('required',true);
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="executed" value="1">');
|
||||
}
|
||||
else{
|
||||
$('#execution-execution_date,#execution-dr_list_submitted_to_ho,#execution-no_of_drs_attended').parent().hide();
|
||||
$('#execution-execution_date,#execution-dr_list_submitted_to_ho,#execution-no_of_drs_attended').attr('required',false);
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="not_executed" value="1">');
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
$('#report-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
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'
|
||||
})
|
||||
window.location.reload();
|
||||
//$('#report-form').trigger("reset");
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Data not submitted',
|
||||
text: 'Something went wrong, please try again after some time!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#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').prop('readonly', true);
|
||||
$('#field-speciality').prop('readonly', true);
|
||||
|
||||
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').prop({"required":false});
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').parent().hide();
|
||||
|
||||
|
||||
$('#field-contact_id').on('change',function(){
|
||||
let dropDown=$('#field-contact_id').val();
|
||||
if(dropDown==='others'){
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').parent().show();
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').prop({"required":true});
|
||||
$('#field-speciality,#field-msl_code').parent().hide();
|
||||
$('#field-speciality,#field-msl_code').prop({"required":false});
|
||||
}
|
||||
else{
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').parent().hide();
|
||||
$('#field-other_doctor_name,#field-other_speciality,#field-other_msl_code').prop({"required":false});
|
||||
$('#field-speciality,#field-msl_code').parent().show();
|
||||
$('#field-speciality,#field-msl_code').prop({"required":true});
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
//$('#field-contact_id').append('<option value="others">Others</option>');
|
||||
|
||||
$('#execution-sitazit_d_rx,#execution-sitazit_dm_rx,#execution-ziten_m_rx').on('input', function() {
|
||||
var total=(
|
||||
(parseInt($('#execution-sitazit_d_rx').val()) ||0)+
|
||||
(parseInt($('#execution-sitazit_dm_rx').val()) ||0)+
|
||||
(parseInt($('#execution-ziten_m_rx').val()) ||0)
|
||||
);
|
||||
|
||||
|
||||
$('#execution-total_camp_rx').val(total)
|
||||
})
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#field-contact_id').trigger('change');
|
||||
});
|
||||
|
||||
$('#execution-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
data: new FormData($('#execution-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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
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 recordDateField = document.getElementById('field-plan_date');
|
||||
//recordDateField.setAttribute('min', today);
|
||||
|
||||
var executionDateField = document.getElementById('execution-plan_date');
|
||||
//executionDateField.setAttribute('min', today);
|
||||
|
||||
// $('.edit-btn').click(function() {
|
||||
// var executionexeField = document.getElementById('execution-record_date');
|
||||
// executionexeField.setAttribute('min', executionDateField.value);
|
||||
// });
|
||||
|
||||
$('.edit-btn').click(function() {
|
||||
var executionexeField = document.getElementById('execution-execution_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
});
|
||||
|
||||
|
||||
|
||||
executionDateField.addEventListener('change', function() {
|
||||
console.log('gg');
|
||||
var executionexeField = document.getElementById('execution-record_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@include('layouts.shared/title-meta', ['title' => "History"])
|
||||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||
</head>
|
||||
|
||||
<body class="loading">
|
||||
<div class="account-pages">
|
||||
<div class="container">
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-8 p-2">
|
||||
<h4 class="page-title">{{$formname}}</h4>
|
||||
</div>
|
||||
<div class="col-4 p-2">
|
||||
<a href="/form/show" class="float-end pt-1">New Submission</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
@if(session()->has('message'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('message') }}
|
||||
</div>
|
||||
@endif
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
<div class="row">
|
||||
<div class="col-12 p-0">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="responsive-table-plugin">
|
||||
<div class="table-rep-plugin">
|
||||
<div class="table-responsive" data-pattern="priority-columns">
|
||||
<table id="tech-companies-1" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-priority="1">Submission Date</th>
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue;
|
||||
@endif
|
||||
<th data-priority="1">{{$question->label}}</th>
|
||||
@endforeach
|
||||
<th data-priority="1">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($submissions as $submission)
|
||||
<tr>
|
||||
<th>{{date("d M Y", strtotime($submission->updatedAt))}}</th>
|
||||
@foreach($questions as $code => $question)
|
||||
@if($question->type == 'hidden')
|
||||
@continue;
|
||||
@endif
|
||||
@if($question->type == 'file')
|
||||
<td><a target="_blank" href="{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) :(is_string($submission->formdata->{$code}) ? $submission->formdata->{$code} : '' ) : $code }}" download="{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) : (is_string($submission->formdata->{$code}) ? $submission->formdata->{$code} : '' ) : $code }}" class="btn btn-dark btn-xs"><i class="mdi mdi-cloud-download me-1"></i> Download</a></td>
|
||||
|
||||
@elseif($question->type == 'radiometrix' && isset($submission->formdata->{$code}) && is_object($submission->formdata->{$code}))
|
||||
<td>
|
||||
{{ collect((array)$submission->formdata->{$code})->map(function($val, $key){ return "$key: $val"; })->implode(', ') }}
|
||||
</td>
|
||||
|
||||
@elseif(count((array)$question->options) > 0 && 1==2 )
|
||||
<td>{{ $question->options->{ $submission->formdata->{$code} } }}</td>
|
||||
@else
|
||||
<td>{{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) :$submission->formdata->{$code} : $code }}</td>
|
||||
@endif
|
||||
@endforeach
|
||||
<th>
|
||||
|
||||
@if($question->can_edit == 'yes' || sizeof($submission->workflow_approvals) == 0 )
|
||||
|
||||
@if($submission->workflow == 'yes' && $submission->workflow_status == 'approved')
|
||||
|
||||
<p>Approved</p>
|
||||
|
||||
@else
|
||||
|
||||
{{-- EDIT BUTTON COMMENTED --}}
|
||||
{{--
|
||||
<a href="/form/show?form_id={{$submission->formdata->form_id}}&id={{$submission->id}}"
|
||||
class="btn btn-primary btn-xs">
|
||||
Edit
|
||||
</a>
|
||||
--}}
|
||||
|
||||
@if(true)
|
||||
|
||||
<!-- <a href="/form/delete?form_id={{$submission->formdata->form_id}}&id={{$submission->id}}"
|
||||
class="btn btn-danger btn-xs mt-1">
|
||||
|
||||
Delete
|
||||
|
||||
</a> -->
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-danger btn-xs mt-1 delete-submission"
|
||||
data-id="{{$submission->id}}"
|
||||
data-form="{{$submission->formdata->form_id}}">
|
||||
|
||||
Delete
|
||||
|
||||
</button>
|
||||
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
||||
</th>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end .table-responsive -->
|
||||
|
||||
</div> <!-- end .table-rep-plugin-->
|
||||
</div> <!-- end .responsive-table-plugin-->
|
||||
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
<!-- end row-->
|
||||
</div> <!-- container -->
|
||||
|
||||
</div>
|
||||
<!-- end page -->
|
||||
@include('layouts.shared/footer-script')
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
$(document).on(
|
||||
'click',
|
||||
'.delete-submission',
|
||||
function(){
|
||||
|
||||
let formId =
|
||||
$(this).data('form');
|
||||
|
||||
let submissionId =
|
||||
$(this).data('id');
|
||||
|
||||
$.ajax({
|
||||
|
||||
url:
|
||||
'/form/delete?form_id='
|
||||
+ formId
|
||||
+ '&id='
|
||||
+ submissionId,
|
||||
|
||||
type: 'GET',
|
||||
|
||||
success: function(response){
|
||||
|
||||
// reopen form page
|
||||
window.location.href =
|
||||
'/form/show?form_id='
|
||||
+ formId;
|
||||
alert('Deleted successfully');
|
||||
},
|
||||
|
||||
error: function(){
|
||||
|
||||
alert('Delete failed');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
@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>
|
||||
<!-- <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
|
||||
|
|
@ -58,6 +58,22 @@
|
|||
@endif
|
||||
|
||||
@foreach($questions as $question)
|
||||
@php
|
||||
|
||||
$hideFields = [
|
||||
'date',
|
||||
'contact_id',
|
||||
'month_1_rx',
|
||||
'month_2_rx',
|
||||
'month_3_rx',
|
||||
'converted'
|
||||
];
|
||||
|
||||
@endphp
|
||||
|
||||
@if(in_array($question->code, $hideFields))
|
||||
@continue
|
||||
@endif
|
||||
<div class="{{ in_array($question->code, ['upload-supporting-doc1', 'upload-supporting-doc2']) ? 'upload-doc-fields' : '' }} 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)
|
||||
|
|
@ -97,8 +113,12 @@
|
|||
// Decode the first option's value to use as heading labels
|
||||
$headings =
|
||||
count($question->options) > 0
|
||||
? json_decode($question->options[0]->value)
|
||||
? json_decode($question->options[0]->value, true)
|
||||
: [];
|
||||
|
||||
if(!is_array($headings)){
|
||||
$headings = [];
|
||||
}
|
||||
@endphp
|
||||
|
||||
{{-- Matrix Wrapper with Horizontal Scroll on Small Screens --}}
|
||||
|
|
@ -116,7 +136,14 @@
|
|||
|
||||
{{-- Table Rows --}}
|
||||
@foreach ($question->options as $option)
|
||||
@php $nn = json_decode($option->value); @endphp
|
||||
@php
|
||||
$nn = json_decode($option->value, true);
|
||||
|
||||
// fallback if invalid json
|
||||
if(!is_array($nn)){
|
||||
$nn = [];
|
||||
}
|
||||
@endphp
|
||||
<div class="d-table-row align-middle">
|
||||
<div class="d-table-cell font-weight-bold p-2"
|
||||
style="width: 150px;">
|
||||
|
|
@ -180,18 +207,45 @@
|
|||
</div>
|
||||
@endforeach
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
<div class="text-center d-gri mt-3">
|
||||
<div class="col-md-12 mt-3">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Tagged Doctors</h5>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Doctor Name</th>
|
||||
<th>Speciality</th>
|
||||
<th>Month1 Rx</th>
|
||||
<th>Month2 Rx</th>
|
||||
<th>Month3 Rx</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="doctor-table-body">
|
||||
<tr>
|
||||
<td colspan="8" class="text-center">
|
||||
No Doctors Found
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
<!-- SAMPLE FORM MODAL -->
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div> <!-- end col -->
|
||||
</div>
|
||||
<!-- end row -->
|
||||
|
|
@ -224,20 +278,231 @@
|
|||
.upload-doc-fields {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rx_count{
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
@php
|
||||
// KEEP ORIGINAL DOCTOR LOGIC
|
||||
$doctors = [];
|
||||
foreach($questions as $question) {
|
||||
if($question->code == 'contact_id') {
|
||||
$doctors = $question->options;
|
||||
foreach($questions as $question){
|
||||
if($question->code == 'contact_id'){
|
||||
$doctors = is_iterable($question->options ?? null) ? $question->options : [];
|
||||
}
|
||||
}
|
||||
// RX HISTORY DATA ONLY
|
||||
$history = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id );
|
||||
$categorySubmissions = [];
|
||||
$categoryDoctorSubmissions = [];
|
||||
$doctorRxCounts = [];
|
||||
$doctorMonthData = [];
|
||||
|
||||
$categoryAttributes = [
|
||||
'foracort-ciphaler' => 'foracort_ciphaler',
|
||||
'duolin-synchrobreathe' => 'duolin_synchrobreathe',
|
||||
'foracort-g' => 'foracort_g',
|
||||
'pedia' => 'pedia',
|
||||
'triple-combination-voltido-trio-indaflo-g' => 'triple_combination_voltido_trio_indaflo_g',
|
||||
'ics-laba-seroflo-maxiflo-voltido' => 'ics_laba_seroflo_maxiflo_voltido',
|
||||
'competition-dr' => 'competition_dr',
|
||||
];
|
||||
|
||||
$doctorNameById = [];
|
||||
$doctorIdByName = [];
|
||||
foreach ($doctors as $doc) {
|
||||
$doctorNameById[$doc->value] = $doc->display;
|
||||
$doctorIdByName[trim($doc->display)] = $doc->value;
|
||||
}
|
||||
|
||||
if (isset($history->data->submissions) && is_iterable($history->data->submissions)) {
|
||||
foreach ($history->data->submissions as $sub) {
|
||||
$formdata = $sub->formdata ?? null;
|
||||
if (!$formdata) {
|
||||
continue;
|
||||
}
|
||||
$category = strtolower(trim($formdata->{'select-category'} ?? ''));
|
||||
if (!$category) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($categorySubmissions[$category])) {
|
||||
$categorySubmissions[$category] = [];
|
||||
}
|
||||
if (isset($formdata->sample_count)) {
|
||||
$doctorId = trim($formdata->contact_id ?? '');
|
||||
$doctorName = $doctorNameById[$doctorId] ?? trim($formdata->contact_id ?? '');
|
||||
$rxValue = intval($formdata->sample_count ?? 0);
|
||||
if (!$doctorId) {
|
||||
continue;
|
||||
}
|
||||
$categorySubmissions[$category][] = [
|
||||
'type' => 'rx',
|
||||
'doctor_id' => $doctorId,
|
||||
'doctor_name' => $doctorName,
|
||||
'sample_count' => $rxValue,
|
||||
'date' => $formdata->date ?? '',
|
||||
];
|
||||
if (!isset($doctorRxCounts[$category])) {
|
||||
$doctorRxCounts[$category] = [];
|
||||
}
|
||||
if (!isset($doctorRxCounts[$category][$doctorName])) {
|
||||
$doctorRxCounts[$category][$doctorName] = 0;
|
||||
}
|
||||
$doctorRxCounts[$category][$doctorName] += $rxValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
$rawDoctorId = '';
|
||||
if (!empty($formdata->contact_id)) {
|
||||
$contactId = $formdata->contact_id;
|
||||
if (is_array($contactId) || $contactId instanceof \Traversable) {
|
||||
$contactValues = array_values((array) $contactId);
|
||||
$rawDoctorId = trim((string) ($contactValues[0] ?? ''));
|
||||
} else {
|
||||
$rawDoctorId = trim((string) $contactId);
|
||||
}
|
||||
}
|
||||
|
||||
$doctorId = $rawDoctorId;
|
||||
if (
|
||||
$doctorId !== '' &&
|
||||
!isset($doctorNameById[$doctorId]) &&
|
||||
isset($doctorIdByName[$doctorId])
|
||||
) {
|
||||
$doctorId = $doctorIdByName[$doctorId];
|
||||
}
|
||||
|
||||
$categoryPrefix = $categoryAttributes[$category] ?? null;
|
||||
$month1Val = $formdata->month_1 ?? '';
|
||||
$month2Val = $formdata->month_2 ?? '';
|
||||
$month3Val = $formdata->month_3 ?? '';
|
||||
|
||||
if ($categoryPrefix) {
|
||||
if (isset($formdata->{$categoryPrefix . '_month_1'}) && $formdata->{$categoryPrefix . '_month_1'} !== '') {
|
||||
$month1Val = $formdata->{$categoryPrefix . '_month_1'};
|
||||
}
|
||||
if (isset($formdata->{$categoryPrefix . '_month_2'}) && $formdata->{$categoryPrefix . '_month_2'} !== '') {
|
||||
$month2Val = $formdata->{$categoryPrefix . '_month_2'};
|
||||
}
|
||||
if (isset($formdata->{$categoryPrefix . '_month_3'}) && $formdata->{$categoryPrefix . '_month_3'} !== '') {
|
||||
$month3Val = $formdata->{$categoryPrefix . '_month_3'};
|
||||
}
|
||||
}
|
||||
|
||||
$submissionRow = [
|
||||
'submission_id' => $sub->id,
|
||||
'converted' => $formdata->converted ?? '',
|
||||
'doctor_id' => $doctorId,
|
||||
'doctor_name' => $doctorNameById[$doctorId] ?? $rawDoctorId,
|
||||
'month_1' => $month1Val,
|
||||
'month_2' => $month2Val,
|
||||
'month_3' => $month3Val,
|
||||
];
|
||||
|
||||
if ($categoryPrefix) {
|
||||
$submissionRow[$categoryPrefix . '_month_1'] = $month1Val;
|
||||
$submissionRow[$categoryPrefix . '_month_2'] = $month2Val;
|
||||
$submissionRow[$categoryPrefix . '_month_3'] = $month3Val;
|
||||
}
|
||||
|
||||
$categorySubmissions[$category][] = $submissionRow;
|
||||
|
||||
if (!isset($doctorMonthData[$category])) {
|
||||
$doctorMonthData[$category] = [];
|
||||
}
|
||||
|
||||
if (!isset($categoryDoctorSubmissions[$category])) {
|
||||
$categoryDoctorSubmissions[$category] = [];
|
||||
}
|
||||
|
||||
if ($doctorId !== '') {
|
||||
$categoryDoctorSubmissions[$category][$doctorId] = $submissionRow;
|
||||
$doctorMonthData[$category][$doctorId] = [
|
||||
'month_1' => $submissionRow['month_1'],
|
||||
'month_2' => $submissionRow['month_2'],
|
||||
'month_3' => $submissionRow['month_3'],
|
||||
];
|
||||
}
|
||||
|
||||
foreach (['month_1', 'month_2', 'month_3'] as $monthKey) {
|
||||
$formMonthKey = $monthKey;
|
||||
if ($categoryPrefix && isset($formdata->{$categoryPrefix . '_' . $monthKey}) && $formdata->{$categoryPrefix . '_' . $monthKey} !== '' && $formdata->{$categoryPrefix . '_' . $monthKey} !== null) {
|
||||
$formMonthKey = $categoryPrefix . '_' . $monthKey;
|
||||
}
|
||||
|
||||
if (!isset($formdata->$formMonthKey) || $formdata->$formMonthKey === '' || $formdata->$formMonthKey === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$monthValue = $formdata->$formMonthKey;
|
||||
$monthEntries = [];
|
||||
|
||||
if (is_array($monthValue) || $monthValue instanceof \stdClass) {
|
||||
foreach ((array) $monthValue as $entryKey => $val) {
|
||||
$normalizedKey = trim((string) $entryKey);
|
||||
if (
|
||||
$normalizedKey !== '' &&
|
||||
!isset($doctorNameById[$normalizedKey]) &&
|
||||
isset($doctorIdByName[$normalizedKey])
|
||||
) {
|
||||
$normalizedKey = $doctorIdByName[$normalizedKey];
|
||||
}
|
||||
$monthEntries[$normalizedKey] = $val;
|
||||
}
|
||||
} elseif ($doctorId !== '') {
|
||||
$monthEntries = [$doctorId => $monthValue];
|
||||
}
|
||||
|
||||
foreach ($monthEntries as $entryDoctorId => $val) {
|
||||
if ($entryDoctorId === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($doctorMonthData[$category][$entryDoctorId])) {
|
||||
$doctorMonthData[$category][$entryDoctorId] = [
|
||||
'month_1' => '',
|
||||
'month_2' => '',
|
||||
'month_3' => '',
|
||||
];
|
||||
}
|
||||
|
||||
$doctorMonthData[$category][$entryDoctorId][$monthKey] = $val;
|
||||
|
||||
if (!isset($categoryDoctorSubmissions[$category][$entryDoctorId])) {
|
||||
$categoryDoctorSubmissions[$category][$entryDoctorId] = [
|
||||
'submission_id' => $sub->id,
|
||||
'converted' => $formdata->converted ?? '',
|
||||
'doctor_id' => $entryDoctorId,
|
||||
'doctor_name' => $doctorNameById[$entryDoctorId] ?? $entryDoctorId,
|
||||
'month_1' => '',
|
||||
'month_2' => '',
|
||||
'month_3' => '',
|
||||
];
|
||||
}
|
||||
|
||||
$categoryDoctorSubmissions[$category][$entryDoctorId][$monthKey] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
var allDoctors = {!! json_encode($doctors) !!};
|
||||
var categorySubmissions = {!! json_encode($categorySubmissions) !!};
|
||||
var categoryDoctorSubmissions = {!! json_encode($categoryDoctorSubmissions) !!};
|
||||
var doctorRxCounts = {!! json_encode($doctorRxCounts) !!};
|
||||
var doctorMonthData = {!! json_encode($doctorMonthData) !!};
|
||||
|
||||
console.log("CATEGORY SUBMISSIONS", categorySubmissions);
|
||||
console.log("DOCTOR RX COUNTS", doctorRxCounts);
|
||||
console.log("DOCTOR MONTH DATA", doctorMonthData);
|
||||
console.log("INITIAL DOCTORS FROM BACKEND", allDoctors);
|
||||
|
||||
// $.ajax({
|
||||
|
|
@ -282,8 +547,18 @@
|
|||
|
||||
let selectedCategory = $(this).val();
|
||||
|
||||
$('#field-contact_id').html('');
|
||||
if (!selectedCategory) {
|
||||
$('#doctor-table-body').html(`
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
No Doctors Found
|
||||
</td>
|
||||
</tr>
|
||||
`);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#field-contact_id').html('');
|
||||
$('#field-contact_id').append(
|
||||
$("<option></option>")
|
||||
.attr("value",'')
|
||||
|
|
@ -291,9 +566,7 @@
|
|||
);
|
||||
|
||||
if(allDoctors.length === 0) {
|
||||
|
||||
console.log("Doctors array empty");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -303,19 +576,48 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
// convert category slug
|
||||
let categoryKey = selectedCategory
|
||||
.replace(/-/g, '_');
|
||||
const categoryMap = {
|
||||
"foracort-ciphaler": "foracort_ciphaler",
|
||||
"duolin-synchrobreathe": "duolin_synchrobreathe",
|
||||
"foracort-g": "foracort_g",
|
||||
"pedia": "pedia",
|
||||
"triple-combination-voltido-trio-indaflo-g":"triple_combination_voltido_trio_indaflo_g",
|
||||
"ics-laba-seroflo-maxiflo-voltido":"ics_laba_seroflo_maxiflo_voltido",
|
||||
"competition-dr":"competition_dr"
|
||||
};
|
||||
|
||||
console.log("Checking:", categoryKey, doc.contact[categoryKey]);
|
||||
let categoryKey = categoryMap[selectedCategory];
|
||||
|
||||
return doc.contact[categoryKey] === 'yes';
|
||||
let categoryValue = doc.contact[categoryKey];
|
||||
|
||||
console.log(
|
||||
"Doctor:",
|
||||
doc.display,
|
||||
"Category:",
|
||||
categoryKey,
|
||||
"Value:",
|
||||
categoryValue
|
||||
);
|
||||
|
||||
// normalize value
|
||||
categoryValue = String(categoryValue)
|
||||
.toLowerCase()
|
||||
.trim();
|
||||
|
||||
return (
|
||||
categoryValue === 'yes' ||
|
||||
categoryValue === '1' ||
|
||||
categoryValue === 'true'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
console.log("Filtered Doctors:", filteredDoctors);
|
||||
|
||||
console.log(filteredDoctors);
|
||||
let requiredCount = mandatoryDoctorCount[selectedCategory] || 0;
|
||||
|
||||
let requiredCount =
|
||||
mandatoryDoctorCount[selectedCategory] || 0;
|
||||
if(filteredDoctors.length < requiredCount){
|
||||
|
||||
let categoryName = $('#field-select-category option:selected').text();
|
||||
|
|
@ -337,9 +639,27 @@
|
|||
.attr("value",'')
|
||||
.text('-- Select --')
|
||||
);
|
||||
|
||||
// reset doctor table
|
||||
$('#doctor-table-body').html(`
|
||||
<tr>
|
||||
<td colspan="8" class="text-center">
|
||||
No Doctors Found
|
||||
</td>
|
||||
</tr>
|
||||
`);
|
||||
return;
|
||||
}
|
||||
// limit doctors to required count
|
||||
filteredDoctors =
|
||||
filteredDoctors.slice(0, requiredCount);
|
||||
|
||||
console.log(
|
||||
"Final Allowed Doctors:",
|
||||
filteredDoctors.length
|
||||
);
|
||||
|
||||
// NOW render limited doctors
|
||||
renderDoctorTable(filteredDoctors);
|
||||
filteredDoctors.forEach(function(itm){
|
||||
|
||||
$('#field-contact_id').append(
|
||||
|
|
@ -418,123 +738,201 @@
|
|||
|
||||
|
||||
|
||||
function appendConvertedField() {
|
||||
|
||||
// remove old hidden fields
|
||||
$('#report-form input.converted-hidden').remove();
|
||||
|
||||
let convertedValue = $('#field-converted').val();
|
||||
const categoryThresholds = {
|
||||
|
||||
let selectedCategory = $('#field-select-category').val();
|
||||
"foracort-ciphaler": 10,
|
||||
"duolin-synchrobreathe": 10,
|
||||
"foracort-g": 10,
|
||||
"pedia": 5,
|
||||
"triple-combination-voltido-trio-indaflo-g": 10,
|
||||
"ics-laba-seroflo-maxiflo-voltido": 10,
|
||||
"competition-dr": 20
|
||||
|
||||
if(!convertedValue || !selectedCategory){
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// category mapping
|
||||
let categoryMap = {
|
||||
const conversionMetricFields = {
|
||||
"foracort-ciphaler":"foracort_ciphaler",
|
||||
"duolin-synchrobreathe":"duolin_synchrobreathe",
|
||||
"foracort-g":"foracort_g",
|
||||
"pedia":"pedia",
|
||||
"triple-combination-voltido-trio-indaflo-g": "triple_combination_voltido_trio_indaflo_g",
|
||||
"ics-laba-seroflo-maxiflo-voltido": "ics_laba_seroflo_maxiflo_voltido",
|
||||
"competition-dr": "competition_dr"
|
||||
|
||||
"foracort-ciphaler": "foracort_ciphaler",
|
||||
"duolin-synchrobreathe": "duolin_synchrobreathe",
|
||||
"foracort-g": "foracort_g",
|
||||
"pedia": "pedia",
|
||||
"triple-combination-voltido-trio-indaflo-g": "triple_combination_voltido_trio_indaflo_g",
|
||||
"ics-laba-seroflo-maxiflo-voltido": "ics_laba_seroflo_maxiflo_voltido",
|
||||
"competition-dr": "competition_dr"
|
||||
};
|
||||
|
||||
function getCategoryMonthFieldNames(selectedCategory) {
|
||||
let prefix = conversionMetricFields[selectedCategory] || '';
|
||||
|
||||
return {
|
||||
month1: prefix ? `${prefix}_month_1` : 'month_1',
|
||||
month2: prefix ? `${prefix}_month_2` : 'month_2',
|
||||
month3: prefix ? `${prefix}_month_3` : 'month_3',
|
||||
};
|
||||
|
||||
let categoryKey = categoryMap[selectedCategory];
|
||||
|
||||
if(!categoryKey){
|
||||
return;
|
||||
}
|
||||
|
||||
// category data
|
||||
let categoryValue = (convertedValue === 'Yes') ? '1' : '0';
|
||||
|
||||
// append original category field
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="converted-hidden" name="' + categoryKey + '" value="' + categoryValue + '">'
|
||||
);
|
||||
|
||||
// extra metric fields
|
||||
if(convertedValue === 'Yes'){
|
||||
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="converted-hidden" name="conversion_yes" value="1">'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if(convertedValue === 'No'){
|
||||
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="converted-hidden" name="conversion_no" value="1">'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
console.log("Category:", categoryKey, categoryValue);
|
||||
|
||||
}
|
||||
|
||||
$('#field-converted').on('change', appendConvertedField);
|
||||
function getSubmissionMonthValues(submission, monthFields) {
|
||||
return {
|
||||
month1: submission[monthFields.month1] ?? submission.month_1 ?? '',
|
||||
month2: submission[monthFields.month2] ?? submission.month_2 ?? '',
|
||||
month3: submission[monthFields.month3] ?? submission.month_3 ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
$('#field-select-category').on('change', appendConvertedField);
|
||||
function getMonthRxTotal(month1, month2, month3) {
|
||||
return (parseInt(month1, 10) || 0)
|
||||
+ (parseInt(month2, 10) || 0)
|
||||
+ (parseInt(month3, 10) || 0);
|
||||
}
|
||||
|
||||
function calculateDoctorConverted(month1, month2, month3, selectedCategory) {
|
||||
let threshold = categoryThresholds[selectedCategory] || 0;
|
||||
let totalRx = getMonthRxTotal(month1, month2, month3);
|
||||
|
||||
return totalRx >= threshold ? 1 : 0;
|
||||
}
|
||||
|
||||
function syncCategoryMonthFields($row) {
|
||||
let selectedCategory = $('#field-select-category').val() || '';
|
||||
let monthFields = getCategoryMonthFieldNames(selectedCategory);
|
||||
let doctorId = $row.data('doctor-id') || '';
|
||||
let month1 = $row.find('.rx-month-1').val();
|
||||
let month2 = $row.find('.rx-month-2').val();
|
||||
let month3 = $row.find('.rx-month-3').val();
|
||||
|
||||
$row.find('.doctor-category-month-1').val(month1).attr('name', `${monthFields.month1}[${doctorId}]`);
|
||||
$row.find('.doctor-category-month-2').val(month2).attr('name', `${monthFields.month2}[${doctorId}]`);
|
||||
$row.find('.doctor-category-month-3').val(month3).attr('name', `${monthFields.month3}[${doctorId}]`);
|
||||
}
|
||||
|
||||
function updateDoctorRowConverted($row) {
|
||||
let selectedCategory = $('#field-select-category').val() || '';
|
||||
let month1 = $row.find('.rx-month-1').val();
|
||||
let month2 = $row.find('.rx-month-2').val();
|
||||
let month3 = $row.find('.rx-month-3').val();
|
||||
let converted = calculateDoctorConverted(
|
||||
month1,
|
||||
month2,
|
||||
month3,
|
||||
selectedCategory
|
||||
);
|
||||
|
||||
$row.find('.doctor-converted').val(converted);
|
||||
syncCategoryMonthFields($row);
|
||||
}
|
||||
|
||||
function recalculateAllDoctorConverted() {
|
||||
$('#doctor-table-body tr').each(function() {
|
||||
if ($(this).find('.rx_count').length) {
|
||||
updateDoctorRowConverted($(this));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function findDoctorSubmission(selectedCategory, doctorId, doctorName) {
|
||||
let categoryDoctors = categoryDoctorSubmissions[selectedCategory] || {};
|
||||
let monthData = doctorMonthData[selectedCategory] || {};
|
||||
let categoryRows = categorySubmissions[selectedCategory] || [];
|
||||
|
||||
return categoryDoctors[doctorId]
|
||||
|| categoryDoctors[doctorName]
|
||||
|| monthData[doctorId]
|
||||
|| monthData[doctorName]
|
||||
|| categoryRows.find(function(row) {
|
||||
return row.doctor_id === doctorId
|
||||
|| row.doctor_id === doctorName
|
||||
|| row.doctor_name === doctorName;
|
||||
})
|
||||
|| {};
|
||||
}
|
||||
|
||||
function renderDoctorTable(filteredDoctors){
|
||||
let tbody = $('#doctor-table-body');
|
||||
let selectedCategory = $('#field-select-category').val() || '';
|
||||
|
||||
tbody.html('');
|
||||
|
||||
if(filteredDoctors.length === 0){
|
||||
tbody.html(`
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
No Doctors Found
|
||||
</td>
|
||||
</tr>
|
||||
`);
|
||||
return;
|
||||
}
|
||||
|
||||
filteredDoctors.forEach(function(doc){
|
||||
let doctorName = doc.display || '-';
|
||||
let speciality = doc.contact?.speciality || '-';
|
||||
let doctorId = doc.value || doc.contact?.id || '';
|
||||
let submission = findDoctorSubmission(selectedCategory, doctorId, doctorName);
|
||||
let monthFields = getCategoryMonthFieldNames(selectedCategory);
|
||||
let months = getSubmissionMonthValues(submission, monthFields);
|
||||
let converted = calculateDoctorConverted(
|
||||
months.month1,
|
||||
months.month2,
|
||||
months.month3,
|
||||
selectedCategory
|
||||
);
|
||||
|
||||
tbody.append(`
|
||||
<tr data-doctor-id="${doctorId}">
|
||||
<input type="hidden" name='submission_id[${doctorId}]' value="${submission.submission_id || ''}" />
|
||||
<input type="hidden" class="doctor-converted" name='converted[${doctorId}]' value="${converted}" />
|
||||
<input type="hidden" class="doctor-category-month-1" name='${monthFields.month1}[${doctorId}]' value="${months.month1 || ''}" />
|
||||
<input type="hidden" class="doctor-category-month-2" name='${monthFields.month2}[${doctorId}]' value="${months.month2 || ''}" />
|
||||
<input type="hidden" class="doctor-category-month-3" name='${monthFields.month3}[${doctorId}]' value="${months.month3 || ''}" />
|
||||
<td>${doctorName}</td>
|
||||
<td>${speciality}</td>
|
||||
<td><input type="number" name='month_1[${doctorId}]' class="rx_count rx-month-1" min="0" max="9999999999" step="1" value="${months.month1 || ''}" /></td>
|
||||
<td><input type="number" name='month_2[${doctorId}]' class="rx_count rx-month-2" min="0" max="9999999999" step="1" value="${months.month2 || ''}" /></td>
|
||||
<td><input type="number" name='month_3[${doctorId}]' class="rx_count rx-month-3" min="0" max="9999999999" step="1" value="${months.month3 || ''}" /></td>
|
||||
</tr>
|
||||
`);
|
||||
});
|
||||
|
||||
recalculateAllDoctorConverted();
|
||||
}
|
||||
|
||||
$(document).on('input change', '#doctor-table-body .rx_count', function() {
|
||||
updateDoctorRowConverted($(this).closest('tr'));
|
||||
});
|
||||
|
||||
function toggleUploadFields() {
|
||||
|
||||
let value = $('#field-converted').val();
|
||||
|
||||
console.log(value);
|
||||
|
||||
if (value === 'Yes') {
|
||||
|
||||
$('.upload-doc-fields').show();
|
||||
|
||||
// make upload mandatory
|
||||
$('#field-upload-supporting-doc1').prop('required', true);
|
||||
|
||||
} else {
|
||||
|
||||
$('.upload-doc-fields').hide();
|
||||
|
||||
// remove mandatory validation
|
||||
$('#field-upload-supporting-doc1').prop('required', false);
|
||||
|
||||
// optional cleanup
|
||||
$('#field-upload-supporting-doc1').val('');
|
||||
$('#field-upload-supporting-doc2').val('');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// hide initially always
|
||||
$('.upload-doc-fields').css('display', 'none');
|
||||
|
||||
|
||||
// run after small delay so dropdown is fully rendered
|
||||
setTimeout(function () {
|
||||
|
||||
toggleUploadFields();
|
||||
|
||||
}, 200);
|
||||
|
||||
|
||||
// initial hide/show
|
||||
toggleUploadFields();
|
||||
|
||||
|
||||
// dropdown change
|
||||
$(document).on('change', '#field-converted', function () {
|
||||
|
||||
toggleUploadFields();
|
||||
|
||||
if ($(this).val() === 'No') {
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: $('#submit-btn').offset().top
|
||||
}, 500);
|
||||
|
|
@ -542,27 +940,6 @@ $(document).on('change', '#field-converted', function () {
|
|||
});
|
||||
|
||||
|
||||
|
||||
// $(document).on('change', '#field-converted', function () {
|
||||
// let converted = $(this).val();
|
||||
// if (converted == 'No') {
|
||||
// $('.metric-field-wrapper').hide();
|
||||
// } else {
|
||||
// $('.metric-field-wrapper').show();
|
||||
// incrementMetric();
|
||||
// }
|
||||
// });
|
||||
|
||||
// function incrementMetric() {
|
||||
// let category = $('#field-select-category').val();
|
||||
// let metricField = categoryMetricMap[category];
|
||||
// if (!metricField) {
|
||||
// return;
|
||||
// }
|
||||
// let selector = '#field-' + metricField;
|
||||
// let currentVal = parseInt($(selector).val()) || 0;
|
||||
// $(selector).val(currentVal + 1);
|
||||
// }
|
||||
|
||||
$('input[type="file"]').on('change', function () {
|
||||
let file = this.files[0];
|
||||
|
|
@ -574,48 +951,167 @@ $(document).on('change', '#field-converted', function () {
|
|||
|
||||
];
|
||||
if (!allowedTypes.includes(file.type)) {
|
||||
alert('Only JPG and PDF files are allowed.');
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Invalid file',
|
||||
text: 'Only JPG and PDF files are allowed.'
|
||||
});
|
||||
$(this).val('');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
$("#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'
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: data.hasOwnProperty('message') ? 'You are not mapped to any position code' : 'Data not submitted',
|
||||
text: data.hasOwnProperty('message') ? 'for resolution please email Position code, L1 Manager and L2 Manager details to support1@stratawiz.com' : 'Something went wrong, please try again after some time!'
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#pageloader").fadeOut();
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
text: 'Something went wrong'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@if($id)
|
||||
setTimeout(function () {
|
||||
console.log("EDIT MODE TRIGGERED");
|
||||
$('#field-select-category').trigger('change');
|
||||
}, 300);
|
||||
@endif
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
data: new FormData($('#report-form')[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
console.log(allDoctors);
|
||||
console.log(data);
|
||||
$("#pageloader").fadeOut();
|
||||
if(data.status == 'success') {
|
||||
Swal.fire({
|
||||
title: 'Great!',
|
||||
text: 'Your data is successfully submitted!',
|
||||
icon: 'success'
|
||||
})
|
||||
$('#report-form').trigger("reset");
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: data.hasOwnProperty('message') ? 'You are not mapped to any position code' : 'Data not submitted',
|
||||
text: data.hasOwnProperty('message') ? 'for resolution please email Position code, L1 Manager and L2 Manager details to support1@stratawiz.com':'Something went wrong, please try again after some time!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
// OPEN SAMPLE MODAL
|
||||
|
||||
$(document).on(
|
||||
'click',
|
||||
'.open-sample-modal',
|
||||
function(){
|
||||
|
||||
let doctorId =
|
||||
$(this).data('doctor-id');
|
||||
|
||||
let doctorName =
|
||||
$(this).data('doctor-name');
|
||||
|
||||
let category =
|
||||
$(this).data('category');
|
||||
|
||||
let categoryDisplay =
|
||||
$(this).data('category-display');
|
||||
|
||||
// set hidden values
|
||||
|
||||
$('#sample-doctor-id').val(doctorId);
|
||||
|
||||
$('#sample-category').val(category);
|
||||
|
||||
// display values
|
||||
|
||||
$('#sample-doctor-name').val(doctorName);
|
||||
|
||||
$('#sample-category-display')
|
||||
.val(categoryDisplay);
|
||||
|
||||
// open modal
|
||||
|
||||
$('#sampleFormModal').modal('show');
|
||||
// set today's date by default
|
||||
$('#sample-date').val(
|
||||
new Date().toISOString().split('T')[0]
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
function appendConvertedField(
|
||||
selectedCategory,
|
||||
convertedValue
|
||||
){
|
||||
|
||||
const categoryMap = {
|
||||
"foracort-ciphaler":"foracort_ciphaler",
|
||||
"duolin-synchrobreathe":"duolin_synchrobreathe",
|
||||
"foracort-g":"foracort_g",
|
||||
"pedia":"pedia",
|
||||
"triple-combination-voltido-trio-indaflo-g":"triple_combination_voltido_trio_indaflo_g",
|
||||
"ics-laba-seroflo-maxiflo-voltido":"ics_laba_seroflo_maxiflo_voltido",
|
||||
"competition-dr":"competition_dr"
|
||||
};
|
||||
|
||||
let categoryKey =
|
||||
categoryMap[selectedCategory];
|
||||
|
||||
// converted field
|
||||
$('#sample-converted')
|
||||
.val(convertedValue);
|
||||
|
||||
// category metric field
|
||||
$('#sample-category-metric')
|
||||
.attr('name', categoryKey)
|
||||
.val(
|
||||
convertedValue === 'Yes'
|
||||
? 1
|
||||
: 0
|
||||
);
|
||||
|
||||
console.log(
|
||||
"CATEGORY KEY",
|
||||
categoryKey
|
||||
);
|
||||
|
||||
console.log(
|
||||
"CONVERTED",
|
||||
convertedValue
|
||||
);
|
||||
}
|
||||
|
||||
// allow only whole numbers in sample count
|
||||
$(document).on('keypress', '#sample-count', function(e){
|
||||
// allow only 0-9
|
||||
if(
|
||||
e.which < 48 ||
|
||||
e.which > 57
|
||||
){
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('paste', '#sample-count', function(e){
|
||||
let pastedData =
|
||||
(e.originalEvent || e)
|
||||
.clipboardData
|
||||
.getData('text');
|
||||
if(!/^\d+$/.test(pastedData)){
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('input', '#sample-count', function(){
|
||||
this.value =
|
||||
this.value.replace(/[^0-9]/g, '');
|
||||
});
|
||||
$('input[type="date"]').attr(
|
||||
'max',
|
||||
new Date().toISOString().split("T")[0]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,704 @@
|
|||
<!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" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="/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">
|
||||
<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">(RA-1)Catch Up Camp</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> -->
|
||||
<button type="button" class="btn btn-primary btn-xs" id="add-camp-btn">Add
|
||||
Plan</button>
|
||||
@else
|
||||
<a href="{{ url()->previous() }}" class="float-end pt-1">Back</a>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@php
|
||||
$history = Formhelper::getMultiformData(
|
||||
$form->partition,
|
||||
$form->form_id,
|
||||
$form->user_id,
|
||||
);
|
||||
@endphp
|
||||
|
||||
|
||||
|
||||
<div class="col-12" id="table-wrapper">
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless table-nowrap table-hover table-centered m-0">
|
||||
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Action.</th>
|
||||
<th>Camp Plan Date</th>
|
||||
<th>Execution Completed</th>
|
||||
|
||||
<th>Doctor Name</th>
|
||||
|
||||
<th>MSL Code</th>
|
||||
<th>Speciality</th>
|
||||
<th>Type of camp</th>
|
||||
<th>Execution Done</th>
|
||||
<th>Reason For Not-Executing</th>
|
||||
<th>Patient Screened</th>
|
||||
<th>Patient Diagnosed</th>
|
||||
<th>Foracort Rx</th>
|
||||
<th>Duolin Rx</th>
|
||||
<th>Foracort G Rx</th>
|
||||
<th>Glycohale FB Rx</th>
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (collect($history->data->submissions)->sortByDesc('formdata.record_date') as $sub)
|
||||
@php
|
||||
$sub->formdata->id = $sub->id;
|
||||
|
||||
@endphp
|
||||
<tr class="text-center">
|
||||
<td>
|
||||
<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>
|
||||
</td>
|
||||
<td>{{ $sub->formdata->plan_date }}</td>
|
||||
<td>{{ isset($sub->formdata->execution_done) && $sub->formdata->execution_done == 'yes' ? 'Yes' : 'No' }}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@if (isset($sub->formdata->contact_id) && $sub->formdata->contact_id !== '')
|
||||
{{ $sub->formdata->contact_id }}
|
||||
@elseif (isset($sub->formdata->doctor_name))
|
||||
{{ $sub->formdata->doctor_name }}
|
||||
@else
|
||||
{{-- Default value or empty string, adjust as needed --}}
|
||||
{{ '' }}
|
||||
@endif
|
||||
</td>
|
||||
|
||||
|
||||
<td>{{ isset($sub->formdata->msl_code) ? $sub->formdata->msl_code : '' }}
|
||||
</td>
|
||||
<td>{{ isset($sub->formdata->speciality) ? $sub->formdata->speciality : '' }}
|
||||
</td>
|
||||
<td>{{ isset($sub->formdata->type_of_camp) ? $sub->formdata->type_of_camp : '' }}
|
||||
</td>
|
||||
<td>{{ isset($sub->formdata->execution) ? $sub->formdata->execution : '' }}
|
||||
</td>
|
||||
<td>{{ isset($sub->formdata->reason) ? $sub->formdata->reason : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->patient_screened) ? $sub->formdata->patient_screened : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->patients_diagnosed) ? $sub->formdata->patients_diagnosed : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->foracort_rx) ? $sub->formdata->foracort_rx : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->duolin_rx) ? $sub->formdata->duolin_rx : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->foracort_g_rx) ? $sub->formdata->foracort_g_rx : '' }}</td>
|
||||
<td>{{ isset($sub->formdata->glycohale_fb_rx) ? $sub->formdata->glycohale_fb_rx : '' }}</td>
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="form-wrapper">
|
||||
<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 }}">
|
||||
@endif
|
||||
@foreach ($questions as $question)
|
||||
@if (in_array($question->code, [
|
||||
'execution_date',
|
||||
'execution',
|
||||
'reason',
|
||||
'patient_screened',
|
||||
'patients_diagnosed',
|
||||
'foracort_rx',
|
||||
'duolin_rx',
|
||||
'foracort_g_rx',
|
||||
'glycohale_fb_rx',
|
||||
|
||||
]))
|
||||
@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)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type != 'Chemist' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@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>
|
||||
@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
|
||||
|
||||
</select>
|
||||
@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 }}[]" 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')
|
||||
<input type="file" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control" value=""
|
||||
accept="image/jpg, image/jpeg, image/png" required>
|
||||
@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">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="execution-form-wrapper">
|
||||
<form method="POST" action="/form/submit" id="execution-form"
|
||||
enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
||||
@csrf
|
||||
<input type="hidden" name="id" value="" id="execution-id">
|
||||
<input type="hidden" name="execution_done" value="yes">
|
||||
@foreach ($questions as $question)
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="execution-{{ $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="execution-{{ $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="execution-{{ $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="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}
|
||||
value="{{ isset($question->value) ? $question->value : 0 }}">
|
||||
@break
|
||||
|
||||
@case('textarea')
|
||||
<textarea id="execution-{{ $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="execution-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type != 'Chemist' )
|
||||
<option value="{{ $option->value }}"
|
||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||
@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>
|
||||
@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
|
||||
|
||||
</select>
|
||||
@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="execution-{{ $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="execution-{{ $question->code }}-{{ $option->value }}">{{ $option->display }}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
|
||||
@case('file')
|
||||
<input type="file" id="execution-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control" value=""
|
||||
accept="image/jpg, image/jpeg, image/png">
|
||||
@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">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</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%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{ asset('assets/libs/sweetalert2/sweetalert2.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('#form-wrapper').hide()
|
||||
$('#execution-form-wrapper').hide()
|
||||
|
||||
// $('#add-camp-btn').click(function() {
|
||||
// $('#form-wrapper').show()
|
||||
// $('#table-wrapper').hide()
|
||||
// })
|
||||
|
||||
$('#add-camp-btn').click(function() {
|
||||
$('#table-wrapper').hide(0)
|
||||
$('#form-wrapper').show(100, () => {
|
||||
$('#add-camp-btn').hide(0);
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
$('.edit-btn').click(function() {
|
||||
$('#execution-form-wrapper').show(100, () => {
|
||||
$('#add-camp-btn').hide(0);
|
||||
})
|
||||
$('#table-wrapper').hide()
|
||||
let contacts = document.getElementById('execution-contact_id');
|
||||
contacts.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
let type = document.getElementById('execution-type_of_camp');
|
||||
type.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
$('#execution-msl_code,#execution-speciality,execution-plan_date').prop('readonly',true);
|
||||
|
||||
let selected = JSON.parse($(this).attr('plan_details'));
|
||||
console.log("Plan Detail : ", selected);
|
||||
if (selected['contact_id']) {
|
||||
selected['contact_id'] = selected['contact_id'].trim();
|
||||
}
|
||||
console.log("Selected Doctor:", selected['contact_id']);
|
||||
|
||||
|
||||
|
||||
for (let k of Object.keys(selected)) {
|
||||
//console.log("k",k);
|
||||
if (selected[k] != '') {
|
||||
if (k == 'contact_id') {
|
||||
//$("#execution-contact_id option:contains(" + selected[k] + ")").prop('selected', true)
|
||||
// console.log($("#execution-contact_id option:contains(" + selected[k] + ")").attr('value'))
|
||||
$('#execution-contact_id').val($("#execution-contact_id option:contains(" +
|
||||
selected[k] + ")").attr('value'));
|
||||
} else if (k == 'upload_photo_1' || k == 'upload_photo_2') {
|
||||
continue;
|
||||
} else {
|
||||
$('#execution-' + k).val(selected[k]);
|
||||
}
|
||||
}
|
||||
// if(selected[k] != '')
|
||||
// $('#execution-'+k).val(selected[k]);
|
||||
}
|
||||
|
||||
let docid = $('#execution-contact_id option').map(function() {
|
||||
if ($(this).text().trim() == selected['contact_id'] || $(this).val().trim() == selected['cont_id']) return this;
|
||||
}).attr('value')
|
||||
|
||||
$('#execution-contact_id').val(docid)
|
||||
$('#execution-id').val(selected['id'])
|
||||
|
||||
|
||||
|
||||
|
||||
$('#execution-reason').parent().hide();
|
||||
$('#execution-reason').prop('required',false);
|
||||
|
||||
/* $('#execution-execution_done').on('change',function(){
|
||||
let value=$(this).val();
|
||||
console.log("Value is ",value);
|
||||
|
||||
if(value==='Yes'){
|
||||
$('#execution-reason').parent().hide();
|
||||
$('#execution-reason').prop('required',false);
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="executed" value="1">');
|
||||
}
|
||||
else{
|
||||
$('#execution-reason').parent().show();
|
||||
$('#execution-reason').prop('required',true);
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="not_executed" value="0">');
|
||||
}
|
||||
}) */
|
||||
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').parent().hide();
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').attr('required',false);
|
||||
|
||||
$('#execution-execution').on('change',function(){
|
||||
let value=$('#execution-execution').val();
|
||||
if(value==='Yes'){
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').parent().show();
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').attr('required',true);
|
||||
$('#execution-reason').parent().hide();
|
||||
$('#execution-reason').prop('required',false);
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="executed" value="1">');
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').parent().hide();
|
||||
$('#execution-execution_date,#execution-patient_screened,#execution-patients_diagnosed,#execution-foracort_rx,#execution-seroflo_rx,#execution-duolin_rx,#execution-aerocort_rx,#execution-glycohale_fb_rx,#execution-e_voltido_rx,#execution-e_foracort_g_rx,#execution-e_synchrobreathe_range_rx').attr('required',false);
|
||||
$('#execution-reason').parent().show();
|
||||
$('#execution-reason').prop('required',true);
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="not_executed" value="0">');
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#execution-execution').trigger('change');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
const screened = document.getElementById('execution-patient_screened');
|
||||
const diagnosed = document.getElementById('execution-patients_diagnosed');
|
||||
|
||||
function validatePatients() {
|
||||
let screenedVal = parseInt(screened.value) || 0;
|
||||
let diagnosedVal = parseInt(diagnosed.value) || 0;
|
||||
|
||||
if (diagnosedVal > screenedVal) {
|
||||
alert('Patients Diagnosed cannot be greater than Patients Screened');
|
||||
diagnosed.value = screenedVal; // reset to max allowed
|
||||
}
|
||||
}
|
||||
|
||||
diagnosed.addEventListener('input', validatePatients);
|
||||
screened.addEventListener('input', validatePatients);
|
||||
|
||||
$('#execution-execution').on('change', function () {
|
||||
let value=$(this).val();
|
||||
|
||||
// Remove old hidden inputs
|
||||
$('#execution-form input.dynamic-hidden').remove();
|
||||
|
||||
// Convert dropdown value into slug format
|
||||
let slugName = $(this).val()
|
||||
.toLowerCase() // lowercase
|
||||
.replace(/\s+/g, '_'); // spaces to underscore
|
||||
|
||||
// Append hidden input
|
||||
if(value==='Yes'){
|
||||
$('#execution-form').append('<input type="hidden" class="dynamic-hidden" name="' + slugName + '" value="1">');
|
||||
}
|
||||
});
|
||||
|
||||
let typeValue=$('#execution-type_of_camp').val();
|
||||
console.log("Type of Value : ",typeValue);
|
||||
if(typeValue==='In Clinic camp'){
|
||||
$('#execution-form').append('<input type="hidden" name="in_clinic_camp_exe" value="1">');
|
||||
|
||||
}
|
||||
else{
|
||||
$('#execution-form').append('<input type="hidden" name="outreach_camp_exe" value="1">');
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$('#report-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
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'
|
||||
})
|
||||
window.location.reload();
|
||||
//$('#report-form').trigger("reset");
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Data not submitted',
|
||||
text: 'Something went wrong, please try again after some time!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#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').prop('readonly', true);
|
||||
|
||||
//$('#field-contact_id').append('<option value="others">Others</option>');
|
||||
|
||||
|
||||
$('#field-type_of_camp').on('change', function () {
|
||||
|
||||
// Remove old hidden inputs
|
||||
$('#report-form input.dynamic-hidden').remove();
|
||||
|
||||
// Convert dropdown value into slug format
|
||||
let slugName = $(this).val()
|
||||
.toLowerCase() // lowercase
|
||||
.replace(/\s+/g, '_'); // spaces to underscore
|
||||
|
||||
// Append hidden input
|
||||
$('#report-form').append(
|
||||
'<input type="hidden" class="dynamic-hidden" name="' + slugName + '" value="1">'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#execution-form').on('submit', function(event) {
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
data: new FormData($('#execution-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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var today = new Date(); // keep as Date object
|
||||
|
||||
var dd = String(today.getDate()).padStart(2, '0');
|
||||
var mm = String(today.getMonth() + 1).padStart(2, '0');
|
||||
var yyyy = today.getFullYear();
|
||||
|
||||
// formatted string (only if needed)
|
||||
var todayFormatted = yyyy + '-' + mm + '-' + dd;
|
||||
|
||||
var recordDateField = document.getElementById('field-plan_date');
|
||||
|
||||
// 👉 First day of current month
|
||||
let minDateObj = new Date(today.getFullYear(), today.getMonth(), 1);
|
||||
|
||||
// 👉 Last day of (current month + 2 months)
|
||||
let maxDateObj = new Date(today.getFullYear(), today.getMonth() + 3, 0);
|
||||
|
||||
// Convert to YYYY-MM-DD
|
||||
let minDate = minDateObj.toISOString().split('T')[0];
|
||||
let maxDate = maxDateObj.toISOString().split('T')[0];
|
||||
|
||||
// Apply
|
||||
recordDateField.min = minDate;
|
||||
recordDateField.max = maxDate;
|
||||
|
||||
// (Optional) set default value = today
|
||||
recordDateField.value = todayFormatted;
|
||||
|
||||
var executionDateField = document.getElementById('execution-plan_date');
|
||||
//executionDateField.setAttribute('min', today);
|
||||
|
||||
// $('.edit-btn').click(function() {
|
||||
// var executionexeField = document.getElementById('execution-record_date');
|
||||
// executionexeField.setAttribute('min', executionDateField.value);
|
||||
// });
|
||||
|
||||
|
||||
|
||||
executionDateField.addEventListener('change', function() {
|
||||
console.log('gg');
|
||||
var executionexeField = document.getElementById('execution-record_date');
|
||||
executionexeField.setAttribute('min', executionDateField.value);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,594 @@
|
|||
<!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" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</div>
|
||||
|
||||
@php
|
||||
// echo "<pre>";
|
||||
// print_r($form);
|
||||
// exit;
|
||||
|
||||
$data = DB::table('team3_tripleimpact')->where('hierarchy_id', $form->hierarchy_id)->get();
|
||||
// echo "<pre>";
|
||||
// print_r($data);
|
||||
// exit;
|
||||
|
||||
$history = Formhelper::getMultiformData($form->partition, $form->form_id, $form->user_id);
|
||||
// echo '<pre>';
|
||||
// print_r($history);
|
||||
// echo '</pre>';
|
||||
// exit
|
||||
|
||||
$existingCounts = [
|
||||
'chest' => 0,
|
||||
'pedia' => 0,
|
||||
'gp' => 0,
|
||||
];
|
||||
|
||||
if (!empty($history->data->submissions)) {
|
||||
foreach ($history->data->submissions as $sub) {
|
||||
$spec = strtolower($sub->formdata->speciality ?? '');
|
||||
|
||||
if ($spec === 'chest') {
|
||||
$existingCounts['chest']++;
|
||||
}
|
||||
if ($spec === 'pedia') {
|
||||
$existingCounts['pedia']++;
|
||||
}
|
||||
if ($spec === 'gp') {
|
||||
$existingCounts['gp']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
|
||||
<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
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
||||
<input type="hidden" name="user_id" value="{{ $form->user_id }}">
|
||||
|
||||
@csrf
|
||||
@php
|
||||
$editmode = false;
|
||||
@endphp
|
||||
@if ($id)
|
||||
<input type="hidden" name="id" value="{{ $id }}">
|
||||
@php
|
||||
$editmode = true;
|
||||
@endphp
|
||||
@endif
|
||||
@if ($id)
|
||||
<input type="hidden" name="id" 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 ($question->code == 'msl_code' && !$editmode)
|
||||
@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')
|
||||
@if ($question->code == 'contact_id')
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}" disabled
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option>--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
|
||||
</select>
|
||||
@else
|
||||
<select class="form-control" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option>--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
|
||||
</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 }}[]" 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
|
||||
|
||||
@case('time')
|
||||
<input type="time" id="field-{{ $question->code }}"
|
||||
name="{{ $question->code }}" class="form-control"
|
||||
{{ $question->required == 'yes' ? 'required' : '' }}
|
||||
value="{{ isset($question->value) ? $question->value : '' }}">
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<div
|
||||
class="d-flex flex-column flex-md-row align-items-start align-items-md-center gap-2 mt-2">
|
||||
|
||||
<button type="button" id="add_row" class="btn btn-primary">
|
||||
Add Doctor
|
||||
</button>
|
||||
|
||||
<span id="doctor_limit_info" class="text-muted fw-semibold"></span>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-2" id="doctor_msl_wrapper"></div>
|
||||
@if (!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'))
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
</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%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{ asset('assets/libs/sweetalert2/sweetalert2.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
let specialityData = @json($data[0]);
|
||||
let existingCounts = @json($existingCounts);
|
||||
let history = @json($history ?? null);
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
// =========================
|
||||
// HISTORY SETUP
|
||||
// =========================
|
||||
let submittedMSL = new Set();
|
||||
let submittedIDs = new Set();
|
||||
|
||||
if (history && history.data && history.data.submissions) {
|
||||
history.data.submissions.forEach(sub => {
|
||||
if (sub.contacts && sub.contacts.length) {
|
||||
sub.contacts.forEach(doc => {
|
||||
if (doc.msl_code) submittedMSL.add(String(doc.msl_code));
|
||||
if (doc.id) submittedIDs.add(String(doc.id));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// =========================
|
||||
// GLOBAL TRACKING (NEW FIX)
|
||||
// =========================
|
||||
function getAllSelectedDoctors() {
|
||||
let arr = [];
|
||||
$('.field-contact').each(function() {
|
||||
let v = $(this).val();
|
||||
if (v) arr.push(v);
|
||||
});
|
||||
return arr;
|
||||
}
|
||||
|
||||
function isDuplicate(value) {
|
||||
return getAllSelectedDoctors().filter(v => v === value).length > 1;
|
||||
}
|
||||
|
||||
function isAlreadySubmitted(value) {
|
||||
return submittedIDs.has(String(value));
|
||||
}
|
||||
|
||||
// =========================
|
||||
// USER CHANGE → LOAD DOCTORS
|
||||
// =========================
|
||||
$('#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) {
|
||||
|
||||
let id = String(itm.value);
|
||||
|
||||
let isDisabled = isAlreadySubmitted(id);
|
||||
|
||||
let option = $("<option></option>")
|
||||
.attr("value", id)
|
||||
.text(itm.display)
|
||||
.attr("msl_code", itm.contact.msl_code)
|
||||
.attr("speciality", itm.contact.speciality);
|
||||
|
||||
if (isDisabled) {
|
||||
option.prop('disabled', true)
|
||||
.text(itm.display + " (Already Submitted)");
|
||||
}
|
||||
|
||||
$('#field-contact_id').append(option);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// =========================
|
||||
// MATERIAL FILTER (UNCHANGED)
|
||||
// =========================
|
||||
const pediaMaterials = ['Pedia Hight Chart','Pedia Weighing Scale','Examination bedsheet','Torch'];
|
||||
const chestMaterials = ['X-ray Screen','BP Appratus Digital','Adult Weighing Scale'];
|
||||
const gpMaterials = ['X-ray Screen - H1','Pulse Oximeter - H1','BP Appratus Analog - H1','Torch - H1','Adult Weighing Scale - H1','Sthetoscope - H1'];
|
||||
|
||||
$('#field-speciality').on('change', function() {
|
||||
|
||||
let speciality = $(this).val();
|
||||
|
||||
$('#field-material_name option').each(function() {
|
||||
|
||||
let text = $(this).text().trim();
|
||||
|
||||
if (speciality === 'Pedia') {
|
||||
$(this).toggle(pediaMaterials.includes(text) || text === '-- Select --');
|
||||
} else if (speciality === 'Chest') {
|
||||
$(this).toggle(chestMaterials.includes(text) || text === '-- Select --');
|
||||
} else if (speciality === 'GP') {
|
||||
$(this).toggle(gpMaterials.includes(text) || text === '-- Select --');
|
||||
} else {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
|
||||
$('#field-material_name').val('');
|
||||
});
|
||||
|
||||
$('#field-contact_id').parent().hide();
|
||||
$('#field-contact_id').prop('required', false);
|
||||
|
||||
// =========================
|
||||
// DOCTOR CONFIG
|
||||
// =========================
|
||||
let maxCount = 0;
|
||||
let currentCount = 0;
|
||||
let batchSize = 5;
|
||||
let doctorName = $('#field-contact_id').html();
|
||||
|
||||
// =========================
|
||||
// SPECIALITY LOGIC
|
||||
// =========================
|
||||
$('#field-speciality').on('change', function() {
|
||||
|
||||
let selected = $(this).val().toLowerCase();
|
||||
|
||||
let totalAllowed =
|
||||
selected === 'chest' ? specialityData.chest :
|
||||
selected === 'pedia' ? specialityData.pedia :
|
||||
selected === 'gp' ? specialityData.gp : 0;
|
||||
|
||||
let alreadyAdded = existingCounts[selected] || 0;
|
||||
|
||||
maxCount = totalAllowed - alreadyAdded;
|
||||
if (maxCount < 0) maxCount = 0;
|
||||
|
||||
$('#doctor_msl_wrapper').html('');
|
||||
currentCount = 0;
|
||||
|
||||
if (maxCount === 0) {
|
||||
$('#submit-btn').prop('disabled', true);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#submit-btn').prop('disabled', false);
|
||||
|
||||
$('#doctor_limit_info')
|
||||
.removeClass('text-danger text-success')
|
||||
.addClass('text-success')
|
||||
.html(`You can add up to ${maxCount} doctors (in multiples of 5).`);
|
||||
|
||||
addDoctorBatch(5);
|
||||
});
|
||||
|
||||
// =========================
|
||||
// ADD DOCTOR BATCH
|
||||
// =========================
|
||||
function addDoctorBatch(count) {
|
||||
|
||||
if (maxCount === 0) return;
|
||||
|
||||
let nextBatch = count;
|
||||
|
||||
if (currentCount + nextBatch > maxCount) {
|
||||
nextBatch = maxCount - currentCount;
|
||||
}
|
||||
|
||||
if (nextBatch <= 0) return;
|
||||
|
||||
for (let i = 1; i <= nextBatch; i++) {
|
||||
|
||||
let index = currentCount + i;
|
||||
|
||||
$('#doctor_msl_wrapper').append(`
|
||||
<div class="doctor-row card shadow-sm border-0 mb-3" data-index="${index}">
|
||||
<div class="card-body p-3">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h6 class="mb-0 fw-semibold text-primary">Doctor ${index}</h6>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger remove_row">Remove</button>
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label mb-1">Doctor Name</label>
|
||||
<select class="form-control field-contact" name="contact_id[]" required>
|
||||
${doctorName}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label mb-1">MSL Code</label>
|
||||
<input type="text" class="form-control field-msl" name="msl_code[]" readonly required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
currentCount += nextBatch;
|
||||
}
|
||||
|
||||
// =========================
|
||||
// ADD BUTTON
|
||||
// =========================
|
||||
$('#add_row').on('click', function() {
|
||||
if (maxCount === 0) return;
|
||||
if (currentCount >= maxCount) return;
|
||||
addDoctorBatch(batchSize);
|
||||
});
|
||||
|
||||
// =========================
|
||||
// REMOVE ROW
|
||||
// =========================
|
||||
$(document).on('click', '.remove_row', function() {
|
||||
$(this).closest('.doctor-row').remove();
|
||||
currentCount = Math.max(0, currentCount - 1);
|
||||
});
|
||||
|
||||
// =========================
|
||||
// AUTO MSL FILL + DUPLICATE FIX (IMPORTANT CHANGE)
|
||||
// =========================
|
||||
$(document).on('change', '.field-contact', function() {
|
||||
|
||||
let val = $(this).val();
|
||||
let row = $(this).closest('.doctor-row');
|
||||
|
||||
// ❌ prevent already submitted doctor
|
||||
if (isAlreadySubmitted(val)) {
|
||||
$(this).val('');
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Already submitted doctor cannot be selected again'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// ❌ prevent duplicate in current UI
|
||||
if (isDuplicate(val)) {
|
||||
$(this).val('');
|
||||
Swal.fire({
|
||||
icon: 'warning',
|
||||
title: 'Duplicate Doctor'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let msl = $(this).find(':selected').attr('msl_code');
|
||||
row.find('.field-msl').val(msl);
|
||||
});
|
||||
|
||||
// =========================
|
||||
// SUBMIT AJAX
|
||||
// =========================
|
||||
$('#report-form').on('submit', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
$("#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('Success', 'Submitted!', 'success')
|
||||
.then(() => location.reload());
|
||||
} else {
|
||||
Swal.fire('Error', 'Failed', 'error');
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,426 @@
|
|||
<!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" />
|
||||
</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
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||
|
||||
@csrf
|
||||
@php
|
||||
$editmode = false;
|
||||
@endphp
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@php
|
||||
$editmode = true;
|
||||
@endphp
|
||||
@endif
|
||||
@if($id)
|
||||
<input type="hidden" name="id" 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(($question->code == 'msl_code') && !$editmode)
|
||||
@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>--Select--</option>
|
||||
@foreach ($question->options as $option)
|
||||
<option value="{{ $option->display }}" {{ isset($question->display) && $question->display == $option->display ? '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
|
||||
</select>
|
||||
@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}}[]" 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
|
||||
|
||||
@case('time')
|
||||
<input type="time"
|
||||
id="field-{{$question->code}}"
|
||||
name="{{$question->code}}"
|
||||
class="form-control"
|
||||
{{$question->required == 'yes' ? 'required' : ''}}
|
||||
value="{{isset($question->value) ? $question->value : ''}}">
|
||||
@break
|
||||
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
<div class=" mb-2" id="doctor_msl_wrapper">
|
||||
|
||||
</div>
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
</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%;
|
||||
}
|
||||
</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,
|
||||
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)
|
||||
})
|
||||
|
||||
|
||||
const pediaMaterials = [
|
||||
'Pedia Hight Chart',
|
||||
'Pedia Weighing Scale',
|
||||
'Examination bedsheet',
|
||||
'Torch'
|
||||
];
|
||||
|
||||
const chestMaterials=[
|
||||
'X-ray Screen',
|
||||
'BP Appratus Digital',
|
||||
'Adult Weighing Scale'
|
||||
];
|
||||
|
||||
const gpMaterials=[
|
||||
'X-ray Screen - H1',
|
||||
'Pulse Oximeter - H1',
|
||||
'BP Appratus Analog - H1',
|
||||
'Torch - H1',
|
||||
'Adult Weighing Scale - H1',
|
||||
'Sthetoscope - H1'
|
||||
];
|
||||
|
||||
$('#field-speciality').on('change', function () {
|
||||
let speciality = $(this).val();
|
||||
|
||||
$('#field-material_name option').each(function () {
|
||||
let text = $(this).text().trim();
|
||||
|
||||
if (speciality === 'Pedia') {
|
||||
if (!pediaMaterials.includes(text) && text !== '-- Select --') {
|
||||
$(this).hide();
|
||||
}
|
||||
|
||||
else {
|
||||
$(this).show();
|
||||
}
|
||||
}
|
||||
else if (speciality === 'Chest') {
|
||||
if (!chestMaterials.includes(text) && text !== '-- Select --') {
|
||||
$(this).hide();
|
||||
}
|
||||
|
||||
else {
|
||||
$(this).show();
|
||||
}
|
||||
}
|
||||
|
||||
else if (speciality === 'GP') {
|
||||
if (!gpMaterials.includes(text) && text !== '-- Select --') {
|
||||
$(this).hide();
|
||||
}
|
||||
|
||||
else {
|
||||
$(this).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
else {
|
||||
$(this).show(); // show all for other specialities
|
||||
}
|
||||
});
|
||||
|
||||
// Reset dropdown value
|
||||
$('#field-material_name').val('');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#field-contact_id').parent().hide();
|
||||
$('#field-contact_id').prop('required',false);
|
||||
|
||||
@if(!$editmode)
|
||||
$('#field-input_qty').on('change',function(){
|
||||
let doctorName=$('#field-contact_id').html();
|
||||
|
||||
console.log(doctorName);
|
||||
let qtyValue=parseInt($(this).val());
|
||||
$('#doctor_msl_wrapper').html('')
|
||||
for(let i = 1; i <= qtyValue; i++) {
|
||||
$('#doctor_msl_wrapper').append(`<div class="col-md-12 mb-2">
|
||||
<label for="field-doctor_name_${i}" class="form-label">Doctor Name ${i}<span class="text-danger">*</span> </label>
|
||||
<select class="form-control" id="field-contact_id_${i}" name="contact_id_${i}" required>
|
||||
${doctorName}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-msl_code_${i}" class="form-label">MSL Code ${i}<span class="text-danger">*</span> </label>
|
||||
<input type="text" id="field-msl_code_${i}" name="msl_code_${i}" class="form-control" value="" required>
|
||||
</div>
|
||||
`)
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
$(`#field-contact_id_${i}`).on('change',function(){
|
||||
$(`#field-msl_code_${i}`).val($(this).find(":selected").attr("msl_code"));
|
||||
})
|
||||
|
||||
$(`#field-msl_code_${i}`).attr('readonly',true);
|
||||
|
||||
}, 500);
|
||||
|
||||
}
|
||||
})
|
||||
@else
|
||||
$('#field-input_qty').prop('readonly', true)
|
||||
|
||||
@endif
|
||||
|
||||
|
||||
$(document).on('change', 'select[id^="field-contact_id_"]', function () {
|
||||
|
||||
let selectedValues = [];
|
||||
|
||||
// Collect all selected doctor values
|
||||
$('select[id^="field-contact_id_"]').each(function () {
|
||||
let val = $(this).val();
|
||||
if (val) {
|
||||
selectedValues.push(val);
|
||||
}
|
||||
});
|
||||
|
||||
// Loop again to disable already selected options
|
||||
$('select[id^="field-contact_id_"]').each(function () {
|
||||
let currentDropdown = $(this);
|
||||
|
||||
currentDropdown.find('option').each(function () {
|
||||
let optionVal = $(this).val();
|
||||
let originalText = $(this).data('original-text');
|
||||
|
||||
// Store original text once
|
||||
if (!originalText) {
|
||||
$(this).data('original-text', $(this).text());
|
||||
originalText = $(this).text();
|
||||
}
|
||||
|
||||
if (optionVal === '') return; // skip "-- Select --"
|
||||
|
||||
// Enable all first & reset text
|
||||
$(this).prop('disabled', false).text(originalText);
|
||||
|
||||
// Disable if already selected in another dropdown
|
||||
if (selectedValues.includes(optionVal) && optionVal !== currentDropdown.val()) {
|
||||
$(this)
|
||||
.prop('disabled', true)
|
||||
.text(originalText + ' (Already added)');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
const formData = new FormData($('#report-form')[0]);
|
||||
// Log form data to console
|
||||
for (let [key, value] of formData.entries()) {
|
||||
console.log(key, value);
|
||||
}
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
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!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
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>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue