Skip to content

Commit

Permalink
last
Browse files Browse the repository at this point in the history
  • Loading branch information
SgcWeb2 committed Nov 15, 2021
1 parent 21a49ae commit c989c3d
Show file tree
Hide file tree
Showing 16 changed files with 286 additions and 46 deletions.
55 changes: 55 additions & 0 deletions app/Http/Controllers/CtrFondo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Condominio;
use App\Models\Fondo;
use Illuminate\Support\Str;
use PDF;

class CtrFondo extends Controller
Expand All @@ -18,6 +19,60 @@ public function show(Fondo $fondo)
return view('fondo.show', compact('fondo'));
}

public function exportar($filtros)
{
$filtros = Str::after($filtros, '-');
$busqueda = Str::before($filtros, '-');

$filtros = Str::after($filtros, '-');
$orden = Str::before($filtros, '-');

$filtros = Str::after($filtros, '-');
$direccion = Str::before($filtros, '-');

$filtros = Str::after($filtros, '-');
$moneda = Str::before($filtros, '-');

$filtros = Str::after($filtros, '-');
$minimo = Str::before($filtros, '-');

$filtros = Str::after($filtros, '-');
$maximo = Str::before($filtros, '-');
$fondos = Fondo::all();

switch ($moneda) {
case '0':
$fondos = $fondos->intersect(Fondo::where('moneda', 'Dólar')->get());
break;

case '1':
$fondos = $fondos->intersect(Fondo::where('moneda', 'Bolívar')->get());
break;

default:
# code...
break;
}

if ($minimo != '') {
$fondos = $fondos->intersect(Fondo::where('saldo', '>=', $minimo)->get());
}

if ($maximo != '') {
$fondos = $fondos->intersect(Fondo::where('saldo', '<=', $maximo)->get());
}

$fondos = $fondos->toQuery()
->where('descripcion', 'like', '%' . $busqueda . '%')
->orderBy($orden, $direccion)
->get();

$condominio = Condominio::first();

$pdf = PDF::loadView('fondo.pdf', compact('fondos', 'condominio'));
return $pdf->stream('fondos.pdf');
}

public function exportarMovimientos(Fondo $fondo)
{
$condominio = Condominio::first();
Expand Down
5 changes: 0 additions & 5 deletions app/Http/Livewire/Admin/Unidad/TablaUnidad.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ class TablaUnidad extends Component
public $unidad;

public $busqueda = '';
// public $orden = 'numero';
// public $direccion = "asc";
public $cantidad = '10';

public $readyToLoad = false;

protected $listeners = ['render'];

// Modal exportar
public $openExportar = false;

public $propietario = '2';
public $habitantes = '2';
public $facturas = '2';
Expand Down
65 changes: 52 additions & 13 deletions app/Http/Livewire/Fondo/TablaFondo.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class TablaFondo extends Component
public $openEdit = false;
public $openDestroy = false;

public $moneda = '2';
public $minimo = '';
public $maximo = '';

protected $rules = [
'fondo.descripcion' => 'required|max:255',
'fondo.moneda' => 'required'
Expand All @@ -32,15 +36,26 @@ class TablaFondo extends Component

public function render()
{
$fondos = $this->filtrar();

if ($this->readyToLoad) {
$fondos = Fondo::where('descripcion', 'like', '%' . $this->busqueda . '%')
->orWhere('moneda', 'like', '%' . $this->busqueda . '%')
->orderBy($this->orden, $this->direccion)
->paginate($this->cantidad);

foreach ($fondos as $fondo) {
$fondo->saldoFormateado = $this->formatearMonto($fondo->saldo, $fondo->moneda);
}

if ($fondos->count()) {

$fondos = $fondos->toQuery()
->where(function ($query) {
$query->where('descripcion', 'like', '%' . $this->busqueda . '%');
})
->orderBy($this->orden, $this->direccion)
->paginate($this->cantidad);

} else {
$fondos = [];
}

foreach ($fondos as $fondo) {
$fondo->saldoFormateado = $this->formatearMonto($fondo->saldo, $fondo->moneda);
}
} else {
$fondos = [];
}
Expand Down Expand Up @@ -78,11 +93,6 @@ public function updatingCantidad()
$this->resetPage();
}

public function loadFondos()
{
$this->readyToLoad = true;
}

public function orden($orden)
{
if ($this->orden == $orden) {
Expand All @@ -96,4 +106,33 @@ public function orden($orden)
$this->direccion = 'asc';
}
}

private function filtrar()
{
$fondos = Fondo::all();

switch ($this->moneda) {
case '0':
$fondos = $fondos->intersect(Fondo::where('moneda', 'Dólar')->get());
break;

case '1':
$fondos = $fondos->intersect(Fondo::where('moneda', 'Bolívar')->get());
break;

default:
# code...
break;
}

if ($this->minimo != '') {
$fondos = $fondos->intersect(Fondo::where('saldo', '>=', $this->minimo)->get());
}

if ($this->maximo != '') {
$fondos = $fondos->intersect(Fondo::where('saldo', '<=', $this->maximo)->get());
}

return $fondos;
}
}
17 changes: 13 additions & 4 deletions app/Http/Livewire/Pago/NuevoPago.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function rules()
'recibo' => 'required|numeric|unique:pagos_gastos,recibo',
'formaPago' => 'required',
'moneda' => 'required',
'fondo.id' => 'required',
'fondo.id' => 'required|not_in:0',
'referencia' => 'exclude_unless:formaPago,Transferencia,Pago móvil,Cheque|min:4|max:8',
'tasaCambio.tasa' => 'exclude_if:conCambio,false|required|numeric',
];
Expand Down Expand Up @@ -89,6 +89,7 @@ protected function rules()

