
<?php $__env->startSection('content'); ?>
<?php $__env->startSection('title'); ?>
<?php echo app('translator')->getFromJson('attendance.my_attendance_report'); ?>
<?php $__env->stopSection(); ?>
<style>
	.employeeName{
		position: relative;
	}
	#employee_id-error{
		position: absolute;
		top: 66px;
		left: 0;
		width: 100%he;
		width: 100%;
		height: 100%;
	}
		/*
		tbody {
			display:block;
			height:500px;
			overflow:auto;
		}
		thead, tbody tr {
			display:table;
			width:100%;
			table-layout:fixed;
		}
		thead {
			width: calc( 100% - 1em )
		}*/


</style>
<script>
    jQuery(function (){
        $("#monthlyAttendance").validate();
     });

</script>
<div class="container-fluid">
	<div class="row bg-title">
		<div class="col-lg-7 col-md-7 col-sm-7 col-xs-12">
			<ol class="breadcrumb">
				<li class="active breadcrumbColor"><a href="<?php echo e(url('dashboard')); ?>"><i class="fa fa-home"></i> <?php echo app('translator')->getFromJson('dashboard.dashboard'); ?></a></li>
				<li><?php echo $__env->yieldContent('title'); ?></li>
			</ol>
		</div>

	</div>

	<div class="row">
		<div class="col-sm-12">
			<div class="panel panel-info">
				<div class="panel-heading"><i class="mdi mdi-table fa-fw"></i><?php echo $__env->yieldContent('title'); ?></div>
				<div class="panel-wrapper collapse in" aria-expanded="true">
					<div class="panel-body">
						<div class="row">
							<div id="searchBox">
								<?php echo e(Form::open(array('route' => 'myAttendanceReport.myAttendanceReport','id'=>'monthlyAttendance'))); ?>

								<div class="col-md-1"></div>
								<div class="col-md-3">
									<div class="form-group employeeName">
										<label class="control-label" for="email"><?php echo app('translator')->getFromJson('common.employee'); ?><span class="validateRq">*</span></label>
										<select  class="form-control employee_id select2 required" required name="employee_id">
											<?php $__currentLoopData = $employeeList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
												<option value="<?php echo e($value->employee_id); ?>" ><?php echo e($value->first_name); ?> <?php echo e($value->last_name); ?></option>
											<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
										</select>
									</div>
								</div>
								<div class="col-md-3">
									<label class="control-label" for="email"><?php echo app('translator')->getFromJson('common.from_date'); ?><span class="validateRq">*</span></label>
									<div class="input-group">
										<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
										<input type="text" class="form-control dateField required" readonly placeholder="<?php echo app('translator')->getFromJson('common.from_date'); ?>"  name="from_date" value="<?php if(isset($from_date)): ?> <?php echo e($from_date); ?><?php else: ?> <?php echo e(dateConvertDBtoForm(date('Y-m-01'))); ?> <?php endif; ?>">
									</div>
								</div>

								<div class="col-md-3">
									<label class="control-label" for="email"><?php echo app('translator')->getFromJson('common.to_date'); ?><span class="validateRq">*</span></label>
									<div class="input-group">
										<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
										<input type="text" class="form-control dateField required" readonly placeholder="<?php echo app('translator')->getFromJson('common.to_date'); ?>"  name="to_date" value="<?php if(isset($to_date)): ?> <?php echo e($to_date); ?><?php else: ?> <?php echo e(dateConvertDBtoForm( date("Y-m-t", strtotime(date('Y-m-01'))))); ?> <?php endif; ?>">
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<input type="submit" id="filter" style="margin-top: 25px; width: 100px;" class="btn btn-info " value="<?php echo app('translator')->getFromJson('common.filter'); ?>">
									</div>
								</div>
								<?php echo e(Form::close()); ?>

							</div>
							</div>
						<hr>
						<h4 class="text-right">
							<?php if(isset($from_date)): ?>
								<?php if(count($results) > 0): ?>
									<a class="btn btn-success" style="color: #fff" href="<?php echo e(URL('downloadMyAttendance/?employee_id='.$employee_id.'&from_date='.$from_date.'&to_date='.$to_date)); ?>"><i class="fa fa-download fa-lg" aria-hidden="true"></i> <?php echo app('translator')->getFromJson('common.download'); ?> PDF</a>
								<?php endif; ?>
							<?php else: ?>
								<?php if(count($results) > 0): ?>
									<a class="btn btn-success" style="color: #fff" href="<?php echo e(URL('downloadMyAttendance/?employee_id='.session('logged_session_data.employee_id').'&from_date='.dateConvertDBtoForm(date('Y-m-01')).'&to_date='.dateConvertDBtoForm( date("Y-m-t", strtotime(date('Y-m-01')))))); ?>"><i class="fa fa-download fa-lg" aria-hidden="true"></i> <?php echo app('translator')->getFromJson('common.download'); ?> PDF</a>
								<?php endif; ?>
							<?php endif; ?>
						</h4>
						<div class="table-responsive">
							<table id="" class="table table-bordered">
								<thead class="tr_header">
								<tr>
									<th style="width:100px;"><?php echo app('translator')->getFromJson('common.serial'); ?></th>
									<th><?php echo app('translator')->getFromJson('common.date'); ?></th>
									<th><?php echo app('translator')->getFromJson('common.employee_name'); ?></th>
									<th><?php echo app('translator')->getFromJson('attendance.in_time'); ?></th>
									<th><?php echo app('translator')->getFromJson('attendance.out_time'); ?></th>
									<th><?php echo app('translator')->getFromJson('attendance.working_time'); ?></th>
									<th><?php echo app('translator')->getFromJson('attendance.late'); ?></th>
									<th><?php echo app('translator')->getFromJson('attendance.late_time'); ?></th>
									<th><?php echo app('translator')->getFromJson('attendance.over_time'); ?></th>
									<th><?php echo app('translator')->getFromJson('common.status'); ?></th>
								</tr>
								</thead>
								<tbody>
                                <?php
                                $totalPresent = 0;
                                $totalAbsence = 0;
                                $totalLeave   = 0;
								$totalLate    = 0;
								$totalHour    = 0;
                                $totalMinit   = 0;
                                ?>

								<?php echo e($serial = null); ?>

								<?php if(count($results) > 0): ?>
									<?php $__currentLoopData = $results; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

										<tr>
											<td style="width:100px;"><?php echo e(++$serial); ?></td>
											<td><?php echo e($value['date']); ?></td>
											<td><?php echo e($value['fullName']); ?></td>
											<td>
                                                <?php
                                                if ($value['in_time'] != '') {
                                                    echo $value['in_time'];
                                                } else {
                                                    echo "--";
                                                }
                                                ?>
											</td>
											<td>
                                                <?php
                                                if ($value['out_time'] != '') {
                                                    echo $value['out_time'];
                                                } else {
                                                    echo "--";
                                                }
                                                ?>
											</td>

											<td>
                                                <?php
													if( $value['working_time'] ==''){
                                                        echo "--";
													}else{
                                                        if ($value['working_time'] != '00:00:00' ) {
                                                            echo $d =  date('H:i', strtotime($value['working_time']));

                                                            $hour_minit = explode(':',$d);

                                                            $totalHour += $hour_minit[0];
                                                            $totalMinit += $hour_minit[1];
                                                             

                                                        } else {
                                                            echo 'One Time Punch';
                                                        }
													}

                                                ?>
											</td>
											<td>
                                                <?php
													if($value['ifLate'] == ''){
													    echo "--";
													}else{
														if($value['ifLate'] == 'Yes'){
															echo "<b style='color: red'>".__('common.yes')."</b>";
															$totalLate +=1;
														}else{
															echo __('common.no');
														}
                                                    }

                                                ?>
											</td>
											<td>
                                                <?php
													if($value['totalLateTime'] ==''){
                                                        echo "--";
													}else{
                                                        if ($value['totalLateTime'] != '00:00:00') {
                                                            echo date('H:i', strtotime($value['totalLateTime']));
                                                        }else{
                                                            echo "--";
                                                        }
													}
                                                ?>

											</td>
											<td>
                                                <?php
												if($value['workingHour'] == '')	{
												    echo "--";
												}else{
													$workingHour = new DateTime($value['workingHour']);
													$workingTime = new DateTime($value['working_time']);
													if($workingHour < $workingTime){
														$interval = $workingHour->diff($workingTime);
														echo $interval->format('%H:%I');
													}else{
														echo "--";
													}
                                                }
                                                ?>
											</td>
											<td>
                                                <?php
                                                if($value['action'] =='Absence'){
                                                    echo "<span class='label label-danger'>".__('common.absence')."</span>";
                                                    $totalAbsence +=1;
                                                }elseif($value['action'] =='Leave'){
                                                    echo "<span class='label label-info'>".__('common.leave')."</span></p>";
                                                    $totalLeave +=1;
                                                }else{
                                                    echo "<span class='label label-success'>".__('common.present')."</span>";
                                                    $totalPresent +=1;
                                                }
                                                ?>
											</td>
										</tr>
									<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
								<?php else: ?>
									<tr>
										<td colspan="9"><?php echo app('translator')->getFromJson('common.no_data_available'); ?> !</td>
									</tr>
								<?php endif; ?>
                               <?php 

								$total_working_hour = (($totalHour*60)+$totalMinit)/60;

								?>
								<?php if(count($results) > 0): ?>
									<tr>
										<td colspan="8"></td>
										<td style="background: #eee"><b><?php echo app('translator')->getFromJson('attendance.total_working_days'); ?>: &nbsp;</b></td>
										<td style="background: #eee"><b><?php echo e($serial); ?></b>  <?php echo app('translator')->getFromJson('common.days'); ?></td>
									</tr>
									<tr>
										<td colspan="8"></td>
										<td style="background: #fff"><b><?php echo app('translator')->getFromJson('attendance.total_present'); ?>: &nbsp;</b></td>
										<td style="background: #fff"><b><?php echo e($totalPresent); ?></b> <?php echo app('translator')->getFromJson('common.days'); ?></td>
									</tr>
									<tr>
										<td colspan="8"></td>
										<td style="background: #eee"><b><?php echo app('translator')->getFromJson('attendance.total_absence'); ?>: &nbsp;</b></td>
										<td style="background: #eee"><b><?php echo e($totalAbsence); ?></b> <?php echo app('translator')->getFromJson('common.days'); ?></td>
									</tr>
									<tr>
										<td colspan="8"></td>
										<td style="background: #fff"><b><?php echo app('translator')->getFromJson('attendance.total_leave'); ?>: &nbsp;</b></td>
										<td style="background: #fff"><b><?php echo e($totalLeave); ?></b> <?php echo app('translator')->getFromJson('common.days'); ?></td>
									</tr>
									<tr>
										<td colspan="8"></td>
										<td style="background: #eee"><b><?php echo app('translator')->getFromJson('attendance.total_late'); ?>: &nbsp;</b></td>
										<td style="background: #eee"><b><?php echo e($totalLate); ?></b> <?php echo app('translator')->getFromJson('common.days'); ?></td>
									</tr>


								     <tr>
										<td colspan="8"></td>
										<td style="background: #eee"><b><?php echo app('translator')->getFromJson('attendance.expected_working_hour'); ?>: &nbsp;</b></td>
										<td style="background: #eee"><b><?php echo e($expected = $totalPresent*8); ?></b> <?php echo app('translator')->getFromJson('common.hours'); ?></td>
									</tr>	

									<tr>
										<td colspan="8"></td>
										<td style="background: #eee"><b><?php echo app('translator')->getFromJson('attendance.actual_working_hour'); ?>: &nbsp;</b></td>
										<td style="background: #eee"><b><?php echo e(round($total_working_hour)); ?></b> <?php echo app('translator')->getFromJson('common.hours'); ?></td>
									</tr>	
                                    
                                    <?php
                                      $overtime = $total_working_hour - $expected;
                                     ?>
									<tr>
										<td colspan="8"></td>
										<td style="background: #eee"><b><?php echo app('translator')->getFromJson('attendance.over_time'); ?>: &nbsp;</b></td>
										<td style="background: #eee"><b><?php if($overtime > 0): ?> <?php echo e(round($overtime)); ?> <?php else: ?> 0 <?php endif; ?></b> <?php echo app('translator')->getFromJson('common.hours'); ?></td>
									</tr>	

									<tr>
										<td colspan="8"></td>
										<td style="background: #eee"><b><?php echo app('translator')->getFromJson('attendance.deficiency'); ?>: &nbsp;</b></td>
										<td style="background: #eee"><b><?php if($overtime < 0): ?> <?php echo e(round($overtime)); ?> <?php else: ?> 0 <?php endif; ?></b> <?php echo app('translator')->getFromJson('common.hours'); ?></td>
									</tr>
								<?php endif; ?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>