@extends('layouts.app', ['title' => 'Zeiterfassung']) @section('content') {{-- newitem --}} {{-- edit Item --}} {{-- delete Item --}} {{-- main content --}} {{--

Anwesenheitsübersicht für Heute {{ Carbon\Carbon::now()->format('d.m.Y') }}

Anwesend heute: {{ $HrTimeRecordingToday->groupBy('fk_employee_id')->pluck(['fk_employee_id'])->count() }} / {{ $employees->count() }} Mitarbeiter

--}} @php $toDay = Carbon\Carbon::parse($ddate); // $ddate wird aus dem Controller übergeben $currentDate = Carbon\Carbon::parse($ddate); // $ddate wird aus dem Controller übergeben $prevDate = $currentDate->copy()->subDay()->format('Y-m-d'); $nextDate = $currentDate->copy()->addDay()->format('Y-m-d'); @endphp

Anwesenheitsübersicht für {{ $currentDate->format('d.m.Y') }}

Anwesend heute: {{ $HrTimeRecordingToday->groupBy('fk_employee_id')->count() }} / {{ $employees->count() }} Mitarbeiter


@if (session('msg'))

{{ session('msg') }}

@endif {{--
hi
--}}
{{-- --}}
{{--

Heute,den {{ Carbon\Carbon::now()->format('d.m.Y') }}

--}}
@if (Auth::user()->get_employee->is_hrm) @endif
@foreach ($employees as $item) @if ($HrTimeRecordingToday->where('fk_employee_id', $item->employee_id)->count()) {{-- {{ $item->employee_id }} --}} @if ($user_att->where('fk_employee_id', $item->employee_id)->where('work', '1')->where('status_open', '1')->count() > 0) @if ($user_att->where('fk_employee_id', $item->employee_id)->where('break', '1')->where('status_open', '1')->count() > 0) @else 🧑‍💻 @endif @else @endif {{ $item->first_name }} {{ $item->last_name }} @if ($user_att->where('fk_employee_id', $item->employee_id)->where('work', '1')->where('status_open', '1')->count() > 0) @if ($user_att->where('fk_employee_id', $item->employee_id)->where('break', '1')->where('status_open', '1')->count() > 0) {{-- --}} @else {{-- 🧑‍💻 --}} @endif @else 🚪 @endif @else {{ $item->first_name }} {{ $item->last_name }} @endif @endforeach

{{-- hier new --}} @php // Group employees by 'fk_emp_id' and get unique items $groupedEmployees = $HrTimeRecordingToday->pluck('fk_employee_id')->unique(); @endphp @foreach ($department->sortBy('code') as $item) @foreach ($item->get_employee as $iteme) {{-- --}} @if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->count()) {{-- Datum --}} {{-- beginn --}} {{-- Ende --}} {{-- Arbeitsschichten --}} {{-- Pausen --}} {{-- soll --}} {{-- ist --}} {{-- Notiz --}} @endif @endforeach {{-- @foreach ($item->get_employee as $iteme) @endforeach --}} @endforeach {{-- @foreach ($department as $item)
{{ $HrTimeRecordingToday->groupBy('fk_employee_id')->get(['fk_employee_id'])->whereIn('fk_employee_id', $item->get_employee->pluck('employee_id'))->count() }} / {{ $item->get_employee->count() }}

@foreach ($item->get_employee as $iteme) @if (!$HrTimeRecordingToday->groupBy('fk_employee_id')->get(['fk_employee_id'])->contains('fk_employee_id', $iteme->employee_id)) {{ $iteme->first_name }} {{ $iteme->last_name }} @else {{ $iteme->first_name }} {{ $iteme->last_name }} @endif @endforeach

