/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $profesional = Profesional::find($id); $profesional->activo = 0; $profesional->update(); return Redirect::action('ProfesionalController@index')->with('message', 'Profesional eliminado con éxito.'); }
public function listado_gf() { $validator = Validator::make(Input::all(), Guardias::$rules); if ($validator->passes()) { $profesional = Profesional::find(Input::get('profesional')); $sede = Sedes::find(Input::get('sede')); $fecha_inicio = explode('/', Input::get('fecha_inicio')); $fecha_inicio = $fecha_inicio[2] . "-" . $fecha_inicio[1] . "-" . $fecha_inicio[0]; $fecha_fin = explode('/', Input::get('fecha_fin')); $fecha_fin = $fecha_fin[2] . "-" . $fecha_fin[1] . "-" . $fecha_fin[0]; $guardias = Guardias::whereBetween('fecha_guardia', array($fecha_inicio, $fecha_fin))->where('sede_id', $sede->id)->where('profesional_id', $profesional->id)->select(DB::raw("DATE_FORMAT(fecha_guardia, '%d/%m/%Y') as fecha"), DB::raw("DATE_FORMAT(fecha_guardia, '%w') as dow"))->get(); $opciones = Opciones::where('nombre', 'guardia_finde')->orWhere('nombre', 'guardia_laborable')->lists('valor', 'nombre'); var_dump($opciones); $suma = 0; foreach ($guardias as $guardia) { if ($guardia->dow != 0) { $guardia->euros = number_format($opciones['guardia_laborable'], 2, ',', '.'); } else { $guardia->euros = number_format($opciones['guardia_finde'], 2, ',', '.'); } $suma = number_format($suma + $guardia->euros, 2, ',', '.'); } //var_dump($guardias);die; return View::make('guardias.listado_gf')->with('guardias', $guardias)->with('profesional', $profesional)->with('sede', $sede)->with('fecha_inicio', $fecha_inicio)->with('fecha_fin', $fecha_fin)->with('opciones', $opciones)->with('suma', $suma); } else { return Redirect::to('guardia/listado')->with('message', '<h3 style="color: red"> Debe de indicar una fecha de inicio y de fin válidas.</h3>')->withErrors($validator)->withInput(); } }
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)); }