/** * Remove the specified solvencia from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::user()->residencia->id == Solvencia::find($id)->residencia_id) { Solvencia::destroy($id); return Response::json(['status' => 'TRUE'], 200); } else { return Response::json(['status' => 'ERROR'], 403); } }
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)); } } }
public function generarRecibo($id) { $solvencia = Solvencia::find($id); if (Auth::user()->residencia_id != $solvencia->residencia_id) { return Response::make("No posee los permisos para ver este recibo", 403); } $año = $solvencia->año; $mes = $solvencia->mes; $user = Auth::user(); $residencia = $solvencia->residencia; $html = View::make('pdf.comprobante')->with('año', $año)->withMes($mes)->withResidencia($residencia)->withPersona($user)->withSolvencia($solvencia); $html = renderVariables($html); header('Content-Type : application/pdf'); $headers = array('Content-Type' => 'application/pdf'); return Response::make(PDF::load($html, 'A4', 'portrait')->show('Solvencia-' . $mes . "-" . $año), 200, $headers); }