Separar datos inicio

This commit is contained in:
2023-10-11 09:03:44 -03:00
parent e4328d8604
commit 0d558b7980
9 changed files with 327 additions and 119 deletions

View File

@ -1,6 +1,7 @@
<?php
use Incoviba\Controller\Ventas\Cierres;
use Incoviba\Controller\API\Ventas\Cierres;
$app->group('/cierres', function($app) {
$app->get('/vigentes[/]', [Cierres::class, 'vigentes']);
$app->post('[/]', [Cierres::class, 'proyecto']);
});

View File

@ -0,0 +1,8 @@
<?php
use Incoviba\Controller\API\Ventas\Cuotas;
$app->group('/cuotas', function($app) {
$app->get('/hoy[/]', [Cuotas::class, 'hoy']);
$app->get('/pendiente[/]', [Cuotas::class, 'pendiente']);
$app->get('/vencer[/]', [Cuotas::class, 'porVencer']);
});

View File

@ -4,23 +4,83 @@
<div class="ui container">
<h4 class="ui header">Bienvenid@ {{$user->name}}</h4>
<div class="ui basic fitted segment">
@if ($cuotas_hoy > 0)
Existe{{$cuotas_hoy > 1 ? 'n' : ''}} {{$cuotas_hoy}} deposito{{$cuotas_hoy > 1 ? 's' : ''}} para hoy.
<br />
@endif
@if ($cuotas_pendientes > 0)
<a href="{{$urls->base}}/ventas/cuotas/pendientes">
Existe{{$cuotas_pendientes > 1 ? 'n' : ''}} {{$cuotas_pendientes}} cuota{{$cuotas_pendientes > 1 ? 's' : ''}} pendiente{{$cuotas_pendientes > 1 ? 's' : ''}}. <i class="right arrow icon"></i>
</a>
@endif
<span id="cuotas_hoy"></span>
<span id="cuotas_pendientes"></span>
</div>
<div class="ui two column grid">
<div class="column">
@include('home.cuotas_por_vencer')
</div>
<div class="column">
Alertas
</div>
<div class="column">
@include('home.cierres_vigentes')
</div>
</div>
</div>
@endsection
@push('page_scripts')
<script type="text/javascript">
const cuotas = {
get: function() {
return {
hoy: () => {
const span = $('#cuotas_hoy')
return fetch('{{$urls->api}}/ventas/cuotas/hoy').then(response => {
span.html('')
if (response.ok) {
return response.json()
}
}).then(data => {
let output = 'Existe'
if (data.cuotas > 1) {
output += 'n'
}
output += ' ' + data.cuotas + ' deposito'
if (data.cuotas > 1) {
output += 's'
}
output += ' para hoy.<br />'
span.html(output)
})
},
pendiente: () => {
const span = $('#cuotas_pendientes')
return fetch('{{$urls->api}}/ventas/cuotas/pendiente').then(response => {
span.html('')
if (response.ok) {
return response.json()
}
}).then(data => {
const link = $('<a></a>').attr('href', '{{$urls->base}}/ventas/cuotas/pendientes')
let output = 'Existe'
if (data.cuotas > 1) {
output += 'n'
}
output += ' ' + data.cuotas + ' cuota'
if (data.cuotas > 1) {
output += 's'
}
output += ' pendiente'
if (data.cuotas > 1) {
output += 's'
}
output += ' por cobrar. <i class="right arrow icon"></i>'
link.html(output)
span.html(link)
})
}
}
},
run: function() {
this.get().hoy()
this.get().pendiente()
}
}
$(document).ready(() => {
cuotas.run()
})
</script>
@endpush

View File

