function getdeuda($residencia_id, $mes, $año) { $maestra = json_decode(File::get(app_path("config/maestra.php")), true); $total = Facturas::wherenull("residencia_id")->where("mes", "=", $mes)->where("año", "=", $año)->where("porcentual", "=", 1)->sum('monto') * (Residencias::find($residencia_id)->alicuota / 100); $total += Facturas::wherenull("residencia_id")->where("mes", "=", $mes)->where("año", "=", $año)->where("porcentual", "=", 0)->sum('monto') / Residencias::where("id", "<>", "1")->count(); $total += Facturas::where("residencia_id", "=", $residencia_id)->where("mes", "=", $mes)->where("año", "=", $año)->sum('monto'); if ($maestra['is_fondo']) { $total += $total * ($maestra['fondo_%'] / 100); } return $total; }
public function residencias($action) { if (isset($action)) { if ($action == "create") { $data = Residencias::firstOrCreate(Input::all()); return $respuesta = array('Record' => $data, 'Result' => "OK"); } if ($action == "edit") { Residencias::where("id", Input::get("id"))->update(Input::except("id")); return $respuesta = array('Record' => Residencias::find(Input::get('id')), 'Result' => "OK"); } if ($action == "remove") { Residencias::where('id', Input::get("id"))->delete(); return '{"Result":"OK"}'; } if ($action == "list") { if (Input::has('q')) { $Records = Residencias::where("id", Input::get('q'))->get(); } else { $Records = Residencias::get(); } $respuesta = array('Records' => $Records, 'Result' => "OK"); return json_encode($respuesta); } if ($action == "personas") { $nulos = DB::table('personas')->select(DB::raw("'NO POSEE' as DisplayText,'null' as value")); $respuesta = DB::table('personas')->select("nombre as DisplayText", "id as Value")->union($nulos)->orderby('value', 'desc')->distinct()->get(); return "var opciones=" . json_encode($respuesta); } } }
public function gestionResidencias() { if (Input::has('residencia')) { $residencias = Residencias::where("nombre", 'LIKE', '%' . Input::get('residencia') . '%')->distinct()->orderby("id")->paginate(12); } else { $residencias = Residencias::distinct()->orderby("id")->paginate(Input::get('per_page', 12)); } return View::make('admin/gestionResidencias', compact('residencias')); }
public function generarFactura() { if (Input::has("persona_id")) { $persona = User::find(Input::get('persona_id')); } else { $persona = Auth::user(); } $residencia = $persona->residencia; $time = new Carbon(); $mes = Input::get('mes', $time->month); $año = Input::get('año', $time->year); $factura = DB::select(DB::raw(getFactura($residencia->id, $mes, $año))); $cant_residencias = Residencias::where("id", "<>", "1")->count(); $maestra = json_decode(File::get(app_path("config/maestra.php")), true); $html = View::make('pdf.factura')->withFactura($factura)->withResidencia($residencia)->withPersona($persona)->withMes($mes)->with('año', $año)->withMaestra($maestra)->with('cant_residencias', $cant_residencias); $html = renderVariables($html); header('Content-Type : application/pdf'); $headers = array('Content-Type' => 'application/pdf'); return Response::make(PDF::load($html, 'A4', 'portrait')->show('factura-' . $mes . "-" . $año), 200, $headers); }
<?php $stocksTable = Lava::DataTable(); $stocksTable->addStringColumn('Cantidad de Usuarios')->addNumberColumn('Cantidad'); $rowData = array('Al Día', Residencias::where('solvencia', "=", 1)->count()); $stocksTable->addRow($rowData); $rowData = array('Morosos', Residencias::where('solvencia', "=", 0)->count()); $stocksTable->addRow($rowData); $chart = Lava::PieChart('morosoChart')->title("Usuarios Morosos Vs Al Día")->colors(array('green', 'red')); $chart->datatable($stocksTable); ?> <h3 class="text-success text-center">Grafico de Usuarios Por Morosidad</h3> {{Lava:: render('PieChart', 'morosoChart', 'morosoChart', array('width'=> 500, 'height' => 300));}}