示例#1
0
 public function getDashboard()
 {
     $users = User::where('padre_id', '=', Auth::user()->id)->orderBy('id', 'DESC')->take(5)->get();
     $eventos = Evento::where('user_id', '=', Auth::user()->id)->orderBy('id', 'DESC')->take(5)->get();
     $ventas = Venta::where('user_id', '=', Auth::user()->id)->orderBy('id', 'DESC')->take(5)->get();
     $this->layout->content = View::make('admin/dashboard')->with('users', $users)->with('eventos', $eventos)->with('ventas', $ventas);
 }
 public function run()
 {
     DB::table('pasaje')->delete();
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '651CDC', 'fecha' => '2014-10-01', 'gasto' => '2200', 'tipo' => 'ida', 'compania_id' => '1', 'ciudad_origen_id' => '1', 'ciudad_destino_id' => '2'));
     $eventos = Evento::where('id', '=', '1')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '984DFG', 'fecha' => '2014-10-05', 'gasto' => '2200', 'tipo' => 'regreso', 'compania_id' => '1', 'ciudad_origen_id' => '2', 'ciudad_destino_id' => '1'));
     $eventos = Evento::where('id', '=', '1')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
     /* Evento 2 */
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '234JKB', 'fecha' => '2014-09-15', 'gasto' => '1500', 'tipo' => 'ida', 'compania_id' => '2', 'ciudad_origen_id' => '1', 'ciudad_destino_id' => '3'));
     $eventos = Evento::where('id', '=', '2')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '546DFG', 'fecha' => '2014-09-17', 'gasto' => '1500', 'tipo' => 'regreso', 'compania_id' => '2', 'ciudad_origen_id' => '3', 'ciudad_destino_id' => '1'));
     $eventos = Evento::where('id', '=', '2')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
     /* Evento 3 */
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '678DFG', 'fecha' => '2013-01-01', 'gasto' => '3200', 'tipo' => 'ida', 'compania_id' => '3', 'ciudad_origen_id' => '2', 'ciudad_destino_id' => '4'));
     $eventos = Evento::where('id', '=', '3')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '674GTH', 'fecha' => '2013-01-07', 'gasto' => '3600', 'tipo' => 'regreso', 'compania_id' => '3', 'ciudad_origen_id' => '4', 'ciudad_destino_id' => '2'));
     $eventos = Evento::where('id', '=', '3')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
     /* Evento 4 */
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '976XCV', 'fecha' => '2014-08-01', 'gasto' => '2700', 'tipo' => 'ida', 'compania_id' => '1', 'ciudad_origen_id' => '1', 'ciudad_destino_id' => '5'));
     $eventos = Evento::where('id', '=', '4')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '643TGH', 'fecha' => '2013-08-05', 'gasto' => '2500', 'tipo' => 'regreso', 'compania_id' => '1', 'ciudad_origen_id' => '5', 'ciudad_destino_id' => '1'));
     $eventos = Evento::where('id', '=', '4')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
     /* Evento 5 */
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '345WAS', 'fecha' => '2013-10-01', 'gasto' => '6000', 'tipo' => 'ida', 'compania_id' => '1', 'ciudad_origen_id' => '1', 'ciudad_destino_id' => '7'));
     $eventos = Evento::where('id', '=', '5')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
     $pasaje = Pasaje::create(array('cubre_pasaje' => 'IFAI', 'tipo_pasaje' => 'Aéreo', 'numero_viaje' => '651WER', 'fecha' => '2013-10-05', 'gasto' => '6300', 'tipo' => 'regreso', 'compania_id' => '1', 'ciudad_origen_id' => '7', 'ciudad_destino_id' => '1'));
     $eventos = Evento::where('id', '=', '5')->get();
     foreach ($eventos as $evento) {
         $evento->pasajes()->attach($pasaje->id);
     }
 }
 public function traza($modelo, $id)
 {
     try {
         //$traza  = DB::table('eventos')->where('modelo_id','=',$id)->where('modelo','=',$modelo)->get();
         $traza = Evento::where('modelo_id', '=', $id)->where('modelo', '=', $modelo)->get();
         return Response::json(array('error' => false, 'listado' => $traza), 200);
     } catch (Exception $e) {
         return Response::json(array('error' => true, 'mensaje' => $e->getMessage()), 200);
     }
 }
