<?php
// Debug: check ALL penugasan regardless of status
require __DIR__ . '/vendor/autoload.php';
$app = require_once __DIR__ . '/bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();

use App\Models\Penugasan;
use App\Models\Absensi;

echo "=== SEMUA PENUGASAN (termasuk semua status) ===\n";
$all = Penugasan::withTrashed()->get();
echo "Total penugasan (inc soft-deleted): " . $all->count() . "\n\n";

$statuses = $all->groupBy('status_pekerjaan');
echo "Per status:\n";
foreach ($statuses as $status => $items) {
    echo "  {$status}: " . $items->count() . "\n";
}

echo "\n=== PENUGASAN YANG BELUM SOFT-DELETED ===\n";
$active = Penugasan::all();
echo "Total: " . $active->count() . "\n";
foreach ($active as $p) {
    echo "  ID: {$p->id_penugasan}, Teknisi: {$p->id_teknisi}, Status: {$p->status_pekerjaan}\n";
    echo "  Jenis: {$p->jenis_pekerjaan}, Lokasi: {$p->alamat_lokasi}\n";
    echo "  total_nilai_pekerjaan: {$p->total_nilai_pekerjaan}\n";
    echo "  tanggal_diberikan: {$p->tanggal_diberikan}\n";
    echo "  tanggal_diselesaikan: {$p->tanggal_diselesaikan}\n";
    echo "  ---\n";
}

echo "\n=== ABSENSI ===\n";
$absensi = Absensi::all();
echo "Total absensi records: " . $absensi->count() . "\n";
$hadir = Absensi::where('status', 'hadir')->count();
echo "Status hadir: {$hadir}\n";

echo "\nDone.\n";
