690 lines
37 KiB
PHP
690 lines
37 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" />
|
||
</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> -->
|
||
<button type="button" class="btn btn-primary btn-xs" id="add-camp-btn">Add
|
||
Plan</button>
|
||
@else
|
||
<a href="{{ url()->previous() }}" class="float-end pt-1">Back</a>
|
||
@endif
|
||
</div>
|
||
@endif
|
||
|
||
|
||
|
||
@php
|
||
$history = Formhelper::getMultiformData(
|
||
$form->partition,
|
||
$form->form_id,
|
||
$form->user_id,
|
||
);
|
||
@endphp
|
||
|
||
{{-- @php
|
||
echo "<div class='container'>";
|
||
echo "<pre>";
|
||
print_r($history->data->submissions);
|
||
echo "</pre>";
|
||
echo "</div>";
|
||
@endphp --}}
|
||
|
||
<div class="col-md-12" id="table-wrapper">
|
||
<div class="card">
|
||
<div class="card-body p-0">
|
||
<div class="table-responsive">
|
||
<table
|
||
class="table table-striped table-hover table-nowrap table-centered m-0">
|
||
<thead class="table-light">
|
||
<tr>
|
||
<th>Action</th>
|
||
<th>Execution Done</th>
|
||
{{-- <th>Workflow</th> --}}
|
||
<th>Plan Date</th>
|
||
{{-- <th>Team Name</th> --}}
|
||
<th>Type of meeting</th>
|
||
<th>Other Type of meeting</th>
|
||
|
||
<th>Execution Date</th>
|
||
<th>Name of speaker</th>
|
||
<th>MSL Code</th>
|
||
<th>Speciality</th>
|
||
|
||
<th>Honorarium Amount</th>
|
||
<th>Other expenses</th>
|
||
<th>Total EAS </th>
|
||
<th>Attendence</th>
|
||
<th>New/Continue</th>
|
||
<th>LTA/Regional</th>
|
||
<th>Physical/Virtual</th>
|
||
<th>Yearly honorarium</th>
|
||
<th>Venue/AV/Food etc cost</th>
|
||
<th>Total EAS required</th>
|
||
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@foreach ($history->data->submissions as $sub)
|
||
@php
|
||
$sub->formdata->id = $sub->id;
|
||
@endphp
|
||
<tr>
|
||
<td>
|
||
{{-- @if($sub->workflow_status=='approved')
|
||
<button type="button"
|
||
class="btn btn-xs btn-info edit-btn"
|
||
plan_details="{{ json_encode($sub->formdata) }}"><i
|
||
class="mdi mdi-pencil"></i> Execute</button>
|
||
@else
|
||
<button type="button"
|
||
class="btn btn-xs btn-info edit-plan-btn"
|
||
plan_details="{{ json_encode($sub->formdata) }}"><i
|
||
class="mdi mdi-pencil"></i> Edit Plan</button>
|
||
@endif --}}
|
||
|
||
@php
|
||
$execution_done = isset($sub->formdata->record_date) && $sub->formdata->record_date > 0 ? 'Yes' : 'No'
|
||
@endphp
|
||
|
||
@if($sub->workflow_status=='approved' && $execution_done == 'No')
|
||
<button type="button"
|
||
class="btn btn-xs btn-info edit-btn"
|
||
plan_details="{{ json_encode($sub->formdata) }}"><i
|
||
class="mdi mdi-pencil"></i> Execute</button>
|
||
|
||
@elseif($sub->workflow_status=='unapproved' && $execution_done == 'No')
|
||
<button type="button"
|
||
class="btn btn-xs btn-info edit-plan-btn"
|
||
plan_details="{{ json_encode($sub->formdata) }}"><i
|
||
class="mdi mdi-pencil"></i> Edit Plan</button>
|
||
|
||
@elseif($sub->workflow_status=='approved' && $execution_done == 'Yes')
|
||
|
||
@elseif($sub->workflow_status=='rejected' && $execution_done == 'No')
|
||
<button type="button"
|
||
class="btn btn-xs btn-info edit-plan-btn"
|
||
plan_details="{{ json_encode($sub->formdata) }}"><i
|
||
class="mdi mdi-pencil"></i> Edit Plan</button>
|
||
|
||
@elseif($sub->workflow_status=='approved' && $execution_done == 'No')
|
||
<button type="button"
|
||
class="btn btn-xs btn-info edit-btn"
|
||
plan_details="{{ json_encode($sub->formdata) }}"><i
|
||
class="mdi mdi-pencil"></i> Execute</button>
|
||
|
||
@endif
|
||
</td>
|
||
<td>{{ isset($sub->formdata->record_date) && $sub->formdata->record_date > 0 ? 'Yes' : 'No' }}
|
||
</td>
|
||
{{-- <td>{{$sub->workflow_status}}</td> --}}
|
||
<td>{{ $sub->formdata->plan_date }}</td>
|
||
{{-- <td>{{ $sub->formdata->team_name }}</td> --}}
|
||
<td>{{ $sub->formdata->type_of_meeting }}</td>
|
||
<td>{{ isset($sub->formdata->specify_other_meeting) ?? '-' }}</td>
|
||
|
||
<td>{{ $sub->formdata->record_date }}</td>
|
||
<td>{{ $sub->formdata->name_of_the_speaker }}</td>
|
||
<td>{{ $sub->formdata->msl_code }}</td>
|
||
<td>{{ $sub->formdata->speciality }}</td>
|
||
|
||
|
||
<td>{{ $sub->formdata->honorarium_amount }}</td>
|
||
<td>{{ $sub->formdata->other_expenses }}</td>
|
||
<td>{{ $sub->formdata->total_eas }}</td>
|
||
<td>{{ $sub->formdata->attendence }}</td>
|
||
|
||
<td>{{ $sub->formdata->new_continue }}</td>
|
||
<td>{{ $sub->formdata->lta_regional }}</td>
|
||
<td>{{ $sub->formdata->physical_virtual }}</td>
|
||
<td>{{ $sub->formdata->yearly_honorarium }}</td>
|
||
<td>{{ $sub->formdata->venue_av_food_etc_cost }}</td>
|
||
<td>{{ $sub->formdata->total_eas_required }}</td>
|
||
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="form-wrapper">
|
||
<form method="POST" action="/form/submit" id="report-form">
|
||
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
||
<input type="hidden" name="planning" value="yes">
|
||
@csrf
|
||
@foreach ($questions as $question)
|
||
@if (in_array($question->code, ['record_date','attendence','new_continue','lta_regional','physical_virtual','yearly_honorarium','venue_av_food_etc_cost','total_eas_required','no_of_patients_on_duolin','no_of_units_duolin_respules']))
|
||
@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' : '' }}>
|
||
{{ $option->display }}</option>
|
||
@endforeach
|
||
</select>
|
||
@break
|
||
|
||
@case('checkbox')
|
||
@foreach ($question->options as $option)
|
||
<div class="form-check mb-2 form-check-primary">
|
||
<input class="form-check-input" type="checkbox"
|
||
id="field-{{ $question->code }}-{{ $option->value }}"
|
||
name="{{ $question->code }}[]" value="{{ $option->value }}"
|
||
{{ isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked' : '' }}>
|
||
<label class="form-check-label"
|
||
for="field-{{ $question->code }}-{{ $option->value }}">{{ $option->display }}</label>
|
||
</div>
|
||
@endforeach
|
||
@break
|
||
@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">
|
||
@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
|
||
@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">
|
||
const slugify = str =>
|
||
str
|
||
.toLowerCase()
|
||
.trim()
|
||
.replace(/[^\w\s-]/g, '')
|
||
.replace(/[\s_-]+/g, '-')
|
||
.replace(/^-+|-+$/g, '');
|
||
|
||
$('#form-wrapper').hide()
|
||
$('#execution-form-wrapper').hide()
|
||
|
||
$('#add-camp-btn').click(function() {
|
||
$('#form-wrapper').show()
|
||
$('#table-wrapper').hide()
|
||
$('#execution-form-wrapper').hide()
|
||
})
|
||
|
||
$('.edit-btn').click(function() {
|
||
let selected = JSON.parse($(this).attr('plan_details'))
|
||
for (let k of Object.keys(selected)) {
|
||
if (selected[k] != '')
|
||
$('#execution-' + k).val(selected[k]);
|
||
}
|
||
$('#execution-id').val(selected['id'])
|
||
$('#form-wrapper').hide()
|
||
$('#execution-form-wrapper').show()
|
||
$('#table-wrapper').hide()
|
||
$('#execution-attendence').attr({min:"1"});
|
||
|
||
|
||
|
||
|
||
let type_of_meet=$('#execution-type_of_meeting').val();
|
||
console.log("type of meet",type_of_meet);
|
||
|
||
if(type_of_meet==='GNP Camp'){
|
||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().show();
|
||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',true);
|
||
$('#execution-no_of_patients_on_duolin').attr('max',10);
|
||
$('label[for="execution-name_of_the_speaker"]').html('Name of the Speaker');
|
||
}
|
||
else{
|
||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
||
$('label[for="execution-name_of_the_speaker"]').html('Name of the speaker');
|
||
}
|
||
|
||
$('#execution-type_of_meeting').on('change',function(){
|
||
let type_of_meet=$('#execution-type_of_meeting').val();
|
||
if(type_of_meet==='GNP Camp'){
|
||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().show();
|
||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',true);
|
||
}
|
||
else{
|
||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').parent().hide();
|
||
$('#execution-no_of_patients_on_duolin,#execution-no_of_units_duolin_respules').attr('required',false);
|
||
}
|
||
})
|
||
|
||
})
|
||
|
||
|
||
|
||
$('.edit-plan-btn').click(function(){
|
||
|
||
$('#execution-new_continue,#execution-lta_regional,#execution-physical_virtual,#execution-yearly_honorarium,#execution-venue_av_food_etc_cost,#execution-total_eas_required').parent().hide();
|
||
$('#execution-new_continue,#execution-lta_regional,#execution-physical_virtual,#execution-yearly_honorarium,#execution-venue_av_food_etc_cost,#execution-total_eas_required').prop('required',false);
|
||
|
||
|
||
let selected = JSON.parse($(this).attr('plan_details'))
|
||
for (let k of Object.keys(selected)) {
|
||
let $input = $('#execution-' + k);
|
||
|
||
if (k === 'record_date' || k === 'attendence') {
|
||
$input.hide().removeAttr('required').val(''); // hide + remove required + clear value
|
||
$input.parent().hide();
|
||
continue;
|
||
}
|
||
|
||
if (selected[k] !== '') {
|
||
$input.show().prop('required', true).val(selected[k]); // show + make required if needed
|
||
|
||
}
|
||
else {
|
||
$input.show().prop('required', false).val('');
|
||
}
|
||
}
|
||
$('#execution-id').val(selected['id'])
|
||
$('#form-wrapper').hide()
|
||
$('#execution-form-wrapper').show()
|
||
$('#table-wrapper').hide();
|
||
|
||
|
||
$('#execution-type_of_meeting').prop('disabled', false).prop('required', true).val(selected['type_of_meeting'] || '');
|
||
$('#execution-speciality').prop('disabled', false).prop('required', true).val(selected['speciality'] || '');
|
||
|
||
|
||
})
|
||
|
||
jQuery(document).ready(function($) {
|
||
|
||
|
||
|
||
|
||
|
||
$('#report-form').on('submit', function(event) {
|
||
event.preventDefault();
|
||
$("#pageloader").fadeIn();
|
||
//$('#report-form').append('<input type="hidden" name="' + slugify($('#field-type_of_meeting').val()) + '" value="1">')
|
||
// formData.append('planning', 'yes');
|
||
$.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();
|
||
} else {
|
||
Swal.fire({
|
||
icon: 'error',
|
||
title: 'Data not submitted',
|
||
text: data.message
|
||
})
|
||
}
|
||
},
|
||
});
|
||
});
|
||
|
||
$('#execution-form').on('submit', function(event) {
|
||
event.preventDefault();
|
||
$("#pageloader").fadeIn();
|
||
$('#execution-form').append('<input type="hidden" name="' + slugify($(
|
||
'#execution-type_of_meeting').val()) + '" value="1">')
|
||
$.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('max', 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('max', today);
|
||
});
|
||
|
||
/* executionDateField.addEventListener('change', function() {
|
||
console.log('gg');
|
||
var executionexeField = document.getElementById('execution-record_date');
|
||
executionexeField.setAttribute('min', executionDateField.value);
|
||
}); */
|
||
|
||
|
||
|
||
});
|
||
|
||
$(document).ready(function() {
|
||
function toggleOtherMeetingField() {
|
||
const selectedValue = $('#field-type_of_meeting').val();
|
||
if (selectedValue == 'Others') {
|
||
$('#field-specify_other_meeting').closest('.col-md-12.mb-2').show();
|
||
} else {
|
||
$('#field-specify_other_meeting').closest('.col-md-12.mb-2').hide();
|
||
}
|
||
}
|
||
|
||
toggleOtherMeetingField();
|
||
|
||
$('#field-type_of_meeting').on('change', toggleOtherMeetingField);
|
||
|
||
|
||
});
|
||
|
||
$(document).ready(function () {
|
||
|
||
$('#execution-type_of_meeting').prop('disabled', true);
|
||
$('#execution-specify_other_meeting').prop('readonly', true);
|
||
|
||
function toggleOtherMeetingexecution() {
|
||
const selectedValue = $('#execution-type_of_meeting').val();
|
||
if (selectedValue === 'Others') {
|
||
$('#execution-specify_other_meeting').closest('.col-md-12.mb-2').show();
|
||
} else {
|
||
$('#execution-specify_other_meeting').closest('.col-md-12.mb-2').hide();
|
||
}
|
||
}
|
||
|
||
// Bind event
|
||
$('#execution-type_of_meeting').on('change', toggleOtherMeetingexecution);
|
||
|
||
// Wait until the select has a value, then run
|
||
const waitForValue = setInterval(() => {
|
||
const val = $('#execution-type_of_meeting').val();
|
||
if (val) {
|
||
toggleOtherMeetingexecution();
|
||
clearInterval(waitForValue);
|
||
}
|
||
}, 50);
|
||
});
|
||
|
||
|
||
$(document).ready(function () {
|
||
|
||
function formatYMD(date) {
|
||
let dd = String(date.getDate()).padStart(2, '0');
|
||
let mm = String(date.getMonth() + 1).padStart(2, '0');
|
||
let yyyy = date.getFullYear();
|
||
return yyyy + '-' + mm + '-' + dd;
|
||
}
|
||
|
||
|
||
/*
|
||
function setPlanDateRange() {
|
||
let today = new Date();
|
||
|
||
let currentDay = today.getDate();
|
||
let currentMonth = today.getMonth(); // 0 = Jan
|
||
let currentYear = today.getFullYear();
|
||
|
||
// Last day of current month
|
||
let lastDayOfCurrentMonth = new Date(currentYear, currentMonth + 1, 0).getDate();
|
||
|
||
// Allow only from 20th till month end
|
||
if (currentDay >= 20 && currentDay <= 25) {
|
||
|
||
// Next month calculation (auto handles year change)
|
||
let nextMonthStart = new Date(currentYear, currentMonth + 1, 1);
|
||
let nextMonthEnd = new Date(currentYear, currentMonth + 2, 0);
|
||
|
||
$('#field-plan_date')
|
||
.attr('min', formatYMD(nextMonthStart))
|
||
.attr('max', formatYMD(nextMonthEnd))
|
||
.val(formatYMD(nextMonthStart)) // default = 1st of next month
|
||
.prop('disabled', false)
|
||
.show();
|
||
|
||
} else {
|
||
// 1st–19th → hide & disable
|
||
$('#field-plan_date')
|
||
.val('')
|
||
.prop('disabled', true);
|
||
}
|
||
}
|
||
|
||
// Call on page load
|
||
setPlanDateRange();
|
||
|
||
*/
|
||
|
||
|
||
|
||
|
||
|
||
|
||
});
|
||
|
||
|
||
</script>
|
||
|
||
|
||
|
||
|
||
</body>
|
||
|
||
</html>
|