/** * Display a listing of the resource. * * @return string Data shift dan request. */ public function index() { // if (Auth::check()) { $id_karyawan = Auth::user()->id_karyawan; $today = date("Y-m-d"); $getNotice = Notice::byDivisi(Auth::user()->id_divisi); $shift = \DB::table('shift')->get(); $month_end = date('Y-m-d', strtotime('last day of this month', time())); $shiftLine = Shift::join("shift", "shift_line.id_shift", "=", "shift.id_shift")->where("id_karyawan", "=", $id_karyawan)->whereBetween("tanggal_shift", array($today, $month_end))->orderBy("id_shiftline")->get(); $req = rModel::join("shift_line", "request.shift_lama", "=", "shift_line.tanggal_shift")->where("request.id_karyawan", "=", "{$id_karyawan}")->orderBy("id", "DESC")->first(); return view('shift/index')->with("getNotice", $getNotice)->with("shift", $shift)->with("shiftLine", $shiftLine)->with("req", $req); } else { return \Redirect::to('login'); } }
/** * Display a listing of the resource. * * @return string Data shift dan request. */ public function index() { // if (Auth::check()) { $id_karyawan = Auth::user()->id_karyawan; $today = date("Y-m-d"); $getNotice = Notice::where("id_karyawan", "=", $id_karyawan)->where("tanggal", "=", $today)->get(); $shift = \DB::table('shift')->get(); $month_end = date('Y-m-d', strtotime('last day of this month', time())); $shiftLine = Shift::join("shift", "shift_line.id_shift", "=", "shift.id_shift")->where("id_karyawan", "=", $id_karyawan)->whereBetween("tanggal_shift", array($today, $month_end))->orderBy("id_shiftline")->get(); $req = rModel::where("id_karyawan", "=", $id_karyawan)->orderBy("id", "DESC")->first(); \DB::table('logs')->insert(['id_karyawan' => $id_karyawan, 'content' => Auth::user()->username . ' akses halaman daftar shift', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); return view('shift/index')->with("getNotice", $getNotice)->with("shift", $shift)->with("shiftLine", $shiftLine)->with("req", $req); } else { return \Redirect::to('login'); } }
/** * Display a listing of the resource. * * @return string */ public function index() { if (Auth::check()) { $id_karyawan = Auth::user()->id_karyawan; $absen = Absen::where("id_karyawan", "=", $id_karyawan)->orderBy("id_absen", "DESC")->first(); $today = date('Y-m-d'); $report = Laporan::where("id_karyawan", "=", $id_karyawan)->where("tanggal", "=", $today)->first(); $note = Dashboard::where("id_karyawan", "=", $id_karyawan)->first(); $getNotice = Notice::where("id_karyawan", "=", $id_karyawan)->where("tanggal", "=", $today)->get(); $shiftLine = Shift::join("shift", "shift_line.id_shift", "=", "shift.id_shift")->where("tanggal_shift", "=", $today)->where("id_karyawan", "=", $id_karyawan)->first(); $yesterday = date("Y-m-d", time() - 86400); $shiftKmrn = Shift::join("shift", "shift_line.id_shift", "=", "shift.id_shift")->where("tanggal_shift", "=", $yesterday)->where("id_karyawan", "=", $id_karyawan)->first(); $besok = date("Y-m-d", time() + 86400); $shiftBesok = Shift::join("shift", "shift_line.id_shift", "=", "shift.id_shift")->where("tanggal_shift", "=", $besok)->where("id_karyawan", "=", $id_karyawan)->first(); /** * untuk mengecek $id_karyawan * masuk shift berapa * @return string */ if ($shiftLine != null) { $shiftname = $shiftLine->nama_shift; } else { $shiftname = "Non Shift"; } if ($absen != null) { $tgl = explode(" ", $absen->created_at); if ($absen->status == "masuk" && $tgl[0] == $yesterday) { $absen = new Absen(); $absen->id_karyawan = $id_karyawan; $absen->id_shift = $shiftKmrn->id_shift; $absen->status = "keluar"; $absen->save(); } elseif ($absen->status == "masuk" && $tgl[0] != $today) { $absen = new Absen(); $absen->id_karyawan = $id_karyawan; $absen->id_shift = "4"; $absen->status = "keluar"; $absen->save(); } } return view('dashboard/index')->with("absen", $absen)->with("report", $report)->with("note", $note)->with("getNotice", $getNotice)->with("shiftLine", $shiftLine)->with("shiftKmrn", $shiftKmrn)->with("shiftBesok", $shiftBesok)->with("shiftname", $shiftname); } else { return \Redirect::to('login'); } }