예제 #1
0
 public function postLogin(Request $request)
 {
     //Arrays needed
     $estado = new estados();
     $estados = $estado->getEstados();
     $respuesta = ['loginSelected' => "toggled", 'regSelected' => "", 'recoverSelected' => "", 'regSuccess' => "", 'estados' => $estados];
     //Authenticating the user
     if (AdminAuth::login($request->userName, $request->password)) {
         if (AdminAuth::isSuperAdmin(Session::get('idEnt'))) {
             return view('adminSuper.super-principal');
         } else {
             $entidad = entidadTuristica::where("rif", Session::get('idEnt'))->first();
             if ($entidad->tipoentidad == "Hotel") {
                 return view('adminHotel.hotel-principal')->with(['foto' => $entidad->imagen]);
             } else {
                 return view('adminEntidad.entidad-principal')->with(['foto' => $entidad->imagen]);
             }
         }
     } else {
         return view("login2")->with($respuesta)->withErrors(["login" => 'No existe un usuario con esas credenciales']);
     }
 }
예제 #2
0
 public function transformForPaginate($hoteles)
 {
     if (count($hoteles) > 0) {
         $ids = [];
         foreach ($hoteles as $hotel) {
             array_push($ids, $hotel->rif);
         }
         $new = entidadTuristica::where(function ($q) use($ids) {
             foreach ($ids as $id) {
                 $q->orWhere('rif', $id);
             }
         })->paginate(4);
     } else {
         $new = [];
     }
     return $new;
 }
예제 #3
0
 public function sendEmailContact(Request $request)
 {
     $email = userAdmin::where('identidad', $request->identidad)->first();
     $ent = entidadTuristica::where('rif', $request->identidad)->first();
     $camas = new camas();
     $hab = new habitacion();
     $email = $email->email;
     // Buscando habitaciones para el email de respaldo de la persona
     // todo este codigo deberia estar en una función aparte -- mejorar modularidad en codigo para futuros proyectos.
     $legalMessage = "";
     $f = "";
     $f2 = "";
     if ($ent->tipoentidad == "Hotel") {
         $habitaciones = habitacion::where('identidad', $request->identidad)->get();
         $camas = $camas->camasPorHabitacion($habitaciones);
         $habitaciones = $hab->serviciosOrdenados($habitaciones);
         $desde = Carbon::now();
         $desdeInicio = Carbon::create($desde->year, $desde->month, 1);
         $desdeFin = Carbon::create($desde->year, $desde->month, $desde->daysInMonth);
         $desdeInicio = $desdeInicio->toDateString();
         $desdeFin = $desdeFin->toDateString();
         $dias = 1;
         $legalMessage = "NOTA: Las tarifas son validas desde el " . $desdeInicio . " hasta el " . $desdeFin . " y las mismas estan sujetas a cambios.";
         if (Session::has('fecha')) {
             $fecha = explode(" - ", Session::get('fecha'));
             $f = new Carbon($fecha[0]);
             $f2 = new Carbon($fecha[1]);
             $dias = $f->diffInDays($f2);
             $query = " SELECT idperfilhabitacion FROM habitacionesperfil WHERE id NOT IN ( SELECT disponibilidad.idhabitacion from disponibilidad WHERE (estado = 'Habilitado')\n                AND ((disponibilidad.fecha_inicio BETWEEN '" . $fecha[0] . "' AND '" . $fecha[1] . "')\n                OR (disponibilidad.fecha_fin BETWEEN '" . $fecha[0] . "' AND '" . $fecha[1] . "')\n                OR ( ('" . $fecha[0] . "' >= disponibilidad.fecha_inicio) AND ('" . $fecha[1] . "' <= disponibilidad.fecha_fin) ) ) ) ";
             $search = DB::select(DB::raw($query));
             $arraySearch = [];
             foreach ($search as $s) {
                 array_push($arraySearch, $s->idperfilhabitacion);
             }
             foreach ($habitaciones as $h) {
                 $h['disponible'] = in_array($h->id, $arraySearch);
             }
         }
         foreach ($habitaciones as $h) {
             $h['total'] = $dias * $h['tarifa'];
         }
     } else {
         $habitaciones = null;
     }
     $data = ['nombre' => $request->nombre, "email" => $request->email, "telefono" => $request->telefono, "mensaje" => $request->mensaje];
     $data2 = ['habitaciones' => $habitaciones, 'legalMessage' => $legalMessage, 'nombreEntidad' => $ent->nombre, 'f' => $f->toDateString(), 'f2' => $f2->toDateString()];
     $response;
     $statusCode;
     try {
         Mail::send('emails.contacto', $data, function ($message) use($email) {
             $message->from(env('MAIL_USERNAME'), 'AppHoteles');
             $message->subject('Contacto - AppHoteles');
             // Aqui iria el titulo...
             $message->to($email);
         });
         Mail::send('emails.usuarioContacto', $data2, function ($message) use($request) {
             $message->from(env('MAIL_USERNAME'), 'AppHoteles');
             $message->subject('Contacto - AppHoteles');
             // Aqui iria el titulo...
             $message->to($request->email);
         });
         $response = ['success' => true, 'message' => 'Email enviado.'];
         $statusCode = 200;
     } catch (Exception $e) {
         $response = ["error" => $e->getMessage()];
         $statusCode = 400;
     } finally {
         return Response::json($response, $statusCode);
     }
 }
