Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 301 |
| AttendanceReportController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
7832 | |
0.00% |
0 / 301 |
| index | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 11 |
|||
| create | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| store | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| show | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| edit | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| update | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| destroy | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| SelectTeamReport | |
0.00% |
0 / 1 |
5112 | |
0.00% |
0 / 245 |
|||
| makeColumnHeaders | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 21 |
|||
| isLeave | |
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 18 |
|||
| <?php | |
| namespace App\Http\Controllers\Reports; | |
| use Illuminate\Http\Request; | |
| use App\Http\Controllers\Controller; | |
| use App\Models\Admin\Team; | |
| use DB; | |
| use Carbon\CarbonPeriod; | |
| use Carbon\Carbon; | |
| use App\Models\Leave\ApplyLeave; | |
| use App\Models\Auth\User; | |
| use App\Models\Admin\Holiday; | |
| use App\Models\Dashboard\AttendanceDetail; | |
| use App\Models\Auth\UserWeeklyOff; | |
| use GetShiftDetailHelper; | |
| use App\Helpers\HolidayHelper; | |
| use Illuminate\Support\Facades\Auth; | |
| use App\Helpers\AttendanceHelper; | |
| use Mockery\Undefined; | |
| class AttendanceReportController extends Controller | |
| { | |
| //private $dataArr, $columnHeaders; | |
| /** | |
| * Display a listing of the resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function index(Request $request) | |
| { | |
| $title = '/Reports/Attendance Report'; | |
| //$teams = Team::all(); | |
| $userIds = ''; | |
| if (auth()->user()->can('View All Attendance Report')) { | |
| $teams = Team::all(); | |
| } else if ( | |
| auth()->user()->can('View Team Attendance Report') || | |
| auth()->user()->can('View Reporting Employees Report') | |
| ) { | |
| $teams = GetShiftDetailHelper::getMyteams(); | |
| } | |
| // For Attendance Marking | |
| $val = AttendanceHelper::getAttendanceMarkValue(); | |
| $valTeam = AttendanceHelper::getAttendanceTeam($request); | |
| $valUser = AttendanceHelper::getAttendanceUser($request); | |
| return view('Reports.attendanceReportTable', compact('teams', 'title','val','valTeam','valUser')); | |
| } | |
| /** | |
| * Show the form for creating a new resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function create() | |
| { | |
| // | |
| } | |
| /** | |
| * Store a newly created resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function store(Request $request) | |
| { | |
| // | |
| } | |
| /** | |
| * Display the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function show($id) | |
| { | |
| // | |
| } | |
| /** | |
| * Show the form for editing the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function edit($id) | |
| { | |
| // | |
| } | |
| /** | |
| * Update the specified resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function update(Request $request, $id) | |
| { | |
| // | |
| } | |
| /** | |
| * Remove the specified resource from storage. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function destroy($id) | |
| { | |
| } | |
| public function SelectTeamReport(Request $request) //$startDate,$endDate,$teamId | |
| { | |
| // if(!empty($request->month_year)){ | |
| // $startDate = Carbon::parse('01-' . $request->month_year, Config('app.timezone')); | |
| // $startDate = $startDate->format('Y-m-d'); | |
| // $endDate = Carbon::parse('01-' . $request->month_year, Config('app.timezone'))->endOfMonth()->format('Y-m-d'); | |
| // $endDateForQuery = Carbon::parse('01-' . $request->month_year, Config('app.timezone'))->addMonth()->format('Y-m-d'); | |
| // }else{ | |
| // $startDate = Carbon::parse( Carbon::createFromFormat( config('settings.php_date_format') , $request->fromDate ) )->format('Y-m-d'); | |
| // $endDate = Carbon::parse( Carbon::createFromFormat( config('settings.php_date_format') , $request->toDate ) )->format('Y-m-d'); | |
| // $endDateForQuery = Carbon::parse(Carbon::createFromFormat( config('settings.php_date_format') , $request->toDate ) )->addDay()->format('Y-m-d'); | |
| // } | |
| $startDate = Carbon::parse( $request->fromDate)->format('Y-m-d'); | |
| $endDate = Carbon::parse( $request->toDate )->format('Y-m-d'); | |
| $endDateForQuery = Carbon::parse($request->toDate )->addDay()->format('Y-m-d'); | |
| $columnHeadersList = collect($this->makeColumnHeaders($startDate, $endDate)); | |
| $selectedDateWithTimezone = Carbon::parse($startDate . '000000', config('settings.time_zone'))->setTimezone(config('app.time_zone')); | |
| $selectedEndDateWithTimezone = Carbon::parse($endDateForQuery . '000000', config('settings.time_zone'))->setTimezone(config('app.time_zone')); | |
| $columnHeaders = $columnHeadersList[0]; | |
| $columnHeaderDisp = $columnHeadersList[1]; | |
| $teamId = $request->teamId; | |
| $engId = $request->engId; | |
| $userIds = ''; | |
| $userIdsQuery = ''; | |
| if ( | |
| auth()->user()->can('View Reporting Employees Report') && | |
| !auth()->user()->can('View Team Attendance Report') && | |
| !auth()->user()->can('View All Attendance Report') | |
| ) { | |
| $getuserIds = GetShiftDetailHelper::getMyReportingEmployeesIds(); | |
| $userIdsQuery = ' and us.id in (' . implode(',', $getuserIds) . ')'; | |
| } | |
| if (($teamId === '0') && $engId === '0') { | |
| $teamQuery = ''; | |
| if ((auth()->user()->can('View Reporting Employees Report') || | |
| auth()->user()->can('View Team Attendance Report')) && | |
| !auth()->user()->can('View All Attendance Report') | |
| ) { | |
| $getTeamIds = GetShiftDetailHelper::getMyteamIds(); | |
| $teamQuery = 'and t.id in (' . implode(',', $getTeamIds) . ')'; | |
| } | |
| // $attendanceReport = DB::select( | |
| // 'select us.id,us.name,us.lastName,t.team,a.check_in as check_in, | |
| // a.check_out as check_out | |
| // from users us | |
| // join user_details u on us.id = u.user_id | |
| // join team_user_detail tsd on tsd.user_detail_id = u.id | |
| // join teams t on t.id = tsd.team_id | |
| // left join attendance_details a on a.user_id = u.user_id | |
| // AND ((a.check_in between :startDate1 and :endDate1)) | |
| // where us.deleted_at IS NULL '.$teamQuery.$userIdsQuery.' | |
| // order by us.id,a.id', | |
| // ['startDate1' => $selectedDateWithTimezone, 'endDate1' => $selectedEndDateWithTimezone] | |
| // ); | |
| $attendanceReport = DB::select('SELECT us.id, us.name, us.lastName, MAX(t.team) AS team, MAX(a.check_in) AS check_in, MAX(a.check_out) AS check_out, | |
| MAX(a.attendance_setting) AS attendance_setting, MAX(a.created_at) AS created_at | |
| FROM users us | |
| JOIN user_details u ON us.id = u.user_id | |
| JOIN teams t ON t.id = u.primary_team_id | |
| LEFT JOIN attendance_details a ON a.user_id = u.user_id | |
| WHERE ( | |
| (a.created_at BETWEEN ? AND ? OR a.check_in BETWEEN ? AND ?) | |
| AND us.deleted_at IS NULL | |
| ' . $teamQuery . $userIdsQuery . ' | |
| ) | |
| GROUP BY us.id, a.check_in | |
| ORDER BY us.id, MAX(a.id) DESC | |
| ', [ | |
| $selectedDateWithTimezone, $selectedEndDateWithTimezone, | |
| $selectedDateWithTimezone, $selectedEndDateWithTimezone | |
| ]); | |
| }else if ($teamId == 0 && $engId !== '0') { | |
| $teamQuery = ''; | |
| if ((auth()->user()->can('View Reporting Employees Report') || | |
| auth()->user()->can('View Team Attendance Report')) && | |
| !auth()->user()->can('View All Attendance Report') | |
| ) { | |
| $getTeamIds = GetShiftDetailHelper::getMyteamIds(); | |
| $teamQuery = 'and t.id in (' . implode(',', $getTeamIds) . ')'; | |
| } | |
| $attendanceReport = DB::select('SELECT us.id, us.name, us.lastName, MAX(t.team) AS team, MAX(a.check_in) AS check_in, MAX(a.check_out) AS check_out, | |
| MAX(a.attendance_setting) AS attendance_setting, MAX(a.created_at) AS created_at | |
| FROM users us | |
| JOIN user_details u ON us.id = u.user_id | |
| JOIN teams t ON t.id = u.primary_team_id | |
| LEFT JOIN attendance_details a ON a.user_id = u.user_id | |
| WHERE ( | |
| (a.created_at BETWEEN ? AND ? OR a.check_in BETWEEN ? AND ?) | |
| AND us.deleted_at IS NULL | |
| ' . $teamQuery . $userIdsQuery . ' | |
| AND u.engagement_type = ? | |
| ) | |
| GROUP BY us.id, a.check_in | |
| ORDER BY us.id, MAX(a.id) DESC | |
| ', [ | |
| $selectedDateWithTimezone, $selectedEndDateWithTimezone, | |
| $selectedDateWithTimezone, $selectedEndDateWithTimezone, | |
| $engId, | |
| ]); | |
| }else { | |
| // $attendanceReport = DB::select( | |
| // 'select us.id,us.name,us.lastName,t.team,a.check_in as check_in, | |
| // a.check_out as check_out | |
| // from users us | |
| // join user_details u on us.id = u.user_id | |
| // join team_user_detail tsd on tsd.user_detail_id = u.id | |
| // join teams t on t.id = tsd.team_id | |
| // left join attendance_details a on a.user_id = u.user_id | |
| // AND ((a.check_in between :startDate1 and :endDate1)) | |
| // where us.deleted_at IS NULL and tsd.team_id in (' . $teamId . ') '.$userIdsQuery.'order by us.id,a.id', | |
| // ['startDate1' => $selectedDateWithTimezone, 'endDate1' => $selectedEndDateWithTimezone] | |
| // ); | |
| if ($engId === '0') { | |
| $attendanceReport = DB::select('SELECT us.id, us.name, us.lastName, MAX(t.team) AS team, MAX(a.check_in) AS check_in, MAX(a.check_out) AS check_out, | |
| MAX(a.attendance_setting) AS attendance_setting, MAX(a.created_at) AS created_at | |
| FROM users us | |
| JOIN user_details u ON us.id = u.user_id | |
| JOIN teams t ON t.id = u.primary_team_id | |
| LEFT JOIN attendance_details a ON a.user_id = u.user_id | |
| WHERE ( | |
| (a.created_at BETWEEN ? AND ? OR a.check_in BETWEEN ? AND ?) | |
| AND us.deleted_at IS NULL | |
| AND u.primary_team_id IN (' . $teamId . ') | |
| ' . $userIdsQuery . ' | |
| ) | |
| GROUP BY us.id, a.check_in | |
| ORDER BY us.id, MAX(a.id) DESC | |
| ', [ | |
| $selectedDateWithTimezone, $selectedEndDateWithTimezone, | |
| $selectedDateWithTimezone, $selectedEndDateWithTimezone | |
| ]); | |
| }else{ | |
| $attendanceReport = DB::select('SELECT us.id, us.name, us.lastName, MAX(t.team) AS team, MAX(a.check_in) AS check_in, MAX(a.check_out) AS check_out, | |
| MAX(a.attendance_setting) AS attendance_setting, MAX(a.created_at) AS created_at | |
| FROM users us | |
| JOIN user_details u ON us.id = u.user_id | |
| JOIN teams t ON t.id = u.primary_team_id | |
| LEFT JOIN attendance_details a ON a.user_id = u.user_id | |
| WHERE ( | |
| (a.created_at BETWEEN ? AND ? OR a.check_in BETWEEN ? AND ?) | |
| AND us.deleted_at IS NULL | |
| AND u.primary_team_id IN (' . $teamId . ') | |
| ' . $userIdsQuery . ' | |
| AND u.engagement_type = ? | |
| ) | |
| GROUP BY us.id, a.check_in | |
| ORDER BY us.id, MAX(a.id) DESC | |
| ', [ | |
| $selectedDateWithTimezone, $selectedEndDateWithTimezone, | |
| $selectedDateWithTimezone, $selectedEndDateWithTimezone, | |
| $engId, | |
| ]); | |
| } | |
| } | |
| $dataArr = collect([]); | |
| $count = 0; | |
| $currenUserId = 0; | |
| $attendanceReportColl = collect($attendanceReport); | |
| $attendanceReportCollOfColl = collect([]); | |
| $attendanceUserColl = collect([]); | |
| foreach ($attendanceReportColl as $attendance) { | |
| if ($currenUserId == $attendance->id) { | |
| $attendanceUserColl->push($attendance); | |
| } else { | |
| $attendanceReportCollOfColl->push($attendanceUserColl); | |
| $attendanceUserColl = collect([]); | |
| $attendanceUserColl->push($attendance); | |
| $count = 0; | |
| } | |
| if ($count == 0) { | |
| $currenUserId = $attendance->id; | |
| $count = $count + 1; | |
| } | |
| } | |
| if ($attendanceUserColl->count() != 0) { | |
| $attendanceReportCollOfColl->push($attendanceUserColl); | |
| $attendanceUserColl = collect([]); | |
| } | |
| $count = 0; | |
| $present = 0; | |
| $leave = 0; | |
| $absent = 0; | |
| $weekend = 0; | |
| $total = 0; | |
| $holidayCount = 0; | |
| $totalPayDays = 0; | |
| foreach ($attendanceReportCollOfColl as $attendanceUserColl) { | |
| //user on weekend | |
| $user = User::find($attendanceUserColl->pluck('id')->first()); | |
| if (!empty(User::find($attendanceUserColl->pluck('id')->first())->userdetail)) { | |
| $currentDate = Carbon::now(config('settings.timezone'))->toDateString(); | |
| foreach ($columnHeaders as $date) { | |
| if ($count == 0) { | |
| $empAttendanceArr = collect([]); | |
| $fullEmpName = $attendanceUserColl->pluck('name')->first() . ' ' . $attendanceUserColl->pluck('lastName')->first(); | |
| $empAttendanceArr->push($fullEmpName); | |
| $count = $count + 1; | |
| continue; | |
| } | |
| $total = $total + 1; | |
| $startDateForWeeklyOff = Carbon::parse($date . '00:00:00', config('settings.time_zone'))->setTimezone(config('app.time_zone')); | |
| $endDateForWeeklyOff = Carbon::parse(Carbon::parse($date)->addDay()->toDateString() . '00:00:00', config('settings.time_zone'))->setTimezone(config('app.time_zone')); | |
| $userid = Auth::user()->id; | |
| $holidayIds = HolidayHelper::getholidayList($user->id); | |
| $holiday = Holiday::where('date', $date)->whereIn('id', $holidayIds)->first(); | |
| $userWeeklyOff = UserWeeklyOff::where('user_id', $user->id) | |
| ->whereBetween('created_at', [$startDateForWeeklyOff, $endDateForWeeklyOff]) | |
| ->where('weekly_off', 1)->first(); | |
| foreach ($attendanceUserColl as $value) { | |
| if (isset($value->check_in)) { | |
| $value->check_in = Carbon::parse($value->check_in)->setTimezone(config('settings.time_zone'))->toDateString(); | |
| } | |
| if (isset($value->check_out)) { | |
| $value->check_out = Carbon::parse($value->check_out)->setTimezone(config('settings.time_zone'))->toDateString(); | |
| } | |
| } | |
| if (($attendanceUserColl->where('attendance_setting', '=', null)->where('check_in', $date)->isNotEmpty()) && ($attendanceUserColl->contains('check_in', $date))) { | |
| $plucked = $attendanceUserColl->where('check_in', '=', $date); | |
| $isLeave = $this->isLeave($plucked->pluck('id'), $date); | |
| if (($plucked->pluck('check_out')->first() != '')) { | |
| if (!empty($isLeave)) { | |
| if ($isLeave['leave_type'] == 'L') { | |
| $leave = $leave + 1; | |
| } else { | |
| $leave = $leave + 0.5; | |
| $present = $present + 0.5; | |
| } | |
| $empAttendanceArr->push($isLeave['leave_type']); | |
| } else { | |
| $empAttendanceArr->push('P'); | |
| $present = $present + 1; | |
| } | |
| } else { | |
| if ($currentDate > $date) { | |
| if (empty($userWeeklyOff) && empty($holiday)) { | |
| if (!empty($isLeave)) { | |
| if ($isLeave['leave_type'] == 'L') { | |
| $leave = $leave + 1; | |
| } else { | |
| $leave = $leave + 0.5; | |
| $present = $present + 0.5; | |
| } | |
| $empAttendanceArr->push($isLeave['leave_type']); | |
| } else { | |
| $empAttendanceArr->push('A'); | |
| $absent = $absent + 1; | |
| } | |
| } else { | |
| if (!empty($holiday)) { | |
| $empAttendanceArr->push('H'); | |
| $holidayCount = $holidayCount + 1; | |
| } else { | |
| $empAttendanceArr->push('W'); | |
| $weekend = $weekend + 1; | |
| } | |
| } | |
| } else { | |
| $empAttendanceArr->push(' '); | |
| } | |
| } | |
| } | |
| elseif (($attendanceUserColl->where('attendance_setting', '=', 3)->where('check_in', $date)->isNotEmpty()) && ($attendanceUserColl->contains('check_in', $date))) { | |
| $plucked = $attendanceUserColl->where('check_in', '=', $date); | |
| $isLeave = $this->isLeave($plucked->pluck('id'), $date); | |
| if (($plucked->pluck('check_out')->first() != '')) { | |
| if (!empty($isLeave)) { | |
| if ($isLeave['leave_type'] == 'L') { | |
| $leave = $leave + 1; | |
| } else { | |
| $leave = $leave + 0.5; | |
| $present = $present + 0.5; | |
| } | |
| $empAttendanceArr->push($isLeave['leave_type']); | |
| } else { | |
| $empAttendanceArr->push('P'); | |
| $present = $present + 1; | |
| } | |
| } else { | |
| if ($currentDate > $date) { | |
| if (empty($userWeeklyOff) && empty($holiday)) { | |
| if (!empty($isLeave)) { | |
| if ($isLeave['leave_type'] == 'L') { | |
| $leave = $leave + 1; | |
| } else { | |
| $leave = $leave + 0.5; | |
| $present = $present + 0.5; | |
| } | |
| $empAttendanceArr->push($isLeave['leave_type']); | |
| } else { | |
| $empAttendanceArr->push('A'); | |
| $absent = $absent + 1; | |
| } | |
| } else { | |
| if (!empty($holiday)) { | |
| $empAttendanceArr->push('H'); | |
| $holidayCount = $holidayCount + 1; | |
| } else { | |
| $empAttendanceArr->push('W'); | |
| $weekend = $weekend + 1; | |
| } | |
| } | |
| } else { | |
| $empAttendanceArr->push(' '); | |
| } | |
| } | |
| } | |
| elseif (($attendanceUserColl->where('attendance_setting', '=', 2)->where('check_in', $date)->isNotEmpty()) && ($attendanceUserColl->contains('check_in', $date))) { | |
| $plucked = $attendanceUserColl->where('check_in', '=', $date); | |
| $isLeave = $this->isLeave($plucked->pluck('id'), $date); | |
| if (($plucked->pluck('check_in')->first() != '') && ($plucked->pluck('check_out')->first() == '')) { | |
| if (!empty($isLeave)) { | |
| if ($isLeave['leave_type'] == 'L') { | |
| $leave = $leave + 1; | |
| } else { | |
| $leave = $leave + 0.5; | |
| $present = $present + 0.5; | |
| } | |
| $empAttendanceArr->push($isLeave['leave_type']); | |
| } else { | |
| $empAttendanceArr->push('P'); | |
| $present = $present + 1; | |
| } | |
| } else { | |
| if ($currentDate > $date) { | |
| if (empty($userWeeklyOff) && empty($holiday)) { | |
| if (!empty($isLeave)) { | |
| if ($isLeave['leave_type'] == 'L') { | |
| $leave = $leave + 1; | |
| } else { | |
| $leave = $leave + 0.5; | |
| $present = $present + 0.5; | |
| } | |
| $empAttendanceArr->push($isLeave['leave_type']); | |
| } else { | |
| $empAttendanceArr->push('A'); | |
| $absent = $absent + 1; | |
| } | |
| } else { | |
| if (!empty($holiday)) { | |
| $empAttendanceArr->push('H'); | |
| $holidayCount = $holidayCount + 1; | |
| } else { | |
| $empAttendanceArr->push('W'); | |
| $weekend = $weekend + 1; | |
| } | |
| } | |
| } else { | |
| $empAttendanceArr->push(' '); | |
| } | |
| } | |
| } | |
| elseif ($attendanceUserColl->where('attendance_setting', 1)->filter(function ($item) use ($date) { | |
| return Carbon::parse($item->created_at)->format('Y-m-d') === date('Y-m-d', strtotime($date)); | |
| })->isNotEmpty()) { | |
| if (!empty($holiday)) { | |
| $empAttendanceArr->push('H'); | |
| $holidayCount = $holidayCount + 1; | |
| } | |
| else if (!empty($userWeeklyOff)) { | |
| $empAttendanceArr->push('W'); | |
| $weekend = $weekend + 1; | |
| } | |
| else if (!empty($isLeave)) { | |
| if ($isLeave['leave_type'] == 'L') { | |
| $leave = $leave + 1; | |
| } else { | |
| $leave = $leave + 0.5; | |
| $present = $present + 0.5; | |
| } | |
| $empAttendanceArr->push($isLeave['leave_type']); | |
| } | |
| else { | |
| $empAttendanceArr->push('P'); | |
| $present = $present + 1; | |
| } | |
| } | |
| else { | |
| if ($currentDate > $date) { | |
| $isLeave = $this->isLeave($attendanceUserColl->pluck('id')->first(), $date); | |
| if (empty($userWeeklyOff) && empty($holiday)) { | |
| if (!empty($isLeave)) { | |
| if ($isLeave['leave_type'] == 'L') { | |
| $leave = $leave + 1; | |
| } else { | |
| $leave = $leave + 0.5; | |
| $present = $present + 0.5; | |
| } | |
| $empAttendanceArr->push($isLeave['leave_type']); | |
| } else { | |
| $empAttendanceArr->push('A'); | |
| $absent = $absent + 1; | |
| } | |
| } else { | |
| if (!empty($holiday)) { | |
| $empAttendanceArr->push('H'); | |
| $holidayCount = $holidayCount + 1; | |
| } else { | |
| $empAttendanceArr->push('W'); | |
| $weekend = $weekend + 1; | |
| } | |
| } | |
| } else { | |
| $empAttendanceArr->push(' '); | |
| } | |
| } | |
| } | |
| $totalPayDays = $present + $weekend + $holidayCount + $leave; | |
| $empAttendanceArr->push($present); | |
| $empAttendanceArr->push($absent); //Absent | |
| $empAttendanceArr->push($leave); //Leave | |
| $empAttendanceArr->push($weekend); //Weekend | |
| $empAttendanceArr->push($holidayCount); //Holiday | |
| $empAttendanceArr->push($total); //total | |
| $empAttendanceArr->push($totalPayDays); //total | |
| $empAttendanceArr->push(''); //Signature | |
| $dataArr->push($empAttendanceArr); | |
| $count = 0; | |
| $present = 0; | |
| $leave = 0; | |
| $absent = 0; | |
| $weekend = 0; | |
| $total = 0; | |
| $holidayCount = 0; | |
| $totalPayDays = 0; | |
| $empAttendanceArr = collect([]); | |
| } | |
| } | |
| $teams = Team::all(); | |
| $columnHeaders = $columnHeaderDisp; | |
| $startDate = Carbon::parse($startDate)->format(Config('settings.php_date_format')); | |
| $endDate = Carbon::parse($endDate)->format(Config('settings.php_date_format')); | |
| return view('Reports.ReportTable', compact('columnHeaders', 'dataArr', 'teams', 'startDate', 'endDate')); | |
| } | |
| public function makeColumnHeaders($startDate, $endDate) | |
| { | |
| $period = CarbonPeriod::create($startDate, $endDate); | |
| $columnHeaderArr = collect([]); | |
| $columnHeaderArr->push('Emp Name'); | |
| $columnHeaderArrDisp = collect([]); | |
| $columnHeaderArrDisp->push('Emp Name'); | |
| //Iterate over the period | |
| foreach ($period as $date) { | |
| $date = Carbon::parse($date); | |
| $columnHeaderArr->push($date->format('Y-m-d')); | |
| $columnHeaderArrDisp->push($date->format('d D')); | |
| } | |
| $columnHeaderArrDisp->push('P'); | |
| $columnHeaderArrDisp->push('A'); | |
| $columnHeaderArrDisp->push('L'); | |
| $columnHeaderArrDisp->push('W'); | |
| $columnHeaderArrDisp->push('H'); | |
| $columnHeaderArrDisp->push('T'); | |
| $columnHeaderArrDisp->push('Pay'); | |
| $columnHeaderArrDisp->push('Signature'); | |
| $columnList = collect([]); | |
| $columnList->push($columnHeaderArr); | |
| $columnList->push($columnHeaderArrDisp); | |
| return $columnList; | |
| } | |
| public function isLeave($user_id, $date) | |
| { | |
| $userOnLeave = ApplyLeave::where('user_id', [$user_id]) | |
| ->where('from_date', '<=', $date) | |
| ->where('to_date', '>=', $date) | |
| ->where('status', 'Approve') | |
| ->first(); | |
| $leave_details = []; | |
| if (!empty($userOnLeave)) { | |
| if ($userOnLeave->leave_type == 'full_day') { | |
| $type = 'L'; | |
| } else { | |
| if ($userOnLeave->half_day_type == 'first_half') { | |
| $type = 'L-FN'; | |
| } else { | |
| $type = 'L-AN'; | |
| } | |
| } | |
| $leave_details['leave_type'] = $type; | |
| if (strstr($userOnLeave->reason , 'System : Leave length reduced due to approving attendance)')){ | |
| $resaonHasSystemText = 'yes'; | |
| }else{ | |
| $resaonHasSystemText = 'no'; | |
| } | |
| $leave_details['resaonHasSystemText'] = $resaonHasSystemText; | |
| } | |
| return $leave_details; | |
| } | |
| } |