IMMREX7
<?php $__env->startSection('content'); ?>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Leave Approval Master</strong></h2>
</div>
<div class="body">
<?php if(isset($late)): ?>
<?php echo Form::model($late, ['method' => 'PATCH', 'action' => ['School\LeaveController@updateRights', $late->idLateArrival], 'class' => 'form-horizontal', 'files' => true]); ?>
<?php else: ?>
<?php echo Form::open(['url' => 'school/leave-approval', 'class' => 'form-horizontal', 'id' => 'form', 'files' => true]); ?>
<?php endif; ?>
<div class="row clearfix">
<div class="col-sm-12">
<div class="col-sm-6 form-control-label">
<p class="required"><strong>Leave Approver</strong></p>
</div>
<div class="col-sm-5">
<div class="form-group">
<?php echo Form::select('employee', $employee, null, ['class' => 'form-control show-tick ms select2']); ?>
<?php if($errors->has('employee')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('employee')); ?></strong>
</label>
<?php endif; ?>
<span id='depterror'></span>
</div>
</div>
</div>
</div>
<hr>
<p><strong>Select Employees</strong></p>
<div class="row clearfix">
<div class="col-sm-6">
<div class="row clearfix">
<div class="col-sm-5 form-control-label required">
<label for="classname">Department</label>
</div>
<div class="col-sm-7">
<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>
<div class="row clearfix">
<div class="col-sm-5 form-control-label">
<label for="classname">EC No.</label>
</div>
<div class="col-sm-7">
<div class="form-group">
<?php if(isset($late)): ?>
<?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 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>
</div>
<div class="col-sm-6">
<div class="row clearfix">
<div class="col-sm-5 form-control-label">
<label for="classname" class="required">Designation</label>
</div>
<div class="col-sm-7">
<div class="form-group">
<?php if(isset($late)): ?>
<?php echo Form::select('idDesignation', $designations, null, ['class' => 'form-control show-tick ms']); ?>
<?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>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
<?php if(isset($late)): ?>
<?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>Leave Approval Master</strong></h2>
</div>
<div class="body table-responsive">
<table class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead>
<tr>
<th>S. No.</th>
<th>Ec No.</th>
<th>Approver<br>Designation</th>
<th>Approver<br>Department</th>
<th>Approver<br>Name</th>
<th>Employee<br>Designation</th>
<th>Employee</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i =1;?>
<?php $__currentLoopData = $approval; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $var): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<tr>
<?php $assignEmployee = \App\Employee::where('idEmployee', '=', $var->permit)->first();?>
<td><?php echo e($i); ?></td>
<td><?php echo e($assignEmployee->enrollmentNo); ?></td>
<td><?php echo e($assignEmployee->designation->designationName); ?></td>
<td><?php echo e($assignEmployee->department->departmentName); ?></td>
<td><?php echo e($assignEmployee->name); ?></td>
<td><?php echo e($var->designation->designationName); ?></td>
<?php if($var->idEmployee != null): ?>
<?php $emp = \App\Employee::where('idEmployee', '=', $var->idEmployee)->first();?>
<td><?php echo e($emp->name); ?></td>
<?php else: ?>
<td>All</td>
<?php endif; ?>
<td><button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="<?php echo e($var->id); ?>" 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 approval",
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/leave-approval/')); ?>" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Leave Approval Entry 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() {
$('input[type="number"]').on('keyup',function(){
var maxDays = $(this).val();
if(maxDays > 31) $(this).val("31");
console.log(maxDays);
});
$('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/leave-approval')); ?>",
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/leave-approval')); ?>";
}
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['lateAllowed']=== undefined){
$( '#lateallowed' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['lateAllowed']+'</strong></span>';
$( '#lateallowed' ).html( errorname );
}
if(errors['deductionRatio']=== undefined){
$( '#dedratio' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['deductionRatio']+'</strong></span>';
$( '#dedratio' ).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 -