예제 #4
0
 public function passwordRecovery(Request $request)
 {
     $response;
     $statusCode;
     $newPassword = str_random(8);
     $user = userAdmin::where('email', $request->email)->first();
     if ($user) {
         $ent = entidadTuristica::where('rif', $user->identidad)->where("estado", "activo")->first();
         if ($ent) {
             $user->update(["password" => $newPassword]);
             try {
                 $data = ["contraseña" => $newPassword, "type" => null];
                 $email = $user->email;
                 Mail::send('emails.recovery', $data, function ($message) use($email) {
                     $message->from(env('MAIL_USERNAME'), 'AppHoteles');
                     $message->subject('Recuperacion de contraseña - AppHoteles');
                     // Aqui iria el titulo...
                     $message->to($email);
                 });
                 $response = ['success' => true, 'message' => 'Email enviado.', 'emailValid' => true];
                 $statusCode = 200;
             } catch (Exception $e) {
                 $response = ["error" => $e->getMessage()];
                 $statusCode = 400;
             }
         } else {
             $response = ['success' => true, 'emailValid' => false];
             $statusCode = 400;
         }
     } else {
         $response = ['success' => true, 'emailValid' => false];
         $statusCode = 400;
     }
     return Response::json($response, $statusCode);
 }
예제 #5
0
 public function getServices(Request $request)
 {
     $servs = new servicios();
     $hotel = entidadTuristica::where('rif', Session::get("idEnt"))->first();
     $servicios = (array) $hotel->servicios['attributes'];
     $array_keys = array_keys($servicios);
     unset($array_keys[12]);
     $nombreFotos = $servs->nombreFotos();
     $nombres = $servs->nombres();
     $respuesta = ['servicios' => $servicios, 'array_keys' => $array_keys, 'nombres' => $nombres, 'nombreFotos' => $nombreFotos];
     $view = View::make('adminHotel.serviciosHotel')->with($respuesta);
     if ($request->ajax()) {
         $sections = $view->renderSections();
         $response = Response::json(['success' => true, 'data' => $sections['serviciosHotel']], 200);
     } else {
         $response = $view;
     }
     return $response;
 }
예제 #6
0
 public function getHotel(Request $request)
 {
     $servs = new servicios();
     $hotel = entidadTuristica::where('rif', Session::get("idEnt"))->first();
     $fotos = $hotel->galeria;
     $servicios = (array) $hotel->servicios['attributes'];
     $array_keys = array_keys($servicios);
     unset($array_keys[12]);
     $nombreFotos = $servs->nombreFotos();
     $nombres = $servs->nombres();
     $galeria = new galeria();
     if ($hotel->imagen != null) {
         $idFotoPerfil = $galeria->getFotoID($hotel->imagen);
     } else {
         $idFotoPerfil = null;
     }
     $respuesta = ['hotel' => $hotel, 'fotos' => $fotos, 'servicios' => $servicios, 'array_keys' => $array_keys, 'nombres' => $nombres, 'nombreFotos' => $nombreFotos, 'idFotoPerfil' => $idFotoPerfil];
     $view = View::make('adminHotel.hotel')->with($respuesta);
     if ($request->ajax()) {
         $sections = $view->renderSections();
         $response = Response::json(['success' => true, 'data' => $sections['hotel']], 200);
     } else {
         $response = $view;
     }
     return $response;
 }