482 lines
30 KiB
PHP
482 lines
30 KiB
PHP
<!DOCTYPE html>
|
||
<html lang="en">
|
||
|
||
<head>
|
||
@include('layouts.shared/title-meta', ['title' => "Form"])
|
||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
||
<link href="{{asset('assets/libs/flatpickr/flatpickr.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}}">
|
||
@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')
|
||
@if($question->code == 'record_date')
|
||
<input type="text" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$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')
|
||
<input type="{{$question->type}}" min="1" 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':''}}>{{$option->display}}</option>
|
||
@endforeach --}}
|
||
|
||
@foreach ($question->options as $option)
|
||
@if($question->code == 'contact_id')
|
||
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'uid= ' . (isset($option->contact->uid_number)?$option->contact->uid_number:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'sbu_code= ' . (isset($option->contact->msl_code) ? $option->contact->msl_code :'') . ' ' : '' }} >
|
||
{{ $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>
|
||
@if($id && $question->code == 'select_brandsku')
|
||
<input type="hidden" name="select_brandsku" id="field-text-{{$question->code}}" value="{{$question->value}}">
|
||
@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
|
||
@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 src="{{asset('assets/libs/flatpickr/flatpickr.min.js')}}"></script>
|
||
<script type="text/javascript">
|
||
jQuery(document).ready(function($) {
|
||
@if($id)
|
||
$('#field-select_brandsku').attr("disabled", true);
|
||
@endif
|
||
|
||
let sku_brand_maps = [
|
||
{sku_code:'exhep_pen_cartridge_300mg3ml', brand:'EXHEP', sku:'EXHEP PEN CARTRIDGE 300MG/3ML', material_code:'421112261'},
|
||
{sku_code:'exhep_40enoxaparin_sodinj', brand:'EXHEP', sku:'EXHEP-40[ENOXAPARIN SOD.INJ]', material_code:'421112413'},
|
||
{sku_code:'materna_hmg_150_iu', brand:'MATERNA HMG ', sku:'MATERNA - HMG 150 I.U.', material_code:'491110369'},
|
||
{sku_code:'materna_hcg_5000_iu_injhp', brand:'MATERNA HCG', sku:'MATERNA - HCG 5000 IU INJ.H.P.', material_code:'491110366'},
|
||
{sku_code:'emprogest_gel_1125_gm', brand:'EMPROGEST', sku:'EMPROGEST GEL 1.125 GM', material_code:'421111436'},
|
||
{sku_code:'ciscure_025_mg_inj', brand:'CISCURE', sku:'CISCURE - 0.25 MG INJ.', material_code:'421110589'},
|
||
{sku_code:'materna_depot_375_mg_injection', brand:'MATERNA DEPOT ', sku:'MATERNA DEPOT 3.75 MG INJECTION', material_code:'421112215'},
|
||
{sku_code:'materna_hmg_hp_1200_iu4ml_md', brand:'MATERNA HMG ', sku:'MATERNA-HMG HP 1200 IU/4ML MD', material_code:'421112530'},
|
||
{sku_code:'emgra_tablets_1x28_t', brand:'EMGRA', sku:'EMGRA TABLETS 1X28 T', material_code:'421110734'},
|
||
{sku_code:'emprogest_400_capsule_1x10c', brand:'EMPROGEST', sku:'EMPROGEST - 400 CAPSULE 1X10C', material_code:'421111442'},
|
||
{sku_code:'ciscure_pfs', brand:'CISCURE', sku:'CISCURE PFS', material_code:'421112188'},
|
||
{sku_code:'materna_hcg_10000_iu_inj_hp', brand:'MATERNA HCG', sku:'MATERNA - HCG 10000 IU INJ. H.P.', material_code:'491110367'},
|
||
{sku_code:'xgrast_inj_300_mcg05_ml_pfs', brand:'XGRAST', sku:'XGRAST INJ 300 MCG/0.5 ML PFS', material_code:'492220092'},
|
||
{sku_code:'materna_hmg_75_iu', brand:'MATERNA HMG ', sku:'MATERNA - HMG 75 I.U.', material_code:'491110368'},
|
||
{sku_code:'silnafil_tablet_10x1x10t', brand:'SILNAFIL', sku:'SILNAFIL TABLET 10X1X10T', material_code:'421110947'},
|
||
{sku_code:'exhep_60enoxaparin_sodinj', brand:'EXHEP', sku:'EXHEP-60[ENOXAPARIN SOD.INJ]', material_code:'421112412'},
|
||
{sku_code:'exhep_20enoxaparin_sodium_inj', brand:'EXHEP', sku:'EXHEP-20(ENOXAPARIN SODIUM INJ.)', material_code:'421111105'},
|
||
{sku_code:'dydroeva_tablets_1x10t', brand:'DYDROEVA', sku:'DYDROEVA TABLETS 1X10T', material_code:'421112651'},
|
||
{sku_code:'emprogest_ev_200_tablet_1x5t', brand:'EMPROGEST', sku:'EMPROGEST EV 200 TABLET 1X5T', material_code:'421111435'},
|
||
{sku_code:'emprogest_200_capsule_1x10c', brand:'EMPROGEST', sku:'EMPROGEST - 200 CAPSULE 1X10C', material_code:'421111441'},
|
||
{sku_code:'emprogest_sr_300_tablet_10x1x10t', brand:'EMPROGEST', sku:'EMPROGEST SR 300 TABLET 10X1X10T', material_code:'421111438'},
|
||
{sku_code:'exhep_pen_reusable_1x1', brand:'EXHEP', sku:'EXHEP PEN REUSABLE 1X1', material_code:'421112262'},
|
||
{sku_code:'emprogest_sr_200_tablet_10x1x10t', brand:'EMPROGEST', sku:'EMPROGEST SR 200 TABLET 10X1X10T', material_code:'421111437'},
|
||
{sku_code:'dydroeva_tablets_1x30t', brand:'DYDROEVA', sku:'DYDROEVA TABLETS 1X30T', material_code:'421112692'},
|
||
{sku_code:'dydroeva_sr_30_tablets_1x10t', brand:'DYDROEVA', sku:'DYDROEVA SR 30 TABLETS 1X10T', material_code:'421112836'},
|
||
{sku_code:'dydroeva_sr_20_tablets_1x10t', brand:'DYDROEVA', sku:'DYDROEVA SR 20 TABLETS 1X10T', material_code:'421112835'},
|
||
{sku_code:'fcmo_500_injection_10ml', brand:'FCMO', sku:'FCMO 500 INJECTION 10ML', material_code:'421112709'},
|
||
{sku_code:'fcmo_1k_injection_20ml', brand:'FCMO', sku:'FCMO 1K INJECTION 20ML', material_code:'421112711'},
|
||
{sku_code:'materna_hmg_hp_300_iu1ml_pfs', brand:'MATERNA HMG ', sku:'MATERNA-HMG HP 300 IU/1ML PFS', material_code:'421112532'},
|
||
{sku_code:'materna_hmg_hp_225_iu075ml_pfs', brand:'MATERNA HMG ', sku:'MATERNA-HMG HP 225 IU/0.75ML PFS', material_code:'421112531'},
|
||
]
|
||
|
||
|
||
$('#field-user_id').change(function() {
|
||
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 --'));
|
||
for(let itm of data) {
|
||
//$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display));
|
||
$('#field-contact_id').append($("<option></option>").attr("ciscure_dr_tagging", itm.contact.ciscure_dr_tagging).attr("emprogest_gel_dr_tagging", itm.contact.emprogest_gel_dr_tagging).attr("dydroeva_dr_tagging", itm.contact.dydroeva_dr_tagging).attr("depot_dr_tagging", itm.contact.depot_dr_tagging).attr("materna_hcg_dr_tagging", itm.contact.materna_hcg_dr_tagging).attr("materna_hmg_dr_tagging", itm.contact.materna_hmg_dr_tagging).attr("value", itm.value).attr("sbu_code", itm.contact.msl_code).attr("uid", itm.contact.uid_number).text(itm.display));
|
||
}
|
||
$('#field-contact_id').unbind()
|
||
|
||
$('#field-contact_id').on('change',function(){
|
||
let ciscure=$(this).find(":selected").attr('ciscure_dr_tagging');
|
||
console.log("Value of ciscure : ",ciscure);
|
||
|
||
if(ciscure==='yes'){
|
||
$('#field-ciscure_dr_tagging').val('yes');
|
||
}
|
||
else{
|
||
$('#field-ciscure_dr_tagging').val('no');
|
||
}
|
||
|
||
})
|
||
|
||
$('#field-contact_id').change(function(){
|
||
let emprogest=$(this).find(":selected").attr('emprogest_gel_dr_tagging');
|
||
console.log("Value of emprogest : ",emprogest);
|
||
|
||
if(emprogest==='yes'){
|
||
$('#field-emprogest_gel_dr_tagging').val('yes');
|
||
}
|
||
else{
|
||
$('#field-emprogest_gel_dr_tagging').val('no');
|
||
}
|
||
|
||
})
|
||
|
||
$('#field-contact_id').change(function(){
|
||
let dydroeva =$(this).find(":selected").attr('dydroeva_dr_tagging');
|
||
console.log("Value of dydroeva : ",dydroeva);
|
||
|
||
if(dydroeva==='yes'){
|
||
$('#field-dydroeva_dr_tagging').val('yes');
|
||
}
|
||
else{
|
||
$('#field-dydroeva_dr_tagging').val('no');
|
||
}
|
||
|
||
})
|
||
|
||
$('#field-contact_id').change(function(){
|
||
let depot =$(this).find(":selected").attr('depot_dr_tagging');
|
||
console.log("Value of depot : ",depot);
|
||
|
||
if(depot==='yes'){
|
||
$('#field-depot_dr_tagging').val('yes');
|
||
}
|
||
else{
|
||
$('#field-depot_dr_tagging').val('no');
|
||
}
|
||
|
||
})
|
||
|
||
$('#field-contact_id').change(function(){
|
||
let materna1 =$(this).find(":selected").attr('materna_hcg_dr_tagging');
|
||
console.log("Value of materna1 :",materna1);
|
||
|
||
if(materna1==='yes'){
|
||
$('#field-materna_hcg_dr_tagging').val('yes');
|
||
}
|
||
else{
|
||
$('#field-materna_hcg_dr_tagging').val('no');
|
||
}
|
||
|
||
})
|
||
|
||
$('#field-contact_id').change(function(){
|
||
let materna2 =$(this).find(":selected").attr('materna_hmg_dr_tagging');
|
||
console.log("Value of materna2 : ",materna2);
|
||
|
||
if(materna2==='yes'){
|
||
$('#field-materna_hmg_dr_tagging').val('yes');
|
||
}
|
||
else{
|
||
$('#field-materna_hmg_dr_tagging').val('no');
|
||
}
|
||
|
||
})
|
||
|
||
|
||
$('#field-contact_id').change(function() {
|
||
$('#field-sbu_code').val($('option:selected', this).attr('sbu_code'));
|
||
})
|
||
|
||
$('#field-contact_id').change(function() {
|
||
$('#field-uid').val($('option:selected', this).attr('uid'));
|
||
})
|
||
|
||
|
||
}
|
||
});
|
||
|
||
console.log(hierarchy)
|
||
})
|
||
|
||
$('#field-pob_units,#field-add_rate').on('input', function() {
|
||
let a = parseFloat($('#field-pob_units').val()) || 0;
|
||
let b = parseFloat($('#field-add_rate').val()) || 0;
|
||
let product = a * b;
|
||
let c = parseFloat($('#field-pob_value').val()) || 0;
|
||
$('#field-pob_value').val(product);
|
||
})
|
||
|
||
$('#field-upload_ledger').parent().hide();
|
||
//$('#field-upload_ledger').attr("required",false);
|
||
|
||
$('#field-enter_investment_amount').parent().hide();
|
||
$('#field-enter_investment_amount').attr("required",false);
|
||
|
||
$('#field-enter_investment_amount').attr("min",0);
|
||
|
||
|
||
|
||
$('#field-select_brandsku').on('change',function(){
|
||
let value=$('#field-select_brandsku').val().trim();
|
||
if(value===''){
|
||
$('#field-upload_ledger').parent().hide();
|
||
//$('#field-upload_ledger').attr("required",false);
|
||
|
||
$('#field-enter_investment_amount').parent().hide();
|
||
$('#field-enter_investment_amount').attr("required",false);
|
||
}
|
||
else{
|
||
$('#field-upload_ledger').parent().show();
|
||
//$('#field-upload_ledger').attr("required",true);
|
||
|
||
$('#field-enter_investment_amount').parent().show();
|
||
$('#field-enter_investment_amount').attr("required",true);
|
||
|
||
}
|
||
})
|
||
|
||
$('#field-contact_id').on('change',function(){
|
||
let ciscure=$(this).find(":selected").attr('ciscure_dr_tagging');
|
||
if(ciscure==='-'){
|
||
$('#field-ciscure_dr_tagging').val('No');
|
||
}
|
||
else{
|
||
$('#field-ciscure_dr_tagging').val(ciscure);
|
||
}
|
||
})
|
||
|
||
|
||
|
||
|
||
$('#field-sbu_code').prop('readonly', true);
|
||
$('#field-uid').prop('readonly', true);
|
||
|
||
$('#report-form').on('submit', function(event) {
|
||
event.preventDefault();
|
||
$("#pageloader").fadeIn();
|
||
// $('#report-form').append('<input type="hidden" name="' + $('#field-select_brandsku').val() + '_pob_units" value="' + $("#field-pob_value").val() + '">')
|
||
// $('#report-form').append('<input type="hidden" name="' + $('#field-select_brandsku').val() + '_pob_value" value="' + $("#field-pob_value_for_selected_brandsku").val() + '">')
|
||
@if($id)
|
||
$('#report-form').append('<input type="hidden" name="'+ $('#field-text-select_brandsku').val() +'_pob_units" value="'+ $("#field-pob_units").val() +'">')
|
||
$('#report-form').append('<input type="hidden" name="'+ $('#field-text-select_brandsku').val() +'_pob_value" value="'+ $("#field-pob_value").val() +'">')
|
||
let sku_brand_map = sku_brand_maps.find(sb => sb.sku_code == $('#field-text-select_brandsku').val())
|
||
$('#report-form').append('<input type="hidden" name="selected_brand" value="'+ sku_brand_map.brand +'">')
|
||
$('#report-form').append('<input type="hidden" name="material_code" value="'+ sku_brand_map.material_code +'">')
|
||
$('#report-form').append('<input type="hidden" name="sku_name" value="'+ sku_brand_map.sku +'">')
|
||
@else
|
||
$('#report-form').append('<input type="hidden" name="'+ $('#field-select_brandsku').val() +'_pob_units" value="'+ $("#field-pob_units").val() +'">')
|
||
$('#report-form').append('<input type="hidden" name="'+ $('#field-select_brandsku').val() +'_pob_value" value="'+ $("#field-pob_value").val() +'">')
|
||
let sku_brand_map = sku_brand_maps.find(sb => sb.sku_code == $('#field-select_brandsku').val())
|
||
$('#report-form').append('<input type="hidden" name="selected_brand" value="'+ sku_brand_map.brand +'">')
|
||
$('#report-form').append('<input type="hidden" name="material_code" value="'+ sku_brand_map.material_code +'">')
|
||
$('#report-form').append('<input type="hidden" name="sku_name" value="'+ sku_brand_map.sku +'">')
|
||
@endif
|
||
|
||
|
||
$.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'
|
||
})
|
||
//$('#report-form').trigger("reset");
|
||
window.location.reload(true)
|
||
} 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);
|
||
|
||
let today = new Date(new Date().getTime());
|
||
// console.log("today = ",today);
|
||
let day = String(today.getDate()).padStart(2, '0');
|
||
let month = String(today.getMonth() + 1).padStart(2, '0');
|
||
let year = today.getFullYear();
|
||
// console.log("day = ",day)
|
||
// console.log("month = ",month)
|
||
// console.log("year = ",year)
|
||
let minDateStr = year + '/' + month + '/' + day;
|
||
let maxDateStr = year + '/' + month + '/' + day;
|
||
|
||
// console.log("minDateStr = ",minDateStr)
|
||
// console.log("maxDateStr = ",maxDateStr)
|
||
|
||
// let minDate = new Date(new Date(minDate).getTime()+(9*24*60*60*1000))
|
||
let minDate = new Date (today - (30*24*60*60*1000));
|
||
minDateStr = minDate.getFullYear() + '/' + String(minDate.getMonth() + 1).padStart(2, '0') + '/' + String(minDate.getDate()).padStart(2, '0');
|
||
|
||
// console.log("minDate = ",minDate)
|
||
// console.log("minDateStr = ",minDateStr)
|
||
|
||
//Setting min, max dates and value to Datepicker...
|
||
$('#field-record_date').flatpickr({
|
||
minDate: minDateStr,
|
||
maxDate: maxDateStr,
|
||
defaultDate: maxDateStr,
|
||
dateFormat: 'Y/m/d'
|
||
// dateFormat: 'd/m/Y'
|
||
});
|
||
|
||
});
|
||
</script>
|
||
</body>
|
||
|
||
</html> |