Ejemplo n.º 1
0
 public static function getroleemail($userid)
 {
     $role_id = User::where('id', $userid)->value('role_id');
     $role = Role::findOrFail($role_id);
     $chucnang = 'thuden';
     $rolechucnangs = RoleChucnang::join('danhmucchucnangs', 'role_chucnangs.danhmucchucnang_id', '=', 'danhmucchucnangs.id')->where('role_id', $role->id)->where('danhmucchucnangs.chucnang_id', $chucnang)->select('danhmucchucnangs.id', 'role_chucnangs.role_id', 'role_chucnangs.danhmucchucnang_id', 'role_chucnangs.Danhsach', 'role_chucnangs.Xem', 'role_chucnangs.Them', 'role_chucnangs.Sua', 'role_chucnangs.Xoa', 'danhmucchucnangs.tenchucnang', 'danhmucchucnangs.chucnang_id', 'danhmucchucnangs.orders', 'danhmucchucnangs.level')->first();
     return $rolechucnangs;
 }
Ejemplo n.º 2
0
 public static function checkSua($chucnang)
 {
     $rolechucnangs = RoleChucnang::join('danhmucchucnangs', 'role_chucnangs.danhmucchucnang_id', '=', 'danhmucchucnangs.id')->where('role_id', \Auth::user()->role_id)->where('danhmucchucnangs.chucnang_id', $chucnang)->first();
     if ($rolechucnangs->Sua == 1) {
         return TRUE;
     }
     return FALSE;
 }
Ejemplo n.º 3
0
 protected function rolechucnangs($chucnang)
 {
     $userid = Auth::user()->id;
     //Cookie::make('userfolder', Auth::user()->username);
     Cookie::queue(Cookie::make('userfolder', Auth::user()->username, 5));
     $role_id = User::where('id', $userid)->value('role_id');
     $role = Role::findOrFail($role_id);
     $this->menus = $role->danhmuchucnangs()->orderBy('orders')->orderBy('tenchucnang')->get();
     $rolechucnangs = RoleChucnang::join('danhmucchucnangs', 'role_chucnangs.danhmucchucnang_id', '=', 'danhmucchucnangs.id')->where('role_id', $role->id)->where('danhmucchucnangs.chucnang_id', $chucnang)->select('danhmucchucnangs.id', 'role_chucnangs.role_id', 'role_chucnangs.danhmucchucnang_id', 'role_chucnangs.Danhsach', 'role_chucnangs.Xem', 'role_chucnangs.Them', 'role_chucnangs.Sua', 'role_chucnangs.Xoa', 'danhmucchucnangs.tenchucnang', 'danhmucchucnangs.chucnang_id', 'danhmucchucnangs.orders', 'danhmucchucnangs.level')->first();
     return $rolechucnangs;
 }
Ejemplo n.º 4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Sua == 1) {
         $roles = Role::all();
         $chucnangs = Danhmucchucnang::orderBy('orders')->get();
         $rolechucnangs = RoleChucnang::where('role_id', $id)->get();
         $role = Role::findOrFail($id);
         //echo '<pre>';
         //print_r($rolechucnangs);
         return view('role.edit')->with(array('menus' => $this->menus, 'roles' => $roles, 'role' => $role, 'chucnangs' => $chucnangs, 'rolechucnangs' => $rolechucnangs));
     } else {
         return \Redirect::route('role.index')->with('message-error', 'Không có quyền truy cập');
     }
 }
