Titans (ISP Reporting)

This commit is contained in:
zeeshan 2026-11-17 11:00:31 +05:30
parent 8f1381d6aa
commit 9c3fdd6c04
1 changed files with 300 additions and 330 deletions

View File

@ -4,6 +4,7 @@
@include('layouts.shared/title-meta', ['title' => "Form"])
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
<link href="{{ asset('assets/libs/select2/select2.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..." />
@ -38,39 +39,24 @@
<h6>Submitted By: {{$form->user_info->name}}</h6>
</div>
@endif
@php
$submissions = Formhelper::getMultiformData($form->partition, $form_id, $form->user_id);
$submissions = isset($submissions->data->submissions) ? $submissions->data->submissions : [];
@endphp
@if(count($submissions) <= 4)
<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
@php
$hcpQuestion = null;
$pcodeQuestion = null;
@endphp
@foreach($questions as $question)
@if($question->code === 'contact_id')
@php $hcpQuestion = $question; @endphp
@continue
@endif
@if($question->code === 'legacy_code')
@php $pcodeQuestion = $question; @endphp
@continue
@endif
<div class="col-md-12 mb-2 {{ $question->code === 'amount_given' ? 'js-amount-given-wrap' : '' }}" @if($question->code === 'amount_given') style="display:none;" @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')
@ -80,104 +66,50 @@
@case('email')
@case('tel')
@case('date')
@if($question->code === 'amount_given')
<input type="text" inputmode="numeric" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="{{isset($question->value) && $question->value !== '' && $question->value !== 0 ? $question->value : ''}}">
@else
<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
@break
@case('number')
@if($question->code === 'amount_given')
<input type="text" inputmode="numeric" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="{{isset($question->value) && $question->value !== '' && $question->value !== 0 ? $question->value : ''}}">
@else
<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}}">
@endif
@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 === 'no_of_attendees')
@for($attendeeCount = 1; $attendeeCount <= 50; $attendeeCount++)
<option value="{{$attendeeCount}}" {{isset($question->value) && (string)$question->value === (string)$attendeeCount ? 'selected':''}}>{{$attendeeCount}}</option>
@endfor
@else
@foreach($question->options as $option)
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
@endforeach
@endif
</select>
@break
@case('radio')
@foreach($question->options as $option)
<div class="form-check mb-2 form-check-success">
<input class="form-check-input" type="radio" name="{{$question->code}}" id="field-{{$question->code}}_{{$option->value}}" value="{{$option->value}}">
<label class="form-check-label" for="field-{{$question->code}}_{{$option->value}}">{{$option->display}}</label>
</div>
<select class="form-control" id="field-{{ $question->code }}" name="{{ $question->code }}" data-preselected="{{ isset($question->value) ? (string)$question->value : '' }}" {{ $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->legacy_code) ? $option->contact->legacy_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' : '' }}>
{{ $option->display }}
</option>
@endif
@endforeach
</select>
@break
@case('radiometrix')
@php
// Decode the first option's value to use as heading labels
$headings =
count($question->options) > 0
? json_decode($question->options[0]->value)
: [];
@endphp
{{-- Matrix Wrapper with Horizontal Scroll on Small Screens --}}
<div class="table-responsive">
<div class="d-table w-100">
{{-- Table Headers --}}
<div class="d-table-row font-weight-bold">
<div class="d-table-cell p-2" style="width: 150px;"></div>
{{-- Placeholder for row labels --}}
@foreach ($headings as $head)
<div class="d-table-cell text-center p-2">{{ $head }}
</div>
@endforeach
</div>
{{-- Table Rows --}}
@foreach ($question->options as $option)
@php $nn = json_decode($option->value); @endphp
<div class="d-table-row align-middle">
<div class="d-table-cell font-weight-bold p-2"
style="width: 150px;">
{{ $option->display }}
</div>
@foreach ($nn as $value)
<div class="d-table-cell text-center p-2">
<input type="radio"
id="field-{{ $option->display }}-{{ $value }}"
name="{{ $question->code }}[{{$option->display}}]" value="{{$value}}" class="form-check-input"
{{ isset($question->display) && $option->display != $option->display ? 'checked' : '' }}>
</div>
@endforeach
</div>
@endforeach
</div>
</div>
@break
@case('checkbox')
@foreach($question->options as $option)
<div class="form-check mb-2 form-check-primary ms-2">
<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':''}}>
<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, (array)$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="" accept="image/jpeg,image/jpg,image/png,.jpg,.jpeg,.png" {{$question->required == 'yes'?'required':'' }}>
<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">
@ -189,51 +121,33 @@
@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($hcpQuestion)
<div class="doctor-group-wrapper col-12" style="display:none;">
<div class="doctor-group">
<div class="mb-2">
<label for="field-contact_id" class="form-label hcp-label">{{$hcpQuestion->question}} <span class="row-index">1</span> {!!$hcpQuestion->required == 'yes' ? '<span class="text-danger">*</span>':''!!}</label>
<select class="form-control hcp-select" id="field-contact_id" name="contact_id" data-originally-required="{{$hcpQuestion->required == 'yes' ? 'yes' : 'no'}}">
<option value=""> -- Select -- </option>
@foreach(($hcpQuestion->options ?? []) as $option)
<option value="{{$option->value}}" legacy_code="{{ isset($option->contact->legacy_code) ? $option->contact->legacy_code : (isset($option->contact->pcode) ? $option->contact->pcode : (isset($option->legacy_code) ? $option->legacy_code : '')) }}" {{isset($hcpQuestion->value) && $hcpQuestion->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
@endforeach
</select>
</div>
@if($pcodeQuestion)
<div class="mb-2">
<label for="field-legacy_code" class="form-label pcode-label">{{$pcodeQuestion->question}} <span class="row-index">1</span> {!!$pcodeQuestion->required == 'yes' ? '<span class="text-danger">*</span>':''!!}</label>
<input type="text" id="field-legacy_code" name="legacy_code" class="form-control pcode-input" readonly data-originally-required="{{$pcodeQuestion->required == 'yes' ? 'yes' : 'no'}}" value="{{isset($pcodeQuestion->value)?$pcodeQuestion->value:''}}">
</div>
@endif
</div>
<div class="doctor-group-clones"></div>
</div>
@endif
@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 -->
@else
<div class="alert alert-danger">You have already submitted 5 Doctors <div>
@endif
</div>
</div>
<!-- end card -->
<!-- end row -->
</div> <!-- end col -->
</div>
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
<style type="text/css">
#pageloader {
background: rgba( 255, 255, 255, 0.8 );
@ -243,7 +157,6 @@
width: 100%;
z-index: 9999;
}
#pageloader img {
left: 50%;
margin-left: -32px;
@ -251,196 +164,251 @@
position: absolute;
top: 50%;
}
.form-label {
font-weight:bold;
font-size:16px;
}
</style>
@include('layouts.shared/footer-script')
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
function setPcodeFromSelect($select) {
let selectId = $select.attr('id') || '';
let pcodeId = selectId.replace('field-contact_id', 'field-legacy_code');
let pcode = $select.find('option:selected').attr('legacy_code') || '';
$('#' + pcodeId).val(pcode);
}
$('[data-toggle="select2"]').select2();
var hierarcies = [];
var contacts = [];
function fillHcpSelects(data) {
if (!Array.isArray(data)) {
return;
}
$('[id^="field-contact_id"]').each(function() {
let $select = $(this);
let current = $select.val();
$select.empty().append($('<option></option>').attr('value', '').text('-- Select --'));
data.forEach(function(itm) {
let legacyCode = '';
if (itm.contact) {
legacyCode = itm.contact.legacy_code || itm.contact.pcode || '';
}
$select.append(
$('<option></option>')
.attr('value', itm.value)
.attr('legacy_code', legacyCode)
.text(itm.display)
);
});
if (current) {
$select.val(current);
if ($select.val() !== current) {
$select.val('');
}
}
setPcodeFromSelect($select);
});
}
var allSubmissions = @json($submissions ?? []);
var currentEditId = '{{ $id ?? '' }}';
var submittedDoctors = [];
function applyRowRequired($row, on) {
$row.find('.hcp-select, .pcode-input').each(function() {
let needed = $(this).attr('data-originally-required') === 'yes';
$(this).prop('required', !!(on && needed));
});
}
function syncAttendeeRows() {
if (!$('.doctor-group').length) {
return;
}
let attendees = parseInt($('#field-no_of_attendees').val(), 10) || 0;
if (attendees > 50) {
attendees = 50;
$('#field-no_of_attendees').val('50');
}
$('.doctor-group-clones').empty();
let $first = $('.doctor-group').first();
if (attendees < 1) {
$('.doctor-group-wrapper').hide();
applyRowRequired($first, false);
return;
}
$('.doctor-group-wrapper').show();
applyRowRequired($first, true);
$first.find('.row-index').text('1');
for (let i = 2; i <= attendees; i++) {
let $row = $first.clone();
$row.find('.hcp-select')
.attr('id', 'field-contact_id_' + i)
.attr('name', 'contact_id_' + i)
.val('');
$row.find('.hcp-label').attr('for', 'field-contact_id_' + i);
$row.find('.pcode-input')
.attr('id', 'field-legacy_code_' + i)
.attr('name', 'legacy_code_' + i)
.val('');
$row.find('.pcode-label').attr('for', 'field-legacy_code_' + i);
$row.find('.row-index').text(i);
applyRowRequired($row, true);
$('.doctor-group-clones').append($row);
}
}
function syncAmountGiven() {
let $amount = $('#field-amount_given');
if (!$amount.length) {
return;
}
let $field = $('#field-honorarium_amount_received');
let value = ($field.val() || '').toString().trim().toLowerCase();
let label = ($field.find('option:selected').text() || '').toString().trim().toLowerCase();
let showAmount = value === 'yes' || label === 'yes';
let $wrap = $amount.closest('.js-amount-given-wrap');
if (showAmount) {
$wrap.show();
$amount.prop('required', true);
} else {
$wrap.hide();
$amount.prop('required', false).val('');
}
}
$('#field-user_id').change(function(event){
let hierarchy = $('option:selected', this).attr('hierarchy');
$('#field-hierarchy_id').val(hierarchy)
event.preventDefault();
$.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 --'));
if (Array.isArray(data)) {
for(let itm of data) {
let legacyCode = (itm.contact && (itm.contact.legacy_code || itm.contact.pcode)) ? (itm.contact.legacy_code || itm.contact.pcode) : '';
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).attr("legacy_code", legacyCode).text(itm.display));
}
}
fillHcpSelects(data);
},
});
})
$(document).on('change', '[id^="field-contact_id"]', function() {
let $select = $(this);
let val = $select.val();
if (val) {
let duplicate = false;
$('[id^="field-contact_id"]').not(this).each(function() {
if ($(this).val() === val) {
duplicate = true;
}
});
if (duplicate) {
Swal.fire({
icon: 'error',
title: 'Already selected',
text: 'This doctor is already selected.'
});
$select.val('');
setPcodeFromSelect($select);
if (Array.isArray(allSubmissions)) {
allSubmissions.forEach(function(sub) {
if (currentEditId && sub.id && String(sub.id) === String(currentEditId)) {
return;
}
if (sub && sub.formdata) {
if (sub.formdata.contact_id) {
submittedDoctors.push(String(sub.formdata.contact_id).trim().toLowerCase());
}
if (sub.formdata.cont_id) {
submittedDoctors.push(String(sub.formdata.cont_id).trim().toLowerCase());
}
}
});
}
let docNameFields = document.querySelectorAll('#field-doctor_name');
let mslCodeFields = document.querySelectorAll('#field-msl_code');
//Hide all doctor fields
hideDoctorFields();
// docNameFields.forEach((docField, index) => {
// if(index !== 0)
// $(docField).parent().hide();
// })
//Hide all msl code fields
hideMSLCodeFields()
// mslCodeFields.forEach((mslField, index) => {
// if(index !== 0)
// $(mslField).parent().hide();
// })
$('#field-quantity').on('change',function(){
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>
<input type="text" id="field-doctor_name_${i}" name="doctor_name[]" class="form-control" value="" required>
</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[]" class="form-control" value="" required>
</div>`)
}
setPcodeFromSelect($select);
});
})
$('#field-isp_venue_name').on('input', function() {
this.value = this.value.replace(/[^A-Za-z0-9\s]/g, '');
});
//hide doctor fields
function hideDoctorFields (){
docNameFields.forEach((docField, index) => {
if(index !== 0)
$(docField).parent().hide();
$(docField).prop({"required":false});
})
}
//hide msl code fields
function hideMSLCodeFields (){
mslCodeFields.forEach((mslField, index) => {
if(index !== 0)
$(mslField).parent().hide();
$(mslField).prop({"required":false});
})
}
$('#field-program_city, #field-isp_moderator_name').on('input', function() {
this.value = this.value.replace(/[^A-Za-z\s]/g, '');
});
//show doctor fields
function showDoctorFields (numOfFields){
docNameFields.forEach((docField, index) => {
if(index < numOfFields)
$(docField).parent().show();
})
}
//show msl code fields
function showMSLCodeFields (numOfFields){
mslCodeFields.forEach((mslField, index) => {
if(index < numOfFields)
$(mslField).parent().show();
})
}
$('#field-amount_given').on('input', function() {
this.value = this.value.replace(/\D/g, '').replace(/^0+/, '');
});
$('#field-honorarium_amount_received').on('change', syncAmountGiven);
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
@foreach($form->users as $option)
hierarcies.push('{{$option->hierarchy_id}}');
@endforeach
$("#pageloader").fadeIn();
Promise.all(
hierarcies.map(hierarchy => {
return $.ajax({
type: "GET",
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy=' + hierarchy,
processData: false,
contentType: false
}).then(data => {
contacts = contacts.concat(data);
}).catch(function(err) {
console.log(err);
});
})
).then(function() {
contacts = contacts.filter(function(itm) { return itm && itm.value !== 'sample'; });
$('#field-no_of_attendees').on('change', syncAttendeeRows);
function applySelect2ToDoctorDropdowns() {
$("[id^='field-contact_id']").each(function () {
var select = $(this);
if (select.data("select2")) return;
select.select2({
width: "100%",
placeholder: "-- Select --",
allowClear: true
});
});
}
$('#report-form input[type="file"]').attr('accept', 'image/jpeg,image/jpg,image/png,.jpg,.jpeg,.png').on('change', function() {
let file = this.files && this.files[0];
if (!file) {
return;
}
let ext = (file.name.split('.').pop() || '').toLowerCase();
let allowedExt = ['jpg', 'jpeg', 'png'];
let allowedType = ['image/jpeg', 'image/jpg', 'image/png'];
if (allowedExt.indexOf(ext) === -1 || (file.type && allowedType.indexOf(file.type) === -1)) {
Swal.fire({
icon: 'error',
title: 'Invalid file',
text: 'Please upload a jpeg, jpg, or png image.'
function enforceUniqueDoctorSelections() {
var selectedValues = [];
$("[id^='field-contact_id']").each(function () {
var v = $(this).val();
if (v) selectedValues.push(String(v));
});
$("[id^='field-contact_id']").each(function () {
var currentSelect = $(this);
var currentVal = currentSelect.val() ? String(currentSelect.val()) : "";
currentSelect.find("option").each(function () {
var opt = $(this);
var optVal = String(opt.val() || '');
var optText = opt.text();
if (optText.indexOf("Already Added") !== -1) {
opt.prop("disabled", true);
} else if (optVal && selectedValues.includes(optVal) && optVal !== currentVal) {
opt.prop("disabled", true);
} else {
opt.prop("disabled", false);
}
});
if (currentSelect.data("select2")) {
currentSelect.trigger("change.select2");
}
});
}
$("[id^='field-contact_id']").each(function() {
var select = $(this);
var existingVal = select.attr('data-preselected') !== undefined && select.attr('data-preselected') !== ''
? String(select.attr('data-preselected'))
: (select.val() ? String(select.val()) : '');
select.empty();
select.append($("<option></option>").attr("value", '').text('-- Select --'));
contacts.forEach(function(itm) {
var itmVal = String(itm.value);
var itmText = String(itm.display);
var valCheck = itmVal.trim().toLowerCase();
var textCheck = itmText.trim().toLowerCase();
var isAlreadySubmitted = submittedDoctors.includes(valCheck) || submittedDoctors.includes(textCheck);
var isCurrentSelected = (existingVal !== '' && (existingVal.toLowerCase() === valCheck || existingVal.toLowerCase() === textCheck));
var displayText = itmText;
var isDisabled = false;
if (isAlreadySubmitted && !isCurrentSelected) {
displayText += " - Already Added";
isDisabled = true;
}
var option = $("<option></option>")
.attr("value", itm.value)
.text(displayText)
.prop("disabled", isDisabled);
if (itm.contact && itm.contact.msl_code) {
option.attr("msl_code", itm.contact.msl_code);
}
if (itm.contact && itm.contact.speciality) {
option.attr("speciality", itm.contact.speciality);
}
if (isCurrentSelected) {
option.prop('selected', true);
}
select.append(option);
});
if (existingVal) {
select.val(existingVal);
}
select.off('change').on('change', function () {
var selected = $(this).find(':selected');
var selectId = $(this).attr('id');
var match = selectId.match(/^field-contact_id(_\d+)?$/);
var suffix = match && match[1] ? match[1] : '';
var mslCodeField = $('#field-msl_code' + suffix);
var specialityField = $('#field-speciality' + suffix);
if (mslCodeField.length) {
mslCodeField.val(selected.attr('msl_code') || '');
}
if (specialityField.length) {
specialityField.val(selected.attr('speciality') || '');
}
enforceUniqueDoctorSelections();
});
});
this.value = '';
}
});
applySelect2ToDoctorDropdowns();
$("[id^='field-contact_id']").each(function() {
var select = $(this);
var preVal = select.attr('data-preselected');
if (preVal) {
select.val(String(preVal)).trigger('change');
}
});
enforceUniqueDoctorSelections();
$("#pageloader").fadeOut();
});
@endif
$('#report-form').on('submit', function(event){
event.preventDefault();
@ -458,39 +426,41 @@
title: 'Great!',
text: 'Your data is successfully submitted!',
icon: 'success'
})
}).then(() => {
location.reload();
});
$('#report-form').trigger("reset");
syncAmountGiven();
syncAttendeeRows();
} 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!'
})
title: 'Data not submitted',
text: 'Something went wrong, please try again after some time!'
});
}
},
error: function() {
$("#pageloader").fadeOut();
Swal.fire({
icon: 'error',
title: 'Server Error',
text: 'An unexpected error occurred. Please try again.'
});
}
});
});
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 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');
if (plandateField) {
plandateField.setAttribute('max', today);
}
syncAmountGiven();
syncAttendeeRows();
if ($('#field-contact_id').val()) {
setPcodeFromSelect($('#field-contact_id'));
}
var plandateField = document.getElementById('field-record_date');
if(plandateField) {
plandateField.setAttribute('min', "2026-11-01");
plandateField.setAttribute('max', today);
}
});
</script>
</body>
</html>