Merge branch 'main' of http://192.168.1.200:3000/Stratawiz/Rapport-Laravel
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m37s Details

This commit is contained in:
Tanuja Pansare 2026-06-17 10:45:14 +05:30
commit c87cf631b4
3 changed files with 1368 additions and 254 deletions

View File

@ -33,6 +33,12 @@
'nac + acebrophylline' => 'nac_acebrophylline', 'nac + acebrophylline' => 'nac_acebrophylline',
]; ];
$categoryMoleculeUse = [
'erdosteine' => 'Erdosteine Prescriber',
'erdosteine + acebrophylline' => 'Erdosteine + Acebrophylline',
'nac + acebrophylline' => 'NAC + Acebrophylline',
];
$moleculeUseToCategory = [ $moleculeUseToCategory = [
'erdosteine prescriber' => 'erdosteine', 'erdosteine prescriber' => 'erdosteine',
'erdosteine' => 'erdosteine', 'erdosteine' => 'erdosteine',
@ -183,10 +189,10 @@
@php @php
$hideFields = [ $hideFields = [
'contact_id', 'contact_id',
'rx_support', 'rx_support',
'other_molecule_use' 'other_molecule_use',
'molecule_use',
]; ];
@endphp @endphp
@ -328,114 +334,69 @@
@endforeach @endforeach
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) ) @if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
<div class="text-center d-gri mt-3"> <div class="text-center d-gri mt-3">
@php $globalRowIndex = 0; @endphp
@foreach($categoryAttributes as $categoryLabel => $categoryPrefix)
<div class="col-md-12 mt-3"> <div class="col-md-12 mt-3">
<div class="card"> <div class="card">
{{-- <div class="card-header"> <div class="card-header">
<h5 class="mb-0">Tagged Doctors</h5> <h5 class="mb-0">{{ ucwords($categoryLabel) }}</h5>
</div> --}} </div>
<div class="card-body p-0"> <div class="card-body p-0">
<div class="table-responsive"> <div class="table-responsive">
@php <table class="table table-bordered mb-0">
$doctors = []; <thead>
<tr>
foreach($questions as $question){ <th>Doctor Name</th>
if($question->code == 'contact_id'){ <th>Rxn/Week Support</th>
$doctors = $question->options ?? []; <th>Other Molecule Use</th>
break; </tr>
} </thead>
} <tbody
@endphp class="doctor-table-body"
<table class="table table-bordered mb-0"> data-category="{{ $categoryPrefix }}"
<thead> data-molecule-use="{{ $categoryMoleculeUse[$categoryLabel] }}"
<tr> >
<th>Doctor Name</th> @for($i = 1; $i <= 5; $i++)
<tr class="doctor-row" data-row-index="{{ $globalRowIndex }}">
<th>Rxn/Week Support</th> <td>
<select
<th>Other Molecule Use</th> class="form-control doctor-select"
</tr> required
</thead> >
<tbody id="doctor-table-body"> <option value="">-- Select Doctor --</option>
@foreach($doctors as $doctor)
@for($i=1; $i<=5; $i++) <option value="{{ $doctor->value }}">{{ $doctor->display }}</option>
<tr>
<td>
<select
name="contact_id[]"
class="form-control doctor-select"
required
>
<option value="">-- Select Doctor --</option>
@foreach($questions as $question)
@if($question->code == 'contact_id')
@foreach($question->options as $doctor)
<option value="{{$doctor->value}}">
{{$doctor->display}}
</option>
@endforeach @endforeach
</select>
@endif </td>
<td>
@endforeach <select class="form-control rx-support-select" required>
<option value="">-- Select --</option>
</select> <option value="1-3 Rxn/Week">1-3 Rxn/Week</option>
</td> <option value="4-7 Rxn/Week">4-7 Rxn/Week</option>
<option value="8-11 Rxn/Week">8-11 Rxn/Week</option>
<td> <option value=">11 Rxn/Week">&gt;11 Rxn/Week</option>
</select>
<select </td>
name="rx_support[]" <td>
class="form-control" <select class="form-control other-molecule-select" required>
required <option value="">-- Select --</option>
> <option value="Erdosteine Prescriber">Erdosteine Prescriber</option>
<option value="">-- Select --</option> <option value="Erdosteine + Acebrophylline">Erdosteine + Acebrophylline Prescriber</option>
<option value="1-3 Rxn/Week">1-3 Rxn/Week</option> <option value="NAC + Acebrophylline">NAC + Acebrophylline Prescriber</option>
<option value="4-7 Rxn/Week">4-7 Rxn/Week</option> <option value="No">No</option>
<option value="8-11 Rxn/Week">8-11 Rxn/Week</option> </select>
<option value=">11 Rxn/Week">&gt;11 Rxn/Week</option> </td>
</select> </tr>
</td> @php $globalRowIndex++; @endphp
@endfor
<td> </tbody>
</table>
<select </div>
name="other_molecule_use[]"
class="form-control"
required
>
<option value="">-- Select --</option>
<option value="Erdosteine Prescriber">
Erdosteine Prescriber
</option>
<option value="Erdosteine + Acebrophylline">
Erdosteine + Acebrophylline
</option>
<option value="NAC + Acebrophylline">
NAC + Acebrophylline
</option>
<option value="No">
No
</option>
</select>
</td>
</tr>
@endfor
</tbody>
</table>
</div> </div>
</div> </div>
</div> </div>
</div> @endforeach
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button> <button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
</div> </div>
@ -500,78 +461,61 @@ select option:disabled {
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script> <script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
<script type="text/javascript"> <script type="text/javascript">
var allDoctors = {!! json_encode($doctors) !!};
var categoryAttributes = {!! json_encode($categoryAttributes) !!};
var moleculeUseToCategory = {!! json_encode($moleculeUseToCategory) !!};
var categorySubmissions = {!! json_encode($categorySubmissions) !!};
var categoryDoctorSubmissions = {!! json_encode($categoryDoctorSubmissions) !!}; var categoryDoctorSubmissions = {!! json_encode($categoryDoctorSubmissions) !!};
jQuery(document).ready(function($){ jQuery(document).ready(function($){
function resolveCategoryIndex(moleculeUse) { function getDoctorRows() {
if (!moleculeUse) { let rows = [];
return null;
}
let normalized = moleculeUse.toLowerCase().trim(); $('.doctor-table-body').each(function() {
let categoryKey = moleculeUseToCategory[normalized] || normalized; let $tbody = $(this);
let moleculeUse = $tbody.data('molecule-use');
return categoryAttributes[categoryKey] || null; $tbody.find('tr.doctor-row').each(function() {
rows.push({
$row: $(this),
moleculeUse: moleculeUse,
rowIndex: $(this).data('row-index')
});
});
});
return rows;
} }
function removeSubmissionId($row) { function removeSubmissionId($row) {
$row.removeAttr('data-submission-id');
$row.find('.submission-id').remove(); $row.find('.submission-id').remove();
} }
function setSubmissionId($row, submissionId) { function setSubmissionId($row, submissionId) {
let $input = $row.find('.submission-id'); if (submissionId) {
$row.attr('data-submission-id', submissionId);
if (!$input.length) {
$input = $('<input>', {
type: 'hidden',
class: 'submission-id',
name: 'id[]'
});
$row.find('td').first().prepend($input);
} else { } else {
$input.attr('name', 'id[]'); removeSubmissionId($row);
} }
$input.val(submissionId || '');
} }
function clearDoctorTableRow($row) { function clearDoctorTableRow($row) {
removeSubmissionId($row); removeSubmissionId($row);
$row.find('.doctor-select').val('').trigger('change'); $row.find('.doctor-select').val('').trigger('change');
$row.find('select[name="rx_support[]"]').val(''); $row.find('.rx-support-select').val('');
$row.find('select[name="other_molecule_use[]"]').val(''); $row.find('.other-molecule-select').val('');
} }
function clearDoctorTable() { function prefillDoctorTableSection($tbody, categoryPrefix) {
$('#doctor-table-body tr').each(function() { let categoryDoctors = categoryDoctorSubmissions[categoryPrefix] || {};
clearDoctorTableRow($(this));
});
$('#field-record_date').val('');
}
function prefillDoctorTableFromCategory(categoryIndex) {
clearDoctorTable();
if (!categoryIndex) {
return;
}
let categoryDoctors = categoryDoctorSubmissions[categoryIndex] || {};
let submissions = Object.values(categoryDoctors); let submissions = Object.values(categoryDoctors);
if (!submissions.length) { if (!submissions.length) {
return; return;
} }
if (submissions[0].record_date) { if (submissions[0].record_date && !$('#field-record_date').val()) {
$('#field-record_date').val(submissions[0].record_date); $('#field-record_date').val(submissions[0].record_date);
} }
$('#doctor-table-body tr').each(function(index) { $tbody.find('tr.doctor-row').each(function(index) {
let submission = submissions[index]; let submission = submissions[index];
if (!submission) { if (!submission) {
return false; return false;
@ -581,137 +525,175 @@ select option:disabled {
$row.find('.doctor-select') $row.find('.doctor-select')
.val(submission.doctor_id) .val(submission.doctor_id)
.trigger('change'); .trigger('change');
$row.find('select[name="rx_support[]"]') $row.find('.rx-support-select')
.val(submission.rx_support || ''); .val(submission.rx_support || '');
$row.find('select[name="other_molecule_use[]"]') $row.find('.other-molecule-select')
.val(submission.other_molecule_use || ''); .val(submission.other_molecule_use || '');
setSubmissionId($row, submission.submission_id); setSubmissionId($row, submission.submission_id);
}); });
} }
function updateDoctorDropdowns() { function prefillAllDoctorTables() {
$('.doctor-table-body').each(function() {
let selectedDoctors = []; prefillDoctorTableSection($(this), $(this).data('category'));
});
$('.doctor-select').each(function(){
let value = $(this).val();
if(value){
selectedDoctors.push(value);
} }
}); function updateDoctorDropdowns($tbody) {
let selectedDoctors = [];
$('.doctor-select').each(function(){ $tbody.find('.doctor-select').each(function() {
let value = $(this).val();
if (value) {
selectedDoctors.push(value);
}
});
let currentDropdown = $(this); $tbody.find('.doctor-select').each(function() {
let currentValue = currentDropdown.val(); let currentDropdown = $(this);
let currentValue = currentDropdown.val();
currentDropdown.find('option').each(function(){ currentDropdown.find('option').each(function() {
let option = $(this);
let originalText = option.data('original-text') || option.text();
let option = $(this); option.data('original-text', originalText);
option.text(originalText);
option.prop('disabled', false);
let originalText = let optionValue = option.val();
option.data('original-text') || option.text();
option.data('original-text', originalText); if (
optionValue &&
optionValue !== currentValue &&
selectedDoctors.includes(optionValue)
) {
option.prop('disabled', true);
option.text(originalText + ' (Already Added)');
}
});
});
}
option.text(originalText); function updateOtherMoleculeDropdowns($tbody) {
let sectionMolecule = $tbody.data('molecule-use');
option.prop('disabled', false); $tbody.find('.other-molecule-select').each(function() {
let ddl = $(this);
let optionValue = option.val(); ddl.find('option').each(function() {
let option = $(this);
let originalText = option.data('original-text') || option.text();
if( option.data('original-text', originalText);
optionValue && option.text(originalText);
optionValue !== currentValue && option.prop('disabled', false);
selectedDoctors.includes(optionValue)
){
option.prop('disabled', true);
option.text( if (sectionMolecule && option.val() === sectionMolecule) {
originalText + option.prop('disabled', true);
' (Already Added)' option.text(originalText + ' (Already Added)');
); }
} });
});
}
function buildSubmitFormData() {
let fd = new FormData();
let form = $('#report-form')[0];
let rowFieldClasses = ['doctor-select', 'rx-support-select', 'other-molecule-select'];
Array.from(form.elements).forEach(function(el) {
if (!el.name || el.disabled) {
return;
}
if (el.name.match(/^id(\[|$)/)) {
return;
}
if (rowFieldClasses.some(function(cls) { return el.classList.contains(cls); })) {
return;
}
if (el.type === 'file') {
if (el.files.length) {
fd.append(el.name, el.files[0]);
}
return;
}
if (el.type === 'checkbox') {
if (el.checked) {
fd.append(el.name, el.value);
}
return;
}
if (el.type === 'radio') {
if (el.checked) {
fd.append(el.name, el.value);
}
return;
}
if (el.tagName === 'SELECT' && el.multiple) {
Array.from(el.selectedOptions).forEach(function(option) {
fd.append(el.name, option.value);
});
return;
}
fd.append(el.name, el.value);
});
getDoctorRows().forEach(function(item) {
let $row = item.$row;
fd.append('contact_id[]', $row.find('.doctor-select').val());
fd.append('rx_support[]', $row.find('.rx-support-select').val());
fd.append('other_molecule_use[]', $row.find('.other-molecule-select').val());
fd.append('molecule_use[]', item.moleculeUse);
let submissionId = $row.attr('data-submission-id');
if (submissionId) {
fd.append('id[' + item.rowIndex + ']', submissionId);
}
});
return fd;
}
$(document).on('change', '.doctor-select', function() {
updateDoctorDropdowns($(this).closest('.doctor-table-body'));
}); });
});
}
$(document).on(
'change',
'.doctor-select',
updateDoctorDropdowns
);
updateDoctorDropdowns();
function updateOtherMoleculeDropdowns() {
let selectedMolecule = $('#field-molecule_use').val();
let categoryIndex = resolveCategoryIndex(selectedMolecule);
$('select[name="other_molecule_use[]"]').each(function(){
let ddl = $(this);
ddl.find('option').each(function(){
let option = $(this);
let originalText =
option.data('original-text') || option.text();
option.data('original-text', originalText);
option.text(originalText);
option.prop('disabled', false);
if(
selectedMolecule &&
option.val() === selectedMolecule
){
option.prop('disabled', true);
option.text(
originalText + ' (Already Added)'
);
}
});
});
prefillDoctorTableFromCategory(categoryIndex);
updateDoctorDropdowns();
}
$('#field-molecule_use').on('change', updateOtherMoleculeDropdowns);
$('.doctor-select').select2({ $('.doctor-select').select2({
width: '100%', width: '100%',
placeholder: 'Search Doctor', placeholder: 'Search Doctor',
allowClear: true allowClear: true
}); });
if ($('#field-molecule_use').val()) { prefillAllDoctorTables();
updateOtherMoleculeDropdowns();
} else {
clearDoctorTable();
}
$('#report-form').on('submit', function(event){
$('.doctor-table-body').each(function() {
let $tbody = $(this);
updateOtherMoleculeDropdowns($tbody);
updateDoctorDropdowns($tbody);
});
$('#report-form').on('submit', function(event) {
event.preventDefault(); event.preventDefault();
let fd = new FormData($('#report-form')[0]);
for (let pair of fd.entries()) {
console.log(pair[0], pair[1]);
}
$("#pageloader").fadeIn(); $("#pageloader").fadeIn();
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '/form/ajaxsubmitmultiple', url: '/form/ajaxsubmitmultiple',
data: new FormData($('#report-form')[0]), data: buildSubmitFormData(),
processData: false, processData: false,
contentType: false, contentType: false,
success: function(data) { success: function(data) {
$("#pageloader").fadeOut(); $("#pageloader").fadeOut();
if(data.status == 'success') { if (data.status == 'success') {
Swal.fire({ Swal.fire({
title: 'Great!', title: 'Great!',
text: 'Your data is successfully submitted!', text: 'Your data is successfully submitted!',
@ -735,14 +717,6 @@ for (let pair of fd.entries()) {
} }
}); });
}); });
@if($id)
setTimeout(function () {
console.log("EDIT MODE TRIGGERED");
$('#field-select-category').trigger('change');
}, 300);
@endif
}); });
</script> </script>
</body> </body>

View File

@ -0,0 +1,375 @@
<!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>
@if ($question->code == 'contact_id')
@foreach ($question->options as $option)
@if( isset($option->contact->ciphaler_rxber) && $option->contact->ciphaler_rxber == 'Yes' )
<option value="{{ $option->value }}" pcode="{{isset($option->contact->pcode)?$option->contact->pcode:''}}" msl_code="{{isset($option->contact->msl_code)?$option->contact->msl_code:''}}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
{{ $option->display }}
</option>
@endif
@endforeach
<option value="others">Others</option>
@else
@foreach ($question->options as $option)
<option value="{{ $option->value }}" pcode="{{isset($option->contact->pcode)?$option->contact->pcode:''}}" msl_code="{{isset($option->contact->msl_code)?$option->contact->msl_code:''}}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
{{ $option->display }}
</option>
@endforeach
@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($){
var today = new Date().toISOString().split('T')[0];
$('#field-record_date').attr('max', today);
// Allow only whole numbers between 0 and 100
$('#field-no_foracort_g_ciphaler_rxns_generated, #field-no_glycohale_fb_ciphaler_rxns_generated').on('input', function () {
let value = $(this).val();
// Remove decimals and non-numeric characters
value = value.replace(/[^0-9]/g, '');
if (value !== '') {
value = parseInt(value, 10);
if (value > 100) value = 100;
if (value < 0) value = 0;
}
$(this).val(value);
});
$('#field-no_foracort_g_ciphaler_rxns_generated, #field-no_glycohale_fb_ciphaler_rxns_generated')
.attr({
min: 0,
max: 100,
step: 1
});
$('#field-user_id').change(function(){
let hierarchy = $('option:selected', this).attr('hierarchy');
$('#field-hierarchy_id').val(hierarchy)
event.preventDefault();
$("#pageloader").fadeIn();
$.ajax({
type: "GET",
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
processData: false,
contentType: false,
success: function( data ) {
$("#pageloader").fadeOut();
$('#field-contact_id').html('')
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
for (let itm of data) {
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display).attr("msl_code", itm.contact.msl_code).attr('speciality',itm.contact.speciality));
}
$('#field-contact_id').change(function() {
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
})
$('#field-contact_id').change(function() {
$('#field-speciality').val($('option:selected', this).attr('speciality'))
})
},
});
console.log(hierarchy)
})
$('#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-name_of_other_hcp').change(function() {
$('#field-p_code_of_other_hcp').val($('option:selected', this).attr('msl_code'))
})
$('#field-p_code_of_other_hcp').attr('readonly',true);
$('#field-msl_code').attr('readonly',true);
$('#field-name_of_other_hcp,#field-p_code_of_other_hcp').prop({"required":false});
$('#field-name_of_other_hcp,#field-p_code_of_other_hcp').parent().hide();
$('#field-contact_id').on('change',function(){
let dropDown=$('#field-contact_id').val();
if(dropDown==='others'){
$('#field-name_of_other_hcp,#field-p_code_of_other_hcp').parent().show();
$('#field-name_of_other_hcp,#field-p_code_of_other_hcp').prop({"required":true});
$('#field-msl_code').parent().hide();
$('#field-msl_code').prop({"required":false});
}
else{
$('#field-name_of_other_hcp,#field-p_code_of_other_hcp').parent().hide();
$('#field-name_of_other_hcp,#field-p_code_of_other_hcp').prop({"required":false});
$('#field-msl_code').parent().show();
$('#field-msl_code').prop({"required":true});
}
})
// $('#field-contact_id').append('<option value="others">Others</option>');
$('#field-sitazit_d_rx,#field-sitazit_dm_rx,#field-ziten_m_rx').on('input', function() {
var total=(
(parseInt($('#execution-sitazit_d_rx').val())*15 ||0)+
(parseInt($('#execution-sitazit_dm_rx').val())*25 ||0)+
(parseInt($('#execution-ziten_m_rx').val())*35 ||0)
);
$('#execution-total_camp_rx').val(total)
})
$('#field-file_upload').on('change', function () {
let file = this.files[0];
if (file) {
let allowedTypes = ['image/png', 'image/jpg', 'image/jpeg'];
let maxSize = 10 * 1024 * 1024; // 10 MB
// Type validation
if (!allowedTypes.includes(file.type)) {
alert('Only PNG, JPG, and JPEG files are allowed.');
$(this).val('');
return;
}
// Size validation
if (file.size > maxSize) {
alert('File size should not exceed 10 MB.');
$(this).val('');
return;
}
}
});
$(document).ready(function () {
$('#field-contact_id').trigger('change');
});
$('#field-city,#field-state,#field-departmental_head_name').on('input', function () {
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
});
$('#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>

View File

@ -0,0 +1,765 @@
<!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">Report Novel 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 Novel Meet 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 Done</th>
<th>Speaker Name</th>
<th>Actual Activity Date</th>
<th>Pcode</th>
<th>Expected No. Of Attendees</th>
<th>Actual No. Of Attendees</th>
</tr>
</thead>
<tbody>
@foreach ($history->data->submissions 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>Report Execution</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>{{$sub->formdata->execution_date}}</td>
<td>{{isset($sub->formdata->msl_code ) ? $sub->formdata->msl_code : ''}}
</td>
<td>{{isset($sub->formdata->expected_no_of_attendees) ? $sub->formdata->expected_no_of_attendees : '' }}
</td>
<td>{{isset($sub->formdata->actual_no_of_attendees) ? $sub->formdata->actual_no_of_attendees : '' }}
</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','actual_no_of_attendees' ,'hcp_name','pcode_of_wrapper_doctor','speaker_name']))
@continue
@endif
<div class="col-md-12 mb-2">
<label for="field-{{ $question->code }}"
class="form-label">{{ $question->question }} {!! $question->required ==
'yes' ? '<span class="text-danger">*</span>' : '' !!}
</label>
@switch($question->type)
@case('hidden')
<input type="{{ $question->type }}" id="field-{{ $question->code }}"
name="{{ $question->code }}"
value="{{ isset($question->value) ? $question->value : '' }}">
@break
@case('text')
@case('email')
@case('tel')
@case('date')
<input type="{{ $question->type }}" id="field-{{ $question->code }}"
name="{{ $question->code }}" class="form-control"
{{ $question->required == 'yes' ? 'required' : '' }}
value="{{ isset($question->value) ? $question->value : '' }}">
@break
@case('number')
<input type="{{ $question->type }}" min="0" max="9999999999" step="1"
id="field-{{ $question->code }}" name="{{ $question->code }}"
class="form-control" {{ $question->required == 'yes' ? 'required' : '' }}
value="{{ isset($question->value) ? $question->value : 0 }}">
@break
@case('textarea')
<textarea id="field-{{ $question->code }}" name="{{ $question->code }}"
class="form-control"
{{ $question->required == 'yes' ? 'required' : '' }}>{{ isset($question->value) ? $question->value : '' }}</textarea>
@break
@case('dropdown')
<select class="form-control" id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
<option value=""> -- Select -- </option>
@foreach ($question->options as $option)
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
{{ $option->display }}
</option>
@endforeach
<option value="Other">Other</option>
</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)
<option value="{{ $option->value }}"
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
{{ $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="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
<div class="doctor-group-wrapper">
<div class="row">
<div class="col-6"><h4>Add Doctors</h4></div>
{{-- <div class="col-6"><button class="btn btn-info btn-xs float-end" type="button" id="add-doctor">Add</button></div>
</div> --}}
<div class="doctor-group row">
<div class="col-10">
@foreach ($questions as $question)
@if(in_array($question->code,['hcp_name','speaker_name']))
<label for="field-{{ $question->code }}"
class="form-label mt-2">{{ $question->question }} {!! $question->required == 'yes' ? '<span class="text-danger">*</span>' : '' !!}
</label>
<select class="form-control doctor_select" id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
<option value=""> -- Select -- </option>
@foreach ($question->options as $option)
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'hcp_name' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'hcp_name' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
{{ $option->display }}
</option>
@endforeach
</select>
@endif
@if(in_array($question->code,['pcode_of_wrapper_doctor']))
<label for="field-{{ $question->code }}"
class="form-label mt-2">{{ $question->question }} {!! $question->required == 'yes' ? '<span class="text-danger">*</span>' : '' !!}
</label>
<input type="{{ $question->type }}" id="field-{{ $question->code }}"
name="{{ $question->code }}" class="form-control"
{{ $question->required == 'yes' ? 'required' : '' }}
value="{{ isset($question->value) ? $question->value : '' }}">
@endif
@endforeach
</div>
<div class="col-2">
<button class="btn btn-danger btn-xs float-end remove-doctor mt-4 d-none" type="button"><i class="mdi mdi-close"></i></button>
</div>
</div>
<hr style="margin:0px" />
</div>
<div class="execution-doctor-group-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>
</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()
var count = 1
// $("#add-doctor").click(function(){
// count++;
// var doctor_html = $(".doctor-group").first().html();
// let loop = 0;
// doctor_html = doctor_html.replaceAll('hcp_name', 'hcp_name_'+count)
// doctor_html = doctor_html.replaceAll('pcode_of_wrapper_doctor', 'pcode_of_wrapper_doctor_'+count)
// doctor_html = doctor_html.replaceAll('speaker_name', 'speaker_name_'+count)
// $(".doctor-group-wrapper").append('<div class="doctor-group row">'+doctor_html+'</div>')
// $(".doctor-group").each(function(index){
// if(index > 0)
// $(this).find('.remove-doctor').removeClass('d-none')
// })
// $('.remove-doctor').unbind()
// $('.remove-doctor').click(function(){
// $(this).parent().parent()[0].remove()
// })
// $('#field-hcp_name_'+count).change(function() {
// $('#field-pcode_of_wrapper_doctor_'+count).val($('option:selected', this).attr('msl_code'))
// })
// });
$('.doctor-group-wrapper').hide();
/* $('#execution-actual_no_of_attendees').on('input', function() {
let attendees = parseInt($(this).val()) || 0;
$('.doctor-group-wrapper').show();
// Existing generated groups remove
$('.doctor-group-wrapper .doctor-group:not(:first)').remove();
if (attendees <= 0) {
$('.doctor-group-wrapper').hide();
return;
}
let firstGroup = $('.doctor-group').first();
// First group reset
firstGroup.find('select').val('');
firstGroup.find('input[type=text]').val('');
// Required number of groups create
for (let count = 2; count <= attendees; count++) {
let doctor_html = firstGroup.html();
doctor_html = doctor_html.replaceAll(
'hcp_name',
'hcp_name_' + count
);
doctor_html = doctor_html.replaceAll(
'pcode_of_wrapper_doctor',
'pcode_of_wrapper_doctor_' + count
);
doctor_html = doctor_html.replaceAll(
'speaker_name',
'speaker_name_' + count
);
$('.execution-doctor-group-wrapper').append(
'<div class="doctor-group row">' +
doctor_html +
'</div>'
);
$('#field-hcp_name_' + count).change(function() {
$('#field-pcode_of_wrapper_doctor_' + count).val(
$('option:selected', this).attr('msl_code')
);
});
}
}); */
$('#execution-actual_no_of_attendees').on('input', function() {
let attendees = parseInt($(this).val()) || 0;
$('.doctor-group-wrapper').show();
// आधीचे सर्व जनरेट झालेले ग्रुप्स साफ करा
$('.execution-doctor-group-wrapper').empty();
if (attendees <= 0) {
$('.doctor-group-wrapper').hide();
return;
}
let firstGroup = $('.doctor-group').first();
firstGroup.find('select').val('');
firstGroup.find('input[type=text]').val('');
for (let count = 2; count <= attendees; count++) {
let doctor_html = firstGroup.html();
doctor_html = doctor_html.replaceAll('hcp_name', 'hcp_name_' + count);
doctor_html = doctor_html.replaceAll('pcode_of_wrapper_doctor', 'pcode_of_wrapper_doctor_' + count);
doctor_html = doctor_html.replaceAll('speaker_name', 'speaker_name_' + count);
$('.execution-doctor-group-wrapper').append(
'<div class="doctor-group row">' + doctor_html + '</div>'
);
(function(c) {
$('#field-hcp_name_' + c).change(function() {
let selectedOption = $('option:selected', this);
$('#field-pcode_of_wrapper_doctor_' + c).val(selectedOption.attr('msl_code'));
// २. सर्वात महत्त्वाचे: या ड्रॉपडाउनची 'value' बदलून थेट डॉक्टरांचे 'नाव' सेट करा
let doctorName = selectedOption.text().trim();
if(doctorName !== "" && doctorName !== "-- Select --") {
selectedOption.val(doctorName);
}
});
})(count);
}
});
$('#field-hcp_name').change(function() {
$('#field-pcode_of_wrapper_doctor').val($('option:selected', this).attr('msl_code'))
})
$('.remove-doctor').click(function(){
$(this).parent().parent()[0].remove()
})
$('#field-doctor_1').change(function() {
$('#field-speciality_1').val($('option:selected', this).attr(
'speciality'))
$('#field-msl_code_1').val($('option:selected', this).attr(
'msl_code'))
})
$('#add-camp-btn').click(function() {
$('#table-wrapper').hide(0)
$('#form-wrapper').show(100, () => {
$('#add-camp-btn').hide(0);
})
})
$('#execution-actual_no_of_attendees').on('input', function () {
if (parseInt($(this).val()) > 40) {
$(this).val(40);
}
});
$('.edit-btn').click(function() {
$('#execution-form-wrapper').show(100, () => {
$('#add-camp-btn').hide(0);
})
$('#table-wrapper').hide()
$('#execution-plan_date').prop('readonly', true);
$('#execution-msl_code').prop('readonly',true);
$('#execution-expected_no_of_attendees').prop('readonly',true);
let contacts = document.getElementById('execution-contact_id');
contacts.addEventListener('mousedown', function(e) {
e.preventDefault();
})
let selected = JSON.parse($(this).attr('plan_details'))
if (selected['contact_id']) {
selected['contact_id'] = selected['contact_id'].trim();
}
console.log("Selected Doctor:", selected['contact_id']);
if(selected['contact_id']==='Other'){
$('#execution-name_of_other_doctor,#execution-pcode_of_other_doctor').parent().show();
$('#execution-name_of_other_doctor,#execution-pcode_of_other_doctor').prop({"required":true});
$('#execution-msl_code').parent().hide();
$('#execution-msl_code').prop({"required":false});
}
if(selected['contact_id']!='Other'){
$('#execution-name_of_other_doctor,#execution-pcode_of_other_doctor').parent().hide();
$('#execution-name_of_other_doctor,#execution-pcode_of_other_doctor').prop({"required":false});
$('#execution-msl_code').parent().show();
$('#execution-msl_code').prop({"required":true});
}
for (let k of Object.keys(selected)) {
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
$('#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']) return this;
}).attr('value')
$('#execution-contact_id').val(docid)
$('#execution-id').val(selected['id'])
$('#execution-hcp_name,#execution-pcode_of_wrapper_doctor,#execution-speaker_name').parent().hide();
$('#execution-hcp_name,#execution-pcode_of_wrapper_doctor,#execution-speaker_name').attr('required',false);
})
$('#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-msl_code').attr({'readonly':true});
$('#field-name_of_other_doctor,#field-pcode_of_other_doctor').parent().hide();
$('#field-name_of_other_doctor,#field-pcode_of_other_doctor').attr('required',false);
$('#field-contact_id').on('change',function(){
let value=$(this).val();
if(value==='Other'){
$('#field-name_of_other_doctor,#field-pcode_of_other_doctor').parent().show();
$('#field-name_of_other_doctor,#field-pcode_of_other_doctor').attr('required',true);
$('#field-msl_code').parent().hide();
$('#field-msl_code').attr('required',false);
}
else{
$('#field-name_of_other_doctor,#field-pcode_of_other_doctor').parent().hide();
$('#field-name_of_other_doctor,#field-pcode_of_other_doctor').attr('required',false);
$('#field-msl_code').parent().show();
$('#field-msl_code').attr('required',true);
}
})
$('#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'))
})
$('#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'
})
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!'
})
}
},
});
});
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>