Ejemplo n.º 5
0
 public function searchfull_bk()
 {
     $capphathanhs = Danhmucnhomdonvi::get(array('id', 'name'));
     $noiphathanhs = Danhmucdonvi::get(array('id', 'name', 'danhmucnhomdonvi_id'));
     $mucdichs = Danhmucmucdich::get(array('id', 'name'));
     $linhvucchuyendes = Linhvucchuyende::get(array('id', 'name'));
     $chuyendes = Danhmucchuyende::get(array('id', 'name', 'linhvucchuyende_id'));
     $chutrixulys = Danhmucphong::get(array('id', 'name'));
     $phoihopxulys = Danhmucphong::get(array('id', 'name'));
     $canboxulys = Canbo::get(array('id', 'name'));
     $domats = Danhmucdomat::get(array('id', 'name'));
     $dokhans = Danhmucdokhan::get(array('id', 'name'));
     $loaicongvans = Danhmucloaicongvan::get(array('id', 'name'));
     // Input
     $loaivanban = Input::get('loaivanban');
     $noidung = Input::get('noidungcongvan');
     //noidungcongvan
     $noidungtrichyeu = false;
     $ykienlanhdao = false;
     if (Input::get('noidungtrichyeu-checkbox') == 'on') {
         $noidungtrichyeu = true;
     }
     if (Input::get('noidungykienlanhdao-checkbox') == 'on') {
         $ykienlanhdao = true;
     }
     $socongvandenso = Input::get('socongvandenso');
     if ($socongvandenso == '') {
         $querysocongvandenso = 'socongvandenso > 0';
     } else {
         $querysocongvandenso = 'socongvandenso = ' . $socongvandenso;
     }
     $socongvandenchu = Input::get('socongvandenchu');
     $sohosoluu = Input::get('sohosoluu');
     if ($sohosoluu == '') {
         $querysohosoluu = 'sohosoluu > 0';
     } else {
         $querysohosoluu = 'sohosoluu = ' . $sohosoluu;
     }
     $trichyeucongvan = Input::get('trichyeucongvanden');
     $noiluutru = Input::get('noiluutru');
     // Tim kiem
     if ($loaivanban == 0) {
         isset($loaivanban);
         if ($noidungtrichyeu && !$ykienlanhdao) {
             $congvandens = Congvanden::where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
         } else {
             if ($ykienlanhdao && !$noidungtrichyeu) {
                 $congvandens = Congvanden::where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
             } else {
                 if ($noidungtrichyeu && $ykienlanhdao) {
                     $congvandens = Congvanden::where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at')->orWhere(function ($query) use($noidung, $socongvandenso, $socongvandenchu, $sohosoluu) {
                         $query->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at');
                     })->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 } else {
                     $congvandens = Congvanden::where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 }
             }
         }
     } else {
         if ($loaivanban != 0) {
             if ($noidungtrichyeu && !$ykienlanhdao) {
                 $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
             } else {
                 if ($ykienlanhdao && !$noidungtrichyeu) {
                     $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 } else {
                     if ($noidungtrichyeu && $ykienlanhdao) {
                         $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at')->orWhere(function ($query) use($loaivanban, $noidung, $socongvandenso, $sohosoluu) {
                             $query->where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at');
                         })->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     } else {
                         $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     }
                 }
             }
         }
     }
     // Tim kiem nang cao
     // input
     $timnangcao = Input::get('timnangcao-checkbox');
     //input
     $capphathanh = Input::get('capphathanh');
     $noiphathanh = Input::get('noiphathanh');
     $domat = Input::get('domatcongvan');
     $mucdich = Input::get('mucdich');
     $linhvucchuyende = Input::get('linhvucchuyende');
     $chuyende = Input::get('chuyende');
     $nguoiky = Input::get('nguoiky');
     $dokhan = Input::get('dokhancongvan');
     $querycapphathanh = '';
     $querynoiphathanh = '';
     $querydomat = '';
     $querydokhan = '';
     $querymucdich = '';
     $querylinhvucchuyende = '';
     $querychuyende = '';
     //cap phát hành
     if ($capphathanh != 0) {
         $querycapphathanh = 'capphathanh_id = ' . $capphathanh;
     } else {
         $querycapphathanh = 'capphathanh_id != 0';
     }
     // nơi phát hành
     if ($noiphathanh != 0) {
         $querynoiphathanh = 'noiphathanh_id = ' . $noiphathanh;
     } else {
         $querynoiphathanh = 'noiphathanh_id != 0';
     }
     // độ mật
     if ($domat != 0) {
         $querydomat = 'danhmucdomat_id = ' . $domat;
     } else {
         $querydomat = 'danhmucdomat_id != 0';
     }
     // mục đích
     if ($mucdich != 0) {
         $querymucdich = 'danhmucmucdich_id = ' . $mucdich;
     } else {
         $querymucdich = 'danhmucmucdich_id != 0';
     }
     // lĩnh vực chuyên đề
     if ($linhvucchuyende != 0) {
         $querylinhvucchuyende = 'linhvucchuyende_id = ' . $linhvucchuyende;
     } else {
         $querylinhvucchuyende = 'linhvucchuyende_id != 0';
     }
     // chuyên đề
     if ($chuyende != 0) {
         $querychuyende = 'danhmucchuyende_id = ' . $chuyende;
     } else {
         $querychuyende = 'danhmucchuyende_id != 0';
     }
     // người ký
     // độ khẩn
     if ($dokhan != 0) {
         $querydokhan = 'danhmucdokhan_id = ' . $dokhan;
     } else {
         $querydokhan = 'danhmucdokhan_id != 0';
     }
     if ($timnangcao == 'on') {
         if ($loaivanban == 0) {
             isset($loaivanban);
             if ($noidungtrichyeu && !$ykienlanhdao) {
                 $congvandens = Congvanden::where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
             } else {
                 if ($ykienlanhdao && !$noidungtrichyeu) {
                     $congvandens = Congvanden::where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 } else {
                     if ($noidungtrichyeu && $ykienlanhdao) {
                         $congvandens = Congvanden::where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at')->orWhere(function ($query) use($noidung, $querysocongvandenso, $socongvandenchu, $sohosoluu, $querycapphathanh, $querynoiphathanh, $querydomat, $querymucdich, $querylinhvucchuyende, $querychuyende, $nguoiky, $querydokhan) {
                             $query->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at');
                         })->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     } else {
                         $congvandens = Congvanden::where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     }
                 }
             }
         } else {
             if ($loaivanban != 0) {
                 if ($noidungtrichyeu && !$ykienlanhdao) {
                     $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 } else {
                     if ($ykienlanhdao && !$noidungtrichyeu) {
                         $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     } else {
                         if ($noidungtrichyeu && $ykienlanhdao) {
                             $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at')->orWhere(function ($query) use($noidung, $querysocongvandenso, $socongvandenchu, $sohosoluu, $querycapphathanh, $querynoiphathanh, $querydomat, $querymucdich, $querylinhvucchuyende, $querychuyende, $nguoiky, $querydokhan) {
                                 $query->where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at');
                             })->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                         } else {
                             $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                         }
                     }
                 }
             }
         }
     }
     // end tim nang cao
     // Tim kiem nang cao theo thoi gian
     //get date
     $ngayphathanhtu = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayphathanh-start'))));
     $ngayphathanhtoi = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayphathanh-end'))));
     $ngaynhancongvantu = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngaynhancongvan-start'))));
     $ngaynhancongvantoi = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngaynhancongvan-end'))));
     $ngayluutu = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayluu-start'))));
     $ngayluutoi = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayluu-end'))));
     $ngaykytu = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayky-start'))));
     $ngaykytoi = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayky-end'))));
     // validate
     //if($ngayphathanhtu > $ngayphathanhtoi)
     //{
     //return \Redirect::url('timkiemcongvanden')->withErrors('Ngày lưu tới phải lớn hơn!');
     //}
     //if($ngaykytu > $ngaykytoi)
     //{
     //return \Redirect::url('timkiemcongvanden')->withErrors('Ngày ký tới phải lớn hơn!');
     //}
     // co
     $ngayhientai = date('Y-m-d');
     if ($ngayphathanhtu == '1970-01-01' && $ngayphathanhtoi == '1970-01-01') {
         $ngayphathanhtoi = $ngayhientai;
         // không chọn
     }
     if ($ngaynhancongvantu == '1970-01-01' && $ngaynhancongvantoi == '1970-01-01') {
         $ngaynhancongvantoi = $ngayhientai;
     }
     if ($ngayluutu == '1970-01-01' && $ngayluutoi == '1970-01-01') {
         $ngayluutoi = $ngayhientai;
     }
     if ($ngaykytu == '1970-01-01' && $ngaykytoi == '1970-01-01') {
         $ngaykytoi = $ngayhientai;
     }
     // input
     $timnangcaotheothoigian = Input::get('timnangcao-checkbox-thoigian');
     if ($timnangcaotheothoigian == 'on') {
         if ($loaivanban == 0) {
             isset($loaivanban);
             if ($noidungtrichyeu && !$ykienlanhdao) {
                 $congvandens = Congvanden::where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
             } else {
                 if ($ykienlanhdao && !$noidungtrichyeu) {
                     $congvandens = Congvanden::where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 } else {
                     if ($noidungtrichyeu && $ykienlanhdao) {
                         $congvandens = Congvanden::where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orWhere(function ($query) use($noidung, $querysocongvandenso, $querysocongvandenso, $sohosoluu, $ngaynhancongvantu, $ngaynhancongvantoi, $ngaykytu, $ngaykytoi) {
                             $query->where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at');
                         })->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     } else {
                         $congvandens = Congvanden::where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     }
                 }
             }
         } else {
             if ($loaivanban != 0) {
                 if ($noidungtrichyeu && !$ykienlanhdao) {
                     $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 } else {
                     if ($ykienlanhdao && !$noidungtrichyeu) {
                         $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     } else {
                         if ($noidungtrichyeu && $ykienlanhdao) {
                             $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orWhere(function ($query) use($loaivanban, $noidung, $querysocongvandenso, $socongvandenchu, $sohosoluu, $ngaynhancongvantu, $ngaynhancongvantoi, $ngaykytu, $ngaykytoi) {
                                 $query->where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at');
                             })->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                         } else {
                             $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                         }
                     }
                 }
             }
         }
     }
     // end tim nang cao theo thoi gian
     // tim nang cao va tim nang cao theo thoi gian
     if ($timnangcao == 'on' && $timnangcaotheothoigian == 'on') {
         if ($loaivanban == 0) {
             isset($loaivanban);
             if ($noidungtrichyeu && !$ykienlanhdao) {
                 $congvandens = Congvanden::where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
             } else {
                 if ($ykienlanhdao && !$noidungtrichyeu) {
                     $congvandens = Congvanden::where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 } else {
                     if ($noidungtrichyeu && $ykienlanhdao) {
                         $congvandens = Congvanden::where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at')->orWhere(function ($query) use($noidung, $querysocongvandenso, $socongvandenchu, $sohosoluu, $querycapphathanh, $querynoiphathanh, $querydomat, $querymucdich, $querylinhvucchuyende, $querychuyende, $nguoiky, $querydokhan, $ngaynhancongvantu, $ngaynhancongvantoi, $ngaykytu, $ngaykytoi) {
                             $query->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at');
                         })->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     } else {
                         $congvandens = Congvanden::where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     }
                 }
             }
         } else {
             if ($loaivanban != 0) {
                 if ($noidungtrichyeu && !$ykienlanhdao) {
                     $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 } else {
                     if ($ykienlanhdao && !$noidungtrichyeu) {
                         $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                     } else {
                         if ($noidungtrichyeu && $ykienlanhdao) {
                             $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orWhere(function ($query) use($noidung, $querysocongvandenso, $socongvandenchu, $sohosoluu, $querycapphathanh, $querynoiphathanh, $querydomat, $querymucdich, $querylinhvucchuyende, $querychuyende, $nguoiky, $querydokhan, $ngaynhancongvantu, $ngaynhancongvantoi, $ngaykytu, $ngaykytoi) {
                                 $query->where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichykienlanhdao', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->whereNull('congvandens.deleted_at');
                             })->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                         } else {
                             $congvandens = Congvanden::where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvanden', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandenso)->where('socongvandenchu', 'LIKE', '%' . $socongvandenchu . '%')->whereRaw($querysohosoluu)->whereRaw($querycapphathanh)->whereRaw($querynoiphathanh)->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->where('nguoiky', 'LIKE', '%' . $nguoiky . '%')->whereRaw($querydokhan)->where('ngayden', '>=', $ngaynhancongvantu)->where('ngayden', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->whereNull('congvandens.deleted_at')->orderBy('ngayden', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                         }
                     }
                 }
             }
         }
     }
     // end tim kiem nang cao full
     //var_dump($tukhoas);
     $userid = Auth::user()->id;
     $role = Role::findOrFail($userid);
     $rolechucnangsearchs = RoleChucnang::where('role_id', $role->id)->where('danhmucchucnang_id', 16)->first();
     return view('congvanden.result')->with(array('congvandens' => $congvandens, 'menus' => $this->menus, 'loaicongvans' => $loaicongvans, 'domats' => $domats, 'dokhans' => $dokhans, 'capphathanhs' => $capphathanhs, 'noiphathanhs' => $noiphathanhs, 'mucdichs' => $mucdichs, 'linhvucchuyendes' => $linhvucchuyendes, 'chuyendes' => $chuyendes, 'chutrixulys' => $chutrixulys, 'phoihopxulys' => $phoihopxulys, 'canboxulys' => $canboxulys, 'rolechucnangsearchs' => $rolechucnangsearchs));
 }
