public function congvandixuatexcel(IncongvandiFormRequest $request)
 {
     $phongid = User::where('id', Auth::user()->id)->value('phong_id');
     $ngaynhanbatdau = $request->input('ngaynhanbatdau');
     $ngaynhanketthuc = $request->input('ngaynhanketthuc');
     //\DB::connection()->setFetchMode(\PDO::FETCH_ASSOC);
     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('baocaocongvandi.index')->withErrors('Ngày nhận bắt đầu phải nhỏ hơn ngày nhận kết thúc!')->withInput();
         } else {
             $congvandis = Congvandi::join('canbos', 'congvandis.nguoiky_id', '=', 'canbos.id')->join('danhmucchucvus', 'canbos.danhmucchucvu_id', '=', 'danhmucchucvus.id')->join('danhmucdomats', 'congvandis.danhmucdomat_id', '=', 'danhmucdomats.id')->where('ngayphathanh', '>=', $ngaynhanbatdau)->where('ngayphathanh', '<=', $ngaynhanketthuc)->where('congvandis.phong_id', $phongid)->select('congvandis.id', 'congvandis.socongvandiso', 'congvandis.socongvandichu', 'congvandis.ngayphathanh', 'congvandis.trichyeucongvandi', 'congvandis.noinhancongvan', 'congvandis.noiluu', 'danhmucdomats.name as domat', 'canbos.name as hoten', 'danhmucchucvus.name as chucvu')->orderBy('congvandis.socongvandiso')->get();
         }
     }
     $tungays = date('d/m/Y', strtotime($ngaynhanbatdau));
     //date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayphathanh-start'))) ) ;
     $denngays = date('d/m/Y', strtotime($ngaynhanketthuc));
     $date = date('d/m/Y');
     $filename = 'Bao_cao_cong_van_di_tu_ngay_' . str_replace('/', '_', $tungays) . '_den_ngay_' . str_replace('/', '_', $denngays);
     \Excel::create($filename, function ($excel) use($congvandis, $tungays, $denngays) {
         $excel->sheet('New sheet', function ($sheet) use($congvandis, $tungays, $denngays) {
             $endcell = count($congvandis) + 5;
             $sheet->loadView('incongvan.resultexcelcongvandi')->with(['congvandis' => $congvandis, 'tungay' => $tungays, 'denngay' => $denngays]);
             $sheet->mergeCells('A1:G1');
             $sheet->mergeCells('A3:G3');
             $sheet->cell('A1:G1', function ($cells) {
                 $cells->setAlignment('center');
             });
             $sheet->cell('A3:G3', function ($cells) {
                 $cells->setAlignment('center');
             });
             $sheet->cell('A5:G5', function ($cells) {
                 $cells->setAlignment('center');
             });
             $sheet->setAutoSize(true);
             //dd($endcell);
             $sheet->setBorder('A5:G' . $endcell . '');
             $sheet->setBorder('A1:G4', 'none');
         });
     })->export('xls');
 }
 public function resultnoisoanthaonguoiky(IncongvandiFormRequest $request)
 {
     $menus = Menu::all();
     $ngaynhanbatdau = $request->input('ngaynhanbatdau');
     $ngaynhanketthuc = $request->input('ngaynhanketthuc');
     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('baocaocongvandi.noisoanthaonguoiky')->withErrors('Ngày nhận bắt đầu phải nhỏ hơn ngày nhận kết thúc!')->withInput();
         } else {
             $congvandis = Congvandi::where('ngayphathanh', '>=', $ngaynhanbatdau)->where('ngayphathanh', '<=', $ngaynhanketthuc)->get();
         }
     }
     //$tungay = '01/02/2015';
     //$denngay = '01/06/2015';
     $tungays = date('d/m/Y', strtotime($ngaynhanbatdau));
     //date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayphathanh-start'))) ) ;
     $denngays = date('d/m/Y', strtotime($ngaynhanketthuc));
     //echo '<pre>';
     //print_r($congvandis);
     return view('baocaocongvandi.noisoanthaonguoiky')->with(['menus' => $this->menus, 'tungay' => $tungays, 'denngay' => $denngays, 'congvandis' => $congvandis])->withInput($request);
 }
示例#3
0
 public static function checksocongvandiso($socongvandiso, $phong_id)
 {
     $find = Congvandi::where('socongvandiso', $socongvandiso)->where('phong_id', $phong_id)->first();
     if ($find) {
         return TRUE;
     }
     return FALSE;
 }
 public function destroyall(Request $request)
 {
     if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Xoa == 1) {
         $map = $request->input('id');
         //var_dump($map);
         foreach ($map as $key => $value) {
             //var_dump($value);
             $congvandi = Congvandi::findOrFail($value);
             $congvandi->delete();
         }
         $message = "Xóa thành công";
         return response()->json($message);
     } else {
         return \Redirect::route('congvandi.index')->with('message-error', 'Không có quyền truy cập');
     }
 }
示例#5
0
 /**
  * check cong van di file is download by user
  * @param $filedown
  * @param $user
  * @return mixed
  */
 public static function downloadcongvandibyusername($filedown, $user)
 {
     $filedown_id = File::getIdByFileName($filedown);
     $is_download = Congvandi::join('file_congvandis', 'congvandis.id', '=', 'file_congvandis.congvandi_id')->leftjoin('congvandi_danhmucphongs', 'congvandis.id', '=', 'congvandi_danhmucphongs.congvandi_id')->leftjoin('congvandi_danhmucdois', 'congvandis.id', '=', 'congvandi_danhmucdois.congvandi_id')->leftjoin('congvandi_users', 'congvandis.id', '=', 'congvandi_users.congvandi_id')->where('congvandis.nguoitao_id', $user->id)->orWhere('congvandi_danhmucphongs.danhmucphong_id', $user->phong_id)->orWhere('congvandi_danhmucdois.danhmucdoi_id', $user->doi_id)->orWhere('congvandi_users.user_id', $user->id)->where('file_congvandis.file_id', $filedown_id)->first();
     return $is_download;
 }
示例#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));
 }