@php $daysArray = [ '1' => 'Monday', '2' => 'Tuesday', '3' => 'Wednesday', '4' => 'Thursday', '5' => 'Friday', '6' => 'Saturday', '7' => 'Sunday' ]; $currentYear = $year; $currentMonth = $month; $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $currentMonth, $currentYear); @endphp @foreach($employees as $key => $emp) @php $thisEmolyeeHolidays = json_decode($emp->salary->weekly_holidays); $filteredDaysArray = array_diff($daysArray, $thisEmolyeeHolidays); $filteredDaysArray = array_keys($filteredDaysArray); $validDaysCount = 0; for ($day = 1; $day <= $daysInMonth; $day++) { $dayOfWeek = date('N', strtotime("$currentYear-$currentMonth-$day")); if (in_array($dayOfWeek, $filteredDaysArray)) { $validDaysCount++; } } $totalHolidays = $daysInMonth - $validDaysCount; $month = str_pad($month, 2, '0', STR_PAD_LEFT); $searchingTimeline = $year . '-' . $month . '-%'; $thisEmployeePaidLeaves = \Modules\HRM\Entities\EmployeeLeave::where([ 'employee_id' => $emp->id, 'status' => 2, 'is_paid' => 1 ]) ->where('start_date', 'like', $searchingTimeline) ->sum('duration'); $thisEmployeeUnPaidLeaves = \Modules\HRM\Entities\EmployeeLeave::where([ 'employee_id' => $emp->id, 'status' => 2, 'is_paid' => 2 ]) ->where('start_date', 'like', $searchingTimeline) ->sum('duration'); // $month = str_pad($month, 2, '0', STR_PAD_LEFT); // $fromdate = $year . '-' . $month . '-01'; // $carbonDate = \Carbon\Carbon::createFromFormat('Y-m-d', $fromdate); // // $toDate = $carbonDate->addMonth()->firstOfMonth()->toDateString(); $thisEmployeeAttendance = \Modules\HRM\Entities\DailyAttendance::where([ 'employee_id' => $emp->id, 'dept_type' => 1, 'approval_status' => 2, 'type' => 1 ]) ->where('check_in_date', 'like', $searchingTimeline) ->select(\Illuminate\Support\Facades\DB::raw('count(id) as attended, sum(working_hour) as attended_hours')) ->groupBy('employee_id') ->first(); $thisEmployeeShiftHours = $emp->salary->shift->shift_hours; $actualWorkingDays = $validDaysCount - $thisEmployeePaidLeaves; $monthlyWorkingHours = $actualWorkingDays * $thisEmployeeShiftHours; @endphp @php $salaryPerHour = $emp->salary->net_salary / $monthlyWorkingHours; $netSalary = $thisEmployeeAttendance->attended_hours * $salaryPerHour; @endphp @endforeach
{{__('file.Employee ID')}} {{__('file.Employee Name')}} {{__('file.Department')}} {{__('file.Shift')}} {{__('file.Total Working Days')}} {{__('file.Total Holidays')}} {{__('file.Total Attended Days')}} {{__('file.Total Paid Leaves')}} {{__('file.Total Un-Paid Leaves')}} {{__('file.Total Working Hours')}} {{__('file.Total Attended Hours')}} {{__('file.Current Salary')}} {{__('file.Increment')}} {{__('file.Gross Salary')}} {{__('file.Net Salary')}}
{{ $emp->employee_id }} {{ $emp->name }} {{ $emp->department->name }} {{ $emp->salary->shift->name }}