/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $req)
 {
     //
     if ($this->auth->user()->type == "administrator") {
         return view('dashboard.admin_dashboard');
     } elseif ($this->auth->user()->type == "support") {
         parent::$_data['tiket_open'] = Tiket::where(['status' => 'open', 'id_support' => Auth::user()->id_user])->count();
         parent::$_data['tiket_process'] = Tiket::where(['status' => 'process', 'id_support' => Auth::user()->id_user])->count();
         parent::$_data['tiket_finish'] = Tiket::where(['status' => 'finish', 'id_support' => Auth::user()->id_user])->count();
         parent::$_data['tiket_cancel'] = Tiket::where(['status' => 'cancelled', 'id_support' => Auth::user()->id_user])->count();
         parent::$_data['sm_waiting'] = ServerMaintenance::where(['status' => 'waiting', 'id_support' => Auth::user()->id_user])->count();
         parent::$_data['sm_approved'] = ServerMaintenance::where(['status' => 'approved', 'id_support' => Auth::user()->id_user])->count();
         parent::$_data['rk_waiting'] = RencanaKunjungan::where(['status' => 'waiting', 'id_support' => Auth::user()->id_user])->count();
         parent::$_data['rk_approved'] = RencanaKunjungan::where(['status' => 'approved', 'id_support' => Auth::user()->id_user])->count();
         return view('dashboard.support_dashboard', parent::$_data);
     } elseif ($this->auth->user()->type == "pm") {
         parent::$_data['tiket_open'] = Tiket::where('status', '=', 'open')->count();
         parent::$_data['tiket_process'] = Tiket::where('status', '=', 'process')->count();
         parent::$_data['tiket_finish'] = Tiket::where('status', '=', 'finish')->count();
         parent::$_data['tiket_cancel'] = Tiket::where('status', '=', 'cancelled')->count();
         parent::$_data['sm_waiting'] = ServerMaintenance::where('status', '=', 'waiting')->count();
         parent::$_data['sm_approved'] = ServerMaintenance::where('status', '=', 'approved')->count();
         parent::$_data['rk_waiting'] = RencanaKunjungan::where('status', '=', 'waiting')->count();
         parent::$_data['rk_approved'] = RencanaKunjungan::where('status', '=', 'approved')->count();
         return view('dashboard.pm_dashboard', parent::$_data);
     } elseif ($this->auth->user()->type == "client") {
         return view('dashboard.client_dashboard');
     }
 }
 public function store(RencanaKunjunganRequest $req)
 {
     $rk = new RencanaKunjungan();
     $rk->tgl_kunjungan = $req->tgl_kunjungan;
     $rk->jam_berangkat = $req->jam_berangkat;
     $rk->jam_pulang = $req->jam_pulang;
     $rk->aktifitas = $req->aktifitas;
     $rk->tipe = $req->tipe_kunjungan;
     $rk->id_support = Auth::user()->id_user;
     $rk->id_tiket = $req->id_tiket;
     $rk->status = "waiting";
     $rk->save();
     foreach ($req->bugs as $item) {
         $rkd = new RencanaKunjunganDetail();
         $rkd->id_bugs = $item;
         $rkd->id_rk = $rk->id_rk;
         $rkd->save();
     }
     $tiket = Tiket::find($req->id_tiket);
     $tiket->status = "process";
     $tiket->save();
     Session::flash("success", "Success add Rencana Kunjungan");
     return redirect()->route('rencana.kunjungan');
 }
 public function ls_post(Request $req)
 {
     if ($req->type == "periode_client") {
         $range = explode('to', trim($req->range));
         $client = $req->client;
         $data = Tiket::whereHas('rk', function ($q) use($req, $range) {
             $q->where('tiket.id_client', '=', $req->client);
             $q->where('tiket.status', '=', "process");
             $q->whereBetween('rencana_kunjungan.created_at', [$range[0] . ' 00:00:01', $range[1] . ' 23:59:59']);
         })->get();
     } else {
         $range = explode('to', trim($req->range));
         $data = Tiket::where('tiket.status', '=', 'process')->whereHas('rk', function ($q) use($req, $range) {
             $q->whereBetween('rencana_kunjungan.created_at', [$range[0] . ' 00:00:01', $range[1] . ' 23:59:59']);
         })->get();
     }
     parent::$_data['results'] = $data;
     return view('report.result_ls', parent::$_data);
 }