Ejemplo n.º 6
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $user = \Auth::user();
     $role = Role::findOrFail($user->role_id);
     $this->menus = $role->danhmuchucnangs()->orderBy('orders')->orderBy('tenchucnang')->get();
     $rolechucnangs = RoleChucnang::join('danhmucchucnangs', 'role_chucnangs.danhmucchucnang_id', '=', 'danhmucchucnangs.id')->where('role_id', $role->id)->select('danhmucchucnangs.id', 'role_chucnangs.role_id', 'role_chucnangs.danhmucchucnang_id', 'role_chucnangs.Danhsach', 'role_chucnangs.Xem', 'role_chucnangs.Them', 'role_chucnangs.Sua', 'role_chucnangs.Xoa', 'danhmucchucnangs.tenchucnang', 'danhmucchucnangs.chucnang_id', 'danhmucchucnangs.orders', 'danhmucchucnangs.level')->get();
     $userid = $user->id;
     $phongid = $user->phong_id;
     $doiid = $user->doi_id;
     $now_time = time();
     // top 10 văn bản đến
     if ($role->name == 'phong') {
         $congvandentop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($phongid) {
             $query->select('congvanden_id')->from('congvanden_danhmucphongs')->whereRaw('congvanden_danhmucphongs.danhmucphong_id = ' . $phongid);
         })->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) {
             $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid);
         })->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orderBy('sohosoluu', 'desc')->take(10)->get();
     } else {
         if ($role->name == 'doi') {
             $congvandentop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($doiid) {
                 $query->select('congvanden_id')->from('congvanden_danhmucdois')->whereRaw('congvanden_danhmucdois.danhmucdoi_id = ' . $doiid);
             })->whereNull('congvandens.deleted_at')->whereNull('congvandens.sohosoluubo')->orWhereIn('id', function ($query) use($userid) {
                 $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid);
             })->whereNull('congvandens.deleted_at')->whereNull('congvandens.sohosoluubo')->orderBy('sohosoluu', 'desc')->take(10)->get();
         } else {
             if ($role->name == 'canbo') {
                 $congvandentop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) {
                     $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid);
                 })->whereNull('congvandens.deleted_at')->whereNull('congvandens.sohosoluubo')->orderBy('sohosoluu', 'desc')->take(10)->get();
             } else {
                 if ($role->name == 'vanthu') {
                     $congvandentop10s = Congvanden::where('phong_id', \Auth::user()->phong_id)->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orderBy('congvandens.created_at')->orderBy('sohosoluu', 'desc')->take(10)->get();
                 } else {
                     if ($role->name == 'admin' || $role->name == 'superadmin') {
                         $congvandentop10s = [];
                     }
                 }
             }
         }
     }
     // top 10 văn bản đến từ bộ
     if ($role->name == 'phong') {
         $congvandenbotop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($phongid) {
             $query->select('congvanden_id')->from('congvanden_danhmucphongs')->whereRaw('congvanden_danhmucphongs.danhmucphong_id = ' . $phongid);
         })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) {
             $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid);
         })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orderBy('sohosoluubo', 'desc')->take(10)->get();
     } else {
         if ($role->name == 'doi') {
             $congvandenbotop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($doiid) {
                 $query->select('congvanden_id')->from('congvanden_danhmucdois')->whereRaw('congvanden_danhmucdois.danhmucdoi_id = ' . $doiid);
             })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) {
                 $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid);
             })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orderBy('sohosoluubo', 'desc')->take(10)->get();
         } else {
             if ($role->name == 'canbo') {
                 $congvandenbotop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) {
                     $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid);
                 })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orderBy('sohosoluubo', 'desc')->take(10)->get();
             } else {
                 if ($role->name == 'vanthu') {
                     $congvandenbotop10s = Congvanden::where('phong_id', \Auth::user()->phong_id)->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orderBy('congvandens.created_at')->orderBy('sohosoluubo', 'desc')->take(10)->get();
                 } else {
                     if ($role->name == 'admin' || $role->name == 'superadmin') {
                         $congvandenbotop10s = [];
                     }
                 }
             }
         }
     }
     /*
     			$congvandenbotop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)
     				->whereNull('congvandens.sohosoluu')
     /*
     ->orWhereIn('id', (function ($query) use ($doiid) {
                     	$query->select('congvanden_id')
                           ->from('congvanden_danhmucdois')
                           ->whereRaw('congvanden_danhmucdois.danhmucdoi_id = ' . $doiid);
     }) )
     ->whereNull('congvandens.deleted_at')   
     */
     /*
                 ->orWhereIn('id', (function ($query) use ($userid) {
     $query->select('congvanden_id')
       ->from('congvanden_users')
       ->whereRaw('congvanden_users.user_id = ' . $userid);
                 }) )
                 ->whereNull('congvandens.deleted_at')
     
             ->orderBy('sohosoluu', 'desc')
     ->take(10)->get();
     */
     // top 10 công van đi
     if ($role->name == 'phong') {
         $congvanditop10s = Congvandi::where('nguoitao_id', \Auth::user()->id)->orWhereIn('id', function ($query) use($phongid) {
             $query->select('congvandi_id')->from('congvandi_danhmucphongs')->whereRaw('congvandi_danhmucphongs.danhmucphong_id = ' . $phongid);
         })->whereNull('congvandis.deleted_at')->orWhereIn('id', function ($query) use($userid) {
             $query->select('congvandi_id')->from('congvandi_users')->whereRaw('congvandi_users.user_id = ' . $userid);
         })->whereNull('congvandis.deleted_at')->orderBy('socongvandiso', 'desc')->take(10)->get();
     } else {
         if ($role->name == 'doi') {
             $congvanditop10s = congvandi::where('nguoitao_id', \Auth::user()->id)->orWhereIn('id', function ($query) use($doiid) {
                 $query->select('congvandi_id')->from('congvandi_danhmucdois')->whereRaw('congvandi_danhmucdois.danhmucdoi_id = ' . $doiid);
             })->whereNull('congvandis.deleted_at')->orWhereIn('id', function ($query) use($userid) {
                 $query->select('congvandi_id')->from('congvandi_users')->whereRaw('congvandi_users.user_id = ' . $userid);
             })->whereNull('congvandis.deleted_at')->orderBy('socongvandiso', 'desc')->take(10)->get();
         } else {
             if ($role->name == 'canbo') {
                 $congvanditop10s = congvandi::where('nguoitao_id', \Auth::user()->id)->orWhereIn('id', function ($query) use($userid) {
                     $query->select('congvandi_id')->from('congvandi_users')->whereRaw('congvandi_users.user_id = ' . $userid);
                 })->whereNull('congvandis.deleted_at')->orderBy('socongvandiso', 'desc')->take(10)->get();
             } else {
                 if ($role->name == 'vanthu') {
                     $congvanditop10s = congvandi::where('phong_id', \Auth::user()->phong_id)->whereNull('congvandis.deleted_at')->orderBy('socongvandiso', 'desc')->take(10)->get();
                 } else {
                     if ($role->name == 'admin' || $role->name == 'superadmin') {
                         $congvanditop10s = [];
                     }
                 }
             }
         }
     }
     // top 10 công việc mới nhất
     $congviectop10s = Congviec::where('user_created', \Auth::user()->id)->orWhereIn('id', function ($query) use($userid) {
         $query->select('congviec_id')->from('congviec_users')->whereRaw('congviec_users.user_id = ' . $userid);
     })->whereNull('congviecs.deleted_at')->orderBy('congviecs.created_at', 'desc')->orderBy('congviecs.updated_at', 'desc')->take(10)->get();
     return view('home')->with(array('now_time' => $now_time, 'menus' => $this->menus, 'congvandentop10s' => $congvandentop10s, 'congvandenbotop10s' => $congvandenbotop10s, 'congvanditop10s' => $congvanditop10s, 'congviectop10s' => $congviectop10s, 'rolechucnangs' => $rolechucnangs));
 }