/**
  * Display a listing of solvencias
  *
  * @return Response
  */
 public function index()
 {
     $solvencias = Solvencia::where('residencia_id', '=', Auth::user()->residencia_id)->orderby("año", "desc")->orderby("mes", "desc")->get();
     $solvencias->each(function ($sol) {
         $sol->facturado = traducir_fecha($sol->facturado_el->formatLocalized("%d/%m/%Y"));
         $sol->cancelado = traducir_fecha($sol->cancelado_el->formatLocalized("%d/%m/%Y"));
     });
     return Response::json($solvencias);
 }
Beispiel #2
0
 public static function getEstadoResidencia($residencia_id, $fecha_inicial = null)
 {
     if ($fecha_inicial == null) {
         $fecha_inicial = Carbon::parse(Carbon::today()->year . "/" . "01/01");
     }
     $estados = Solvencia::where('residencia_id', "=", $residencia_id)->where('año', ">=", $fecha_inicial->year)->orderBy("id", "desc")->get();
     $estados = $estados->filter(function ($estado) use($fecha_inicial) {
         return $estado->año > $fecha_inicial->year or $estado->año == $fecha_inicial->year && $estado->mes >= $fecha_inicial->month;
     });
     return $estados;
 }
Beispiel #3
0
 public function solvencias($action)
 {
     if (isset($action)) {
         if ($action == "solventar") {
             $data = Solvencia::firstOrCreate(Input::all());
             $data->estado = 1;
             $data->save();
             return View::make('admin/estadoSolvencia')->withMes($data->mes)->with('año', $data->año)->withResidencia(Residencias::find($data->residencia_id));
         }
         if ($action == "adeudar") {
             $data = Solvencia::firstOrCreate(Input::all());
             $data->estado = 3;
             $data->save();
             return View::make('admin/estadoSolvencia')->withMes($data->mes)->with('año', $data->año)->withResidencia(Residencias::find($data->residencia_id));
         }
         if ($action == "acreditar") {
             $data = Solvencia::firstOrCreate(Input::all());
             $data->estado = 2;
             $data->save();
             return View::make('admin/estadoSolvencia')->withMes($data->mes)->with('año', $data->año)->withResidencia(Residencias::find($data->residencia_id));
         }
         if ($action == "desactivar") {
             $data = Solvencia::firstOrCreate(Input::all());
             $data->estado = 0;
             $data->save();
             return View::make('admin/estadoSolvencia')->withMes($data->mes)->with('año', $data->año)->withResidencia(Residencias::find($data->residencia_id));
         }
         if ($action == "obtener") {
             $data = Solvencia::firstOrCreate(Input::all());
             $data = array_add($data, 'estado_org', $data->getOriginal('estado'));
             return Response::json($data, 200);
         }
         if ($action == "establecer") {
             Solvencia::where('id', "=", Input::get('id'))->update(Input::except('id', '_token'));
             $data = Solvencia::find(Input::get('id'));
             return Response::json($data, 200);
         }
         if ($action == "vistar") {
             $data = Solvencia::firstOrCreate(Input::all());
             return View::make('admin/estadoSolvencia')->withMes($data->mes)->with('año', $data->año)->withResidencia(Residencias::find($data->residencia_id));
         }
     }
 }