public function run()
 {
     $año = Carbon\Carbon::now()->year;
     foreach (range(1, 12) as $mes) {
         foreach (Residencias::get() as $residencia) {
             $solvencias[] = array('año' => $año, 'mes' => $mes, 'residencia_id' => $residencia->id);
         }
     }
     Solvencia::insert($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
function getDeudaTotal($residencia_id)
{
    $años = Facturas::distinct()->lists("año");
    $deuda = 0;
    foreach ($años as $año) {
        for ($mes = 1; $mes <= 12; $mes++) {
            $solvencia = Solvencia::mes($mes)->ano($año)->residencia($residencia_id)->first();
            if ($solvencia->estado == 'Moroso') {
                $deuda += $solvencia->monto;
            }
        }
    }
    return $deuda;
}
Beispiel #4
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));
         }
     }
 }
<!-- Single button -->
<?php 
$solvencia = Solvencia::firstorCreate(array('mes' => $mes, 'año' => $año, 'residencia_id' => $residencia->id));
?>
<div class="btn-group">
  <button type="button" class="btn btn-sm @if ($solvencia->estado == 'Moroso') btn-danger @elseif ($solvencia->estado =='Al Día')  btn-success @endif dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    {{$solvencia->estado}}
   <span class="caret"></span>
  </button>
  <ul class="dropdown-menu">

    <li onclick='obtener("{{$residencia->id}}","{{$mes}}","{{$año}}")'><a href="#!"><i class="fa fa-eye"></i> Ver</a></li>

    @if($solvencia->estado == "Moroso")
      <li  onclick='pagar("{{$residencia->id}}","{{$mes}}","{{$año}}")'>
      	<a style="color: green;" href="#!"><i class="fa fa-check"></i> Establecer como Pagado</a>
      </li>
      <li onclick='acreditar("{{$residencia->id}}","{{$mes}}","{{$año}}")'>
        <a style="color: orange;" href="#!"><i class="fa fa-credit-card"></i> Establecer como Acreditado</a>
      </li>
      <li onclick='desactivar("{{$residencia->id}}","{{$mes}}","{{$año}}")'>
        <a style="color: grey;" href="#!"><i class="fa fa-eye-slash"></i> No Procesar este Cobro Aún</a>
      </li>
    @endif

    @if($solvencia->estado == "Al Día")
      <li onclick='adeudar("{{$residencia->id}}","{{$mes}}","{{$año}}")'>
      	<a style="color: red;" href="#!"><i class="fa fa-times"></i> Establecer como Moroso</a>
      </li>
      <li onclick='acreditar("{{$residencia->id}}","{{$mes}}","{{$año}}")'>
        <a style="color: orange;" href="#!"><i class="fa fa-credit-card"></i> Establecer como Acreditado</a>
 /**
  * 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 cargarCobros()
 {
     $mes = Input::get('mes');
     $año = Input::get('año');
     foreach (Residencias::all() as $residencia) {
         $solvencia = Solvencia::firstorNew(['mes' => $mes, 'año' => $año, 'residencia_id' => $residencia->id]);
         $solvencia->estado = 3;
         $solvencia->monto = getdeuda($residencia->id, $mes, $año);
         $solvencia->save();
     }
     Notificacion::InsertarNotificacionesMasivas("Nuevo Recibo Agregado", "Se ha agregado el recibo de " . getMeses()[$mes] . $año);
     Session::flash('success', "Cobros cargados Correctamente");
     if (Config::get('var.push', false)) {
         $dispositivos = Dispositivo::active()->mensajes()->get();
         $disp = [];
         foreach ($dispositivos as $dispositivo) {
             $disp[] = PushNotification::Device($dispositivo->token);
         }
         $devices = PushNotification::DeviceCollection($disp);
         $message = PushNotification::Message("Se ha agregado el recibo de " . getMeses()[$mes] . $año, ['badge' => 1, 'image' => 'www/logo.png', 'soundname' => 'alert', "ledColor" => [0, 146, 234, 255], 'title' => 'Nueva Recibo Agregado']);
         $collection = PushNotification::app('android')->to($devices)->send($message);
     }
     return Redirect::to('admin/Finanzas/gestion?mes=' . $mes . '&año=' . $año);
 }
Beispiel #8
0
 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);
 }