@inject('provider', 'Modules\Employee\Http\Controllers\EmployeeTimelineController') @if($employee)

Timeline for: {{ $employee->name }} ({{ $employee->id }})

@else

All Employee Timeline on: {{ \Carbon\Carbon::parse($date)->format('d M Y')->setTimezone('Asia/Kolkata') }}

@endif @php $checkoutDistance = $fromAddress = $next = $duration = $targetLocation = null; $title = ""; $counter = $stoppageFlag = $isChange = $istravelling = 0; if (count($locations) <= 1) { @endphp @php } else { @endphp @foreach($locations as $index => $location) @php if (isset($locations[$index+1]) && $location->address == $locations[$index+1]->address) { if ($stoppageFlag == 0) { $targetLocation = $location; $fromAddress = \Carbon\Carbon::parse($location->timestamp)->setTimezone("Asia/Kolkata"); } $stoppageFlag = 1; continue; } else { if ($istravelling == 1) { $istravelling = 0; continue; } $isChange = 1; if (isset($locations[$index-1])) { // if ($locations[$index-1]->address == $location->address) { // $checkoutDistance = $provider::getDistance($targetLocation->geo_location, $location->geo_location); //} else { $checkoutDistance = $provider::getDistance($locations[$index-1]->geo_location, $location->geo_location); //} } if ($index == count($locations)-1 && count($attendance) > 0) { //if (is_null($fromAddress)) { $fromAddress = \Carbon\Carbon::parse($locations[$index-1]->timestamp)->setTimezone("Asia/Kolkata"); //} if ($checkout_distance <= $config_range) { $title = "Check-out from office"; if ($checkoutDistance > 1000) { $title = "Travel & ".$title; } @endphp @php } else { $title = "Check-out from outside of office"; if ($checkoutDistance > 1000) { $title = "Travel & ".$title; } $title = "".$title."
Reason :"; if (count($attendance) > 0) { if (is_null($attendance[count($attendance)-1]->check_out_traveling_reason)) { $title .= " N/A"; } else { $title .= $attendance[count($attendance)-1]->check_out_traveling_reason; } } else { $title .= " N/A"; } @endphp @php } } else if ($counter == 0) { if (is_null($fromAddress)) { $fromAddress = \Carbon\Carbon::parse($location->timestamp)->setTimezone("Asia/Kolkata"); } if ($checkin_distance <= $config_range) { $title = "Check-in from office"; if ($stoppageFlag == 1) { $title .= " & Stay"; } @endphp @php } else { $title = "Check-in from outside of office"; if ($stoppageFlag == 1) { $title .= " & Stay"; } $title = "".$title."
Reason :"; if (count($attendance) > 0) { if (is_null($attendance[count($attendance)-1]->check_in_traveling_reason)) { $title .= " N/A"; } else { $title .= $attendance[count($attendance)-1]->check_in_traveling_reason; } } else { $title .= " N/A"; } @endphp @php } } else if ($checkoutDistance > 1000) { $title = "Travelling"; @endphp @php } else { $title = "Stoppage"; @endphp @php } $stoppageFlag = 0; $lastTime = $location->timestamp; $next = \Carbon\Carbon::parse($lastTime)->setTimezone("Asia/Kolkata"); $duration = $next ? $fromAddress->diff($next) : null; $counter += 1; if (str_contains($title, "Travel")) { $calculatedDistance = $checkoutDistance/1000; $address = "FROM ".$locations[$index-1]->address." TO ".$location->address." (".sprintf("%.2f", $calculatedDistance)." km)"; } else { $address = trim($location->address ?? "N/A"); if ($checkoutDistance > 1000) { $address .= " (".sprintf("%.2f", ($checkoutDistance/1000))." Km)"; } } $begin = $fromAddress->format("h:i A"); $end = $next ? $next->format("h:i A") : "-"; $duration = $duration ? $duration->format("%h hr %i min") : "-"; //$fromAddress = null; } @endphp @php if ($title == "Travelling") { @endphp @php } if ($isChange == 1 && isset($locations[$index+1])) { $isChange = 0; $calculatedDistance = $provider::getDistance($location->geo_location, $locations[$index+1]->geo_location)/1000; if ($calculatedDistance > 1000) { $istravelling = 1; @endphp @php } $fromAddress = $next; } @endphp @endforeach @php } if ($counter > 1) { @endphp @php } @endphp
Type Location Begin Time End Time Duration
No data for Timeline.
{{ $title }}{!!html_entity_decode($title)!!}{{ $title }}{!!html_entity_decode($title)!!}{{ $title }}{{ $title }}{!!html_entity_decode($address)!!} {{ $begin }} {{ $end }} {{ $duration }}
Stoppage @php echo $location->address; @endphp @php $travelFrom = \Carbon\Carbon::parse($location->timestamp); echo $travelFrom->setTimezone("Asia/Kolkata")->format("h:i A"); @endphp @php $travelTo = \Carbon\Carbon::parse($locations[$index+1]->timestamp); echo $travelTo->setTimezone("Asia/Kolkata")->format("h:i A"); @endphp @php echo $travelFrom->diff($travelTo)->setTimezone("Asia/Kolkata")->format("%h hr %i min"); @endphp
Travelling @php echo "FROM ".$location->address." TO ".$locations[$index+1]->address." (".sprintf("%.2f", $calculatedDistance)." km)"; @endphp @php $travelFrom = \Carbon\Carbon::parse($location->timestamp); echo $travelFrom->setTimezone("Asia/Kolkata")->format("h:i A"); @endphp @php $travelTo = \Carbon\Carbon::parse($locations[$index+1]->timestamp); echo $travelTo->setTimezone("Asia/Kolkata")->format("h:i A"); @endphp @php echo $travelFrom->diff($travelTo)->setTimezone("Asia/Kolkata")->format("%h hr %i min"); @endphp
Timeline Summary Total Trip Duration {{ $locations[0]->timestamp->setTimezone("Asia/Kolkata")->format("h:i A") }} {{ $next->format("h:i A") }} {{ $locations[0]->timestamp->diff($lastTime)->format("%h hr %i min") }}