Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 291 |
| MyteamController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
5550 | |
0.00% |
0 / 291 |
| index | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 6 |
|||
| userlistdataa | |
0.00% |
0 / 1 |
5402 | |
0.00% |
0 / 285 |
|||
| <?php | |
| namespace App\Http\Controllers\Myteam; | |
| use Illuminate\Http\Request; | |
| use App\Http\Controllers\Controller; | |
| use App\Models\Admin\attendanceRequest; | |
| use App\Models\Auth\User; | |
| use App\Models\Admin\UserDetail; | |
| use App\Models\Admin\Department; | |
| use App\Models\Admin\Organisation; | |
| use App\Models\Admin\Team; | |
| use App\Models\Admin\Shift; | |
| use App\Models\Admin\UserAddress; | |
| use App\Models\Admin\UserBankDetail; | |
| use App\Models\Admin\UserDocumentDetail; | |
| use Spatie\Permission\Models\Role; | |
| use Illuminate\Support\Facades\Hash; | |
| use Illuminate\Support\Facades\Validator; | |
| use Illuminate\Support\Facades\Storage; | |
| use Intervention\Image\Facades\Image; | |
| use Session; | |
| use Illuminate\Support\Facades\Crypt; | |
| use App\Notifications\AppNotifications; | |
| use Illuminate\Support\Facades\Auth; | |
| use DB; | |
| use Carbon\Carbon; | |
| use App\Models\Leave\LeaveEntitlement; | |
| use App\Helpers\GetShiftDetailHelper; | |
| use App\Helpers\AttendanceHelper; | |
| use App\Models\Admin\UserDetailUser; | |
| use App\Models\Admin\UserDetailTeam; | |
| use App\Models\Auth\UserShift; | |
| use App\Models\Admin\UserDetailShift; | |
| use App\Models\Leave\ApplyLeave; | |
| use App\Models\Auth\UserWeeklyOff; | |
| use App\Models\Admin\Holiday; | |
| use App\Models\Dashboard\AttendanceDetail; | |
| use App\Models\AttendanceRequests\UserAttendanceRequests; | |
| use DateTime; | |
| class MyteamController extends Controller | |
| { | |
| /** | |
| * Display a listing of the resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function index(Request $request) | |
| { | |
| // dd(); | |
| $title = '/Manage/My Team'; | |
| $backurl = route('home'); | |
| /*$users = User::all();*/ | |
| // For Attendance Marking | |
| $val = AttendanceHelper::getAttendanceMarkValue(); | |
| $valTeam = AttendanceHelper::getAttendanceTeam($request); | |
| $valUser = AttendanceHelper::getAttendanceUser($request); | |
| return view('Myteam.Myteamtable', compact('title', 'backurl', 'val', 'valTeam', 'valUser')); | |
| } | |
| public function userlistdataa(Request $request) | |
| { | |
| //dd("inside "); | |
| $column_key = array("1" => "user_details.employee_id", "2" => "name", "3" => "", "4" => "", "5" => "", "6" => ""); | |
| $where_condition = "1 = 1"; | |
| $order_key = $request->input('order')[0]['column']; | |
| $order = $column_key[$order_key]; | |
| $dir = $request->input('order')[0]['dir']; | |
| if (trim($dir) == '') { | |
| $dir = 'desc'; | |
| } | |
| if ($order != '') { | |
| $orderBy = " ORDER BY " . $order . " " . $dir; | |
| } | |
| if (null !== ($request->input('search.value')) && trim($request->input('search.value')) != '') { | |
| $search = trim($request->input('search.value')); | |
| $ser_array = explode(" ",$search); | |
| if(count($ser_array) >=2){ | |
| $where_condition .= " AND ((name Like '$ser_array[0]%') AND (lastName Like '%$ser_array[1]%') )"; | |
| }else{ | |
| $where_condition .= " AND ((name Like '$ser_array[0]%') OR (employee_id LIKE '$ser_array[0]%'))"; | |
| } | |
| } | |
| $teamUsers = GetShiftDetailHelper::getMyReportingEmployeesIds(); | |
| $where_condition .= ' and users.id in (' . implode(',', $teamUsers) . ')'; | |
| $count_model = User::join('user_details', 'users.id', '=', 'user_details.user_id')->whereRaw($where_condition)->count(); | |
| $total_app_count = $count_model; | |
| $totalFiltered = $count_model; | |
| $data_model = User::join('user_details', 'users.id', '=', 'user_details.user_id')->whereRaw($where_condition) | |
| ->orderBy($order, $dir) | |
| ->offset(intval($request->input('start')))->limit(intval($request->input('length'))) | |
| ->get(); | |
| $data = array(); | |
| //for reporting_to column | |
| $userdetails = UserDetail::select('id', 'user_id', 'primary_reporting_manager_id')->get(); | |
| $matchingUserIds = []; | |
| foreach ($userdetails as $userdetail) { | |
| $id = $userdetail->id; | |
| $userid = $userdetail->user_id; | |
| $primary_reporting_manager_id = $userdetail->primary_reporting_manager_id; | |
| $matchingUserIds[$userid] = UserDetailUser::where('user_detail_id', $id) | |
| ->pluck('user_id') | |
| ->toArray(); | |
| if (isset($matchingUserIds[$userid])) { | |
| $matchingUserIds[$userid] = User::whereIn('id', $matchingUserIds[$userid]) | |
| ->pluck('name', 'id') | |
| ->toArray(); | |
| //dd($matchingUserIds); | |
| if (isset($matchingUserIds[$userid][$primary_reporting_manager_id])) { | |
| $matchingValue = $matchingUserIds[$userid][$primary_reporting_manager_id]; | |
| unset($matchingUserIds[$userid][$primary_reporting_manager_id]); | |
| $matchingUserIds[$userid] = [$primary_reporting_manager_id => $matchingValue] + $matchingUserIds[$userid]; | |
| } | |
| } | |
| // dd($matchingUserIds); | |
| } | |
| //dd($matchingValue); | |
| //for team | |
| $matchingUserIdss = []; | |
| foreach ($userdetails as $userdetail) { | |
| $id = $userdetail->id; | |
| $userid = $userdetail->user_id; | |
| //dd($userid); | |
| $matchingUserIdss[$userid] = UserDetailTeam::where('user_detail_id', $id) | |
| ->pluck('team_id') | |
| ->toArray(); | |
| if (isset($matchingUserIdss[$userid])) { | |
| $matchingUserIdss[$userid] = Team::whereIn('id', $matchingUserIdss[$userid]) | |
| ->pluck('team') | |
| ->toArray(); | |
| } | |
| } | |
| // for shift timing | |
| $usershift = []; | |
| foreach ($userdetails as $userShift) { | |
| $id = $userShift->id; | |
| $userId = $userShift->user_id; | |
| $userweeklyoff = UserWeeklyOff::where('user_id',$userId)->latest()->first(); | |
| if ($userweeklyoff !== null && $userweeklyoff->has_schedule == 1) { | |
| $currentDate = Carbon::now()->toDateString(); | |
| $shiftIds = UserShift::where('user_id', $userId) | |
| ->whereDate('date', $currentDate) | |
| ->pluck('shift_id') | |
| ->toArray(); | |
| } | |
| else { | |
| $shiftIds = userDetailShift::where('user_detail_id', $id) | |
| ->pluck('shift_id') | |
| ->toArray(); | |
| } | |
| $usershift[$userId] = []; | |
| foreach ($shiftIds as $shiftId) { | |
| $matchingUserShift = Shift::find($shiftId); | |
| if ($matchingUserShift) { | |
| $customTimeZone = config('settings.time_zone'); | |
| $utcStartTime = Carbon::parse($matchingUserShift->start_time, 'UTC'); | |
| $customStartTime = $utcStartTime->setTimezone($customTimeZone); | |
| $formattedCustomStartTime = $customStartTime->format('h:i A'); | |
| $utcEndTime = Carbon::parse($matchingUserShift->end_time, 'UTC'); | |
| $customEndTime = $utcEndTime->setTimezone($customTimeZone); | |
| $formattedCustomEndTime = $customEndTime->format('h:i A'); | |
| $usershift[$userId] = [ | |
| 'start_time' => $formattedCustomStartTime, | |
| 'end_time' => $formattedCustomEndTime | |
| ]; | |
| } | |
| } | |
| } | |
| //for upcoming leaves | |
| $upcomingleaves = []; | |
| foreach ($userdetails as $userdetail) { | |
| $id = $userdetail->id; | |
| $userid = $userdetail->user_id; | |
| //dd($userid); | |
| $upcomingleaves[$userid] = ApplyLeave::where('user_id', $userid) | |
| ->whereDate('to_date', '>=', now()->toDateString()) | |
| ->get(['from_date', 'to_date']) | |
| ->map(function ($leave) { | |
| return [ | |
| 'from_date' => date(config('settings.php_date_format'), strtotime($leave['from_date'])), | |
| 'to_date' => date(config('settings.php_date_format'), strtotime($leave['to_date'])), | |
| ]; | |
| }) | |
| ->toArray(); | |
| } | |
| // dd($upcomingleaves); | |
| //weekly attendance | |
| $weeklyattendance = []; | |
| foreach ($userdetails as $userdetail) { | |
| $id = $userdetail->id; | |
| $userid = $userdetail->user_id; | |
| $startDate = Carbon::parse(Carbon::now(config('settings.time_zone'))->subDay(5)->toDateString() . '00:00:00', config('settings.time_zone'))->setTimezone(config('app.time_zone')); | |
| // dd($startDate); | |
| //$endDate = Carbon::parse(Carbon::now(config('settings.time_zone'))->toDateString() . '00:00:00', config('settings.time_zone'))->setTimezone(config('app.time_zone')); | |
| $endDate = Carbon::now(config('settings.time_zone'))->endOfDay(); | |
| $checkOutDate = array(); | |
| $markValue = AttendanceDetail::where('user_id', $userid) | |
| ->value('attendance_setting'); | |
| // dd(Auth::user()->id); | |
| // dd($markValue); | |
| $Checkindata = AttendanceDetail::where('user_id', $userid) | |
| ->where('attendance_setting', 1) | |
| ->get(); | |
| if ($Checkindata->isNotEmpty()) { | |
| $NocheckInDates[$userid]['date'] = $Checkindata->map(function ($attendanceDetail) { | |
| return Carbon::parse($attendanceDetail->created_at)->format('d-m-Y'); | |
| })->toArray(); | |
| } else { | |
| $NocheckInDates[$userid]['date'] = ['0-0-0']; | |
| } | |
| $ocheckindata = AttendanceDetail::where('user_id', $userid) | |
| ->where('attendance_setting', 2) | |
| ->get(); | |
| if ($ocheckindata->isNotEmpty()) { | |
| $OnlycheckInDates[$userid]['date'] = $ocheckindata->map(function ($attendanceDetail) { | |
| $checkIn = Carbon::parse($attendanceDetail->check_in)->timezone('Asia/Kolkata'); | |
| return $checkIn->format('d-m-Y'); | |
| })->toArray(); | |
| } else { | |
| $OnlycheckInDates[$userid]['date'] = ['0-0-0']; | |
| } | |
| //to get the Date of the checkin for calendar | |
| $sevenDays = AttendanceDetail::where('user_id', $userid) | |
| ->select('check_in') | |
| ->whereNotNull('check_out') | |
| ->whereBetween('check_in', [$startDate, $endDate]) | |
| ->get(); | |
| $usercheckoutdate = $sevenDays->map(function ($attendanceDetail) { | |
| $checkIn = Carbon::parse($attendanceDetail->check_in)->timezone('Asia/Kolkata'); | |
| return $checkIn->format('d-m-Y'); | |
| })->toArray(); | |
| $checkout_datess[$userid]['date'] = $usercheckoutdate; | |
| //to get the leave values | |
| $leave_dates = ApplyLeave::where('user_id', '=', $userid) | |
| ->select('from_date', 'to_date') | |
| ->where('status', '=', 'Approve') | |
| ->get(); | |
| $leaveDatess[$userid] = [ | |
| 'date' => [] | |
| ]; | |
| foreach ($leave_dates as $leave) { | |
| $fromDate = Carbon::parse($leave->from_date); | |
| $toDate = Carbon::parse($leave->to_date); | |
| while ($fromDate->lte($toDate)) { | |
| $leaveDatess[$userid]['date'][] = $fromDate->format('d-m-Y'); | |
| $fromDate->addDay(); | |
| } | |
| } | |
| $holidays = Holiday::all('date'); | |
| //$holidayDates = array(); | |
| $useridHolidayDates[$userid]['date'] = []; | |
| foreach ($holidays as $holiday) { | |
| $holidayDate = Carbon::parse($holiday->date)->format('d-m-Y'); | |
| // $holidayDates[] = $holidayDate; | |
| $holidayDates = []; | |
| $holidayDates[] = $holidayDate; | |
| $useridHolidayDates[$userid]['date'][] = $holidayDate; | |
| } | |
| //to get the approve attendance records | |
| $attendance_approved_dates = UserAttendanceRequests::where('user_id', $userid) | |
| ->whereBetween('check_in', [$startDate, $endDate]) | |
| ->where('status', 'approved') | |
| ->where('requested_for', '<>', 'Late Checkin') | |
| ->get(); | |
| $userapprovedate = $attendance_approved_dates->map(function ($attendanceRequest) { | |
| return Carbon::parse($attendanceRequest->check_in)->format('d-m-Y'); | |
| })->toArray(); | |
| $approved_datess[$userid]['date'] = $userapprovedate; | |
| // to get the weekly off dates | |
| $startingDate = Carbon::parse(Carbon::now(config('settings.time_zone'))->subDay(5)->toDateString() . '00:00:00', config('settings.time_zone'))->setTimezone(config('app.time_zone')); | |
| $endingDate = Carbon::parse(Carbon::now(config('settings.time_zone'))->toDateString() . '00:00:00', config('settings.time_zone'))->setTimezone(config('app.time_zone')); | |
| $userWeeklyOff = UserWeeklyOff::where('user_id', $userid) | |
| ->whereBetween('created_at', [$startingDate, $endingDate]) | |
| ->where('weekly_off', 1) | |
| ->get(); | |
| $userweeklydat = $userWeeklyOff->map(function ($weeklyOff) { | |
| return Carbon::parse($weeklyOff->date)->format('d-m-Y'); | |
| })->toArray(); | |
| $weeklyOff_datess[$userid]['date'] = $userweeklydat; | |
| // print_r($weeklyOff_datess); | |
| if (auth()->user()->can('Super Admin')) { | |
| $type = 'admin'; | |
| $checkOutDate = '0-0-0'; | |
| $leaveDates = '0-0-0'; | |
| $approved_dates = '0-0-0'; | |
| $holidayDates = '0-0-0'; | |
| $weeklyOff_dates = '0-0-0'; | |
| $NocheckInDate = '0-0-0'; | |
| $OnlycheckInDate = '0-0-0'; | |
| } | |
| $currentDate = Carbon::now(config('settings.time_zone'))->toDateString(); | |
| $requests = UserAttendanceRequests::select(DB::raw('DATE(check_in) as check_in_date')) | |
| ->where('user_id', '=', $userid) | |
| ->where(DB::raw('DATE(check_in)'), '=', $currentDate) | |
| ->where('requested_for', '=', 'Late Checkin') | |
| ->where('status', '=', 'pending') | |
| ->first(); | |
| if (empty($requests)) { | |
| $requests = "1"; | |
| } | |
| } | |
| if (count($data_model) > 0) { | |
| foreach ($data_model as $database_model) { | |
| if ($database_model->profile_pic) { | |
| $user_image = url('storage/' . $database_model->profile_pic); | |
| } else { | |
| if ($database_model->gender == 'Male') { | |
| $user_image = url("global_assets/images/favicon_io/default-avatar-boy.png"); | |
| } else { | |
| $user_image = url("global_assets/images/favicon_io/default-avatar-girl.jpg"); | |
| } | |
| } | |
| $show_image_container = '<span style="width: 110px;"><div class="img-screen"><img class="rounded-circle" src="' . $user_image . '" alt="No Image" style="width:50px;height:50px;overflow:hidden;"></div></span>'; | |
| // $view_route = route('My-team.show',$database_model->user_id); | |
| $nestedData['name'] = $show_image_container . '' . $database_model->name . ' ' . $database_model->lastName; | |
| $userDetail = UserDetail::where('user_id', '=', $database_model->user_id)->first(); | |
| // $teams = Team::select('team')->leftJoin('team_user_detail','teams.id','=','team_user_detail.team_id')->where('team_user_detail.user_detail_id','=',$userDetailId->id)->first(); | |
| // //get user detail | |
| // //primary team id | |
| $teamId = $userDetail->primary_team_id; | |
| $nestedData['team'] = '-'; | |
| // if(isset($teams) && !empty($teams)) | |
| if ($teamId != 0) { | |
| //primary team name | |
| if (isset($matchingUserIdss[$database_model->user_id])) { | |
| $namess = $matchingUserIdss[$database_model->user_id]; | |
| $userInTeam = $userDetail->primaryTeamName->team; | |
| $teamMembers = implode('/ ', $namess); | |
| $tooltipText = $userInTeam; | |
| $firstName = ''; | |
| if (!empty($teamMembers)) { | |
| $names = explode(' ', $teamMembers); | |
| $firstName = isset($names[0]) ? $names[0] : ''; | |
| $tooltipText .= '/ ' . $teamMembers; | |
| if (count($names) > 1) { | |
| $nestedData['team'] = '<div class="tooltips"><b>' . $userInTeam . '</b>/' . $firstName . '<b>..</b><span class="tooltiptext">' . $tooltipText . '</span></div>'; | |
| } else { | |
| $nestedData['team'] = '<div class="tooltips"><b>' . $userInTeam . '</b>/' . $firstName . '<span class="tooltiptext">' . $tooltipText . '</span></div>'; | |
| } | |
| } else { | |
| $nestedData['team'] = '<div class="tooltips">' . $userInTeam . '<span class="tooltiptext">' . $tooltipText . '</span></div>'; | |
| } | |
| } | |
| } | |
| if (isset($matchingUserIds[$database_model->user_id])) { | |
| $names = array_values($matchingUserIds[$database_model->user_id]); | |
| if (count($names) == 2) { | |
| $managerNames = '<b>' . $names[0] . '</b>/' . $names[1]; | |
| } elseif (count($names) > 2) { | |
| $limitedNames = array_slice($names, 0, 2); | |
| $managerNames = '<b>' . $limitedNames[0] . '</b>/' . $limitedNames[1] . '<b >/..</b>'; | |
| } elseif (count($names) == 1) { | |
| $managerNames = $names[0]; | |
| } else { | |
| $managerNames = ''; | |
| } | |
| $nestedData['manager'] = '<div class="tooltips">' . $managerNames . '<span class="tooltiptext">' . implode('/ ', $names) . '</span></div>'; | |
| } | |
| if (isset($usershift[$database_model->user_id])) { | |
| $shifttime = array_values($usershift[$database_model->user_id]); | |
| if (count($shifttime) >= 2) { | |
| $nestedData['shift'] = $shifttime[0] . '-' . $shifttime[1]; | |
| } else { | |
| $nestedData['shift'] = 'Weekly Off'; | |
| } | |
| } | |
| if (isset($upcomingleaves[$database_model->user_id])) { | |
| $upcomingLeaves = $upcomingleaves[$database_model->user_id]; | |
| //dd( array_values($upcomingLeaves[0])); | |
| if (!empty($upcomingLeaves)) { | |
| $innerArray = array_values($upcomingLeaves[0]); | |
| $nestedData['upcomingleaves'] = $innerArray[0] . ' / ' . $innerArray[1]; | |
| } else { | |
| $nestedData['upcomingleaves'] = '--'; | |
| } | |
| //dd( $innerArray ); | |
| } | |
| // print_r( $database_model->user_id); | |
| if ( | |
| isset($NocheckInDates[$database_model->user_id]) && | |
| isset($OnlycheckInDates[$database_model->user_id]) && | |
| isset($checkout_datess[$database_model->user_id]) && | |
| isset($leaveDatess[$database_model->user_id]) && | |
| isset($approved_datess[$database_model->user_id]) && | |
| isset($weeklyOff_datess[$database_model->user_id]) && | |
| isset($useridHolidayDates[$database_model->user_id]) | |
| ) { | |
| $NoCheckindates = array_values($NocheckInDates[$database_model->user_id]['date']); | |
| $OnlycheckInDate = array_values($OnlycheckInDates[$database_model->user_id]['date']); | |
| $dates = array_values($checkout_datess[$database_model->user_id]['date']); | |
| $leaveDates = array_values($leaveDatess[$database_model->user_id]['date']); | |
| $ApprovedDates = array_values($approved_datess[$database_model->user_id]['date']); | |
| $WeeklyOffDates = array_values($weeklyOff_datess[$database_model->user_id]['date']); | |
| $useridHolidayDate = $useridHolidayDates[$database_model->user_id]['date']; | |
| $nestedData['weekly'] = '<div class="table-responsive" id="calendar"> | |
| <table class="table text-nowrap"> | |
| <tr>'; | |
| // dd($dates) ; | |
| // Generate calendar HTML | |
| for ($i = 4; $i >= 0; $i--) { | |
| $day = new DateTime(); | |
| $day->modify("-$i day"); | |
| $dayName = $day->format('D'); | |
| $className = ''; | |
| // Check if dates match the current date | |
| // if (in_array($day->format('d-m-Y'), $dates)) { | |
| // $className = 'green'; | |
| // } elseif (in_array($day->format('d-m-Y'), $ApprovedDates)) { | |
| // $className = 'green'; | |
| // } elseif (in_array($day->format('d-m-Y'), $leaveDates)) { | |
| // $className = 'yellow'; | |
| // } elseif (in_array($day->format('d-m-Y'), $WeeklyOffDates)) { | |
| // $className = 'blue'; | |
| // } elseif ($day->format('d-m-Y') === date('d-m-Y') && !in_array($day->format('d-m-Y'), $dates)) { | |
| // $className = 'day-box'; | |
| // } | |
| // elseif (in_array($day->format('d-m-Y'), $NoCheckindates)) { | |
| // $className = 'green'; | |
| // } | |
| // else { | |
| // $className = 'red'; | |
| // } | |
| if(in_array($day->format('d-m-Y'), $NoCheckindates)){ | |
| if ($day->format('d-m-Y') === date('d-m-Y') && !in_array($day->format('d-m-Y'), $dates)) { | |
| $className = 'day-box'; | |
| } | |
| else if (in_array($day->format('d-m-Y'), $useridHolidayDate)) { | |
| $className = 'blue'; | |
| } | |
| else if (in_array($day->format('d-m-Y'), $WeeklyOffDates)) { | |
| $className = 'blue'; | |
| } | |
| else if (in_array($day->format('d-m-Y'), $leaveDates)) { | |
| $className = 'yellow'; | |
| } | |
| else if(in_array($day->format('d-m-Y'), $NoCheckindates)){ | |
| $className = 'green'; | |
| } | |
| }else{ | |
| if((in_array($day->format('d-m-Y'), $useridHolidayDate)) || (in_array($day->format('d-m-Y'), $WeeklyOffDates)) || (in_array($day->format('d-m-Y'), $leaveDates)) | |
| || (in_array($day->format('d-m-Y'), $OnlycheckInDate))|| ($day->format('d-m-Y') === date('d-m-Y') && !in_array($day->format('d-m-Y'), $dates)) || (in_array($day->format('d-m-Y'), $dates)) || | |
| (in_array($day->format('d-m-Y'), $ApprovedDates)) ){ | |
| if ($day->format('d-m-Y') === date('d-m-Y') && !in_array($day->format('d-m-Y'), $dates)) { | |
| $className = 'day-box'; | |
| } | |
| if (in_array($day->format('d-m-Y'), $useridHolidayDate)) { | |
| $className = 'blue'; | |
| } | |
| if (in_array($day->format('d-m-Y'), $WeeklyOffDates)) { | |
| $className = 'blue'; | |
| } | |
| if (in_array($day->format('d-m-Y'), $leaveDates)) { | |
| $className = 'yellow'; | |
| } | |
| if (in_array($day->format('d-m-Y'), $OnlycheckInDate)) { | |
| $className = 'green'; | |
| } | |
| if (in_array($day->format('d-m-Y'), $dates)) { | |
| $className = 'green'; | |
| } | |
| if (in_array($day->format('d-m-Y'), $ApprovedDates)) { | |
| $className = 'green'; | |
| } | |
| } | |
| else { | |
| $className = 'red'; | |
| } | |
| } | |
| $nestedData['weekly'] .= '<td><div class="day-box ' . $className . '"><div class="date-box">' . $day->format('d') . '</div><div class="day-name-box">' . $dayName . '</div></div></td>'; | |
| } | |
| $nestedData['weekly'] .= '</tr></table></div>'; | |
| // dd($nestedData); | |
| } | |
| // if (isset($NocheckInDates[$database_model->user_id])) { | |
| // $NoCheckin = array_values($NocheckInDates[$database_model->user_id]['date']); | |
| // } | |
| // if (isset($OnlycheckInDates[$database_model->user_id])) { | |
| // $OnlycheckInDate = array_values($OnlycheckInDates[$database_model->user_id]['date']); | |
| // } | |
| // if (isset($checkout_datess[$database_model->user_id])) { | |
| // $dates = array_values($checkout_datess[$database_model->user_id]['date']); | |
| // } | |
| // if (isset($leaveDatess[$database_model->user_id])) { | |
| // $leaveDates = array_values($leaveDatess[$database_model->user_id]['date']); | |
| // } | |
| // if (isset($approved_datess[$database_model->user_id])) { | |
| // $ApprovedDates = array_values($approved_datess[$database_model->user_id]['date']); | |
| // } | |
| // if (isset($weeklyOff_datess[$database_model->user_id])) { | |
| // $WeeklyOffDates = array_values($weeklyOff_datess[$database_model->user_id]['date']); | |
| // } | |
| // // Generate the calendar HTML | |
| // $calendarHTML = "<table><tr>"; | |
| // $formattedWeek=[]; | |
| // for ($i = 4; $i >= 0; $i--) { | |
| // $prevDay = new DateTime(); | |
| // $prevDay->modify("-$i day"); | |
| // $day = $prevDay; | |
| // $dayName = $day->format('D'); | |
| // $formattedDate = $day->format('d-m-Y'); | |
| // $className = ''; | |
| // $today = new DateTime(); | |
| // $formattedWeek[] = $formattedDate; | |
| // if (in_array($formattedDate, $ApprovedDates)) { | |
| // $className = 'green'; | |
| // } | |
| // // else if ($type == 'admin') { | |
| // // $className = 'day-box'; | |
| // // } | |
| // else if (in_array($formattedDate, $leaveDates)) { | |
| // $className = 'yellow'; | |
| // } | |
| // // else if (in_array($formattedDate, $holidayDates)) { | |
| // // $className = 'blue'; | |
| // // } | |
| // else if (in_array($formattedDate, $WeeklyOffDates)) { | |
| // $className = 'blue'; | |
| // } else if ($day->format('Y-m-d') === $today->format('Y-m-d')) { | |
| // if (in_array($formattedWeek[0], $WeeklyOffDates)) { | |
| // $className = 'blue'; | |
| // } else if (in_array($formattedWeek[0], $leaveDates)) { | |
| // $className = 'yellow'; | |
| // } else if (in_array($formattedWeek[0], $dates)) { | |
| // $className = 'green'; | |
| // } else if (in_array($formattedWeek[0], $NoCheckin)) { | |
| // $className = 'green'; | |
| // } else if (in_array($formattedWeek[0], $OnlycheckInDate)) { | |
| // $className = 'green'; | |
| // } else { | |
| // $className = 'day-box'; | |
| // } | |
| // } else if (in_array($formattedDate, $dates)) { | |
| // $className = 'green'; | |
| // } else if (in_array($formattedDate, $NoCheckin)) { | |
| // $className = 'green'; | |
| // } else if (in_array($formattedDate, $OnlycheckInDate)) { | |
| // $className = 'green'; | |
| // } else { | |
| // $className = 'red'; | |
| // } | |
| // switch ($className) { | |
| // case 'green': | |
| // $tooltip = 'Present'; | |
| // break; | |
| // case 'yellow': | |
| // $tooltip = 'On leave'; | |
| // break; | |
| // case 'blue': | |
| // $tooltip = 'Weekly off / Holiday'; | |
| // break; | |
| // case 'red': | |
| // $tooltip = 'Absent'; | |
| // break; | |
| // default: | |
| // $tooltip = ''; | |
| // } | |
| // $calendarHTML .= "<td><div class='day-box $className' id='day-box' title='$tooltip'><div class='date-box'>" . $day->format('d') . "</div><div class='day-name-box'>$dayName</div></div></td>"; | |
| // } | |
| // $calendarHTML .= "</tr></table>"; | |
| // $nestedData['weekly'] = '<div class="table-responsive" id="calendar">' . $calendarHTML . '</div>'; | |
| $data[] = $nestedData; | |
| } | |
| } | |
| $json_data = array( | |
| "draw" => intval($request->input('draw')), | |
| "recordsTotal" => intval($total_app_count), | |
| "recordsFiltered" => intval($total_app_count), | |
| "data" => $data, // total data array | |
| ); | |
| echo json_encode($json_data); | |
| exit; | |
| } | |
| // /** | |
| // * 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) | |
| // { | |
| // // $tab = 'user'; | |
| // // $title = '/Setup/Edit Users'; | |
| // // $user = User::find($id); | |
| // // $userPassword = $user->password; | |
| // // $userdetail = $user->userdetail; | |
| // // $user_addresses = $userdetail->userAddress; | |
| // // $user_bank_details = $userdetail->userBankdetail; | |
| // // $user_document_details = $userdetail->userDocumentdetail; | |
| // // //$departments = Department::all(); | |
| // // $departmentArr = $userdetail->departments; | |
| // // //$teams = Team::all(); | |
| // // $teamArr =$userdetail->teams; | |
| // // //$roles = Role::all(); | |
| // // // $roleArr = $userdetail->roles; | |
| // // //$shifts= Shift::all(); | |
| // // $selectShift = $userdetail->shifts; | |
| // // //$attendances = attendanceRequest::all(); | |
| // // $attendanceArr = $userdetail->attendanceRequests; | |
| // // //$organisations = Organisation::all(); | |
| // // $editUserdetail = true; | |
| // // $users = User::all(); | |
| // // $secondaryManagerArr = $userdetail->secondaryManager; | |
| // // //$employeeTeam = $user->userdetailWithTeam()->first() != null ? (count($user->userdetailWithTeam()->first()->teams) > 0 ? $user->userdetailWithTeam()->first()->teams[0]['team'] : ''): '-' ; | |
| // // $employeeTeam = !empty($user->userdetail->primaryTeamName->team) ? $user->userdetail->primaryTeamName->team : '-'; | |
| // // $leaves = DB::table('leaves')->get(); | |
| // // $leaveBalances = []; | |
| // // foreach ($leaves as $leave) { | |
| // // $leaveEntitlementQuery = array( | |
| // // 'user_id' => $user->id, | |
| // // 'year' => Carbon::now()->year, | |
| // // 'leave_id' => $leave->id | |
| // // ); | |
| // // $leaveEntitlementArr = LeaveEntitlement::where($leaveEntitlementQuery)->get(); | |
| // // $leaveBalance = null; | |
| // // foreach ($leaveEntitlementArr as $leaveEntitlement) { | |
| // // $leaveBalance = $leaveEntitlement->leave_balance; | |
| // // } | |
| // // if ($leaveBalance == null) { | |
| // // $leaveBalance = 0; | |
| // // } | |
| // // $leaveBalances[] = array( | |
| // // 'id' => $leave->id, | |
| // // 'name' => $leave->name, | |
| // // 'abbr' => $leave->abbr, | |
| // // 'leave_balance' => $leaveBalance | |
| // // ); | |
| // // // $leaveBalances[$leave->id] = $leaveBalance; | |
| // // } | |
| // // $employee_id = ''; | |
| // // if(config('settings.default_employee_id') == 'automatic') | |
| // // { | |
| // // $startId = config('settings.id_starts_from'); | |
| // // $prefix = config('settings.default_id'); | |
| // // for ($i=$startId; $employee_id == '' ; $i++) { | |
| // // if (UserDetail::where('employee_id', '=', $prefix.$i)->exists()) | |
| // // { | |
| // // } | |
| // // else | |
| // // { | |
| // // $employee_id = $prefix.$i; | |
| // // break; | |
| // // } | |
| // // } | |
| // // } | |
| // // $organisations = Organisation::where('id','=',$userdetail->organisation_id)->first(); | |
| // // $orgname = ''; | |
| // // if(!empty($organisations)){ | |
| // // $orgname = $organisations->organisation; | |
| // // } | |
| // // // $teamname = array(); | |
| // // // foreach($teamArr as $teamselect) | |
| // // // { | |
| // // // $team = Team::where('id','=',$teamselect->id)->first(); | |
| // // // array_push($teamname, $team->team); | |
| // // // } | |
| // // // $teamname = implode(',', $teamname); | |
| // // $teamname = ''; | |
| // // if(!empty($userdetail->primary_team_id)){ | |
| // // $teamname = $userdetail->primaryTeamName->team; | |
| // // } | |
| // // $rolename = ''; | |
| // // if(!empty($user->getRoleNames()->first())){ | |
| // // $rolename = $user->getRoleNames()->first(); | |
| // // } | |
| // // $shiftname = array(); | |
| // // foreach($selectShift as $shiftelect) | |
| // // { | |
| // // $shift = Shift::where('id','=',$shiftelect->id)->first(); | |
| // // array_push($shiftname, $shiftelect->shift); | |
| // // } | |
| // // $shiftname = implode(',', $shiftname); | |
| // // $attendancename = array(); | |
| // // foreach($attendanceArr as $sattendanceselect) | |
| // // { | |
| // // $attendance = attendanceRequest::where('id','=',$sattendanceselect->id)->first(); | |
| // // array_push($attendancename, $attendance->name); | |
| // // } | |
| // // $attendancename = implode(',', $attendancename); | |
| // // $reportingmanager = array(); | |
| // // $primaryManager = $userdetail->primary_reporting_manager_id; | |
| // // $primaryReportingManager = ''; | |
| // // if($primaryManager != 0 || $primaryManager != NULL){ | |
| // // $primaryReportingManager = $userdetail->primaryReportingManager->name.' '.$userdetail->primaryReportingManager->lastName; | |
| // // } | |
| // // foreach($secondaryManagerArr as $secondaryManager) | |
| // // { | |
| // // if($primaryManager != $secondaryManager->id){ | |
| // // $username = User::where('id','=',$secondaryManager->id)->first(); | |
| // // $name = $username->name.' '.$username->lastName; | |
| // // array_push($reportingmanager, $name); | |
| // // } | |
| // // } | |
| // // $reportingmanager = implode(',', $reportingmanager); | |
| // // // return $leaveBalances; | |
| // // return view('administrationForms.UserDetail.User.ViewUserDetail', compact('user','userdetail','user_addresses','user_bank_details','orgname','editUserdetail','shiftname','teamname','departmentArr','rolename','attendancename','reportingmanager','user_document_details','tab','leaveBalances','employee_id','employeeTeam','primaryReportingManager')); | |
| // } | |
| // /** | |
| // * 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) | |
| // { | |
| // } | |
| } |