示例#4
0
 /**
  * //Devuelve pdf con datos de reserva
  * @param Input::get('idEventos') string cadena 
  *
  * @return  Response::make($result)->header('Content-Type', 'application/pdf')
  */
 public function build()
 {
     if (Evento::withTrashed()->where('evento_id', '=', Input::get('idEventos'))->count() == 0) {
         return View::make('pdf.msg');
     }
     $event = Evento::withTrashed()->where('evento_id', '=', Input::get('idEventos'))->first();
     $events = Evento::withTrashed()->where('evento_id', '=', Input::get('idEventos'))->get();
     $recursos = Evento::where('evento_id', '=', Input::get('idEventos'))->groupby('recurso_id')->get();
     setlocale(LC_TIME, 'es_ES@euro', 'es_ES.UTF-8', 'esp');
     $strDayWeek = sgrDate::getStrDayWeek($event->fechaEvento);
     $strDayWeekInicio = sgrDate::getStrDayWeek($event->fechaInicio);
     $strDayWeekFin = sgrDate::getStrDayWeek($event->fechaFin);
     $created_at = ucfirst(strftime('%A %d de %B  a las %H:%M:%S', strtotime($event->created_at)));
     $impreso_at = ucfirst(strftime('%A %d de %B  a las %H:%M:%S', strtotime('now')));
     $html = View::make('pdf.justificante')->with(compact('event', 'events', 'strDayWeek', 'strDayWeekInicio', 'strDayWeekFin', 'recursos', 'created_at', 'impreso_at'));
     $result = myPDF::getPDF($html, 'comprobante');
     return Response::make($result)->header('Content-Type', 'application/pdf');
 }
 public function getNoMensajero($id)
 {
     $client_id = '830870432482-po6o126nspi5d3iukgkn7ni6m0qpg5mq.apps.googleusercontent.com';
     $email_address = '*****@*****.**';
     $key_file_location = app_path('key/Bifrost-7c8d70841343.p12');
     $client = new Google_Client();
     $client->setApplicationName('Bifrost');
     $key = file_get_contents($key_file_location);
     $scopes = implode(' ', array(Google_Service_Calendar::CALENDAR));
     $cred = new Google_Auth_AssertionCredentials($email_address, array($scopes), $key);
     $client->setAssertionCredentials($cred);
     if ($client->getAuth()->isAccessTokenExpired()) {
         $client->getAuth()->refreshTokenWithAssertion($cred);
     }
     $evento = Evento::where('recibo_id', '=', $id)->firstOrFail();
     $service = new Google_Service_Calendar($client);
     $service->events->delete('*****@*****.**', $evento->evento);
     $evento->delete();
     $recibo = Recibo::find($id);
     $recibo->mensajero = 0;
     $recibo->save();
     return Redirect::back();
 }
示例#6
0
 /**
  * Devuelve evento de usuario dado su username (uvus) para su atención: debe cumplirse:
  *	1. El eventos está programado en un recurso "atendido" por Auth::user
  *	2. fechaEvento = today && horaFin < now
  *	
  * @param Input array
  * @return object Evento
  * 
  */
 public function getUserEvents()
 {
     $username = Input::get('username', '');
     $usuarioAtendido = User::where('username', '=', $username)->first();
     if (empty($usuarioAtendido)) {
         return '-1';
     }
     //No hay usuario
     $today = date('Y-m-d');
     $now = date('H:i:s');
     $eventosCandidatos = Evento::where('user_id', '=', $usuarioAtendido->id)->where('fechaEvento', '=', $today)->where('horaFin', '>', $now)->get();
     $recursosAtendidos = Auth::user()->atiende;
     //recolectar identificadores
     $idsRecursos = array();
     foreach ($recursosAtendidos as $recurso) {
         $idsRecursos[] = $recurso->id;
     }
     //filtrar eventos candidartos
     $eventos = $eventosCandidatos->filter(function ($evento) use($idsRecursos) {
         return in_array($evento->recurso_id, $idsRecursos);
         //si el evento se realiza en un recurso atendido por Auth::user()
     });
     return View::make('tecnico.resultSearch', compact('eventos', 'username', 'usuarioAtendido'));
 }