@endforeach --}}
Mitarbeiter Beginn Ende Arbeitsschichten Pausen Soll Ist Nachtrag / Notiz
{{ $item->name }} {{-- {{ $groupedEmployees->whereIn('fk_employee_id', $item->get_employee->pluck('employee_id'))->count() }} / {{ $item->get_employee->count() }} --}}
{{ $iteme->first_name }} {{ $iteme->last_name }}
@if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->count()) @endif
{{ $iteme->first_name }} {{ $iteme->last_name }}
@if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->count()) {{-- {{ date('H:i',strtotime($HrTimeRecordingToday->where('work', '1')->first()->start_time)) }} --}} {{-- forjava --}} {{ Carbon\Carbon::parse($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->first()->start_time)->format('H:i') }} @endif @if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->where('status_open', '0')->count()) @if (is_null($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->last()->stop_time)) --- @else {{ Carbon\Carbon::parse($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->where('status_open', '0')->last()->stop_time)->format('H:i') }} @endif @else {{-- {{ $HrTimeRecordingToday->where('work', '1')->sortByDesc('id')->first()->stop_time }} --}} @endif @if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->sortByDesc('id')->first()) {{ $HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->sum('work') }} {{-- {{ Carbon\Carbon::parse($HrTimeRecordingToday->where('work', '1')->sum('work'))->format('H:i') }} --}} @endif @if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('break', '1')->sortByDesc('id')->first()) ({{ $HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('break', '1')->sum('break') }}) @endif @if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('break', '1')->sortByDesc('id')->first()) {{ \Carbon\CarbonInterval::seconds($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('break', '1')->sum('total_second'))->cascade()->format('%H:%I') }} @endif @if ($iteme->contract) @if ($iteme->contract->get_days[strtolower(now()->format('l'))]) {{ $iteme->contract->get_days[strtolower(now()->format('l'))] }} @endif @else -- @endif @if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->sortByDesc('id')->first()) @if ($iteme->contract) @php // Zeitangabe im Format "Stunden:Minuten" (hh:mm) $time = \Carbon\CarbonInterval::seconds( $HrTimeRecordingToday ->where('fk_employee_id', $iteme->employee_id) ->where('work', '1') ->sum('total_second') - $HrTimeRecordingToday ->where('fk_employee_id', $iteme->employee_id) ->where('break', '1') ->sum('total_second'), ) ->cascade() ->format('%H:%I'); // Aufteilen von Stunden und Minuten [$hours, $minutes] = explode(':', $time); // Umrechnen in Stunden (Fließkommazahl) $timeInHours = (float) $hours + $minutes / 60; // Fließkommazahl von Stunden zum Vergleich $floatHours = $iteme->contract->get_days[strtolower(now()->format('l'))]; // Beispiel: 8 Stunden und 30 Minuten als Fließkommazahl @endphp @php // Calculate total work time in seconds $totalWorkTimeInSeconds = $HrTimeRecordingToday ->where('fk_employee_id', $iteme->employee_id) ->where('work', '1') ->where('status_open', '0') ->sum('total_second'); // Calculate total pause time in seconds $totalPauseTimeInSeconds = $HrTimeRecordingToday ->where('fk_employee_id', $iteme->employee_id) ->where('break', '1') ->where('status_open', '0') ->sum('total_second'); // Compute the difference $netTimeInSeconds = $totalWorkTimeInSeconds - $totalPauseTimeInSeconds; // Determine if the time is negative $isNegative = $netTimeInSeconds < 0; // Convert the absolute value of the net time to a CarbonInterval $interval = \Carbon\CarbonInterval::seconds(abs($netTimeInSeconds)); // Format the interval $formattedTime = $interval->cascade()->format('%H:%I'); // Add a negative sign if the time is negative if ($isNegative) { $formattedTime = '-' . $formattedTime; } @endphp @if ($timeInHours < $floatHours) {{-- {{ \Carbon\CarbonInterval::seconds($HrTimeRecordingToday->where('work', '1')->sum('total_second') - $HrTimeRecordingToday->where('break', '1')->sum('total_second'))->cascade()->format('%H:%I') }} --}} {{ $formattedTime }} @else {{ $formattedTime }} @endif @endif @endif @if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('is_updated', '1')->count()) Ja / @endif {{-- @if ($Vacation_all->where('fk_employee_id', $iteme->employee_id)->where('is_accepted', '1')->count()) Urlaub @endif @if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->count()) @if ($Vacation_all->where('fk_employee_id', $iteme->employee_id)->where('is_accepted', '1')->count()) & @endif {{ $HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->first()->get_work_loction->name }} @endif --}} @php $start = Carbon\Carbon::today(); @endphp @if ($start->isoFormat('dd') != 'Sa' && $start->isoFormat('dd') != 'So') @php $isVacation = $Vacation_all ->where('fk_employee_id', $iteme->employee_id) ->where('is_accepted', '1') ->where('date_from', '<=', $start->toDateString()) ->where('date_to', '>=', $start->toDateString()) ->count(); $isSick = $sicks ->where('fk_employee_id', $iteme->employee_id) ->where('date_from', '<=', $start->toDateString()) ->where('date_to', '>=', $start->toDateString()) ->count(); $isHoliday = $holidays->where('date', $start->toDateString())->count(); $workTime = $HrTimeRecordingToday ->where('fk_employee_id', $iteme->employee_id) ->where('start_date', $start->toDateString()) ->where('work', '1') ->first(); @endphp @if ($isHoliday) Feiertag - {{ $holidays->where('date', $start->toDateString())->first()->fname }} @if ($workTime) & {{ $workTime->get_work_loction->name }} @endif @elseif ($isVacation) Urlaub @if ($workTime) & {{ $workTime->get_work_loction->name }} @endif @elseif ($isSick) Krank @if ($workTime) & {{ $workTime->get_work_loction->name }} @endif @else @if ($workTime) {{-- {{ Carbon\Carbon::parse($workTime->start_time)->format('H:i') }} - {{ Carbon\Carbon::parse($workTime->end_time)->format('H:i') }} --}} @if ($workTime->get_work_loction) {{ $workTime->get_work_loction->name }} @endif @else - @endif @endif @else - @endif @if ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1')->where('fk_costcenter_id', '!=', '')->count() > 0)
@foreach ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1') as $item) @endforeach
@if ($item->stop_time) {{ Carbon\Carbon::parse($item->total_time)->format('H:i') }} @else @endif @if ($item->project_title) {{ $item->project_title }} @else * - {{ $item->note }} @endif
@endif
Arbeitzeiten
@if (Auth::user()->get_employee->is_hrm) @endif @foreach ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('work', '1') as $itemT) @if (Auth::user()->get_employee->is_hrm) @endif @endforeach
Beginn Ende Ist ArbeitsortAktionNachtrag
{{ Carbon\Carbon::parse($itemT->start_time)->format('H:i') }} @if ($itemT->stop_time) {{ Carbon\Carbon::parse($itemT->stop_time)->format('H:i') }} @endif @if ($itemT->stop_time) {{ Carbon\Carbon::parse($itemT->total_time)->format('H:i') }} @endif @if ($itemT->fk_work_location_id) {{ $itemT->get_work_loction->name }} @endif

