/** * Post login */ public function postLogin() { $rules = ['username' => 'required', 'password' => 'required']; $validator = Validator::make(Input::all(), $rules); if ($validator->passes()) { if (Auth::attempt(array('username' => Input::get('username'), 'password' => Input::get('password')))) { return Redirect::to('')->with('success', '로그인 되었습니다.'); } else { Input::flashOnly('username'); return Redirect::to('login')->with('error', '아이디 또는 비밀번호가 잘못되었습니다.'); } } return Redirect::to('login')->withErrors($validator); }
public function processSignup() { $validator = \Validator::make(\Input::all(), array('name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required|confirmed')); if ($validator->fails()) { \Input::flashOnly('name', 'email'); return \Redirect::to('signup')->withErrors($validator); } $user = User::firstOrNew(\Input::only('name', 'email', 'password')); if ($user->save()) { // Listen to this event to send a welcome email for example \Event::fire('auth.signup', array($user)); \Auth::login($user); } else { return \Redirect::to('signup')->withError('Invalid name, email address or password.'); } return \Redirect::to(\Config::get('laravel-app-boilerplate::redirect_after_signup', '/')); }
/** * Parses each row of the CSV file and then extracts addresses, groups by category, and GeoCodes address data. * Sends GeoCoded coordinates to mapview.blade View where the Maps API v3 places markers at those locations * @return View */ public function processHeaders() { //flash old input to session in case of errors Input::flashOnly('filePath'); //setup holding array for locations ordered by category $groupedLocations = array(); // Create $locations array to hold address + zip of each row $locations = array(); // Check if all values in the input array only appear once $data = array_count_values(Input::all()); foreach ($data as $key => $value) { if ($value != 1) { return Redirect::to('/')->withInput()->with('errorMsg', 'Multiple headers cannot reference the same column.'); } } //our data is now the keys (integers) of each column. This is a 0-based column index $inputCSV = Reader::createFromPath(urldecode(Input::get('filePath'))); $inputCSV->setDelimiter(','); $validRows = $inputCSV->addFilter(function ($row, $index) { return $index > 0; //ignore headers })->addFilter(function ($row) { return isset($row[Input::get('zip')], $row[Input::get('address')], $row[Input::get('category')]); //only get rows where zip, addr, and category are filled })->fetchAll(); // Loop through fetched rows from CSV for ($i = 0; $i < sizeof($validRows); $i++) { //Add addresses to $locations array formatted as: 555+Address+St+ZIPCODE $locations[] = array('addrMarker' => urlencode($validRows[$i][Input::get('address')] . " " . $validRows[$i][Input::get('zip')]), 'category' => $validRows[$i][Input::get('category')]); } // Get geocoded coordinates for each entry in $location foreach ($locations as $location) { $geocodedLoc = Geocoder::geocode('json', array('address' => $location['addrMarker'])); // Hold Geocoded coordinates $tempLatLang = json_decode($geocodedLoc, $assoc = true); // Build grouped array based on category data // Create new subarray for each unique category if (!isset($groupedLocations[$location['category']])) { $groupedLocations[$location['category']] = array(); } $groupedLocations[$location['category']][] = array('lat' => $tempLatLang['results'][0]['geometry']['location']['lat'], 'lng' => $tempLatLang['results'][0]['geometry']['location']['lng'], 'category' => $location['category']); } return View::make('mapview')->with('mapDataPts', $groupedLocations); }
public function consultaContacto() { $data = Input::all(); Input::flashOnly('nombre', 'email', 'telefono', 'consulta'); $reglas = array('email' => array('required', 'email'), 'nombre' => array('required')); $validator = Validator::make($data, $reglas); if ($validator->fails()) { $messages = $validator->messages(); if ($messages->has('nombre')) { $mensaje = $messages->first('nombre'); } elseif ($messages->has('email')) { $mensaje = $messages->first('email'); } else { $mensaje = Lang::get('controllers.cliente.datos_consulta_contacto_incorrectos'); } return Redirect::to('/contacto')->with('mensaje', $mensaje)->with('error', true)->withInput(); } else { $this->array_view['data'] = $data; Mail::send('emails.consulta-contacto', $this->array_view, function ($message) use($data) { $message->from($data['email'], $data['nombre'])->to('*****@*****.**')->subject('Consulta'); }); if (count(Mail::failures()) > 0) { $mensaje = Lang::get('controllers.cliente.consulta_no_enviada'); } else { $data['nombre_apellido'] = $data['nombre']; Cliente::agregar($data); $mensaje = Lang::get('controllers.cliente.consulta_enviada'); } if (isset($data['continue']) && $data['continue'] != "") { switch ($data['continue']) { case "contacto": return Redirect::to('contacto')->with('mensaje', $mensaje); break; case "menu": $menu = Menu::find($data['menu_id']); return Redirect::to('/' . $menu->url)->with('mensaje', $mensaje); break; } } return Redirect::to("/")->with('mensaje', $mensaje); //return View::make('producto.editar', $this->array_view); } }
public function agregarPedido() { $input = Input::all(); Input::flashOnly('nombre', 'email', 'empresa', 'telefono', 'consulta'); $reglas = array('email' => array('required', 'email'), 'nombre' => array('required'), 'telefono' => array('required')); $validator = Validator::make($input, $reglas); if ($validator->fails()) { $messages = $validator->messages(); if ($messages->has('nombre')) { $mensaje = $messages->first('nombre'); } elseif ($messages->has('email')) { $mensaje = $messages->first('email'); } elseif ($messages->has('telefono')) { $mensaje = $messages->first('telefono'); } else { $mensaje = Lang::get('controllers.pedido.datos_consulta_contacto_incorrectos'); } return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true)->withInput(); } else { $productos = array(); if (Session::has('carrito')) { $carrito_id = Session::get('carrito'); $carrito = Carrito::find($carrito_id); $datos = DB::table('carrito_producto')->where('carrito_id', $carrito->id)->where('estado', 'A')->get(); foreach ($datos as $prod) { $data = array('id' => $prod->producto_id, 'cantidad' => $prod->cantidad, 'precio' => $prod->precio); array_push($productos, $data); } } if (count($productos) == 0) { $mensaje = Lang::get('controllers.pedido.debe_tener_producto'); return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true)->withInput(); } else { //Levanto los datos del formulario del presupuesto para //generar la persona correspondiente al pedido $datos_persona = array('email' => Input::get('email'), 'apellido' => Input::get('nombre'), 'nombre' => Input::get('empresa'), 'tipo_telefono_id' => 2, 'telefono' => Input::get('telefono')); $persona = Persona::agregar($datos_persona); if ($persona['error']) { $mensaje = Lang::get('controllers.pedido.error_realizar_pedido'); return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true); } else { $datos_pedido = array('persona_id' => $persona['data']->id, 'productos' => $productos); $respuesta = Pedido::agregar($datos_pedido); if ($respuesta['error']) { return Redirect::to('/carrito')->with('mensaje', $respuesta['mensaje'])->with('error', true); } else { $datos_resumen_pedido = array('persona_id' => $persona['data']->id, 'productos' => $productos, 'email' => Input::get('email'), 'nombre' => Input::get('nombre'), 'telefono' => Input::get('telefono'), 'empresa' => Input::get('empresa'), 'consulta' => Input::get('consulta')); $envio_mail = $this->resumenPedido($datos_resumen_pedido); if ($envio_mail) { Cart::destroy(); Session::forget('carrito'); $mensaje = Lang::get('controllers.pedido.presupuesto_enviado'); return Redirect::to('/')->with('mensaje', $mensaje)->with('ok', true); } else { $mensaje = Lang::get('controllers.pedido.presupuesto_no_enviado'); return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true); } } } } } }
public function actualizarTabla() { $datos = Input::all(); if (Auth::User()->Rol_Id == 7 or Auth::User()->Rol_Id == 1 or $datos['AreaActual'] == 19) { Input::flashOnly('new-nombre'); //$datos = Input::all(); $nuevoItem = new Contenido(); if ($datos['IdTipoDeContenido'] == 1) { $IdItem = $nuevoItem->nuevoItem($datos, NULL, NULL); Session::flash('msg', 'Item publicado correctamente.'); return Redirect::action('SIGController@editarTabla', array('IdSeccion' => $datos['IdSeccion'], 'IdATS' => $datos['IdATS'], 'TipoContenido' => $datos['IdTipoDeContenido'], 'area' => $datos['AreaActual'])); } else { $file = Input::file('set-archivo'); $fileExt = Input::file('set-archivo')->getClientOriginalExtension(); $fileSize = Input::file('set-archivo')->getSize(); $SizeKB = $fileSize / 1000; if ($SizeKB > 20000) { Session::flash('msgf', 'El tamaño máximo por archivo es de 20 MB.'); return Redirect::action('SIGController@editarTabla', array('IdSeccion' => $datos['IdSeccion'], 'IdATS' => $datos['IdATS'], 'TipoContenido' => $datos['IdTipoDeContenido'], 'area' => $datos['AreaActual']))->withInput(); } if ($fileExt == 'exe' or $fileExt == 'sql') { Session::flash('msgf', 'Debe subir un archivo en formato PDF, Word o Excel.'); return Redirect::action('SIGController@editarTabla', array('IdSeccion' => $datos['IdSeccion'], 'IdATS' => $datos['IdATS'], 'TipoContenido' => $datos['IdTipoDeContenido'], 'area' => $datos['AreaActual']))->withInput(); } $url_doc = $file->getClientOriginalName(); if (!preg_match('/^[\\x20-\\x7e]*$/', $url_doc)) { Session::flash('msgf', 'El nombre del archivo no puede contener caracteres especiales.'); return Redirect::action('SIGController@editarTabla', array('IdSeccion' => $datos['IdSeccion'], 'IdATS' => $datos['IdATS'], 'TipoContenido' => $datos['IdTipoDeContenido'], 'area' => $datos['AreaActual']))->withInput(); } $getNombreArea = Area::where('IdArea', $datos['AreaActual'])->first(); $getNombreSeccion = Secciones::where('IdSeccion', $datos['IdSeccion'])->first(); $path = 'contenido-sig\\archivos\\' . $getNombreArea->NombreArea . '\\' . $getNombreSeccion->NombreSeccion . '\\' . $url_doc; $destinoPath = public_path() . '\\contenido-sig\\archivos\\' . $getNombreArea->NombreArea . '\\' . $getNombreSeccion->NombreSeccion; $subir = $file->move($destinoPath, $url_doc); $IdItem = $nuevoItem->nuevoItem($datos, $path, $fileExt); Session::flash('msg', 'Item publicado correctamente.'); return Redirect::action('SIGController@editarTabla', array('IdSeccion' => $datos['IdSeccion'], 'IdATS' => $datos['IdATS'], 'TipoContenido' => $datos['IdTipoDeContenido'], 'area' => $datos['AreaActual'])); } } else { return Redirect::to('/SIG'); } }
public function iescmpl_nuevoOficio_registrar() { Input::flashOnly('IdOficio', 'DirigidoA', 'FechaEmision', 'FechaRecepcion', 'Asunto', 'IdOficioR', 'FechaLimiteR'); $file = Input::file('DocPDF'); if ($file == NULL) { Session::flash('msgf', 'Debe subir un archivo en formato PDF.'); return Redirect::action('OficiosSalientesController@iescmpl_nuevoOficio')->withInput(); } $fileExt = Input::file('DocPDF')->getClientOriginalExtension(); if ($fileExt != 'pdf' or $fileExt == NULL) { Session::flash('msgf', 'Debe subir un archivo en formato PDF.'); return Redirect::action('OficiosSalientesController@iescmpl_nuevoOficio')->withInput(); } $url_docpdf = $file->getClientOriginalName(); if (!preg_match('/^[\\x20-\\x7e]*$/', $url_docpdf)) { Session::flash('msgf', 'El nombre del archivo PDF no puede contener los caracteres /^[\\-]*$'); return Redirect::action('OficiosEntrantesController@iescmpl_nuevoOficio')->withInput(); } $path = 'oficios\\salientes\\' . $url_docpdf; $destinoPath = public_path() . '\\oficios\\salientes\\'; $subir = $file->move($destinoPath, $url_docpdf); //.'.'.$file->guessExtension()); $datos = Input::all(); $correspondenciaSaliente = new Correspondencia(); $addDatosConfidenciales = new DatosConfidenciales(); $addAnexos = new Anexo(); $oficio = new OficioSaliente(); if ($IdCorrespondencia = $correspondenciaSaliente->nuevaCorrespondenciaSaliente($datos, $path)) { if ($datos['hidden-TagsConfidenciales'] != NULL) { $IdDatos = $addDatosConfidenciales->nuevoDatoConf($datos['hidden-TagsConfidenciales'], $IdCorrespondencia); } if ($datos['hidden-TagsAnexos'] != NULL) { $IdAnexos = $addAnexos->nuevoAnexo($datos['hidden-TagsAnexos'], $IdCorrespondencia); } $IdOficioE = $oficio->nuevoOficioSaliente($datos, $IdCorrespondencia); $Emisor = EntidadExterna::where('IdEntidadExterna', $datos['Destinatario'])->first(); if ($Emisor->DepArea_Cargo_Id != $datos['CargoEmisor']) { $upEmisor = $Emisor->updateCargoSaliente($datos); } if ($Emisor->Dependencia_Area_Id == NULL) { $DTA = new DependenciaTieneArea(); $IdDepTieneArea = $DTA->nuevaDependenciaTieneArea($datos); $AgregarArea = $Emisor->updateAreaSaliente($datos, $IdDepTieneArea); } else { $DepTieneArea = DependenciaTieneArea::where('IdDependenciaTieneArea', $Emisor->Dependencia_Area_Id)->first(); if ($DepTieneArea->DepArea_Id != $datos['AreaE']) { $UpETA = $DepTieneArea->upDateETA($datos, $Emisor->Dependencia_Area_Id); } if ($DepTieneArea->Dependencia_Id != $datos['DependenciaE']) { $UpDTA = $DepTieneArea->updateDependencia($datos, $DepTieneArea->IdDependenciaTieneArea); } } //$fecha = new DateTime(); //$UTC = new UsuarioTurnaCorrespondencia(); //$IdUTC = $UTC->turnarA(Auth::User()->IdUsuario,$IdCorrespondencia,$datos['DirigidoA'],1,$fecha); Session::flash('msg', 'Registro de oficio saliente realizado correctamente.'); return Redirect::action('OficiosController@iescmpl_salientes'); } else { Session::flash('msgf', 'Error al registrar nuevo oficio entrante.'); return Redirect::action('OficiosController@iescmpl_salientes'); } }