示例#7
0
 public function evento()
 {
     return Evento::where('texto_id', $this->id)->first();
 }
 public function traza($id)
 {
     try {
         $eventos = Evento::where('modelo_id', '=', $id)->where('modelo', '=', $this->classname)->orderBy('created_at')->get();
         return Response::json(array('error' => false, 'listado' => $eventos), 200);
     } catch (Exception $e) {
         return Response::json(array('error' => true, 'mensaje' => $e->getMessage()), 200);
     }
 }
 public function doAnnouncement($id)
 {
     global $club, $messageData, $messageSubject, $team, $sms, $user, $recipientMobile, $recipientEmail;
     $user = Auth::user();
     $club = $user->Clubs()->FirstOrFail();
     $event = Evento::where("id", "=", $id)->where("club_id", '=', $club->id)->FirstOrFail();
     $participants = Participant::where('event_id', '=', $event->id)->get();
     $messageData = Input::get('message');
     $messageSubject = Input::get('subject');
     $sms = substr($messageData, 0, 140) . " {$club->name} - Do not reply";
     $uuid = Uuid::generate();
     //get list of recepients
     $recipientUser = array();
     $recipientPlayer = array();
     $recipientContact = array();
     $recipientEmail = array();
     $recipientMobile = array();
     //do selection for children events
     if ($event->children->count() > 0) {
         foreach ($event->children as $e) {
             foreach ($e->participants as $member) {
                 //only members that accepted joined
                 if ($member->accepted_user) {
                     $user = User::find($member->accepted_user);
                     $player = Player::find($member->player_id);
                     $recipientUser[] = array('name' => $user->profile->firstname . " " . $user->profile->lastname, 'email' => $user->email, 'mobile' => $user->profile->mobile);
                     foreach ($player->contacts as $contact) {
                         $recipientContact[] = array('name' => $contact->firstname . " " . $contact->lastname, 'email' => $contact->email, 'mobile' => $contact->mobile);
                     }
                     //allow players with email and mobile
                     if ($player->mobile && $player->email) {
                         $recipientPlayer[] = array('name' => $player->firstname . " " . $player->lastname, 'email' => $player->email, 'mobile' => $player->mobile);
                     }
                 }
             }
         }
     } else {
         foreach ($participants as $member) {
             //only members that accepted joined
             if ($member->accepted_user) {
                 $user = User::find($member->accepted_user);
                 $player = Player::find($member->player_id);
                 $recipientUser[] = array('name' => $user->profile->firstname . " " . $user->profile->lastname, 'email' => $user->email, 'mobile' => $user->profile->mobile);
                 foreach ($player->contacts as $contact) {
                     $recipientContact[] = array('name' => $contact->firstname . " " . $contact->lastname, 'email' => $contact->email, 'mobile' => $contact->mobile);
                 }
                 //allow players with email and mobile
                 if ($player->mobile && $player->email) {
                     $recipientPlayer[] = array('name' => $player->firstname . " " . $player->lastname, 'email' => $player->email, 'mobile' => $player->mobile);
                 }
             }
         }
     }
     //send default function
     function sendmessage($destination)
     {
         global $club, $messageData, $messageSubject, $event, $sms, $user, $recipientMobile, $recipientEmail;
         foreach ($destination as $recipient) {
             //send email notification of acceptance queue
             $data = array('club' => $club, 'messageOriginal' => $messageData, 'subject' => $messageSubject, 'team' => $event);
             Mail::later(3, 'emails.announcement.default', $data, function ($message) use($recipient, $club, $messageSubject) {
                 $message->to($recipient['email'], $recipient['name'])->subject("{$messageSubject} | " . $club->name);
             });
             $recipientEmail[] = array('name' => $recipient['name'], 'email' => $recipient['email']);
             if (Input::get('sms')) {
                 $recipientMobile[] = array('name' => $recipient['name'], 'mobile' => $recipient['mobile']);
                 //queue sms
                 Queue::push(function ($job) use($recipient, $sms) {
                     Twilio::message($recipient['mobile'], $sms);
                     $job->delete();
                 });
             }
         }
     }
     // send to user
     sendmessage($recipientUser);
     //send to player
     if (Input::get('players')) {
         sendmessage($recipientPlayer);
     }
     //send to contacts
     if (Input::get('family')) {
         sendmessage($recipientContact);
     }
     //save message to database
     $announcement = new Announcement();
     $announcement->id = $uuid;
     $announcement->subject = $messageSubject;
     $announcement->message = $messageData;
     $announcement->sms = $sms;
     $announcement->to_email = serialize($recipientEmail);
     $announcement->to_sms = serialize($recipientMobile);
     $announcement->event_id = $event->id;
     $announcement->club_id = $club->id;
     $announcement->user_id = $user->id;
     //$status = $announcement->save();
     return array('success' => true, 'email' => $recipientEmail, 'mobile' => $recipientMobile);
 }
