public function resulttheonoigui(Request $request)
 {
     $capphathanhs = Danhmucnhomdonvi::all();
     $ngaynhanbatdau = $request->input('ngaynhanbatdau');
     $ngaynhanketthuc = $request->input('ngaynhanketthuc');
     $capphathanh = $request->input('capphathanh');
     //$capphathanhresult = 'Tất cả';
     if ($capphathanh == 0) {
         $querycapphathanh = 'capphathanh_id > 0';
         $capphathanhresult = 'Tất cả';
     } else {
         $querycapphathanh = 'capphathanh_id = ' . $capphathanh;
         $capphathanhresult = Danhmucnhomdonvi::where('id', $capphathanh)->select('name')->first();
     }
     if ($ngaynhanbatdau != '' && $ngaynhanketthuc != '') {
         $ngaynhanbatdau = date('Y-m-d', strtotime(str_replace('/', '-', $ngaynhanbatdau)));
         //date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayphathanh-start'))) ) ;
         $ngaynhanketthuc = date('Y-m-d', strtotime(str_replace('/', '-', $ngaynhanketthuc)));
         if ($ngaynhanbatdau > $ngaynhanketthuc) {
             return \Redirect::route('thongkecongvanden.theonoigui')->withErrors('Ngày nhận bắt đầu phải nhỏ hơn ngày nhận kết thúc!')->withInput();
         } else {
             $congvandens = Congvanden::where('ngayden', '>=', $ngaynhanbatdau)->where('ngayden', '<=', $ngaynhanketthuc)->whereRaw($querycapphathanh)->where('phong_id', Auth::user()->phong_id)->get();
         }
     }
     $tungays = date('d/m/Y', strtotime($ngaynhanbatdau));
     $denngays = date('d/m/Y', strtotime($ngaynhanketthuc));
     return view('thongkecongvanden.theonoigui')->with(['menus' => $this->menus, 'tungay' => $tungays, 'denngay' => $denngays, 'congvandens' => $congvandens, 'capphathanhs' => $capphathanhs, 'capphathanhresult' => $capphathanhresult]);
 }
