get()) : collect(); $jalalian_object = Jalalian::now(); $first_day_of_month = $jalalian_object->subDays($jalalian_object->getDay() - 1); $carbon_gregorian = $first_day_of_month->toCarbon(); $thismonth = $carbon_gregorian->format('Y-m-d 00:00:00'); $ids = json_decode(request()->cookie('seen_angizeh_ids', '[]'), true) ?: []; $s = ai::where('key', 'angizeh') ->when($ids, fn($q) => $q->whereNotIn('id', $ids)) ->orderByDesc('id') ->first() ?? ai::where('key', 'angizeh')->orderByDesc('id')->first(); $ids = array_merge($ids, [$s->id]); Cookie::queue('seen_angizeh_ids', json_encode($ids), 14400); //total time $now = Jalalian::fromCarbon(Carbon::now()); $tsec = 0; //dd(->user_profile); if (isset($_COOKIE['token01'])) { $a = json_decode($_COOKIE['token01']); $user = User::where('user_name', $a->user_profile)->with('attendances')->first(); } else { $user = isset($_COOKIE['user_identity']) ? User::where('user_name', $_COOKIE['user_identity'])->with('attendances')->first() : null; } //dd($user); if (!empty($user->attendances)) { foreach ($user->attendances as $att) { $date = $att->entered_at != null ? \App\Support\JalaliHelper::fromDateTime($att->entered_at) : null; $att->date = $date != null ? $date->format('Y/m/d') : null; if ($att->duration != null && $date != null && $now->getMonth() == $date->getMonth()) { [$h, $m, $sec] = explode(':', $att->duration); $tsec += $h * 3600 + $m * 60 + $sec; } } } $hours = floor($tsec / 3600); $minutes = floor(($tsec % 3600) / 60); $totalTime = sprintf('%02d:%02d', $hours, $minutes); $formaction = (isset($_COOKIE['ad']) && $_COOKIE['ad'] == 1) ? 'admin/' : 'attendance/'; $now = Carbon::now()->format('Y-m-d 00:00:00'); $existed = $Attendance->whereNull('exited_at')->where('entered_at', '>=', $now)->first(); //$requested = $Attendance->whereNull('exited_at')->where('requested', 'true')->first(); //$forgot = $Attendance->whereNull('exited_at')->where('entered_at', '<', $now)->isNotEmpty(); //$today = $Attendance->whereNull('exited_at')->where('entered_at', '>=', $now)->isNotEmpty(); //dd($existed); if (isset($_COOKIE['token-0'])) { $hash = md5(strtolower(trim($user->email))); $gravatarUrl = "https://www.gravatar.com/avatar/$hash?s=200&d=identicon"; } if (!empty($user->tasks)) { $backlog = << SVG; $todo = << SVG; $error = << SVG; $in_progress = << SVG; $done = << SVG; $cancelled = << SVG; $state = [ "c73c2044-ea14-42cb-b08d-cecf3d1fdfb5" => "$in_progress",// in progress "a9ce312f-cfca-491e-8e3d-1975aa6ebc10" => "$todo",//to do "dea1fb57-a281-4fe7-8f3e-ee5567637e35" => "$error",// error "770fbe42-99f6-41db-9b9e-773d9cced1a5" => "$backlog",//backlog "b0e464e1-34eb-41ea-b2f7-3ef7483bc9f0" => "$done",//done "d61d14a3-72f7-4f44-894b-efe8b2a75be1" => "$cancelled",//canceled ]; $state_order = [ "c73c2044-ea14-42cb-b08d-cecf3d1fdfb5", "a9ce312f-cfca-491e-8e3d-1975aa6ebc10", "dea1fb57-a281-4fe7-8f3e-ee5567637e35", "770fbe42-99f6-41db-9b9e-773d9cced1a5", "b0e464e1-34eb-41ea-b2f7-3ef7483bc9f0", "d61d14a3-72f7-4f44-894b-efe8b2a75be1", ]; $user->tasks = $user->tasks->sortBy(function ($task) use ($state_order) { return array_search($task->state, $state_order); }); $tasks_with_started = $user->tasks->filter(function ($task) { return $task->pivot && $task->pivot->started_at != null; }); } //dd($tasks_with_started); //dd($user->tasks); //dd($user->tasks->where('started_at', !null)); ?> @extends('app') @section('content')
| نام | @endif {{-- {{dd($user)}}--}}تاریخ | ورود | خروج | {{----}} {{-- استراحت--}} {{-- | --}}جمع |
|---|---|---|---|---|---|
| {{$item->user_identity}} | @endif{{ \App\Support\JalaliHelper::format($item->entered_at, 'm/d') }} | {{ $item->entered_at ? Carbon::parse($item->entered_at)->format('H:i') : '-' }} | {{ $item->exited_at ? Carbon::parse($item->exited_at)->format('H:i') : '-' }} | {{----}} {{-- میزان استراحت--}} {{-- | --}}{{ $item->entered_at && $item->exited_at ? Carbon::parse($item->duration)->format('H:i') : '-' }} |