/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, CongviecCreateFormRequest $request)
 {
     if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Sua == 1) {
         $congviec = Congviec::findOrFail($id);
         $canbonhans = $request->input('nguoinhan');
         if ($canbonhans != NULL) {
             $congviecfind->users()->sync($canbonhans);
         }
         // luu file
         if ($request->input('upload-file') && $request->hasFile('files')) {
             $files = $request->file('files');
             $newnamefiles = File::savefiles($files, Auth::user()->id);
             $congviec->files()->sync($newnamefiles);
         }
         $congviec->update(['ngaybatdau' => makedatemodel($request->input('ngaybatdau')), 'ngayketthuc' => makedatemodel($request->input('ngayketthuc')), 'user_created' => $canbogiao, 'tencongviec' => $request->input('tencongviec'), 'noidungcongviec' => $request->input('noidungcongviec'), 'tinhtrangcongviec_id' => $tinhtrangcongviec]);
         return \Redirect::route('congviec.index')->with('message', 'Cập nhật thành công');
     } else {
         return \Redirect::route('congviec.index')->with('message-error', 'Không có quyền truy cập');
     }
 }
Example #2
0
 public function luunoibo(LuuMailNoiBoFormRequest $request)
 {
     if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Them == 1) {
         $tos = $request->input('nguoinhan');
         $subject = $request->input('tieude');
         $message = $request->input('noidung');
         // has file
         if ($request->hasFile('attachment')) {
             $now_date = str_replace('/', '_', date('d/m/Y'));
             $files = $request->file('attachment');
             $newnamefiles = File::savefiles($files, Auth::user()->id);
             $email = new Mymail(array('subject' => $subject, 'message' => $message, 'nguoigui_id' => \Auth::user()->id, 'draf' => 1));
             $email->save();
             $insertedId = $email->id;
             $emailfind = Mymail::findOrFail($insertedId);
             if ($tos != NULL) {
                 $emailfind->danhmuccanbosends()->sync($tos);
             }
             if ($newnamefiles) {
                 $emailfind->files()->sync($newnamefiles);
             }
             return \Redirect::route('thuden.index')->with('message', 'Lưu thành công!');
         } else {
             $email = new Mymail(array('subject' => $subject, 'message' => $message, 'nguoigui_id' => \Auth::user()->id, 'draf' => 1));
             $email->save();
             $insertedId = $email->id;
             $emailfind = Mymail::findOrFail($insertedId);
             if ($tos != NULL) {
                 $emailfind->danhmuccanbosends()->sync($tos);
             }
             return \Redirect::route('thuden.index')->with('message', 'Lưu thành công!');
         }
         //end send
     } else {
         return \Redirect::route('thuden.index')->with('message-error', 'Không có quyền truy cập');
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, CongvandiUpdateFormRequest $request)
 {
     if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Sua == 1) {
         $congvandi = Congvandi::findOrFail($id);
         // $nowtime = date();
         $nowtime = date("m/d/Y", time());
         $nowyear = date('Y');
         $namky = date('Y-m-d', strtotime(str_replace('/', '-', $request->input('ngayky'))));
         $namkys = substr($namky, 0, 4);
         $namphathanh = date('Y-m-d', strtotime(str_replace('/', '-', $request->input('ngayphathanh'))));
         $namphathanhs = substr($namphathanh, 0, 4);
         $namluu = date('Y-m-d', strtotime(str_replace('/', '-', $request->input('ngayluu'))));
         $namluus = substr($namluu, 0, 4);
         if ($namkys != $nowyear || $namphathanhs != $nowyear || $namluus != $nowyear) {
             return \Redirect::route('congvandi.edit', $id)->withErrors('Năm văn bản không đúng')->withInput();
         } else {
             //update cong van
             $congvandi->update(['socongvandichu' => $request->input('socongvandichu'), 'ngayky' => date('Y-m-d', strtotime(str_replace('/', '-', $request->input('ngayky')))), 'noisoanthao_id' => $request->input('noisoanthao'), 'nguoiky_id' => $request->input('nguoiky'), 'danhmucloaicongvan_id' => $request->input('loaicongvan'), 'sobanphathanh' => $request->input('sobanphathanh'), 'trichyeucongvandi' => $request->input('trichyeucongvandi'), 'noinhancongvan' => $request->input('noinhancongvan'), 'danhmucdomat_id' => $request->input('domatcongvan'), 'ngayphathanh' => date('Y-m-d', strtotime(str_replace('/', '-', $request->input('ngayphathanh')))), 'danhmucdokhan_id' => $request->input('dokhancongvan'), 'ngaynhap' => date('Y-m-d', strtotime(str_replace('/', '-', $request->input('ngayluu')))), 'danhmucmucdich_id' => $request->input('mucdichcongvan'), 'danhmuchinhthucchuyen_id' => $request->input('hinhthucchuyen'), 'linhvucchuyende_id' => $request->input('linhvucchuyende'), 'danhmucchuyende_id' => $request->input('chuyende'), 'hantraloi' => date('Y-m-d', strtotime(str_replace('/', '-', $request->input('hantraloi')))), 'noiluu' => $request->input('noiluutru'), 'nguoisua_id' => \Auth::user()->id]);
             $congvandifind = Congvandi::find($id);
             //var_dump($congvandifind);
             $phongs = $request->input('phong');
             if ($phongs != NULL) {
                 $congvandifind->danhmucphongs()->sync($phongs);
             } else {
                 $congvandifind->danhmucphongs()->detach();
             }
             $dois = $request->input('doi');
             if ($dois != NULL) {
                 $congvandifind->danhmucdois()->sync($dois);
             } else {
                 $congvandifind->danhmucdois()->detach();
             }
             $canbos = $request->input('canbo');
             if ($canbos != NULL) {
                 $congvandifind->danhmuccanbos()->sync($canbos);
             } else {
                 $congvandifind->danhmuccanbos()->detach();
             }
             // xu ly file
             $now_date = str_replace('/', '_', date('d/m/Y'));
             if ($request->input('upload-file') && $request->hasFile('files')) {
                 $files = $request->file('files');
                 $newnamefiles = File::savefiles($files, Auth::user()->id);
             }
             if ($request->input('upload-file') && $request->hasFile('files') && $newnamefiles) {
                 $congvandifind->files()->sync($newnamefiles);
             }
             return \Redirect::route('congvandi.index')->with('message', 'Cập nhật thành công!');
         }
     } else {
         return \Redirect::route('congvandi.index')->with('message-error', 'Không có quyền truy cập');
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function traloi($id, CongvandenTraloiFormRequest $request)
 {
     $congvandenfind = Congvanden::findOrFail($id);
     $congvandenfind->traloicongvan = $request->input('traloicongvan');
     $congvandenfind->save();
     // xu ly file
     $now_date = str_replace('/', '_', date('d/m/Y'));
     if ($request->input('upload-file') && $request->hasFile('files')) {
         $files = $request->file('files');
         $newnamefiles = File::savefiles($files, Auth::user()->id);
     }
     $traloicongvan = $request->input('traloicongvan');
     if ($request->input('upload-file') && $request->hasFile('files') && $newnamefiles) {
         $user = Auth::user();
         $congvandenfind->filetralois()->attach($newnamefiles, ['noidung' => $traloicongvan]);
         $stt = Congvanden::getsolanuptheouserid($id, $user->id);
         foreach ($newnamefiles as $value) {
             \DB::table('file_traloicongvandens')->where('congvanden_id', $id)->whereNull('user_id')->where('file_id', $value)->update(['user_id' => $user->id, 'stt' => $stt]);
         }
     } else {
         $user = Auth::user();
         $stt = Congvanden::getsolanuptheouserid($id, $user->id);
         $traloicongvankhongfile = new File_Traloicongvanden(['congvanden_id' => $congvandenfind->id, 'user_id' => $user->id, 'stt' => $stt, 'noidung' => $traloicongvan]);
         $traloicongvankhongfile->save();
     }
     return \Redirect::route('congvanden.index')->with('message', 'Trả lời thành công!');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request $request
  * @param  int $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Sua == 1) {
         $cuochopfind = Cuochop::findOrFail($id);
         $cuochopfind->update(['name' => $request->input('name'), 'phamvi' => $request->input('phamvi'), 'thoigian' => makedatemodel($request->input('thoigian')), 'luc' => $request->input('luc'), 'diadiemhop_id' => $request->input('diadiem'), 'lanhdao' => $request->input('lanhdao'), 'thuky' => $request->input('thuky'), 'danhsachthamdu' => $request->input('danhsachthamdu')]);
         // xu ly file
         if ($request->input('upload-file') && $request->hasFile('files')) {
             $files = $request->file('files');
             $newnamefiles = File::savefiles($files, Auth::user()->id);
             $cuochopfind->files()->sync($newnamefiles);
         }
         return redirect()->route('cuochop.index')->with('message', 'Cập nhật thành công');
     } else {
         return \Redirect::to('cuochop.index')->with('message-error', 'Không có quyền truy cập');
     }
 }