Example #1
0
 public function sendmailcontact()
 {
     $rules = array('titulo' => 'required', 'texto' => 'required');
     $messages = array('titulo.required' => 'El campo título es obligatorio...', 'texto.required' => 'El campo texto es obligatorio...');
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator->errors());
     } else {
         $data['autor'] = '(' . Auth::user()->username . ') ' . Auth::user()->apellidos . ', ' . Auth::user()->nombre;
         $data['titulo'] = Input::get('titulo', '');
         $data['texto'] = Input::get('texto', '');
         $data['mail'] = Auth::user()->email;
         $sgrMail = new sgrMail();
         $sgrMail->notificaContacto($data);
         Session::flash('message', 'Mensaje enviado correctamente...');
         return Redirect::back();
     }
 }
Example #2
0
 /**
  * //login
  * @return redirect::to
  */
 public function doLogin()
 {
     if (!Cas::authenticate()) {
         return Redirect::to('report.html')->with('msg', Config::get('msg.errorSSO'))->with('alertLevel', 'danger');
     }
     $attributes = Cas::attr();
     $statusUvus = stripos($attributes['schacuserstatus'], 'uvus:OK');
     //Uvus no valido :)
     if ($statusUvus == false) {
         return Redirect::to(route('report.html'))->with('msg', Config::get('msg.uvusNoValido'))->with('alertLevel', 'danger');
     }
     $user = User::where('username', '=', $attributes['uid'])->first();
     //No existe user en BD => Primer Acceso
     if ($this->existsUser($user) == false) {
         // => registrar acceso
         $this->registraAcceso($attributes);
         // => Salva notificación para admins SGR
         $motivo = 'Nuevo acceso';
         $this->salvaNotificacion($attributes, $motivo);
         // => send mail para admins SGR
         $sgrMail = new sgrMail();
         $sgrMail->notificaRegistroUser($user);
         //notifica a los administradores designados que hay un nuevo usuario a registrar.
         // => Redirect report for user
         return Redirect::to(route('report.html'))->with('msg', Config::get('msg.uvusRegistrado'))->with('alertLevel', 'danger');
     }
     //User existe en BD
     // Cuenta desactivada :)
     if ($user->estado == false) {
         return Redirect::to(route('report.html'))->with('msg', Config::get('msg.uvusNoActivo'))->with('alertLevel', 'danger');
     }
     //Cuenta Caducada :)
     if (strtotime($user->caducidad) < strtotime(date('Y-m-d'))) {
         // => Salva notificación para admins SGR
         $motivo = 'Cuenta caducada';
         $this->salvaNotificacion($attributes, $motivo);
         return Redirect::to(route('report.html'))->with('msg', Config::get('msg.cuentaCaducada'))->with('alertLevel', 'danger');
     }
     //Cuenta OK
     Auth::loginUsingId($user->id);
     $sgrUser = new sgrUser($user);
     return Redirect::to($sgrUser->home());
 }
 /**
  * // Activar / desactivar nuevo acceso
  */
 public function ajaxUpdateEstado()
 {
     // :)
     //Output
     $respuesta = array('error' => false, 'errors' => array(), 'msg' => '');
     $rules = array('idnotificacion' => 'required|exists:notificaciones,id', 'username' => 'required|exists:users', 'caducidad' => 'required|date|date_format:d-m-Y');
     $messages = array('required' => 'El campo <strong>:attribute</strong> es obligatorio.', 'idnotificacion.exists' => Config::get('msg.idnotfound'), 'username.exists' => Config::get('msg.usernamenotfound'), 'date' => 'El campo <strong>:attribute</strong> debe ser una fecha válida', 'date_format' => 'El campo <strong>:attribute</strong> debe tener el formato d-m-Y');
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         $respuesta['error'] = true;
         $respuesta['errors'] = $validator->errors()->toArray();
         return $respuesta;
     } else {
         //Input
         $idnotificacion = Input::get('idnotificacion');
         $username = Input::get('username');
         $colectivo = Input::get('colectivo', Config::get('options.colectivoPorDefecto'));
         $capacidad = Input::get('capacidad', Config::get('options.capacidadPorDefecto'));
         $caducidad = Input::get('caducidad');
         //Por defecto hoy
         $observaciones = Input::get('observaciones', '');
         $activar = Input::get('activar', 0);
         $user = User::where('username', '=', $username)->first();
         $user->estado = $activar;
         //Activación cuenta
         $user->colectivo = $colectivo;
         $user->capacidad = $capacidad;
         $user->observaciones = $observaciones;
         // La fecha se debe guardar en formato USA Y-m-d
         $fecha = DateTime::createFromFormat('j-m-Y', Input::get('caducidad'));
         $user->caducidad = $fecha->format('Y-m-d');
         $user->save();
         $this->cierraNotificacion($idnotificacion);
         //mail to User by Activate
         $sgrMail = new sgrMail();
         $sgrMail->notificaActualizacionCuenta($user->id);
         $respuesta['msg'] = (string) View::make('msg.success')->with(array('msg' => Config::get('msg.success') . 'activar = ' . $activar));
         return $respuesta;
     }
 }
 public function valida()
 {
     $sortby = Input::get('sortby', 'estado');
     $order = Input::get('order', 'desc');
     $id_recurso = Input::get('id_recurso', '0');
     $id_user = Input::get('id_user', '0');
     $evento_id = Input::get('evento_id', '');
     $action = Input::get('action', '');
     $idRecurso = Input::get('idRecurso', '0');
     $verpendientes = Input::get('verpendientes');
     $veraprobadas = Input::get('veraprobadas');
     $verdenegadas = Input::get('verdenegadas');
     //$iduser = Input::get('idUser','0';)
     $espaciosConValidacion = $this->espaciosConValidacion();
     //por ejemplo array('10,'11,'21') DONDE 10 -> Salón de actos,11->Sala de juntas, 21->Seminario B2		//validamos (aprobar o denegar) evento
     $solapamientos = false;
     $msgforuser = '';
     if ($action == 'aprobar') {
         //vemos si hay solapamientos con solicitudes ya aprobadas
         $events = Evento::where('evento_id', '=', $evento_id)->get();
         foreach ($events as $event) {
             $where = "fechaEvento = '" . $event->fechaEvento . "' and ";
             $where .= " (( horaInicio <= '" . $event->horaInicio . "' and horaFin >= '" . $event->horaFin . "' ) ";
             $where .= " or ( horaFin > '" . $event->horaFin . "' and horaInicio < '" . $event->horaFin . "')";
             $where .= " or ( horaInicio > '" . $event->horaInicio . "' and horaInicio < '" . $event->horaFin . "')";
             $where .= " or horaFin < '" . $event->horaFin . "' and horaFin > '" . $event->horaInicio . "')";
             $where .= " and evento_id != '" . $evento_id . "'";
             $where .= " and estado = 'aprobada'";
             $numSolapamientos = Recurso::find($idRecurso)->events()->whereRaw($where)->count();
             if ($numSolapamientos > 0) {
                 $solapamientos = true;
             }
         }
         if (!$solapamientos) {
             //update column estado en BD
             $filasAfectadas = Evento::where('evento_id', '=', $evento_id)->update(array('estado' => 'aprobada'));
             $accion = 'aprobar';
             $solapamientos = false;
             $msgforuser = '******';
             //Aquí mail to -> user_id && validadores de recurso_id ($accion = aprobar | denegar)
             $sgrMail = new sgrMail();
             $sgrMail->notificaValidacion($accion, $evento_id);
         } else {
             $solapamientos = true;
         }
     } else {
         Evento::where('evento_id', '=', $evento_id)->update(array('estado' => 'denegada'));
         $accion = 'denegar';
         $msgforuser = '******';
         //Aquí mail to -> user_id && validadores de recurso_id ($accion = aprobar | denegar)
         $sgrMail = new sgrMail();
         $sgrMail->notificaValidacion($accion, $evento_id);
     }
     return Redirect::to(route('validadorHome.html', array('solapamientos' => $solapamientos, 'sortby' => $sortby, 'order' => $order, 'id_recurso' => $id_recurso, 'id_user' => $id_user, 'idEventoValidado' => $evento_id, 'verpendientes' => $verpendientes, 'veraprobadas' => $veraprobadas, 'verdenegadas' => $verdenegadas, 'msgforuser' => $msgforuser)));
 }