@ -1,24 +1,59 @@
<h4 class="ui dividing header">Cierres Vigentes</h4>
<div class="ui divided list">
@foreach($cierres_vigentes as $proyecto => $estados)
<div class="item">
<div class="ui feed">
<div class="date">
<strong>{{$proyecto}}</strong> [{{$estados['total']}}]
</div>
<div class="event">
<div class="content">Promesados</div>
<div class="meta">{{$estados['promesados']}}</div>
</div>
<div class="event">
<div class="content">Pendientes</div>
<div class="meta">{{$estados['pendientes']}}</div>
</div>
<div class="event">
<div class="content">Rechazados</div>
<div class="meta">{{$estados['rechazados']}}</div>
</div>
</div>
</div>
@endforeach
</div>
<div class="ui divided list" id="cierres_vigentes"></div>
@push('page_scripts')
<script type="text/javascript">
const cierres_vigentes = {
get: function() {
const list = $('#cierres_vigentes')
list.html('')
list.append(
$('<div><div>').addClass('ui inline active loader')
)
fetch('{{$urls->api}}/ventas/cierres/vigentes').then(response => {
list.html('')
if (response.ok) {
return response.json()
}
}).then(data => {
this.draw(data.cierres)
})
},
draw: function(cierres) {
const list = $('#cierres_vigentes')
Object.entries(cierres).forEach(([proyecto, estados]) => {
const item = $('<div></div>').addClass('item')
const feed = $('<div></div>').addClass('ui feed')
feed.append(
$('<div></div>').addClass('date').append(
$('<strong></strong>').html(proyecto).append('[' + estados['total'] + ']')
)
).append(
$('<div></div>').addClass('event').append(
$('<div></div>').addClass('content').html('Promesados')
).append(
$('<div></div>').addClass('meta').html(estados['promesados'])
)
).append(
$('<div></div>').addClass('event').append(
$('<div></div>').addClass('content').html('Pendientes')
).append(
$('<div></div>').addClass('meta').html(estados['pendientes'])
)
).append(
$('<div></div>').addClass('event').append(
$('<div></div>').addClass('content').html('Rechazados')
).append(
$('<div></div>').addClass('meta').html(estados['rechazados'])
)
)
item.append(feed)
list.append(item)
})
}
}
$(document).ready(() => {
cierres_vigentes.get()
})
</script>
@endpush

View File

@ -1,22 +1,52 @@
<h4 class="ui dividing header">Cuotas Por Vencer</h4>
<div class="ui divided list">
@foreach ($cuotas_por_vencer as $date => $proyectos)
<div class="item">
<div class="ui feed">
<div class="date">
<strong>{{$format->localDate($date, "EEE. dd 'de' MMMM 'de' yyyy", true)}}</strong>
</div>
@foreach ($proyectos as $proyecto => $cuotas)
<div class="event">
<div class="content">
<span class="ui small text">
{{$proyecto}}
</span>
</div>
<div class="meta">{{$cuotas}}</div>
</div>
@endforeach
</div>
</div>
@endforeach
</div>
<div class="ui divided list" id="cuotas_por_vencer"></div>
@push('page_scripts')
<script type="text/javascript">
const cuotas_por_vencer = {
get: function() {
const list = $('#cuotas_por_vencer')
list.html('')
list.append(
$('<div><div>').addClass('ui inline active loader')
)
return fetch('{{$urls->api}}/ventas/cuotas/vencer').then(response => {
list.html('')
if (response.ok) {
return response.json()
}
}).then(data => {
this.draw(data.cuotas)
})
},
draw: function(cuotas) {
const list = $('#cuotas_por_vencer')
Object.entries(cuotas).forEach(([fecha, proyectos]) => {
const item = $('<div></div>').addClass('item')
const feed = $('<div></div>').addClass('ui feed')
feed.append(
$('<div></div>').addClass('date').append(
$('<strong></strong>').html(fecha)
)
)
Object.entries(proyectos).forEach(([proyecto, cuotas]) => {
const event = $('<div></div>').addClass('event')
event.append(
$('<div></div>').addClass('content').append(
$('<span></span>').addClass('ui small text').html(proyecto)
)
).append(
$('<div></div>').addClass('meta').html(cuotas)
)
feed.append(event)
})
item.append(feed)
list.append(item)
})
}
}
$(document).ready(() => {
cuotas_por_vencer.get()
})
</script>
@endpush

View File

@ -71,6 +71,8 @@
)
).append(
$('<td></td>').append(unidad)
).append(
$('<td></td>').append(this.unidad.descripcion.padStart(4, '0'))
).append(
$('<td></td>').append(propietario)
).append(
@ -160,7 +162,23 @@
table.append(thead).append(tbody)
parent.append(table)
this.table = new DataTable(table)
this.table = new DataTable(table, {
order: [
[0, 'asc'],
[2, 'asc']
],
columnDefs: [
{
target: 2,
visible: false,
searchable: false
},
{
target: 1,
orderData: [2]
}
]
})
},
head: () => {
return $('<thead></thead>').append(
@ -168,6 +186,8 @@
$('<th></th>').html('Proyecto')
).append(
$('<th></th>').html('Unidad')
).append(
$('<th></th>').html('Unidad [Sort]')
).append(
$('<th></th>').html('Propietario')
).append(