I want to exclude the total of days but excluded saturday,sunday and holliday?? I dont know how? Im still trying to learn, my job is more on IT Technical, This is the first time I am trying to build a system with some help of googles.
Filing leave system.In this code,
I know this is from the idea of some templates in free source code, though as I said I am trying to learn :(
<script>
function calc_days(){
var days = 0;
if($('#date_start').val() != ''){
var start = new Date($('#date_start').val());
var end = new Date($('#date_end').val());
var diffDate = (end - start) / (1000 * 60 * 60 * 24);
days = Math.round(diffDate);
}
if($('#type').val() == 2)
$('#leave_days').val('.5')
else
$('#leave_days').val(days +1)
}
$(document).ready(function(){
$('.select2').select2();
$('.select2-selection').addClass('form-control rounded-0')
$('#type').change(function(){
if($(this).val() == 2){
console.log($(this).val())
$('#leave_days').val('.5')
$('#date_end').attr('required',false)
$('#date_end').val($('#date_start').val())
$('#date_end').closest('.form-group').hide('fast')
}else{
$('#date_end').attr('reqiured',true)
$('#date_end').closest('.form-group').show('fast')
$('#leave_days').val(1)
}
calc_days()
})
$('#date_start, #date_end').change(function(){
calc_days()
})
$('#leave_application-form').submit(function(e){
e.preventDefault();
</script>
<?php
<div class="form-group">
<label for="type" class="control-label">Day Type</label>
<select id="type" name="type" class="form-control rounded-0">
<option value="1" <?php echo (isset($type) && $type ==1)?'selected' : '' ?>>Whole Day</option>
<option value="2" <?php echo (isset($type) && $type ==2)?'selected' : '' ?>>Half Day</option>
</select>
</div>
<div class="form-group">
<label for="date_start" class="control-label">Date Start</label>
<input type="date" id="date_start" class="form-control form" required name="date_start" value="<?php echo isset($date_start) ? date("Y-m-d",strtotime($date_start)) : '' ?>">
</div>
<div class="form-group">
<label for="date_end" class="control-label">Date End</label>
<input type="date" id="date_end" class="form-control form" required name="date_end" value="<?php echo isset($date_end) ? date("Y-m-d",strtotime($date_end)) : '' ?>">
</div>
<div class="form-group">
<label for="leave_days" class="control-label">Days</label>
<input type="number" id="leave_days" class="form-control form" name="leave_days" value="<?php echo isset($leave_days) ? $leave_days : 0 ?>" readonly>
</div>