示例#10
0
 public function validate($data)
 {
     //$this->data = $data;
     //return false;
     //formatear fechas
     if (!empty($data['fEvento'])) {
         $date = DateTime::createFromFormat('d-m-Y', $data['fEvento']);
         $data['fEvento'] = $date->format('Y-m-d');
     }
     if (!empty($data['fInicio'])) {
         $date = DateTime::createFromFormat('d-m-Y', $data['fInicio']);
         $data['fInicio'] = $date->format('Y-m-d');
     }
     if (!empty($data['fFin'])) {
         $date = DateTime::createFromFormat('d-m-Y', $data['fFin']);
         $data['fFin'] = $date->format('Y-m-d');
     }
     //mensages
     //req1: alumno solo pueden reservar entre firstMonday y lastFriday  (por implementar)
     if (Auth::user()->isUser()) {
         setlocale(LC_ALL, 'es_ES@euro', 'es_ES', 'esp');
         $this->messages['fInicio.req1'] = '<br />Puedes reservar entre el <strong>' . strftime('%A, %d de %B de %Y', sgrCalendario::fristMonday()) . '</strong> y el <strong>' . strftime('%A, %d de %B de %Y', sgrCalendario::lastFriday()) . '</strong><br />';
     }
     if (Auth::user()->isAvanceUser()) {
         setlocale(LC_ALL, 'es_ES@euro', 'es_ES', 'esp');
         $this->messages['fInicio.req5'] = 'Puedes reservar a partir del <strong>' . strftime('%A, %d de %B de %Y', sgrCalendario::fristMonday()) . '</strong><br />';
     }
     if (Auth::user()->isTecnico()) {
         setlocale(LC_ALL, 'es_ES@euro', 'es_ES', 'esp');
         $tsToday = strtotime('today');
         $this->messages['fInicio.req6'] = 'Puedes reservar a partir del <strong>' . strftime('%A, %d de %B de %Y', $tsToday) . '</strong><br />';
     }
     if (isset($data['dias']) && in_array('6', $data['dias'])) {
         $this->messages['dias.req4'] = $this->messages['dias.req4'] . " No se puede reservar en <strong>sábado</strong><br />";
     }
     if (isset($data['dias']) && in_array('0', $data['dias'])) {
         $this->messages['dias.req4'] = $this->messages['dias.req4'] . " No se puede reservar en <strong>domingo</strong><br />";
     }
     if (!empty($data['fFin'])) {
         $this->messages['fFin.datefincurso'] = 'Las reservas deben de finalizar dentro del curso académico actual. (Fecha limite: ' . date('d-m-Y', strtotime(Config::get('options.fin_cursoAcademico'))) . ')';
     }
     if (!empty($data['fInicio'])) {
         $this->messages['fInicio.dateiniciocurso'] = 'No es posible realizar reservas hasta que se finalice la carga del POD: fecha prevista a partir del día ' . date('d-m-Y', strtotime(Config::get('options.inicio_gestiondesatendida')));
     }
     if (!empty($data['reservarParaUvus'])) {
         $this->messages['reservarParaUvus.existeuvus'] = 'Usuario "' . $data['reservarParaUvus'] . '" no registrado.';
     }
     //fin mensages
     // make a new validator object
     $v = Validator::make($data, $this->rules, $this->messages);
     //requisito: reserva para otro usuario -> debe de existir en la Base de Datos
     if (!empty($data['reservarParaUvus'])) {
         $v->sometimes('reservarParaUvus', 'existeuvus', function ($data) {
             if (User::where('username', '=', $data['reservarParaUvus'])->count() == 0) {
                 return true;
             }
         });
     }
     //requisito: alumnos no pueden reservar dos recurso a la misma hora, mismo día
     if (!empty($data['fEvento']) && !empty($data['hFin']) && !empty($data['hInicio'])) {
         $v->sometimes('fEvento', 'reservaunica', function ($data) {
             if (Auth::user()->capacidad == '1') {
                 //setlocale(LC_ALL,'es_ES@euro','es_ES','esp');
                 //determinar si tiene reserva en otro recurso con misma fechaEvento, horainicio y horafin solapadas.
                 $id_recurso = Recurso::find($data['id_recurso'])->id;
                 $where = " (( horaInicio <= '" . $data['hInicio'] . "' and horaFin >= '" . $data['hFin'] . "' ) ";
                 $where .= " or ( horaFin > '" . $data['hFin'] . "' and horaInicio < '" . $data['hFin'] . "')";
                 $where .= " or ( horaInicio > '" . $data['hInicio'] . "' and horaInicio < '" . $data['hFin'] . "')";
                 $where .= " or horaFin < '" . $data['hFin'] . "' and horaFin > '" . $data['hInicio'] . "')";
                 $where .= " and recurso_id != " . $id_recurso;
                 $numEventosOtroRecurso = Evento::where('user_id', '=', Auth::user()->id)->where('fechaEvento', '=', date('Y-m-d', strtotime($data['fEvento'])))->whereRaw($where)->count();
                 if ($numEventosOtroRecurso > 0) {
                     return true;
                 }
             }
         });
     }
     //req1: alumno solo pueden reservar entre firstMonday y lastFriday
     if (!empty($data['fInicio']) && strtotime($data['fInicio']) != false) {
         $v->sometimes('fInicio', 'req1', function ($data) {
             if (Auth::user()->isUser()) {
                 if (sgrCalendario::fristMonday() > strtotime($data['fInicio']) || sgrCalendario::lastFriday() < strtotime($data['fInicio'])) {
                     return true;
                 }
             }
         });
     }
     //req2: alumno supera el máximo de horas a la semana (12)
     // empty($data['action'] -> solo se comprueba en la reserva nueva (add)
     if (!empty($data['hFin']) && !empty($data['hInicio']) && empty($data['action'])) {
         $v->sometimes('hFin', 'req2', function ($data) {
             if (Auth::user()->isUser()) {
                 $nh = Auth::user()->numHorasReservadas();
                 //Número de horas ya reservadas
                 $nh2 = sgrDate::diffHours($data['hInicio'], $data['hFin']);
                 //números de horas que se quiere reservar
                 $maximo = Config::get('options.max_horas');
                 $credito = $maximo - $nh;
                 //número de horas que aún puede el alumno reservar
                 if ($credito < $nh2) {
                     return true;
                 }
             }
         });
     }
     //deshabilitado
     if (isset($data['id_recurso']) && $data['id_recurso'] != 0) {
         $v->sometimes('titulo', 'deshabilitado', function ($data) {
             if (1 == Recurso::findOrFail($data['id_recurso'])->disabled) {
                 return true;
             }
         });
     }
     //req3:
     if (isset($data['fInicio']) && strtotime($data['fInicio']) != false && isset($data['dias'])) {
         $v->sometimes('titulo', 'req3', function ($data) {
             $idrecurso = $data['id_recurso'];
             $recurso = Recurso::findOrFail($idrecurso);
             $sgrRecurso = RecursoFactory::getRecursoInstance($recurso->tipo);
             $sgrRecurso->setRecurso($recurso);
             $excluyeId = '';
             if (isset($data['idSerie'])) {
                 $excluyeId = $data['idSerie'];
             }
             return $sgrRecurso->recursoOcupado($data, $excluyeId);
         });
     }
     //req4: Sábados y domingos no se puede reservar
     if (isset($data['dias'])) {
         $v->sometimes('dias', 'req4', function ($data) {
             $dias = $data['dias'];
             // 0 = domingo, 6 = sábado
             if (in_array('0', $dias) || in_array('6', $dias)) {
                 return true;
             }
         });
     }
     //Req5:
     // --> alumnos y pdi (capacidades 1 y 2): solo pueden reservar a partir de firstmonday
     if (!empty($data['fInicio']) && strtotime($data['fInicio']) != false) {
         $v->sometimes('fInicio', 'req5', function ($data) {
             if (Auth::user()->isAvanceUser()) {
                 if (sgrCalendario::fristMonday() > strtotime($data['fInicio'])) {
                     return true;
                 }
             }
         });
     }
     //Req6:
     // --> técnicos  (capacidad 3, 4 y 5): reservas a partir del día de hoy (para mañana)
     if (!empty($data['fInicio']) && strtotime($data['fInicio']) != false) {
         $v->sometimes('fInicio', 'req6', function ($data) {
             if (Auth::user()->isTecnico()) {
                 if (strtotime('today') > strtotime($data['fInicio'])) {
                     return true;
                 }
             }
         });
     }
     //after: fInicio & fFin > today
     if (!empty($data['fInicio']) && strtotime($data['fInicio']) != false) {
         $intFinicio = strtotime($data['fInicio']);
         $intNow = strtotime('now');
         $intDiaAnterior = strtotime('-1 day', $intFinicio);
         //fecha posterior al día actual
         $v->sometimes('fInicio', 'after:' . date('d-m-Y', $intDiaAnterior), function ($data) {
             return true;
         });
         //fecha fin mayor o igual que fecha inicio => mayor que el día anterior a fecha inicio
         if ($data['repetir'] == 'CS') {
             $v->sometimes('fFin', 'required|date|date_format:Y-m-d|after:' . date('d-m-Y', $intDiaAnterior), function ($data) {
                 return true;
             });
         }
     }
     //after:hinicio < hfin
     if (!empty($data['hInicio'])) {
         $aHini = explode(':', $data['hInicio']);
         $timehorainicio = mktime($aHini[0], $aHini[1]);
         $v->sometimes('hFin', 'required|date_format:H:i|after:' . date('H:i', $timehorainicio), function ($data) {
             return true;
         });
     }
     // requisito: reservas debe finalizar dentro del curso académico actual (Restringido a todos los usuarios menos a los validadores)
     if (!empty($data['fFin']) && !empty($data['repetir']) && !Auth::user()->isValidador()) {
         $v->sometimes('fFin', 'datefincurso', function ($data) {
             $fechaFinCurso = Config::get('options.fin_cursoAcademico');
             $fechaMaximaEvento = $data['fEvento'];
             if ($data['repetir'] == 'CS') {
                 $fechaMaximaEvento = $data['fFin'];
             }
             //Reptición cada semana
             if (strtotime($fechaMaximaEvento) > strtotime($fechaFinCurso)) {
                 return true;
             }
         });
     }
     // requisito dateiniciocurso: lasreservas debe de ser posteriores a la fecha de inicio curso actual (Restringido a usuarios alumnos, pdi, administradores y tecnicos)
     if (!empty($data['fInicio']) && !Auth::user()->isValidador() && !Auth::user()->isAdmin()) {
         $v->sometimes('fInicio', 'dateiniciocurso', function ($data) {
             $hoy = strtotime('today');
             $diaInicio = strtotime(Config::get('options.inicio_gestiondesatendida'));
             if ($diaInicio > $hoy) {
                 return true;
             }
         });
     }
     // check for failure
     if ($v->fails()) {
         $this->errors = $v->messages()->toArray();
         return false;
     }
     $this->data = $data;
     //return false;
     // validation pass
     return true;
 }
