/** * Display a listing of the resource. * * @return Response */ public function index() { $fechahoy = date("Y-m-j"); $fecha = Turno::where('fechaturno', '=', $fechahoy)->first(); if (count($turnoo = Turno::all()) != 0) { $farmacias = Turno::find($fecha->id)->farmacias; $mensaje = "no esta de Turno"; foreach ($farmacias as $key) { if ($key->id == Session::get('farmacia_id')) { $mensaje = "Esta de turno"; } } return View::make('farmacia.inicio')->with('mensaje', $mensaje)->with('fechahoy', $fechahoy); } else { $mensaje = "no esta de Turno"; return View::make('farmacia.inicio')->with('mensaje', $mensaje)->with('fechahoy', $fechahoy); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { try { // $modelo = $this->modelo->find($id); //turnos asignados $ta = $modelo->turnos()->where('estado', 'A')->get(); if (count($ta) > 0) { return Response::json(array('error' => true, 'mensaje' => 'No se puede eliminar la agenda porque tiene turnos asignados', 'listado' => $modelo->toArray()), 200); } else { $affected_rows = Turno::where('agenda_id', $modelo->id)->delete(); $this->eventoAuditar($modelo); $eliminado = $modelo->delete(); $this->eventoAuditar($modelo); return Response::json(array('error' => false, 'listado' => $modelo->toArray()), 200); } } catch (Exception $e) { return Response::json(array('error' => true, 'mensaje' => $e->getMessage(), 'listado' => $modelo->toArray()), 200); } }
public function tomar_turno($paciente_prepaga_id) { $params = Input::all(); unset($params['apikey']); $turno_id = $params["turno_id"]; $tipo = isset($params["tipo"]) && !empty($params["tipo"]) ? $params["tipo"] : "T"; $user_id = Auth::user()->id; $paciente_prepaga = PacientePrepaga::findOrFail($paciente_prepaga_id); $turnos = explode(",", $turno_id); //si son muchos turnos if (count($turnos) > 1) { $objTurnos = Turno::whereIn('id', $turnos)->where('estado', 'L')->get(); if (count($objTurnos) == count($turnos)) { $affectedRows = Turno::whereIn('id', $turnos)->where('estado', 'L')->update(array('estado' => 'A', 'paciente_prepaga_id' => $paciente_prepaga->id, 'user_id' => $user_id)); if ($affectedRows == count($turnos)) { foreach ($objTurnos as $cadaTurno) { $this->eventoAuditar($cadaTurno); } $turno = Turno::findOrFail($turnos[0]); return Response::json(array('error' => false, 'listado' => array($turno->find($turno->id)->toArray())), 200); } else { return Response::json(array('error' => true, 'mensaje' => 'No se pudieron asignar los turnos', 'envio' => $params), 200); } } else { return Response::json(array('error' => true, 'mensaje' => "alguno de los turnos está tomado"), 200); } } else { //es un solo turno $turno = Turno::findorFail($turno_id); //chequea entreturno if ($tipo == 'E') { $otros_entreturnos = Turno::where('padre', '=', $turno->id)->get(); $new_turno = new Turno(); $new_turno->fill($turno->toArray()); $new_turno->id = null; $new_turno->padre = $turno->id; $turno = $new_turno; $turno->tipo_turno = 'E'; $desde = strtotime(substr($turno->hora_desde, 0, 2) . ":" . substr($turno->hora_desde, -2)); $hasta = strtotime(substr($turno->hora_hasta, 0, 2) . ":" . substr($turno->hora_hasta, -2)); if (count($otros_entreturnos) == 0) { $n_desde = $desde + ($hasta - $desde) / 2; $turno->hora_desde = date('Hi', $n_desde); } else { $intervalo = ($hasta - $desde) / (2 + count($otros_entreturnos)); $n_desde = $desde + $intervalo; foreach ($otros_entreturnos as $entreturno) { $entreturno->hora_desde = date('Hi', $n_desde); $entreturno->save(); $n_desde += $intervalo; } $turno->hora_desde = date('Hi', $n_desde); } $turno->estado = 'L'; } //falta verificar turno bloqueado x mismo usuario if ($turno->estado == 'L') { $turno->estado = 'A'; $turno->paciente_prepaga_id = $paciente_prepaga->id; $turno->user_id = $user_id; if ($turno->save()) { $this->eventoAuditar($turno); return Response::json(array('error' => false, 'listado' => array($turno->find($turno->id)->toArray())), 200); } else { return Response::json(array('error' => true, 'mensaje' => HerramientasController::getErrores($turno->validator), 'envio' => $params), 200); } } else { return Response::json(array('error' => true, 'mensaje' => "turno tomado"), 200); } } }
public function damefarmaciasporturno() { if (Request::ajax()) { $fec = date('Y-m-j'); $fechaa = Turno::where('fechaturno', '=', $fec)->first(); $farmacias = Turno::find($fechaa->id)->farmacias; for ($i = 0; $i < count($farmacias); $i++) { $geolocalizacion = Farmacia::find($farmacias[$i]->id)->geolocalizacion; $array[$i] = array("nombre" => $farmacias[$i]->nombre, "telefono" => $farmacias[$i]->telefono, "direccion" => $farmacias[$i]->direccion, "puntox" => $geolocalizacion->puntox, "puntoy" => $geolocalizacion->puntoy); } echo json_encode($array); } }
@extends('layoutsadministrador.baseturno') @section('content') <center><h1>Informacion sobre asignacion de turnos</h1> <?php $turnos = Turno::all()->lists('fechaturno'); if (count($turnos) > 0) { $primerturno = Turno::where('fechaturno', '=', $turnos[0])->first(); $farmacias = Turno::find($primerturno->id)->farmacias; } else { $farmacias = array(); } ?> @if(count($turnos)!=0) <h2>Turnos</h2> <p>Las fechas de turnos ya fueron asignados, si desea asignarlos nuevamente eliminelos!</p> @endif @if(count($turnos)==0) <h2>Turnos</h2> <p>Turnos vacios puede asignarlos hacendo click en Asignar fechas para turnos</p> @endif @if(count($farmacias)!=0) <h2>Sorteo de turnos</h2> <p>Los turnos ya fueron sorteados, elimine los sorteos si desea sortear nuevamente los turnos</p> @endif @if(count($farmacias)==0) <h2>Sorteo de turnos</h2> <p> El sorteo de turnos esta disponible.</p> @endif </center>
public function Rdehoy() { try { $fecha = date("Y-m-j"); $fe = Turno::where('fechaturno', '=', $fecha)->first(); $farmacias = Turno::find($fe->id)->farmacias; //foreach ($farmacias as $key) { // echo $key->nombre."<br>"; //} $html = View::make('administrador.turnos.reportehoy')->with('farmacias', $farmacias)->with('fecha', $fecha); return PDF::load($html, 'A4', 'portrait')->download('zonasreporte'); } catch (Exception $e) { $error = "No existen fechas de turnos asignadas todava, o esta tratand de realizar acciones incorrectas"; return View::make('administrador.turnos.errores')->with('error', $error); } }