Esempio n. 1
0
 private function existeLugar($idLugar)
 {
     $result = false;
     $recurso = Recurso::where('id_lugar', '=', $idLugar)->get();
     if ($recurso->count() > 0) {
         $result = true;
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Implementa requisito: ofrecer sumatorio de puestos o equipos reservados
  * 
  * @param void
  * @return $total int número total de puestos o equipos asociados a una misma reserva 
  */
 public function total()
 {
     $total = 0;
     if ($this->recurso->tipo != 'espacio') {
         $total = Evento::where('evento_id', '=', $this->evento_id)->where('horaInicio', '=', $this->horaInicio)->where('fechaEvento', '=', $this->fechaEvento)->count();
     }
     //Bug PODController, quitar el año q viene
     $userPOD = User::where('username', '=', 'pod')->first();
     //$eventoTest = Evento::whereIn('recurso_id',$alist_id)->where('fechaEvento','=',$strDate)->orderBy('horaInicio','asc')->groupby('evento_id')->first();
     $idPOD = $userPOD->id;
     $iduser = 0;
     $iduser = $this->user_id;
     if ($iduser == $idPOD) {
         $recursos = Recurso::where('grupo_id', '=', $this->recurso->grupo_id)->get();
         $alist_id = array();
         foreach ($recursos as $recurso) {
             $alist_id[] = $recurso->id;
         }
         $total = Evento::whereIn('recurso_id', $alist_id)->where('fechaEvento', '=', $this->fechaEvento)->where('horaInicio', '=', $this->horaInicio)->where('titulo', '=', $this->titulo)->count();
     }
     //fin del bug
     return $total;
 }
Esempio n. 3
0
 public function imprime()
 {
     //!!!***Validar parámetros de entrada***!!!
     //get Input or default
     $viewActive = Input::get('view', 'month');
     $day = Input::get('day', date('d'));
     $month = Input::get('month', date('m'));
     $year = Input::get('year', date('Y'));
     $id_recurso = Input::get('idRecurso', '');
     //$id_grupo = Input::get('groupID','');
     $id_item = Input::get('item', 0);
     //Todos los items (equipos o puestos)
     $titulo = Input::get('titulo', false);
     $nombre = Input::get('nombre', false);
     $colectivo = Input::get('colectivo', false);
     $total = Input::get('total', false);
     //Total de puestos o equipos de una reserva
     $datatoprint = array('titulo' => $titulo, 'nombre' => $nombre, 'colectivo' => $colectivo, 'total' => $total);
     //Información a imprimir seleccionada por el usuario
     //Output
     $table = array('tCaption' => '', 'tHead' => '', 'tBody' => '');
     $fecha = new DateTime($year . '-' . $month . '-1');
     $recurso = Recurso::findOrFail($id_recurso);
     $sgrRecurso = RecursoFactory::getRecursoInstance($recurso->tipo);
     $sgrRecurso->setRecurso($recurso);
     $sgrCalendario = new sgrCalendario($fecha, $sgrRecurso);
     $table['tCaption'] = CalendarController::caption($viewActive, $day, $sgrCalendario->nombreMes(), $sgrCalendario->year());
     switch ($viewActive) {
         case 'month':
             $table['tHead'] = CalendarController::head($viewActive, $sgrCalendario);
             $table['tBody'] = View::make('calendario.printBodyMonth')->with('sgrCalendario', $sgrCalendario)->with('id_recurso', $id_recurso)->with('id_grupo', '')->with('datatoprint', $datatoprint);
             break;
         case 'week':
             $horas = array('8:30', '9:30', '10:30', '11:30', '12:30', '13:30', '14:30', '15:30', '16:30', '17:30', '18:30', '19:30', '20:30', '21:30');
             $sgrWeek = $sgrCalendario->sgrWeek(strtotime($year . '-' . $month . '-' . $day));
             $table['tHead'] = View::make('calendario.print.weekhead')->with('sgrWeek', $sgrWeek);
             //$table['tBody'] = View::make('calendario.printBodyWeek')->with('horas',$horas)->with('sgrWeek',$sgrWeek)->with('id_recurso',$id_recurso)->with('id_grupo','')->with('datatoprint',$datatoprint);
             $table['tBody'] = (string) View::make('calendario.print.weekbody')->with('sgrCalendario', $sgrCalendario);
             break;
         default:
             # code...
             break;
     }
     if (0 != $id_recurso) {
         $nombre = Recurso::find($id_recurso)->nombre;
     } else {
         $recurso = Recurso::where('grupo_id', '=', $id_grupo)->first();
         $nombre = $recurso->grupo;
     }
     $html = View::make('pdf.calendario')->with(compact('table', 'nombre'));
     //return $html;
     $nombreFichero = $day . '-' . $month . '-' . $year . '_' . $nombre;
     //return $html;
     $result = myPDF::getPDF($html, $nombreFichero);
     return Response::make($result)->header('Content-Type', 'application/pdf');
 }
Esempio n. 4
0
 /**
  * Devuelve recursos contenedores del mismo tipo y del mismo grupo que el recurso contenedor de $this->recurso
  * @param void
  *	@return array
  */
 public function getContenedores()
 {
     $contenedores = array();
     if ($this->recurso->contenedor != null) {
         $contenedores = Recurso::where('tipo', '=', $this->recurso->contenedor->tipo)->where('grupo_id', '=', $this->recurso->contenedor->grupo_id)->get()->toArray();
     } else {
         $contenedores = GrupoRecurso::where('tipo', '=', $this->recurso->tipo)->get()->toArray();
     }
     return $contenedores;
 }
Esempio n. 5
0
 /**
  * Determina si un nuevo evento en $idRecurso en $currentfecha, con hora inicio $hi, hora de finalización $hf, solapa con eventos con $condicionEstado existentes en BD
  *
  * @param $idGrupo int
  * @param $idRecurso int
  * @param $currentfecha (d-m-Y)
  * @param $hi
  * @param $hf
  * @param $condicionEstado
  * @return $numSolapamientos int
  *
  */
 public function solapa($idGrupo, $idRecurso, $currentfecha, $hi, $hf, $condicionEstado = '')
 {
     $numSolapamientos = 0;
     $hi = date('H:i:s', strtotime($hi));
     $hf = date('H:i:s', strtotime($hf));
     //si estamos editando un evento => Existe Input::get('idEvento'), hay que excluir para poder modificar por ejemplo en nombre del evento
     $idEvento = Input::get('idEvento');
     $option = Input::get('option');
     $action = Input::get('action');
     $excludeEvento = '';
     //Excluye eventos de la misma serie en cualquier espacio para poder cambiar el nombre a reservas tanto de un solo equipo//puesto o espacio como a reservas de todos los equipos/puestos
     $idSerie = Input::get('idSerie');
     $excludeEvento = '';
     if (!empty($idSerie) && $action == 'edit') {
         $excludeEvento = " and evento_id != '" . $idSerie . "'";
     }
     $where = "fechaEvento = '" . $currentfecha . "' and ";
     if (!empty($condicionEstado)) {
         $where .= "estado = '" . $condicionEstado . "' and ";
     }
     $where .= " (( horaInicio <= '" . $hi . "' and horaFin > '" . $hi . "' ) ";
     $where .= " or ( horaFin > '" . $hf . "' and horaInicio < '" . $hf . "')";
     $where .= " or ( horaInicio > '" . $hi . "' and horaInicio < '" . $hf . "')";
     $where .= " or horaFin < '" . $hf . "' and horaFin > '" . $hi . "')";
     $where .= $excludeEvento;
     if ($idRecurso != 0) {
         $numSolapamientos = Recurso::find($idRecurso)->events()->whereRaw($where)->count();
     } else {
         //Si idRecurso == 0 entonces tenemos un espacio con puestos o un grupo de equipos, por ejemplo cámaras
         $recursos = Recurso::where('grupo_id', '=', $idGrupo)->get();
         foreach ($recursos as $recurso) {
             $numSolapamientos = $numSolapamientos + $recurso->events()->whereRaw($where)->count();
         }
     }
     return $numSolapamientos;
 }
Esempio n. 6
0
 /**
  * //Devuelve todos los recurso del tipo Input::get('tipo') formateados como html options 
  * @param Input::get('tipo') string
  * @return View::make('admin.html.optionEspacios')
  */
 public function htmlOptionrecursos()
 {
     // prescindible ???
     $tipoRecurso = Input::get('tipo', '');
     $espacios = Recurso::where('tipo', '=', $tipoRecurso)->get();
     return View::make('admin.html.optionEspacios')->with(compact('espacios'));
 }
Esempio n. 7
0
 /**
  * //develve html checkboxes con los recursos contenedores sin grupo
  * @param $idgrupo int identificador de grupo
  * @return View::make string
  */
 public function ajaxGetRecursoContenedoresSinGrupo()
 {
     //input
     $id = Input::get('idgrupo', '');
     //Output
     $result = array('html' => '');
     //Validate
     $rules = array('idgrupo' => 'required|exists:grupoRecursos,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);
     //get personas or return error
     if ($validator->fails()) {
         $messages = $validator->messages();
         $msg = '';
         foreach ($messages->all() as $m) {
             $msg .= $m . '<br />';
         }
         $result['html'] = (string) View::make('msg.error')->with(array('msg' => $msg));
         //$result['html'] = $msg;
     } else {
         $grupo = GrupoRecurso::findOrFail($id);
         $recursosSinGrupo = Recurso::where('grupo_id', '=', '0')->where('tipo', '=', $grupo->tipo)->get();
         $result['html'] = (string) View::make('admin.html.optionscontendoressingrupo')->with(compact('recursosSinGrupo'));
     }
     return $result;
 }