Example #5
0
 public function edit()
 {
     $result = array('error' => false, 'msgSuccess' => '', 'idsDeleted' => array(), 'msgErrors' => array());
     //Controlar errores en el formulario
     $testDataForm = new Evento();
     if (!$testDataForm->validate(Input::all())) {
         $result['error'] = true;
         $result['msgErrors'] = $testDataForm->errors();
     } else {
         //si el usuario es alumno: comprobamos req2 (MAX HORAS = 12 a la semana en cualquier espacio o medio )
         if (Auth::user()->isUser() && $this->superaHoras()) {
             $result['error'] = true;
             $error = array('hFin' => 'Se supera el máximo de horas a la semana.. (12h)');
             $result['msgErrors'] = $error;
         } else {
             $idSerie = Input::get('idSerie');
             $fechaInicio = Input::get('fInicio');
             $fechaFin = Input::get('fFin');
             //Borrar todos los eventos a modificar
             $event = Evento::find(Input::get('idEvento'));
             if (Input::get('id_recurso') == 0) {
                 Evento::where('evento_id', '=', Input::get('idSerie'))->forceDelete();
             } else {
                 Evento::where('evento_id', '=', Input::get('idSerie'))->where('recurso_id', '=', Input::get('id_recurso'))->forceDelete();
             }
             //Añadir los nuevos
             $result['idEvents'] = $this->editEvents($fechaInicio, $fechaFin, $idSerie);
             //Msg confirmación al usuario (edición de evento)
             $newEvent = Evento::Where('evento_id', '=', $idSerie)->first();
             if ($newEvent->estado == 'aprobada') {
                 $result['msgSuccess'] = '<strong class="alert alert-info" > Reserva registrada con éxito. Puede <a target="_blank" href="' . route('justificante', array('idEventos' => $newEvent->evento_id)) . '">imprimir comprobante</a> de la misma si lo desea.</strong>';
             }
             if ($newEvent->estado == 'pendiente') {
                 $result['msgSuccess'] = '<strong class="alert alert-danger" >Reserva pendiente de validación. Puede <a target="_blank" href="' . route('justificante', array('idEventos' => $newEvent->evento_id)) . '">imprimir comprobante</a> de la misma si lo desea.</strong>';
             }
             //notificar a validadores si espacio requiere validación
             if ($event->recurso->validacion()) {
                 $sgrMail = new sgrMail();
                 $sgrMail->notificaEdicionEvento($newEvent);
             }
         }
         //fin else
     }
     return $result;
 }
Example #6
0
 /**
  * //habilita un recursos para su reserva
  *
  * @param Input::get('idrecurso') int
  *
  * @return $result array
  */
 public function AjaxEnabled()
 {
     // :/
     //input
     $id = Input::get('idrecurso', '');
     //Output
     $result = array('errors' => array(), 'msg' => '', 'error' => false);
     //Validate
     $rules = array('idrecurso' => 'required|exists:recursos,id');
     $messages = array('required' => 'El campo <strong>:attribute</strong> es obligatorio.', 'exists' => 'No existe identificador de recurso en BD.');
     $validator = Validator::make(Input::all(), $rules, $messages);
     //Save Input or return error
     if ($validator->fails()) {
         $result['errors'] = $validator->errors()->toArray();
         $result['error'] = true;
     } else {
         //enable
         $recurso = Recurso::findOrFail($id);
         $sgrRecurso = Factoria::getRecursoInstance($recurso);
         $sgrRecurso->enabled();
         //Enviar mail a usuarios con reserva futuras
         $sgrMail = new sgrMail();
         $sgrMail->notificaHabilitaRecurso($id);
         $result['msg'] = (string) View::make('msg.success')->with(array('msg' => Config::get('msg.enabledrecursosuccess')));
     }
     return $result;
 }