예제 #2
0
 public function getcapphathanhid($capphathanh)
 {
     $capphathanhfind = Danhmucphong::where('id', $capphathanh)->first();
     if ($capphathanhfind->cap == 'tinh') {
         $capphathanh_id = Danhmucnhomdonvi::where('id', 17)->value('id');
     } else {
         if ($capphathanhfind->cap == 'huyen') {
             $capphathanh_id = Danhmucnhomdonvi::where('id', 3)->value('id');
         }
     }
     return $capphathanh_id;
 }
 /**
  * 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) {
         $nhomdonvis = Danhmucnhomdonvi::orderBy('name')->get(['id', 'name']);
         $danhmucdonvi = Danhmucdonvi::findOrFail($id);
         return view('danhmucdonvi.edit')->with(array('danhmucdonvi' => $danhmucdonvi, 'nhomdonvis' => $nhomdonvis, 'menus' => $this->menus));
     } else {
         return \Redirect::route('danhmucdonvi.index')->with('message-error', 'Không có quyền truy cập');
     }
 }
예제 #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) {
         $loaicongvans = Danhmucloaicongvan::get(array('id', 'name'));
         $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'));
         $phongs = Danhmucphong::orderBy('name')->get();
         $dois = Danhmucdoi::orderBy('name')->get();
         $canbos = User::where('role_id', '>', 2)->orderBy('name')->get();
         $emails = Danhmucemail::orderBy('name')->get();
         $domats = Danhmucdomat::get(array('id', 'name'));
         $dokhans = Danhmucdokhan::get(array('id', 'name'));
         $congvanden = Congvanden::findOrFail($id);
         if ($congvanden->sohosoluubo) {
             $action = 'congvanden.update';
             $title = 'bộ';
         } else {
             $action = 'congvanden.update';
             $title = '';
         }
         $getfiletralois = \DB::table('file_traloicongvandens')->where('congvanden_id', $id)->get();
         $getcountups = \DB::table('file_traloicongvandens')->where('congvanden_id', $id)->distinct()->select('stt')->get();
         $getusers = \DB::table('file_traloicongvandens')->where('congvanden_id', $id)->distinct()->select('user_id')->get();
         return view('congvanden.edit')->with(array('congvanden' => $congvanden, 'getcountups' => $getcountups, 'getfiletralois' => $getfiletralois, 'getusers' => $getusers, 'loaicongvans' => $loaicongvans, 'domats' => $domats, 'dokhans' => $dokhans, 'menus' => $this->menus, 'capphathanhs' => $capphathanhs, 'noiphathanhs' => $noiphathanhs, 'mucdichs' => $mucdichs, 'linhvucchuyendes' => $linhvucchuyendes, 'chuyendes' => $chuyendes, 'chutrixulys' => $chutrixulys, 'phoihopxulys' => $phoihopxulys, 'canboxulys' => $canboxulys, 'phongs' => $phongs, 'dois' => $dois, 'canbos' => $canbos, 'emails' => $emails, 'action' => $action, 'title' => $title));
     } else {
         return \Redirect::route('congvanden.index')->with('message-error', 'Không có quyền truy cập');
     }
 }
예제 #5
0
 public function searchfull()
 {
     $chucnang = 'timkiemcongvandi';
     $rolechucnangsearchs = Role::getRolebyRoleId($chucnang, Auth::user()->role_id);
     if (Auth::check() && $rolechucnangsearchs && $rolechucnangsearchs->Danhsach == 1) {
         $phongid = User::where('id', Auth::user()->id)->value('phong_id');
         $loaicongvans = Danhmucloaicongvan::get(array('id', 'name'));
         // Input
         $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'));
         $nguoikys = Canbo::get(['id', 'name']);
         $hinhthucchuyens = Danhmuchinhthucchuyen::get(['id', 'name']);
         $noisoanthaos = Danhmucphong::get(['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
         // Tìm theo năm
         $timtheonam = Input::get('timtheonam-checkbox');
         if ($timtheonam == 'on') {
             $namvanban = Input::get('year');
             $querynamvanban = 'year(ngayphathanh) =' . $namvanban;
         } else {
             $querynamvanban = 'year(ngayphathanh) >= 1900';
         }
         $socongvandiso = Input::get('socongvandiso');
         if ($socongvandiso == '') {
             $querysocongvandiso = 'socongvandiso > 0';
         } else {
             $querysocongvandiso = 'socongvandiso = ' . $socongvandiso;
         }
         $socongvandichu = Input::get('socongvandichu');
         $noinhancongvan = Input::get('noinhancongvan');
         // Tim kiem
         if ($loaivanban == 0) {
             $congvandis = Congvandi::where('phong_id', $phongid)->whereRaw($querynamvanban)->where('trichyeucongvandi', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandiso)->where('socongvandichu', 'LIKE', '%' . $socongvandichu . '%')->Where('noinhancongvan', 'LIKE', '%' . $noinhancongvan . '%')->whereNull('congvandis.deleted_at')->orderBy('ngaynhap', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
         } else {
             if ($loaivanban != 0) {
                 $congvandis = Congvandi::where('phong_id', $phongid)->whereRaw($querynamvanban)->where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvandi', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandiso)->where('socongvandichu', 'LIKE', '%' . $socongvandichu . '%')->Where('noinhancongvan', 'LIKE', '%' . $noinhancongvan . '%')->whereNull('congvandis.deleted_at')->orderBy('ngaynhap', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
             }
         }
         // Tim kiem nang cao
         // input
         $timnangcao = Input::get('timnangcao-checkbox');
         //input
         $noisoanthao = Input::get('noisoanthao');
         //
         $nguoiky = Input::get('nguoiky');
         //
         $capphathanh = Input::get('capphathanh');
         $noiphathanh = Input::get('noiphathanh');
         $domat = Input::get('domatcongvan');
         $mucdich = Input::get('mucdich');
         $linhvucchuyende = Input::get('linhvucchuyende');
         //
         $chuyende = Input::get('chuyende');
         $hinhthucchuyen = Input::get('hinhthucchuyen');
         $dokhan = Input::get('dokhancongvan');
         $querynoisoanthao = '';
         $querynguoiky = '';
         $queryhinhthucchuyen = '';
         $querycapphathanh = '';
         $querynoiphathanh = '';
         $querydomat = '';
         $querydokhan = '';
         $querymucdich = '';
         $querylinhvucchuyende = '';
         $querychuyende = '';
         // noi soan thao
         if ($noisoanthao != 0) {
             $querynoisoanthao = 'noisoanthao_id = ' . $noisoanthao;
         } else {
             $querynoisoanthao = 'noisoanthao_id != 0';
         }
         // nguoi ky
         if ($nguoiky != 0) {
             $querynguoiky = 'nguoiky_id = ' . $nguoiky;
         } else {
             $querynguoiky = 'nguoiky_id != 0';
         }
         // hinh thuc chuyen
         if ($hinhthucchuyen != 0) {
             $queryhinhthucchuyen = 'danhmuchinhthucchuyen_id = ' . $hinhthucchuyen;
         } else {
             $queryhinhthucchuyen = 'danhmuchinhthucchuyen_id != 0';
         }
         //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';
         }
         // độ khẩn
         if ($dokhan != 0) {
             $querydokhan = 'danhmucdokhan_id = ' . $dokhan;
         } else {
             $querydokhan = 'danhmucdokhan_id != 0';
         }
         if ($timnangcao == 'on') {
             if ($loaivanban == 0) {
                 isset($loaivanban);
                 $congvandis = Congvandi::where('phong_id', $phongid)->whereRaw($querynamvanban)->where('trichyeucongvandi', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandiso)->where('socongvandichu', 'LIKE', '%' . $socongvandichu . '%')->Where('noinhancongvan', 'LIKE', '%' . $noinhancongvan . '%')->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->whereRaw($querydokhan)->whereRaw($querynoisoanthao)->whereRaw($querynguoiky)->whereRaw($queryhinhthucchuyen)->whereNull('congvandis.deleted_at')->orderBy('ngaynhap', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
             } else {
                 if ($loaivanban != 0) {
                     $congvandis = Congvandi::where('phong_id', $phongid)->whereRaw($querynamvanban)->where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvandi', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandiso)->where('socongvandichu', 'LIKE', '%' . $socongvandichu . '%')->Where('noinhancongvan', 'LIKE', '%' . $noinhancongvan . '%')->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->whereRaw($querydokhan)->whereRaw($querynoisoanthao)->whereRaw($querynguoiky)->whereRaw($queryhinhthucchuyen)->whereNull('congvandis.deleted_at')->orderBy('ngaynhap', '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('ngayphathanhcongvan-start'))));
         $ngayphathanhtoi = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayphathanhcongvan-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'))));
         $ngaynhaptu = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngaynhapcongvan-start'))));
         $ngaynhaptoi = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngaynhapcongvan-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'))));
         $ngayhantraloitu = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngaytraloicongvan-start'))));
         $ngayhantraloitoi = date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngaytraloicongvan-end'))));
         // validate
         //if($ngayphathanhtu > $ngayphathanhtoi)
         //{
         //return \Redirect::url('timkiemcongvandi')->withErrors('Ngày lưu tới phải lớn hơn!');
         //}
         //if($ngaykytu > $ngaykytoi)
         //{
         //return \Redirect::url('timkiemcongvandi')->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 ($ngaynhaptu == '1970-01-01' && $ngaynhaptoi == '1970-01-01') {
             $ngaynhaptoi = $ngayhientai;
         }
         if ($ngaykytu == '1970-01-01' && $ngaykytoi == '1970-01-01') {
             $ngaykytoi = $ngayhientai;
         }
         if ($ngayhantraloitu == '1970-01-01' && $ngayhantraloitoi == '1970-01-01') {
             $ngayhantraloitoi = $ngayhientai;
         }
         // input
         $timnangcaotheothoigian = Input::get('timnangcao-checkbox-thoigian');
         if ($timnangcaotheothoigian == 'on') {
             if ($loaivanban == 0) {
                 $congvandis = Congvandi::where('phong_id', $phongid)->where('trichyeucongvandi', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandiso)->where('socongvandichu', 'LIKE', '%' . $socongvandichu . '%')->Where('noinhancongvan', 'LIKE', '%' . $noinhancongvan . '%')->where('ngaynhap', '>=', $ngaynhancongvantu)->where('ngaynhap', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->where('ngayphathanh', '>=', $ngayphathanhtu)->where('ngayphathanh', '<=', $ngayphathanhtoi)->where('hantraloi', '>=', $ngayhantraloitu)->where('hantraloi', '<=', $ngayhantraloitoi)->whereNull('congvandis.deleted_at')->orderBy('ngaynhap', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
             } else {
                 if ($loaivanban != 0) {
                     $congvandis = Congvandi::where('phong_id', $phongid)->where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvandi', 'LIKE', '%' . $noidung . '%')->WhereRaw($querysocongvandiso)->where('socongvandichu', 'LIKE', '%' . $socongvandichu . '%')->Where('noinhancongvan', 'LIKE', '%' . $noinhancongvan . '%')->where('ngaynhap', '>=', $ngaynhancongvantu)->where('ngaynhap', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->where('ngayphathanh', '>=', $ngayphathanhtu)->where('ngayphathanh', '<=', $ngayphathanhtoi)->where('hantraloi', '>=', $ngayhantraloitu)->where('hantraloi', '<=', $ngayhantraloitoi)->whereNull('congvandis.deleted_at')->orderBy('ngaynhap', '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) {
                 $congvandis = Congvandi::where('phong_id', $phongid)->where('trichyeucongvandi', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandiso)->where('socongvandichu', 'LIKE', '%' . $socongvandichu . '%')->Where('noinhancongvan', 'LIKE', '%' . $noinhancongvan . '%')->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->whereRaw($querydokhan)->whereRaw($querynoisoanthao)->whereRaw($querynguoiky)->whereRaw($queryhinhthucchuyen)->where('ngaynhap', '>=', $ngaynhancongvantu)->where('ngaynhap', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->where('ngayphathanh', '>=', $ngayphathanhtu)->where('ngayphathanh', '<=', $ngayphathanhtoi)->where('hantraloi', '>=', $ngayhantraloitu)->where('hantraloi', '<=', $ngayhantraloitoi)->whereNull('congvandis.deleted_at')->orderBy('ngaynhap', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
             } else {
                 if ($loaivanban != 0) {
                     $congvandis = Congvandi::where('phong_id', $phongid)->where('danhmucloaicongvan_id', '=', $loaivanban)->where('trichyeucongvandi', 'LIKE', '%' . $noidung . '%')->whereRaw($querysocongvandiso)->where('socongvandichu', 'LIKE', '%' . $socongvandichu . '%')->Where('noinhancongvan', 'LIKE', '%' . $noinhancongvan . '%')->whereRaw($querydomat)->whereRaw($querymucdich)->whereRaw($querylinhvucchuyende)->whereRaw($querychuyende)->whereRaw($querynoisoanthao)->whereRaw($querynguoiky)->whereRaw($queryhinhthucchuyen)->whereRaw($querydokhan)->where('ngaynhap', '>=', $ngaynhancongvantu)->where('ngaynhap', '<=', $ngaynhancongvantoi)->where('ngayky', '>=', $ngaykytu)->where('ngayky', '<=', $ngaykytoi)->where('ngayphathanh', '>=', $ngayphathanhtu)->where('ngayphathanh', '<=', $ngayphathanhtoi)->where('hantraloi', '>=', $ngayhantraloitu)->where('hantraloi', '<=', $ngayhantraloitoi)->whereNull('congvandis.deleted_at')->orderBy('ngaynhap', 'desc')->orderBy('updated_at')->orderBy('created_at')->get();
                 }
             }
         }
         // end tim kiem nang cao full
         $chucnang = 'timkiemcongvandi';
         $rolechucnangsearchs = Role::getRolebyRoleId($chucnang, Auth::user()->role_id);
         return view('congvandi.result')->with(array('congvandis' => $congvandis, 'menus' => $this->menus, 'loaicongvans' => $loaicongvans, 'domats' => $domats, 'dokhans' => $dokhans, 'mucdichs' => $mucdichs, 'linhvucchuyendes' => $linhvucchuyendes, 'chuyendes' => $chuyendes, 'noisoanthaos' => $noisoanthaos, 'hinhthucchuyens' => $hinhthucchuyens, 'noisoanthaos' => $noisoanthaos, 'nguoikys' => $nguoikys, 'hinhthucchuyens' => $hinhthucchuyens, 'rolechucnangsearchs' => $rolechucnangsearchs));
     } else {
         return \Redirect::route('congvandi.index')->with('message-error', 'Không có quyền truy cập');
     }
 }
 public function destroyAll(Request $request)
 {
     if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Xoa == 1) {
         $map = $request->input('id');
         foreach ($map as $value) {
             $danhmucnhomdonvi = Danhmucnhomdonvi::findOrFail($value);
             $danhmucnhomdonvi->delete();
         }
         $message = 'Xóa thành công';
         return response()->json($message);
     } else {
         return \Redirect::route('danhmucnhomdonvi.index')->with('message-error', 'Không có quyền truy cập');
     }
 }