protected $messages = [
'fondo.id.required' => 'Debe seleccionar un fondo.',
'fondo.id.not_in' => 'Debe seleccionar un fondo.',
'monto.lte' => 'El monto no debe ser mayor al saldo del fondo seleccionado o al total de la deuda.',
'tasaCambio.tasa.required_if' => 'Debe ingresar la tasa de cambio.'
];
Expand All @@ -106,29 +107,37 @@ public function mount()

public function render()
{
$this->formatoDinero = new NumberFormatter('es_VE', NumberFormatter::CURRENCY);

$gastos = Gasto::where('estado_pago', 'Pendiente')
->orderBy($this->orden, $this->direccion)
->paginate($this->cantidad);

if ($this->formaPago != '') {

if ($this->formaPago == 'Transferencia' || $this->formaPago == 'Punto de venta') {
$fondos = Fondo::has('cuenta')->where('moneda', $this->moneda)->get();

foreach ($fondos as $item) {
$item->cuenta->ocultarNumero();
}

} else if ($this->formaPago == 'Pago móvil') {
$fondos = Fondo::has('cuenta')->where('moneda', $this->moneda)->get()->whereNotNull('cuenta.telefono');

foreach ($fondos as $item) {
$item->cuenta->ocultarNumero();
}

} else {
$fondos = Fondo::doesntHave('cuenta')->where('moneda', $this->moneda)->get();
}

foreach ($fondos as $item) {
if ($item->moneda == 'Bolívar') {
$item->saldoFormateado = $this->formatoDinero->format($item->saldo);
} elseif ($item->moneda == 'Dólar') {
$item->saldoFormateado = $this->formatoDinero->formatCurrency($item->saldo, $this->dolar);
}
}
} else {
$fondos = [];
}
Expand Down
7 changes: 6 additions & 1 deletion app/Models/Cuenta.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function fondo()

public function ocultarNumero()
{
$this->numero = Str::substr($this->numero, 0, 4) . '############' . Str::substr($this->numero, 16, 4);
$this->numero = Str::substr($this->numero, 0, 4) . '-####-##-######' . Str::substr($this->numero, 16, 4);
}

public function getNumeroOculto()
{
return $this->numero = Str::substr($this->numero, 0, 4) . '-####-##-######' . Str::substr($this->numero, 16, 4);
}
}
2 changes: 1 addition & 1 deletion app/Models/Fondo.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getMovimientos()
$item->tipo = 'Crédito';
}

$movimientos = $egresos->merge($ingresos)->sortBy('fecha');
$movimientos = $ingresos->merge($egresos)->sortBy('fecha');

return $movimientos;
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/unidad/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
<div class="bg-white {{-- overflow-hidden --}} shadow-xl sm:rounded-lg">

<div class="p-4">
@livewire('admin.unidad.tabla-unidad')
Expand Down
8 changes: 4 additions & 4 deletions resources/views/components/select-cantidad.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@props([
{{-- @props([
'cantidad'
])
]) --}}

<div class="flex items-center text-sm">
<div class="flex items-center text-sm space-x-2">
<span>Mostrar</span>

<select wire:model="cantidad" class="ml-2 form-control">
<select wire:model="cantidad" class="form-control">
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/fondo/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
<div class="bg-white {{-- overflow-hidden --}} shadow-xl sm:rounded-lg">

<div class="p-4">
@livewire('fondo.tabla-fondo')
Expand Down
64 changes: 64 additions & 0 deletions resources/views/fondo/pdf.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="es">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>

<link rel="stylesheet" href="{{ public_path('css/pdf.css') }}">

<body>

<div>
Condominio: <span>{{ $condominio->nombre }}</span>
<br>
<span>Fecha: {{ substr(today(), 0, 10) }}</span>
</div>

<div class="absolute" style="top: 0px; right: 0px;">
<span style="font-size: 2rem">SGC Web</span>

<div class="bg-azul p-2 relative" style="height: 50px; width: 50px; border-radius: 30px; left:35px">
<img width="50" height="50" src="{{ asset('img/logo/blanco.png') }}" alt="">
</div>
</div>

<div class="text-center">
<h1>Lista de fondos</h1>
</div>

<table>
<thead>
<tr>
<th>Nombre</th>
<th>Saldo</th>
<th>Moneda</th>
<th>Cuenta</th>
</tr>
</thead>
<tbody>
@foreach ($fondos as $item)
<tr>
<td>
{{ $item->descripcion }}
</td>
<td>
{{ $item->moneda }}
</td>
<td>
{{ $item->saldo }}
</td>
<td>
@if ($item->cuenta)
{{ $item->cuenta->getNumeroOculto() }}
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</body>

</html>
7 changes: 4 additions & 3 deletions resources/views/livewire/admin/administracion.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div>

<div class="grid grid-cols-5 gap-4 h-auto">
<div class="flex flex-col lg:grid lg:grid-cols-5 gap-4 h-auto">

<div class="col-span-3 grid grid-cols-3 gap-3">
<x-card-condominio class="col-span-2 lg:order-2" />

<div class="col-span-3 grid grid-cols-2 sm:grid-cols-2 md:grid-cols-3 gap-3 lg:order-1">

@foreach ($menu as $item)
<a href="{{ route($item['ruta']) }}">
Expand All @@ -12,7 +14,6 @@

</div>

<x-card-condominio class="col-span-2" />
</div>

<x-jet-dialog-modal wire:model="openMensualidad">
Expand Down
Loading

0 comments on commit c989c3d

Please sign in to comment.