Example #1
0
 public function obtenerPorHotel($id)
 {
     $disponibilidad = disponibilidad::where('identidad', $id)->get();
     foreach ($disponibilidad as $disponible) {
         $codHab = habitacionesPerfil::where('id', $disponible->idhabitacion)->first();
         $tipohab = habitacion::where('id', $codHab->idperfilhabitacion)->first();
         $disponible['codigo'] = $codHab->codigo;
         $disponible['tipohabitacion'] = $tipohab->nombretipo;
     }
     return $disponibilidad;
 }
Example #2
0
 public function tieneDisponibilidad($id, $fecha)
 {
     $estaDisponible = false;
     $habitaciones = habitacion::where('identidad', $id)->get();
     $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) {
         if ($h['disponible'] == true) {
             $estaDisponible = true;
         }
     }
     return $estaDisponible;
 }
Example #3
0
 public function deleteById($id)
 {
     $isDeleted = habitacion::where('id', $id)->delete();
     return $isDeleted;
 }
Example #4
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);
     }
 }
Example #5
0
 public function getServicesHabitacion(Request $request, $idHabitacion)
 {
     $servhab = new habitacion();
     $habitacion = habitacion::where('id', $idHabitacion)->first();
     $servicios = (array) $habitacion['attributes'];
     $array_keys = array_keys($servicios);
     $nombreFotos = $servhab->nombreFotos();
     $nombres = $servhab->nombres();
     for ($i = 0; $i < 7; $i++) {
         unset($array_keys[$i]);
     }
     unset($array_keys[23]);
     unset($array_keys[24]);
     $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;
 }
Example #6
0
 public function storeHabitacion(habitacionRequest $request)
 {
     $request['identidad'] = Session::get("idEnt");
     unset($request['_token']);
     $habitacion = new habitacion();
     $habsiguales = habitacion::where('identidad', Session::get("idEnt"))->where('nombretipo', $request['nombretipo'])->get();
     if ($habsiguales->isEmpty()) {
         try {
             $statusCode = 200;
             $habitacion = $habitacion->crearNuevo($request->all());
             $response = ['success' => true, 'datahabitacion' => $habitacion, 'idHab' => $habitacion->id, 'message' => 'Habitacion guardada con exito'];
         } catch (Exception $e) {
             $response = ["error" => $e->getMessage()];
             $statusCode = 400;
         } finally {
             return Response::json($response, $statusCode);
         }
     } else {
         $statusCode = 200;
         $response = ['success' => false, 'message' => 'Nombre del perfil ya existe.'];
         return Response::json($response, $statusCode);
     }
 }