IMMREX7
<?php $__env->startSection('content'); ?>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Leave Master</strong></h2>
</div>
<div class="body">
<?php if(isset($leave)): ?>
<?php echo Form::model($leave, ['method' => 'PATCH', 'action' => ['School\LeaveController@update', $leave->idLeave], 'class' => 'form-horizontal','files'=>true]); ?>
<?php else: ?>
<?php echo Form::open(['url' => 'school/leaves', 'class' => 'form-horizontal','id'=>'form','files'=>true]); ?>
<?php endif; ?>
<div class="row clearfix">
<div class="col-sm-2 form-control-label required">
<label for="classname">Department</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php echo Form::select('idDepartment',$departments,null,['class' => 'form-control show-tick ms select2']); ?>
<?php if($errors->has('idDepartment')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idDepartment')); ?></strong>
</label>
<?php endif; ?>
<span id='depterror'></span>
</div>
</div>
<div class="col-sm-2 form-control-label">
<label for="classname" class="required">Designation</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php if(isset($leave)): ?>
<?php echo Form::select('idDesignation',$designations,null,['class' => 'form-control show-tick ms','id'=>'idDesignation']); ?>
<?php else: ?>
<div id="idDesignation" style="border:1px solid #ccc; width:200px; height: 110px; overflow-y: scroll;">
</div>
<?php endif; ?>
<?php if($errors->has('idDesignation')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idDesignation')); ?></strong>
</label>
<?php endif; ?>
<span id='desigerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label">
<label for="classname">EC No.</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php if(isset($leave)): ?>
<?php echo Form::select('idEmployee',$employees,null,['class' => 'form-control show-tick ms']); ?>
<?php else: ?>
<span style="color:red; font-size: 12px;">Please don't select this list if you want to assign a shift on whole department or designation.</span>
<div id="idEmployee" style="border:1px solid #ccc; width:250px; height: 140px; overflow-y: scroll;">
</div>
<?php if($errors->has('ecNO')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('ecNO')); ?></strong>
</label>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
<div class="col-sm-2 form-control-label required">
<label for="classname">Paid Leave Days</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php echo Form::text('paidLeaves',null,['class' => 'form-control','placeholder'=>'eg:2,5,10','minlength'=>'1','maxlength'=>'2','onkeypress'=>'return isNumber(event)']); ?>
<?php if($errors->has('paidLeaves')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('paidLeaves')); ?></strong>
</label>
<?php endif; ?>
<span id='leaveerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label">
<label for="classname">Leave Type</label>
</div>
<div class="col-sm-3">
<?php echo Form::select('leaveType',['monthly' => 'Monthly','yearly' => 'Yearly'],null,['class' => 'form-control show-tick ms']); ?>
</div>
<div class="col-sm-2 form-control-label">
<label for="classname">Max Allowed Per Month</label>
</div>
<div class="col-sm-3">
<?php echo Form::number('max_allowed',null,['class' => 'form-control']); ?>
</div>
</div>
<div class="row clearfix" style="margin-top:1rem;">
<div class="col-sm-2 form-control-label">
<label for="classname">Excluding Month</label>
</div>
<div class="col-sm-3">
<?php $months = [];
if(isset($leave)){
if(isset($leave->exclude_month))
$months = \App\Month::whereIn('idMonth',json_decode($leave->exclude_month,true))->get()->pluck('idMonth')->toArray();
}?>
<select class="selectpicker form-control" multiple name="exclude_month[]"><option value="" disabled>--Select Month---</option><option value="1" <?php if(isset($leave)): ?> <?php if(in_array("1", $months)): ?> selected <?php endif; ?> <?php endif; ?>>January</option><option value="2" <?php if(isset($leave)): ?> <?php if(in_array("2", $months)): ?> selected <?php endif; ?> <?php endif; ?>>February</option><option value="3" <?php if(isset($leave)): ?> <?php if(in_array("3", $months)): ?> selected <?php endif; ?> <?php endif; ?>>March</option><option value="4" <?php if(isset($leave)): ?> <?php if(in_array("4", $months)): ?> selected <?php endif; ?> <?php endif; ?>>April</option><option value="5" <?php if(isset($leave)): ?> <?php if(in_array("5", $months)): ?> selected <?php endif; ?> <?php endif; ?>>May</option><option value="6" <?php if(isset($leave)): ?> <?php if(in_array("6", $months)): ?> selected <?php endif; ?> <?php endif; ?>>June</option><option value="7" <?php if(isset($leave)): ?> <?php if(in_array("7", $months)): ?> selected <?php endif; ?> <?php endif; ?>>July</option><option value="8" <?php if(isset($leave)): ?> <?php if(in_array("8", $months)): ?> selected <?php endif; ?> <?php endif; ?>>August</option><option value="9" <?php if(isset($leave)): ?> <?php if(in_array("9", $months)): ?> selected <?php endif; ?> <?php endif; ?>>September</option><option value="10" <?php if(isset($leave)): ?> <?php if(in_array("10", $months)): ?> selected <?php endif; ?> <?php endif; ?>>October</option><option value="11" <?php if(isset($leave)): ?> <?php if(in_array("11", $months)): ?> selected <?php endif; ?> <?php endif; ?>>November</option><option value="12" <?php if(isset($leave)): ?> <?php if(in_array("12", $months)): ?> selected <?php endif; ?> <?php endif; ?>>December</option></select>
</div>
<div class="col-sm-2 form-control-label">
<label for="classname">Mark Holiday On Leave, If</label>
</div>
<div class="col-sm-3">
<select class="selectpicker form-control" name="sandwich"><option value="0">--Select Pattern---</option><option value="1" <?php if(isset($leave)): ?> <?php if($leave->sandwich == 1): ?> selected <?php endif; ?> <?php endif; ?>>If Absent Before & After</option><option value="2" <?php if(isset($leave)): ?> <?php if($leave->sandwich == 2): ?> selected <?php endif; ?> <?php endif; ?>>If Absent Before/After</option></select>
</div>
</div>
<div class="row clearfix" style="margin-top:1rem;">
<div class="col-sm-2 form-control-label">
<label for="classname">Leave Allocated</label>
</div>
<div class="col-sm-6">
<input type="radio" id="auto" name="leave_allocation" value="A" <?php if(isset($leave)): ?> <?php if($leave->leave_allocation == 'A'): ?> checked <?php endif; ?> <?php endif; ?>>
<label for="auto">Auto</label><br>
<input type="radio" id="manual" name="leave_allocation" value="M" <?php if(isset($leave)): ?> <?php if($leave->leave_allocation == 'M'): ?> checked <?php endif; ?> <?php endif; ?>>
<label for="manual">Manual</label><br>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
<?php if(isset($leave)): ?>
<?php echo Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']); ?>
<?php else: ?>
<?php echo Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-btn']); ?>
<?php endif; ?>
<?php echo Form::close(); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Leaves</strong></h2>
</div>
<div class="body table-responsive">
<?php echo Form::open(['method' => 'GET', 'action' => ['School\LeaveController@index'], 'class' => 'form-horizontal']); ?>
<div class="row clearfix">
<div class="col-sm-2"></div>
<div class="col-sm-2 form-control-label">
<label for="classname">Financial Year</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php echo Form::select('idFinancialYear',fys(),null,['class' => 'form-control show-tick ms']); ?>
</div>
</div>
<div class="col-sm-2">
<?php echo Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']); ?>
</div>
</div>
<?php echo Form::close(); ?>
<br>
<table class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead>
<tr>
<th>S. No.</th>
<th>Department</th>
<th>Designation</th>
<th>Ec No.</th>
<th>Paid Leave Days</th>
<th>Leave Type</th>
<th>Max Allowed</th>
<th>Excluding (Month)</th>
<th>Policy</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
<?php $__currentLoopData = $leaves; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<tr>
<th scope="row"><?php echo e($i); ?></th>
<?php if(isset($value->department)): ?>
<td><?php echo e($value->department->departmentName); ?></td>
<?php else: ?><td></td>
<?php endif; ?>
<?php if(isset($value->designation)): ?>
<td><?php echo e($value->designation->designationName); ?></td>
<?php else: ?><td></td>
<?php endif; ?>
<td><?php echo e(isset($value->employee->enrollmentNo) ? $value->employee->enrollmentNo : ''); ?></td>
<td><?php echo e($value->paidLeaves); ?></td>
<?php if(isset($value->leaveType)): ?>
<td><?php echo e(strtoupper($value->leaveType)); ?></td>
<?php else: ?><td></td>
<?php endif; ?>
<td><?php if($value->max_allowed > 0): ?><?php echo e($value->max_allowed); ?> <?php else: ?> Not Applicable <?php endif; ?></td>
<?php if(isset($value->exclude_month)): ?>
<?php
$month = \App\Month::whereIn('idMonth',json_decode($value->exclude_month,true))->get();
?>
<td>
<?php $__currentLoopData = $month; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $var): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<?php echo e($var->monthName); ?>,
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</td>
<?php else: ?><td>Not Applicable</td>
<?php endif; ?>
<td> Mark Holiday On Leave, If : <?php if($value->sandwich == 0): ?> Not Applicable <?php else: ?> <?php if($value->sandwich == 1): ?> If Absent Befor & After <?php else: ?> If Absent Before/After <?php endif; ?> <?php endif; ?><br>
Leave Allocated : <?php if($value->leave_allocation == 'N'): ?> Not Applicable <?php else: ?> <?php if($value->leave_allocation == 'A'): ?> Auto <?php else: ?> Manual <?php endif; ?> <?php endif; ?>
</td>
<td>
<a href="<?php echo e(url('school/leaves/' . $value->idLeave . '/edit')); ?>" class="btn btn-raised btn-info waves-effect btn-round">Edit </a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="<?php echo e($value->idLeave); ?>" data-type="confirm">DELETE</button>
</td>
</tr>
<?php $i++; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
// Delete Feehead
$(document).on('click', '.js-sweetalert', function (e) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
e.preventDefault();
var id = $(this).data('id');
swal({
title: "Are you sure?",
text: "Are You sure you want to delete this Leave Master!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "<?php echo e(url('/school/leaves/')); ?>" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Leave Master has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
$(document).ready(function() {
$('select[name="idDepartment"]').on('change', function() {
var departmentID = $(this).val();
if(departmentID) {
$.ajax({
url: "<?php echo e(url('/school/departments')); ?>"+'/' +departmentID + "/designations",
type: "GET",
dataType: "json",
success:function(data) {
$('#idDesignation').empty();
$('#idDesignation').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-all" id="selectall"></div>');
$.each(data, function(key, value) {
$('#idDesignation').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:100px;">'+value+'</label><input type="checkbox" name="designations[]" value="'+key+'" class="designationclass"></div>');
});
}
});
}else{
$('select[name="idDesignation"]').empty();
}
});
});
$(document).on('click', '.select-all', function(){
var checkAll = this.checked;
if(checkAll === true){
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
var designationIds = [];
$("input:checkbox[name='designations[]']:checked").each(function () {
designationIds.push($(this).val());
});
if (designationIds.length > 0) {
$.ajax({
url: "<?php echo e(url('/school/designations')); ?>"+'/' +designationIds + "/employees",
type: "GET",
dataType: "json",
success:function(data) {
$('#idEmployee').empty();
$('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
$.each(data, function(key, value) {
$('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="employees[]" value="'+key+'" class="empallselect"></div>');
});
}
});
}
}else{
$('#idEmployee').empty();
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
}
});
$(document).on('click', '.designationclass', function(){
var designationIds = [];
$("input:checkbox[name='designations[]']:checked").each(function () {
designationIds.push($(this).val());
});
if (designationIds.length > 0) {
$.ajax({
url: "<?php echo e(url('/school/designations')); ?>"+'/' +designationIds + "/employees",
type: "GET",
dataType: "json",
success:function(data) {
$('#idEmployee').empty();
$('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
$.each(data, function(key, value) {
$('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="employees[]" value="'+key+'" class="empallselect"></div>');
});
}
});
}else{
$('#idEmployee').empty();
}
});
$(document).on('click', '.select-allstd', function(){
var checkAllstd = this.checked;
if(checkAllstd === true){
$("input:checkbox[name='employees[]']").each(function () {
this.checked = checkAllstd;
});
}else{
$('.empallselect').each(function () {
this.checked = checkAllstd;
});
}
});
// Saving form data
$('#form').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#form')[0]);
$("#submit-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "<?php echo e(url('school/leaves')); ?>",
processData: false,
contentType: false,
data:formData,
dataType: 'json',
success:function(data){
if( data[Object.keys(data)[0]] === 'SUCCESS' ){
$("#submit-btn").prop('disabled', true);
window.location = "<?php echo e(url('school/leaves')); ?>";
}
else { //False Case: With error msg
$("#msg").html(data); //$msg is the id of empty msg
}
},
error: function(data){
if( data.status === 422 ) {
$("#submit-btn").prop('disabled', false);
var errors = data.responseJSON.errors;
var errorHtml = '<div class="alert alert-danger"><ul>';
$('#formerrors').html(errorHtml);
if(errors['idDepartment']=== undefined){
$( '#depterror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idDepartment']+'</strong></span>';
$( '#depterror' ).html( errorname );
}
if(errors['idDesignation']=== undefined){
$( '#desigerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idDesignation']+'</strong></span>';
$( '#desigerror' ).html( errorname );
}
if(errors['paidLeaves']=== undefined){
$( '#leaveerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['paidLeaves']+'</strong></span>';
$( '#leaveerror' ).html( errorname );
}
}
}
});
return false;
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('schools.school_layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Copyright © 2021 -