public static function getdanhsachnguoinhan($emails) { //dd($emails); $toemails = array(); foreach ($emails as $email) { $emailname = Danhmucemail::find($email); $toemails[] = $emailname->email . '@gila1.bca'; } return $toemails; }
function guimails($dataemails) { // get input //$to = $emails //$tos = preg_split("/[\s;]+/", $to); //$cc = \Input::get('nguoinhankhac'); //$ccs = preg_split("/[\s;]+/", $cc); //$subject = $dataemails->tieude; //$message = $dataemails->noidungemail; //dd($dataemails); //echo '<pre>'; //print_r($ccs); //$toEmails = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'); $toEmails = Danhmucemail::getdanhsachnguoinhan($dataemails['emails']); //$paths = File::getduongdanfileemail($dataemails['attachfiles']); //dd($toEmails); /* \Mail::send('layout.emails', $dataemails , function ($dataemails) use ($paths, $toEmails) { //$message->from('*****@*****.**', ''); $dataemails->to($toEmails)->subject('hello'); $size = count($paths); for ($i = 0; $i < $size; $i++) { $dataemails->attach($paths[$i]); } //dd($dataemails); }); */ //dd($toEmails); \Mail::send('layout.emails', $dataemails, function ($dataemails) use($toEmails) { //$message->from('*****@*****.**', ''); $dataemails->to($toEmails)->subject('hello'); echo 'ok'; }); //return $sent = 'ok'; // has file /* if (\Input::hasFile('attachment')) { $now_date = str_replace('/', '_', date('d/m/Y')); $files = \Input::file('attachment'); $newnamefiles = array(); foreach ($files as $file) { $destinationPath = 'uploads'; $filename = $file->getClientOriginalName(); $filename = File::removesign($filename); $filename = File::removespace($filename); $newfilename = $now_date . '_' . rand(1, 99999) . '_' . $filename; $upload_success = $file->move($destinationPath, $newfilename); array_push($newnamefiles, $newfilename); } $path = array(); foreach ($newnamefiles as $value) { $filepath = 'uploads/' . $value; array_push($path, $filepath); } // không cc if ($ccs[0] == '') { \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use ($path, $tos, $ccs, $subject) { $message->from('*****@*****.**', 'Lê Thanh Thái'); $message->to($tos)->subject($subject); $size = count($path); for ($i = 0; $i < $size; $i++) { $message->attach($path[$i]); } }); return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!'); } else { \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use ($path, $tos, $ccs, $subject) { $message->from('*****@*****.**', 'Lê Thanh Thái'); $message->to($tos)->cc($ccs)->subject($subject); $size = count($path); for ($i = 0; $i < $size; $i++) { $message->attach($path[$i]); } }); return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!'); } } else // no file { if ($ccs[0] == '') { \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use ($tos, $ccs, $subject) { $message->from('*****@*****.**', 'Lê Thanh Thái'); $message->to($tos)->subject($subject); }); return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!'); } else { \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use ($tos, $ccs, $subject) { $message->from('*****@*****.**', 'Lê Thanh Thái'); $message->to($tos)->cc($ccs)->subject($subject); }); return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!'); } }//end send */ }
/** * 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'); } }
/** * 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) { $noisoanthaos = Danhmucphong::get(array('id', 'name')); $nguoikys = Canbo::get(array('id', 'name')); $mucdichs = Danhmucmucdich::get(array('id', 'name')); $linhvucchuyendes = Linhvucchuyende::get(array('id', 'name')); $chuyendes = Danhmucchuyende::get(array('id', 'name')); $loaicongvans = Danhmucloaicongvan::get(array('id', 'name')); $hinhthucchuyens = Danhmuchinhthucchuyen::get(array('id', 'name')); $dokhans = Danhmucdokhan::get(array('id', 'name')); $domats = Danhmucdomat::get(array('id', 'name')); $noinhancongvans = Danhmucdonvi::all(); $phongs = Danhmucphong::orderBy('name')->get(); $dois = Danhmucdoi::orderBy('name')->get(); $canbos = User::where('role_id', '>', 2)->orderBy('name')->get(); $emails = Danhmucemail::orderBy('name')->get(); $congvandi = Congvandi::findOrFail($id); return view('congvandi.edit')->with(array('congvandi' => $congvandi, 'loaicongvans' => $loaicongvans, 'hinhthucchuyens' => $hinhthucchuyens, 'domats' => $domats, 'dokhans' => $dokhans, 'menus' => $this->menus, 'noisoanthaos' => $noisoanthaos, 'nguoikys' => $nguoikys, 'mucdichs' => $mucdichs, 'linhvucchuyendes' => $linhvucchuyendes, 'chuyendes' => $chuyendes, 'phongs' => $phongs, 'dois' => $dois, 'canbos' => $canbos, 'emails' => $emails)); } else { return \Redirect::route('congvandi.index')->with('message-error', 'Không có quyền truy cập'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Xoa == 1) { $danhmucemail = Danhmucemail::findOrFail($id); $danhmucemail->delete(); return \Redirect::route('danhmucemail.index')->with('message', 'Xóa thành công!'); } else { return \Redirect::route('danhmucemail.index')->with('message-error', 'Không có quyền truy cập'); } }