63 lines
2.4 KiB
PHP
63 lines
2.4 KiB
PHP
<?php
|
|
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
$app = require_once __DIR__.'/../bootstrap/app.php';
|
|
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
|
$kernel->bootstrap();
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Http\Controllers\BiometricAttendanceController;
|
|
use App\Models\Employee;
|
|
use App\Models\BiometricAttendance;
|
|
use App\Models\AttendanceRecord;
|
|
use Carbon\Carbon;
|
|
|
|
// Ensure we have correct request variables
|
|
$request = new \Illuminate\Http\Request([
|
|
'overwrite' => true,
|
|
'start_date' => '2026-05-18',
|
|
'end_date' => '2026-05-30',
|
|
]);
|
|
|
|
// Run the sync controller's syncAll method logic internally for Ana
|
|
$employee = Employee::with(['user', 'shift'])->where('biometric_emp_id', '2008')->first();
|
|
if (!$employee) {
|
|
die("Employee with biometric ID 2008 not found locally!\n");
|
|
}
|
|
$employee->shift_id = 48;
|
|
$employee->load('shift');
|
|
|
|
echo "Employee Name: " . $employee->user->name . " | Bio ID: " . $employee->biometric_emp_id . " | Shift ID: " . $employee->shift_id . "\n";
|
|
echo "Shift Name: " . $employee->shift->name . " | Start: " . $employee->shift->start_time . " | End: " . $employee->shift->end_time . "\n\n";
|
|
|
|
$pendingRecords = BiometricAttendance::where('biometric_emp_id', '2008')
|
|
->whereBetween('punch_time', ['2026-05-18 00:00:00', '2026-05-30 23:59:59'])
|
|
->get();
|
|
|
|
echo "Found " . count($pendingRecords) . " raw biometric punches.\n";
|
|
|
|
$employees = collect(['2008' => $employee]);
|
|
|
|
$groupedAttendances = $pendingRecords->groupBy(function ($item) use ($employees) {
|
|
$employee = $employees->get($item->biometric_emp_id);
|
|
$workDate = BiometricAttendanceController::getWorkDateForPunch($item->punch_time, $employee);
|
|
return $item->biometric_emp_id . '_' . $workDate;
|
|
});
|
|
|
|
echo "\nGrouped results:\n";
|
|
foreach ($groupedAttendances as $key => $dayEntries) {
|
|
$sorted = $dayEntries->sortBy('punch_time');
|
|
$firstEntry = $sorted->first();
|
|
$lastEntry = $sorted->last();
|
|
|
|
$workDate = BiometricAttendanceController::getWorkDateForPunch($firstEntry->punch_time, $employee);
|
|
$clockInTime = $firstEntry->punch_time->format('H:i:s');
|
|
$clockOutTime = $sorted->count() > 1 ? $lastEntry->punch_time->format('H:i:s') : null;
|
|
|
|
echo "Work Date: {$workDate} | Punch Count: " . count($sorted) . "\n";
|
|
foreach ($sorted as $p) {
|
|
echo " - Punch: {$p->punch_time} (Type: {$p->punch_type})\n";
|
|
}
|
|
echo " => Clock In: {$clockInTime} | Clock Out: " . ($clockOutTime ?? 'NULL') . "\n\n";
|
|
}
|