
<?php namespace App\Controllers;
use App\Models\AttendanceModel;

class Admin extends BaseController {
    public function dashboard() {
        return view('admin_dashboard',['records'=>(new AttendanceModel())->getAll()]);
    }
    public function export() {
        header("Content-Type: text/csv");
        header("Content-Disposition: attachment; filename=attendance.csv");
        $out = fopen("php://output","w");
        fputcsv($out,['Employee','Punch In','Punch Out','Mode']);
        foreach((new AttendanceModel())->getAll() as $r){ fputcsv($out,$r); }
        fclose($out);
    }
}
