/** * //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 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'); }