@if ($itemT->is_updated) Ja - {{ $itemT->last_updated_reason }} @else - @endif

Pausen
@if (Auth::user()->get_employee->is_hrm) @endif @foreach ($HrTimeRecordingToday->where('fk_employee_id', $iteme->employee_id)->where('break', '1') as $itemT) @if (Auth::user()->get_employee->is_hrm) @endif @endforeach
Beginn Ende Ist ArbeitsortAktionNachtrag
{{ Carbon\Carbon::parse($itemT->start_time)->format('H:i') }} @if ($itemT->stop_time) {{ Carbon\Carbon::parse($itemT->stop_time)->format('H:i') }} @endif @if ($itemT->stop_time) {{ Carbon\Carbon::parse($itemT->total_time)->format('H:i') }} @endif @if ($itemT->fk_work_location_id) {{ $itemT->get_work_loction->name }} @endif

@if ($itemT->is_updated) Ja - {{ $itemT->last_updated_reason }} @else - @endif

{{ $iteme->first_name }}
@if (!is_null($HrTimeRecordingToday->first())) @endif
{{ }}
@if (!is_null($HrTimeRecordingToday->where('work', '1')->first())) {{ Carbon\Carbon::parse($HrTimeRecordingToday->where('work', '1')->first()->start_time)->format('H:i') }} @endif @if (is_null($HrTimeRecordingToday->where('work', '1')->where('status_open', '0')->last())) @else @if (is_null($HrTimeRecordingToday->where('work', '1')->last()->stop_time)) --- @else {{ Carbon\Carbon::parse($HrTimeRecordingToday->where('work', '1')->where('status_open', '0')->last()->stop_time)->format('H:i') }} @endif @endif @if (!is_null($HrTimeRecordingToday->where('work', '1')->sortByDesc('id')->first())) {{ $HrTimeRecordingToday->where('work', '1')->sum('work') }} @endif @if (!is_null($HrTimeRecordingToday->where('break', '1')->sortByDesc('id')->first())) {{ $HrTimeRecordingToday->where('break', '1')->sum('break') }} @endif @if (!is_null($HrTimeRecordingToday->where('break', '1')->sortByDesc('id')->first())) {{ \Carbon\CarbonInterval::seconds($HrTimeRecordingToday->where('break', '1')->sum('total_second'))->cascade()->format('%H:%I') }} @endif @if ($iteme->contract) @if ($iteme->contract->get_days[strtolower($start->format('l'))]) {{ $iteme->contract->get_days[strtolower($start->format('l'))] }} @endif @else -- @endif @if (!is_null($HrTimeRecordingToday->where('work', '1')->sortByDesc('id')->first())) @if ($iteme->contract) @php $time = \Carbon\CarbonInterval::seconds( $HrTimeRecordingToday->where('work', '1')->sum('total_second') - $HrTimeRecordingToday->where('break', '1')->sum('total_second'), ) ->cascade() ->format('%H:%I'); [$hours, $minutes] = explode(':', $time); $timeInHours = (float) $hours + $minutes / 60; $floatHours = $iteme->contract->get_days[ strtolower($start->format('l')) ]; @endphp @php $totalWorkTimeInSeconds = $HrTimeRecordingToday ->where('work', '1') ->where('status_open', '0') ->sum('total_second'); $totalPauseTimeInSeconds = $HrTimeRecordingToday ->where('break', '1') ->where('status_open', '0') ->sum('total_second'); $netTimeInSeconds = $totalWorkTimeInSeconds - $totalPauseTimeInSeconds; $isNegative = $netTimeInSeconds < 0; $interval = \Carbon\CarbonInterval::seconds(abs($netTimeInSeconds)); $formattedTime = $interval->cascade()->format('%H:%I'); if ($isNegative) { $formattedTime = '-' . $formattedTime; } @endphp @if ($timeInHours < $floatHours) {{ $formattedTime }} @else {{ $formattedTime }} @endif @endif @endif -
{{-- für container --}} @endsection