示例#11
0
 private function delPOD()
 {
     $userPOD = User::where('username', '=', 'pod')->first();
     $filasAfectadas = Evento::where('user_id', '=', $userPOD->id)->delete();
 }
示例#12
0
 public function ajaxDataEvent()
 {
     $respuesta = array();
     $diasSemana = array('1' => 'lunes', '2' => 'martes', '3' => 'miércoles', '4' => 'jueves', '5' => 'viernes', '6' => 'sabado', '7' => 'domingo');
     $evento = Evento::where('id', '=', Input::get('id'))->groupby('evento_id')->get();
     $respuesta['fPeticion'] = date('d \\d\\e M \\d\\e Y \\a \\l\\a\\s H:i', strtotime($evento[0]->created_at));
     $respuesta['solapamientos'] = false;
     $respuesta['aprobada'] = false;
     if ($evento[0]->estado == 'aprobada') {
         $respuesta['aprobada'] = true;
         $respuesta['estado'] = 'Solicitud aprobada';
     } elseif ($evento[0]->estado == 'denegada') {
         $respuesta['estado'] = 'Solicitud denegada';
     } else {
         if ($evento[0]->solape(strtotime($evento[0]->fechaEvento))) {
             $respuesta['solapamientos'] = true;
             $respuesta['estado'] = 'Pendiente de validar con solapamientos';
         } else {
             $respuesta['estado'] = 'Pendiente de validar sin solapamientos';
         }
     }
     $respuesta['titulo'] = $evento[0]->titulo;
     $respuesta['actividad'] = $evento[0]->actividad;
     $respuesta['usuario'] = $evento[0]->user->nombre . ', ' . $evento[0]->user->apellidos;
     $respuesta['espacio'] = $evento[0]->recurso->nombre;
     setlocale(LC_ALL, 'es_ES@euro', 'es_ES.UTF-8', 'esp');
     $respuesta['fInicio'] = ucfirst(strftime('%A, %d de %B de %Y', strtotime($evento[0]->fechaInicio)));
     $respuesta['fFin'] = ucfirst(strftime('%A, %d de %B de %Y', strtotime($evento[0]->fechaFin)));
     $respuesta['horario'] = date('g:i', strtotime($evento[0]->horaInicio)) . '-' . date('g:i', strtotime($evento[0]->horaFin));
     $dias = explode(',', str_replace(array('[', ']', '"'), '', $evento[0]->diasRepeticion));
     $str = '';
     $cont = 0;
     for ($j = 0; $j < count($dias) - 1; $j++) {
         if (count($dias) == 2) {
             $str .= $diasSemana[$dias[$j]] . ' y ';
         } else {
             $str .= $diasSemana[$dias[$j]] . ', ';
         }
         $cont++;
     }
     $str .= $diasSemana[$dias[$cont]];
     $respuesta['dSemana'] = $str;
     $respuesta['evento_id'] = $evento[0]->evento_id;
     $respuesta['id_recurso'] = $evento[0]->recurso_id;
     $respuesta['user_id'] = $evento[0]->user_id;
     return $respuesta;
 }
