Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $farmacias = Farmacia::all();
     // ->orderBy('created_at','dsc')
     // ->get();
     return Response::json($farmacias, 200);
 }
 public function damefarmacias()
 {
     if (Request::ajax()) {
         $farmacias = Farmacia::all();
         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);
     }
 }
 public function reportefarmaciasgeneral()
 {
     $farmacias = Farmacia::all();
     $html = View::make('administrador.farmacias.reportefarmaciasgeneral')->with('farmacias', $farmacias);
     return PDF::load($html, 'A4', 'portrait')->show();
     //return PDF::load($html, 'A4', 'portrait')->show();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     try {
         $frm = Farmacia::all();
         $trns = Farmacia::find($frm[0]->id)->turnos;
         if (count($trns) != 0) {
             $año = date("Y");
             $añosig = $año + 1;
             $sorteo = rand(1, 31);
             $fec = $año . "-01-" . $sorteo;
             $farmacia = Farmacia::where('nombre', '=', Input::get('farmacia'))->first();
             $farmacia->turnohabilitado = "si";
             $farmacia->save();
             $diass = "";
             //echo $farmacia->id." le todo el dia"." : ".$fec."<br>";
             while ($año != $añosig) {
                 $tur = Turno::where('fechaturno', '=', $fec)->first();
                 $controlaño = $fec[0] . $fec[1] . $fec[2] . $fec[3];
                 if ($controlaño == $añosig) {
                     break;
                 } else {
                     $farmacia->turnos()->attach($tur);
                     //echo $farmacia->id." le todo el dia"." : ".$tur->fechaturno."<br>";
                 }
                 $fec = strtotime('+29 day', strtotime($fec));
                 $fec = date('Y-m-j', $fec);
             }
             return Redirect::route('turno.index');
         } else {
             $error = "todavia no se sortearon los turnos, esta opcion es para asignar turnos a nuevas farmacias despues de haber sorteado los turnos ";
             return View::make('administrador.turnos.errores')->with('error', $error);
         }
     } catch (Exception $e) {
         $error = "esta tratando de hacer cosas incorrectas";
         return View::make('administrador.turnos.errores')->with('error', $error);
     }
 }