IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="body">
<button class="btn btn-raised btn-warning btn-round waves-effect" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">Advance Search</button>
<div class="collapse" id="collapseExample">
<div class="well">
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Advance Search</strong></h2>
</div>
<div class="body">
{!! Form::open(['method' => 'GET', 'action' => ['School\EmpAttendanceController@reportAttendance'], 'class' => 'form-horizontal']) !!}
<div class="row clearfix">
<div class="col-sm-4">
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname">Departments</label>
</div>
<div class="col-sm-7">
<div class="form-group">
{!! Form::select('idDepartment',$departments,null,['class' => 'form-control show-tick ms']) !!}
@if ($errors->has('idDepartment'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idDepartment') }}</strong>
</label>
@endif
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname">Designation</label>
</div>
<div class="col-sm-7">
<div class="form-group">
<div id="idDesignation" style="border:1px solid #ccc; width:200px; height: 150px; overflow-y: scroll;">
<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>
@foreach ($designation as $key =>$value)
<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>
@endforeach
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="row clearfix">
<div class="col-sm-3 form-control-label">
<label for="classname">EC No.</label>
</div>
<div class="col-sm-7">
<div class="form-group">
<div id="idEmployee" style="border:1px solid #ccc; width:200px; height: 150px; overflow-y: scroll;">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-1 form-control-label required">
<label for="classname">Year</label>
</div>
<div class="col-sm-2">
<div class="form-group">
{!! Form::select('year',['2024'=>'2024','2025'=>'2025','2021'=>'2021',2022=>'2022','2023'=>'2023','2020'=>'2020','2019'=>'2019'],null,['class' => 'form-control show-tick ms']) !!}
</div>
</div>
<div class="col-sm-1 form-control-label required">
<label for="classname">Month</label>
</div>
<div class="col-sm-2">
<div class="form-group">
{!! Form::select('idMonth',getMonths(),$current_month->idMonth,['class' => 'form-control show-tick ms']) !!}
@if ($errors->has('idMonth'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idMonth') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
{!! Form::submit('SHOW',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--</div>-->
</div>
</div>
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card">
<button class="btn btn-raised btn-info btn-round waves-effect" type="button" style="float:right;margin:20px;" onclick="location.href='{{url('/school/print-empattendance-report?')}}{{$query}}'">Print Advance Report</button>
<div class="body">
<div class="body">
<!-- Nav tabs -->
<!-- <ul class="nav nav-tabs">
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#profile">Month</a></li>
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#messages">All Time</a></li>
</ul> -->
<!-- Tab panes -->
<div>
<div class="header"><h2><strong>Employee Attandance Report (Late | Overtime)</strong></h2>
</div>
<div class="body table-responsive">
@if(isset($month))
@if(count($employees)>0)
<table class="table table-bordered table-striped table-hover dataTable tableexp">
<thead>
<tr>
<th>EC No.</th>
<th>Name</th>
@foreach($days as $key=>$var)
<th>
@if($var[1] == 'SUNDAY')
<span style="color:green; font-weight: bold;">{{ Carbon\Carbon::parse($var[0])->format('d-m')}}</span>
@elseif($var[1]!=null && $var[1]!='SUNDAY')
<span style="color:green; font-weight: bold;">{{Carbon\Carbon::parse($var[0])->format('d-m')}}</span>
@else
{{Carbon\Carbon::parse($var[0])->format('d-m')}}
@endif
</th>
@endforeach
<th>TP</th>
<th>TA</th>
<th>TH</th>
</tr>
</thead>
<tbody>
@foreach($employees as $emp)
<tr>
<?php
$total_present = 0;
$total_absent = 0;
$total_holiday = 0;
$allowedLateMinutes = 0;
$allowedEarlyMinutes = 0;
$totalLateDays = 0;
$totalEarlyDays = 0;
$empDays = [];
$idFinancialYear = Session::get('idFinancialYear');
$leaveMaster = fetchLeaveMaster($emp,$idFinancialYear);
?>
<td>{{$emp->enrollmentNo}}</td>
<td>{{$emp->firstName}} {{$emp->middleName}} {{$emp->lastName}}</td>
@foreach($days as $key=>$var)
<td>
@php
$tdate = Carbon\Carbon::parse($var[0]);
$now = Carbon\Carbon::now();
$jdate = $tdate->format('Y-m-d');
$cdate = intval($tdate->format('d'));
$length = $tdate->diffInDays($now);
//check for holiday
$holiday = getHoliday($emp,$jdate);
$shifts = fetchShift($emp,$jdate);
$dayNight = "AM";
$nightDay = "AM";
$isLeaveMaster = "N";
$empDays[$cdate] = "A";
$isPaidLeaveMaster = "N";
if($shifts != null && $holiday == null){
$dayNight = strtoupper($shifts->shift_from);
$nightDay = strtoupper($shifts->shift_to);
$arrival = checkArrival($emp,$jdate,$shifts,$school,$dayNight,$idFinancialYear,$allowedLateMinutes,$totalLateDays);
$departure = checkDeparture($emp,$jdate,$shifts,$school,$nightDay,$idFinancialYear,$allowedEarlyMinutes,$totalEarlyDays);
$overtime = fetchOvertime($emp,$shifts,$dayNight,$nightDay,$school,$jdate,$idFinancialYear);
$totalEarlyDays = $departure['days'];
$totalLateDays = $arrival['days'];
$nonPaidLeave = DB::table('employee_leave')
->whereDate('leave_from', '<=', $jdate)
->whereDate('leave_to', '>=', $jdate)
->where('idEmployee', $emp->idEmployee)
->where('status' ,'!=', 'Approve with PL(Paid Leave)')
->first();
if($nonPaidLeave != null){
$isPaidLeaveMaster = "K";
}else
if(fetchPaidLeave($jdate,$emp) == 1){
$isPaidLeaveMaster = "Y";
}else if($leaveMaster != null){
if($leaveMaster->leave_allocation == "A"){
$month = \App\Month::where('monthName', '=', $tdate->format('F'))->first();
if($cdate > 1 && $cdate < $month->noOfDays){
if(isset($leaveMaster->exclude_month)){
$month = \App\Month::where('monthName',$tdate->format('F'))->whereIn('idMonth',json_decode($leaveMaster->exclude_month,true))->get();
if(count($month) == 0){
//check for sandwich leave
if($holiday != null){
if(checkForSandwich($emp,$leaveMaster->sandwich,$empDays,$tdate,$cdate,$school) == 1){
$isLeaveMaster = "Y";
}
}
if($shifts->weekOff == "Y"){
if(checkForSandwich($emp,$leaveMaster->sandwich,$empDays,$tdate,$cdate,$school) == 1){
$isLeaveMaster = "Y";
}
}
}
}else{
//check for sandwich leave
}
}
}
}
}
else {
$arrival = [];
$departure = [];
}
@endphp
@if($isPaidLeaveMaster == "Y" || $isPaidLeaveMaster == "K")
@if($isPaidLeaveMaster == "K")
<?php $total_absent = $total_absent + 1;
$empDays[$cdate] = "A";
?>
<span style="color:red;font-weight:bold">A (Leave)</span><br>
@else
<?php $total_present = $total_present + 1; $empDays[$cdate] = "H";?>
<span style="color:green;font-weight:bold">P (Leave)</span><br>
@endif
@else
@if($isLeaveMaster == "Y" && $shifts != null)
<?php $total_absent = $total_absent + 1;
$empDays[$cdate] = "A";
?>
<span style="color:red;font-weight:bold">A (Leave Rule)</span>
@else
@if($holiday != null)
<?php $total_holiday = $total_holiday + 1;
$empDays[$cdate] = "H";
?>
<span style="color:#6572b8;font-weight:bold">{{$holiday->holidayName}}</span>
@else
@if($shifts != null)
@if($shifts->weekOff == "Y")
<?php $total_holiday = $total_holiday + 1;
$empDays[$cdate] = "H";?>
<span style="color:#007bff;font-weight:bold">Week Off</span>
@else
@if(isset($shifts->fromTime) && isset($shifts->toTime))
@if($arrival['status'] == "I" && $departure['status'] == "I")
<?php $total_absent = $total_absent + 1;
$empDays[$cdate] = "A";
?>
<span style="color:red;font-weight:bold">A</span>
@else
<?php $empDays[$cdate] = "P";?>
<br><span style="color:black;font-weight:bold">Shift : {{Carbon\Carbon::parse($shifts->fromTime.' '.$dayNight)->format('H:i').'-'.Carbon\Carbon::parse($shifts->toTime.' '.$nightDay)->format('H:i')}}</span><br>
<!-- Late Master and IN Time -->
@if($arrival['status'] == "I")
{!! $arrival['html']!!}
@elseif($arrival['status'] == "HF")
{!! $arrival['html']!!}
{!! $arrival['late_html']!!}
@elseif($arrival['status'] == "LT")
{!! $arrival['html']!!}
{!! $arrival['late_html']!!}
@elseif($arrival['status'] == "P")
{!! $arrival['html']!!}
@endif
@if($arrival['status'] == "A")
<?php $total_absent = $total_absent + 1;
$empDays[$cdate] = "AB";?>
{!! $arrival['html']!!}
{!! $arrival['late_html']!!}
@elseif($departure['status'] == "A")
<?php $total_absent = $total_absent + 1;
$empDays[$cdate] = "AB";?>
{!! $departure['html']!!}
{!! $departure['late_html']!!}
@elseif($departure['status'] == "P" && $arrival['status'] == "P")
<?php $total_present = $total_present + 1; ?>
@elseif( ( $departure['status'] == "LT" || $departure['status'] == "P") && ( $arrival['status'] == "LT" || $arrival['status'] == "P"))
<?php $total_present = $total_present + 1; ?>
@elseif($departure['status'] == "HF" || $arrival['status'] == "HF")
<?php $total_present = $total_present + 0.5; ?>
@endif
<!-- Early Going and OUT Time -->
@if($departure['status'] == "I")
{!! $departure['html']!!}
@elseif($departure['status'] == "HF")
{!! $departure['html']!!}
{!! $departure['late_html']!!}
@elseif($departure['status'] == "LT")
{!! $departure['html']!!}
{!! $departure['late_html']!!}
@elseif($departure['status'] == "P")
{!! $departure['html']!!}
@endif
<!-- Overtime and OUT Time -->
@if($overtime['status'] == "Y")
{!! $overtime['html']!!}
@endif
@endif
@endif
@endif
@else
<span style="color:#dc3545;font-weight:bold">No Shift</span>
@endif
@endif
<!-- Leave master -->
@endif
@endif
</td>
@endforeach
<td>{{$total_present}}</td>
<td>{{$total_absent}}</td>
<td>{{$total_holiday}}</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p style="color:red;"><strong>To get Attendance Report please go to 'Advance Search' and select Month.</strong></p>
@endif
@endif
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
$('select[name="idDepartment"]').on('change', function() {
var departmentID = $(this).val();
if(departmentID) {
$.ajax({
url: "{{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: "{{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: "{{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;
});
}
});
$(function () {
$('.tableexp').DataTable({
'lengthMenu': [[25, 50, 100, - 1], [25, 50, 100, "All"]],
dom: 'Bfrtip',
scrollY: "500px",
scrollX: true,
scrollCollapse: true,
fixedColumns: {
left: 1
},
buttons: [
'csv', 'excel', 'pdf', 'print'
]
});
});
$('.dateselector').datepicker({
autoclose: true,
autoWidth: false,
format: 'dd-mm-yyyy',
endDate: '+0d',
orientation: 'auto'
});
</script>
@stop
Copyright © 2021 -