示例#13
0
 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)));
 }
示例#14
0
 private function getIdUnique()
 {
     do {
         $evento_id = md5(microtime());
     } while (Evento::where('evento_id', '=', $evento_id)->count() > 0);
     return $evento_id;
 }
 public function submit_disable_convocatoria()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["permisos"] = Session::get('permisos');
         if (in_array('side_nuevo_usuario', $data["permisos"])) {
             $idperiodo = Input::get('idperiodo');
             $exist_evento = Evento::where('idperiodos', '=', $idperiodo)->get();
             $exist_postulante = PostulantesPeriodo::where('idperiodos', '=', $idperiodo)->get();
             $exist_user = UsersPeriodo::where('idperiodos', '=', $idperiodo)->get();
             $url = "convocatorias/edit_convocatoria/" . $idperiodo;
             if ($exist_evento->isEmpty() && $exist_postulante->isEmpty() && $exist_user->isEmpty()) {
                 $periodo = Periodo::find($idperiodo);
                 $periodo->delete();
                 // Llamo a la función para registrar el log de auditoria
                 $descripcion_log = "Se inhabilitó el periodo con id {{$periodo->idperiodos}}";
                 Helpers::registrarLog(5, $descripcion_log);
                 Session::flash('message', 'Se inhabilitó correctamente la convocatoria.');
             } else {
                 Session::flash('error', 'Existe al menos un evento, postulante o usuario asociado a esta convocatoria. No es posible inhabilitar.');
             }
             return Redirect::to($url);
         } else {
             // Llamo a la función para registrar el log de auditoria
             $descripcion_log = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registrarLog(10, $descripcion_log);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
示例#16
0
 public function notificaValidacion($acccion, $evento_id)
 {
     $evento = Evento::where('evento_id', '=', $evento_id)->first();
     //datos de la solicitud de uso
     $data = array('evento' => serialize($evento), 'validador' => Auth::user()->nombre . ' ' . Auth::user()->apellidos);
     $s = date('d-m-Y H:i') . ': ' . $evento->recurso->nombre . ': ' . $this->subject[$acccion];
     $validadores = User::where('capacidad', '=', 5)->get();
     //Todos los Validadores incluido Auth::user() (validador autenticado)
     //Notifica validadores
     foreach ($validadores as $validador) {
         if (!empty($validador->email)) {
             Mail::queue(array('html' => 'emails.validacion'), $data, function ($m) use($validador, $s) {
                 $m->to($validador->email)->subject($s);
             });
         }
     }
     //Notifica solicitante
     $mailSolicitante = $evento->user->email;
     if (!empty($mailSolicitante)) {
         Mail::queue(array('html' => 'emails.validacion'), $data, function ($m) use($mailSolicitante, $s) {
             $m->to($mailSolicitante)->subject($s);
         });
     }
     //Notifica técnicos
     //if ($this->notificaTecnicos($evento->fechaInicio)) //notificamos
 }