Пример #1
0
 public function editMonth($sede_id, $year, $month)
 {
     if (!Auth::user()->isAdmin()) {
         return Redirect::action('GuardiaController@showMonth', array($sede_id, $year, $month));
     }
     if ($sede_id == Sedes::TODAS) {
         return Redirect::action('GuardiaController@index');
     }
     $sede = Sedes::where('id', $sede_id)->firstOrFail();
     $guardias = Guardias::where('fecha_guardia', 'LIKE', "{$year}-{$month}-%")->where('sede_id', $sede_id)->orderBy('fecha_guardia')->get();
     $events = $this->getHtmlProfsSelect($guardias);
     $calendario = $this->getGuardiaCalendar($events, $year . '-' . $month);
     return View::make('guardias.edit')->with(array('calendario' => $calendario, 'sede' => $sede, 'year' => $year, 'month' => $month));
 }
Пример #2
0
 public function showMonth($sede_id, $ano, $mes)
 {
     if (Input::has('cdate')) {
         $cdate = explode('-', Input::get('cdate'));
         return Redirect::action('TurnoController@showMonth', array($sede_id, $cdate[0], $cdate[1]));
     }
     if ($sede_id == Sedes::TODAS) {
         return Redirect::action('TurnoController@index');
     }
     $sede = Sedes::where('id', $sede_id)->firstOrFail();
     $turnos = Turnos::where('fecha_turno', 'LIKE', "{$ano}-{$mes}-%")->where('sede_id', $sede_id)->orderBy('fecha_turno')->get();
     //-----------------------------------------
     // Si no existe turno para ese mes, crearlo a partir del anterior
     if (count($turnos) == 0) {
         $query = array('sede' => $sede_id, 'cdate' => $ano . '-' . $mes);
         return Redirect::action('TurnoController@create', $query);
     }
     $turnosArray = array();
     $turnosHtml = array();
     $incidenciasArray = array();
     foreach ($turnos as $turno) {
         $profesional = Profesional::find($turno->profesional_id);
         $turnosHtml[$turno->fecha_turno][$turno->tipo_turno] = $this->getHtmlProfRow($turno, $profesional);
         // $turnosArray
         $day = explode('-', $turno->fecha_turno)[2];
         if ($profesional !== null) {
             $turnosArray[$day][$turno->tipo_turno] = array($turno->profesional_id, "{$profesional->nombre} {$profesional->apellido1}");
         } else {
             $turnosArray[$day][$turno->tipo_turno] = array($turno->profesional_id, "");
         }
         $incidenciasArray[$day][$turno->tipo_turno] = $turno->incidencia_text;
     }
     $events = array();
     $turnosHtmlSelect = $this->getHtmlProfesionalesSedeSelects($sede_id, $turnos);
     foreach ($turnosHtml as $fecha => $value) {
         $div = $this->getHtmlCasillaCalendario($fecha, $sede_id, $turnosHtml, $turnosHtmlSelect);
         $events[$fecha] = array($div);
     }
     $calendario = $this->getTurnoCalendar($events, $ano . '-' . $mes, '/turno/' . $sede_id);
     $d = gregoriantojd($mes, 1, $ano);
     $fecha = jdmonthname($d, 1) . ' de ' . $ano;
     return View::make('turnos.show')->with(array('calendario' => $calendario, 'sede' => $sede, 'fecha' => $fecha, 'incidencias' => $incidenciasArray));
 }