Separar datos inicio
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
use Incoviba\Controller\Ventas\Cierres;
|
use Incoviba\Controller\API\Ventas\Cierres;
|
||||||
|
|
||||||
$app->group('/cierres', function($app) {
|
$app->group('/cierres', function($app) {
|
||||||
|
$app->get('/vigentes[/]', [Cierres::class, 'vigentes']);
|
||||||
$app->post('[/]', [Cierres::class, 'proyecto']);
|
$app->post('[/]', [Cierres::class, 'proyecto']);
|
||||||
});
|
});
|
||||||
|
8
app/resources/routes/api/ventas/cuotas.php
Normal file
8
app/resources/routes/api/ventas/cuotas.php
Normal 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']);
|
||||||
|
});
|
@ -4,23 +4,83 @@
|
|||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<h4 class="ui header">Bienvenid@ {{$user->name}}</h4>
|
<h4 class="ui header">Bienvenid@ {{$user->name}}</h4>
|
||||||
<div class="ui basic fitted segment">
|
<div class="ui basic fitted segment">
|
||||||
@if ($cuotas_hoy > 0)
|
<span id="cuotas_hoy"></span>
|
||||||
Existe{{$cuotas_hoy > 1 ? 'n' : ''}} {{$cuotas_hoy}} deposito{{$cuotas_hoy > 1 ? 's' : ''}} para hoy.
|
<span id="cuotas_pendientes"></span>
|
||||||
<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
|
|
||||||
</div>
|
</div>
|
||||||
<div class="ui two column grid">
|
<div class="ui two column grid">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@include('home.cuotas_por_vencer')
|
@include('home.cuotas_por_vencer')
|
||||||
</div>
|
</div>
|
||||||
|
<div class="column">
|
||||||
|
Alertas
|
||||||
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@include('home.cierres_vigentes')
|
@include('home.cierres_vigentes')
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@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
|
||||||
|
@ -1,24 +1,59 @@
|
|||||||
<h4 class="ui dividing header">Cierres Vigentes</h4>
|
<h4 class="ui dividing header">Cierres Vigentes</h4>
|
||||||
<div class="ui divided list">
|
<div class="ui divided list" id="cierres_vigentes"></div>
|
||||||
@foreach($cierres_vigentes as $proyecto => $estados)
|
|
||||||
<div class="item">
|
@push('page_scripts')
|
||||||
<div class="ui feed">
|
<script type="text/javascript">
|
||||||
<div class="date">
|
const cierres_vigentes = {
|
||||||
<strong>{{$proyecto}}</strong> [{{$estados['total']}}]
|
get: function() {
|
||||||
</div>
|
const list = $('#cierres_vigentes')
|
||||||
<div class="event">
|
list.html('')
|
||||||
<div class="content">Promesados</div>
|
list.append(
|
||||||
<div class="meta">{{$estados['promesados']}}</div>
|
$('<div><div>').addClass('ui inline active loader')
|
||||||
</div>
|
)
|
||||||
<div class="event">
|
fetch('{{$urls->api}}/ventas/cierres/vigentes').then(response => {
|
||||||
<div class="content">Pendientes</div>
|
list.html('')
|
||||||
<div class="meta">{{$estados['pendientes']}}</div>
|
if (response.ok) {
|
||||||
</div>
|
return response.json()
|
||||||
<div class="event">
|
}
|
||||||
<div class="content">Rechazados</div>
|
}).then(data => {
|
||||||
<div class="meta">{{$estados['rechazados']}}</div>
|
this.draw(data.cierres)
|
||||||
</div>
|
})
|
||||||
</div>
|
},
|
||||||
</div>
|
draw: function(cierres) {
|
||||||
@endforeach
|
const list = $('#cierres_vigentes')
|
||||||
</div>
|
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
|
||||||
|
@ -1,22 +1,52 @@
|
|||||||
<h4 class="ui dividing header">Cuotas Por Vencer</h4>
|
<h4 class="ui dividing header">Cuotas Por Vencer</h4>
|
||||||
<div class="ui divided list">
|
<div class="ui divided list" id="cuotas_por_vencer"></div>
|
||||||
@foreach ($cuotas_por_vencer as $date => $proyectos)
|
|
||||||
<div class="item">
|
@push('page_scripts')
|
||||||
<div class="ui feed">
|
<script type="text/javascript">
|
||||||
<div class="date">
|
const cuotas_por_vencer = {
|
||||||
<strong>{{$format->localDate($date, "EEE. dd 'de' MMMM 'de' yyyy", true)}}</strong>
|
get: function() {
|
||||||
</div>
|
const list = $('#cuotas_por_vencer')
|
||||||
@foreach ($proyectos as $proyecto => $cuotas)
|
list.html('')
|
||||||
<div class="event">
|
list.append(
|
||||||
<div class="content">
|
$('<div><div>').addClass('ui inline active loader')
|
||||||
<span class="ui small text">
|
)
|
||||||
{{$proyecto}}
|
return fetch('{{$urls->api}}/ventas/cuotas/vencer').then(response => {
|
||||||
</span>
|
list.html('')
|
||||||
</div>
|
if (response.ok) {
|
||||||
<div class="meta">{{$cuotas}}</div>
|
return response.json()
|
||||||
</div>
|
}
|
||||||
@endforeach
|
}).then(data => {
|
||||||
</div>
|
this.draw(data.cuotas)
|
||||||
</div>
|
})
|
||||||
@endforeach
|
},
|
||||||
</div>
|
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
|
||||||
|
@ -71,6 +71,8 @@
|
|||||||
)
|
)
|
||||||
).append(
|
).append(
|
||||||
$('<td></td>').append(unidad)
|
$('<td></td>').append(unidad)
|
||||||
|
).append(
|
||||||
|
$('<td></td>').append(this.unidad.descripcion.padStart(4, '0'))
|
||||||
).append(
|
).append(
|
||||||
$('<td></td>').append(propietario)
|
$('<td></td>').append(propietario)
|
||||||
).append(
|
).append(
|
||||||
@ -160,7 +162,23 @@
|
|||||||
table.append(thead).append(tbody)
|
table.append(thead).append(tbody)
|
||||||
parent.append(table)
|
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: () => {
|
head: () => {
|
||||||
return $('<thead></thead>').append(
|
return $('<thead></thead>').append(
|
||||||
@ -168,6 +186,8 @@
|
|||||||
$('<th></th>').html('Proyecto')
|
$('<th></th>').html('Proyecto')
|
||||||
).append(
|
).append(
|
||||||
$('<th></th>').html('Unidad')
|
$('<th></th>').html('Unidad')
|
||||||
|
).append(
|
||||||
|
$('<th></th>').html('Unidad [Sort]')
|
||||||
).append(
|
).append(
|
||||||
$('<th></th>').html('Propietario')
|
$('<th></th>').html('Propietario')
|
||||||
).append(
|
).append(
|
||||||
|
55
app/src/Controller/API/Ventas/Cierres.php
Normal file
55
app/src/Controller/API/Ventas/Cierres.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Controller\API\Ventas;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||||
|
use Incoviba\Repository;
|
||||||
|
use Incoviba\Service;
|
||||||
|
|
||||||
|
class Cierres
|
||||||
|
{
|
||||||
|
public function proyecto(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Cierre $service): ResponseInterface
|
||||||
|
{
|
||||||
|
$body = $request->getBody();
|
||||||
|
$json = json_decode($body->getContents());
|
||||||
|
$proyecto_id = $json->proyecto_id;
|
||||||
|
$output = ['total' => 0];
|
||||||
|
try {
|
||||||
|
$cierres = $service->getByProyecto($proyecto_id);
|
||||||
|
$output['cierres'] = $cierres;
|
||||||
|
$output['total'] = count($cierres);
|
||||||
|
} catch (EmptyResult) {}
|
||||||
|
$response->getBody()->write(json_encode($output));
|
||||||
|
return $response->withHeader('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
public function vigentes(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cierre $cierreRepository): ResponseInterface
|
||||||
|
{
|
||||||
|
$cierres = $cierreRepository->fetchDatosVigentes();
|
||||||
|
$output = [];
|
||||||
|
$estados = [
|
||||||
|
'revisado' => 'pendientes',
|
||||||
|
'rechazado' => 'rechazados',
|
||||||
|
'aprobado' => 'pendientes',
|
||||||
|
'vendido' => 'promesados',
|
||||||
|
'abandonado' => 'rechazados',
|
||||||
|
'promesado' => 'promesados',
|
||||||
|
'resciliado' => 'rechazados'
|
||||||
|
];
|
||||||
|
foreach ($cierres as $row) {
|
||||||
|
if (!isset($output[$row['Proyecto']])) {
|
||||||
|
$output[$row['Proyecto']] = [
|
||||||
|
'promesados' => 0,
|
||||||
|
'pendientes' => 0,
|
||||||
|
'rechazados' => 0,
|
||||||
|
'total' => 0
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$estado = $estados[$row['Estado']];
|
||||||
|
$output[$row['Proyecto']][$estado] += $row['Cantidad'];
|
||||||
|
$output[$row['Proyecto']]['total'] += $row['Cantidad'];
|
||||||
|
}
|
||||||
|
$response->getBody()->write(json_encode(['cierres' => $output]));
|
||||||
|
return $response->withHeader('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
}
|
59
app/src/Controller/API/Ventas/Cuotas.php
Normal file
59
app/src/Controller/API/Ventas/Cuotas.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Controller\API\Ventas;
|
||||||
|
|
||||||
|
use DateTimeImmutable;
|
||||||
|
use DateInterval;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Incoviba\Repository;
|
||||||
|
use Incoviba\Service;
|
||||||
|
|
||||||
|
class Cuotas
|
||||||
|
{
|
||||||
|
public function hoy(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cuota $cuotaRepository): ResponseInterface
|
||||||
|
{
|
||||||
|
$output = [
|
||||||
|
'cuotas' => count($cuotaRepository->fetchHoy()) ?? 0
|
||||||
|
];
|
||||||
|
$response->getBody()->write(json_encode($output));
|
||||||
|
return $response->withHeader('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
public function pendiente(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cuota $cuotaRepository): ResponseInterface
|
||||||
|
{
|
||||||
|
$output = [
|
||||||
|
'cuotas' => count($cuotaRepository->fetchPendientes()) ?? 0
|
||||||
|
];
|
||||||
|
$response->getBody()->write(json_encode($output));
|
||||||
|
return $response->withHeader('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
public function porVencer(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cuota $cuotaRepository, Service\Format $formatService): ResponseInterface
|
||||||
|
{
|
||||||
|
$cuotas = $cuotaRepository->fetchDatosPorVencer();
|
||||||
|
$output = [];
|
||||||
|
foreach ($cuotas as $row) {
|
||||||
|
$fecha = $row['Fecha'];
|
||||||
|
$date = new DateTimeImmutable($fecha);
|
||||||
|
if (($weekday = $date->format('N')) > 5) {
|
||||||
|
$day_diff = 7 - $weekday + 1;
|
||||||
|
$date = $date->add(new DateInterval("P{$day_diff}D"));
|
||||||
|
$fecha = $date->format('Y-m-d');
|
||||||
|
}
|
||||||
|
$key = $formatService->localDate($fecha, "EEE. dd 'de' MMMM 'de' yyyy", true);
|
||||||
|
if (!isset($output[$key])) {
|
||||||
|
$output[$key] = [];
|
||||||
|
}
|
||||||
|
if (!isset($output[$key][$row['Proyecto']])) {
|
||||||
|
$output[$key][$row['Proyecto']] = 0;
|
||||||
|
}
|
||||||
|
$output[$key][$row['Proyecto']] += $row['Cantidad'];
|
||||||
|
}
|
||||||
|
foreach ($output as $key => $day) {
|
||||||
|
uksort($day, function($a, $b) {
|
||||||
|
return strcmp($a, $b);
|
||||||
|
});
|
||||||
|
$output[$key] = $day;
|
||||||
|
}
|
||||||
|
$response->getBody()->write(json_encode(['cuotas' => $output]));
|
||||||
|
return $response->withHeader('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
}
|
@ -11,10 +11,10 @@ use Incoviba\Repository;
|
|||||||
|
|
||||||
class Base
|
class Base
|
||||||
{
|
{
|
||||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Login $service, Repository\Venta\Cuota $cuotaRepository, Repository\Venta\Cierre $cierreRepository): ResponseInterface
|
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Login $service): ResponseInterface
|
||||||
{
|
{
|
||||||
if ($service->isIn()) {
|
if ($service->isIn()) {
|
||||||
return $this->home($response, $view, $cuotaRepository, $cierreRepository);
|
return $this->home($response, $view);
|
||||||
}
|
}
|
||||||
return $this->login($response, $view);
|
return $this->login($response, $view);
|
||||||
}
|
}
|
||||||
@ -22,72 +22,12 @@ class Base
|
|||||||
{
|
{
|
||||||
return $view->render($response, 'construccion');
|
return $view->render($response, 'construccion');
|
||||||
}
|
}
|
||||||
protected function home(ResponseInterface $response, View $view, Repository\Venta\Cuota $cuotaRepository, Repository\Venta\Cierre $cierreRepository): ResponseInterface
|
protected function home(ResponseInterface $response, View $view): ResponseInterface
|
||||||
{
|
{
|
||||||
$cuotas_hoy = count($cuotaRepository->fetchHoy()) ?? 0;
|
return $view->render($response, 'home');
|
||||||
$cuotas_pendientes = count($cuotaRepository->fetchPendientes()) ?? 0;
|
|
||||||
$cuotas_por_vencer = $this->getCuotasPorVencer($cuotaRepository);
|
|
||||||
$cierres_vigentes = $this->getCierresVigentes($cierreRepository);
|
|
||||||
return $view->render($response, 'home', compact('cuotas_hoy', 'cuotas_pendientes', 'cuotas_por_vencer', 'cierres_vigentes'));
|
|
||||||
}
|
}
|
||||||
protected function login(ResponseInterface $response, View $view): ResponseInterface
|
protected function login(ResponseInterface $response, View $view): ResponseInterface
|
||||||
{
|
{
|
||||||
return $view->render($response, 'guest');
|
return $view->render($response, 'guest');
|
||||||
}
|
}
|
||||||
protected function getCuotasPorVencer(Repository\Venta\Cuota $cuotaRepository): array
|
|
||||||
{
|
|
||||||
$cuotas = $cuotaRepository->fetchDatosPorVencer();
|
|
||||||
$output = [];
|
|
||||||
foreach ($cuotas as $row) {
|
|
||||||
$fecha = $row['Fecha'];
|
|
||||||
$date = new DateTimeImmutable($fecha);
|
|
||||||
if (($weekday = $date->format('N')) > 5) {
|
|
||||||
$day_diff = 7 - $weekday + 1;
|
|
||||||
$date = $date->add(new DateInterval("P{$day_diff}D"));
|
|
||||||
$fecha = $date->format('Y-m-d');
|
|
||||||
}
|
|
||||||
if (!isset($output[$fecha])) {
|
|
||||||
$output[$fecha] = [];
|
|
||||||
}
|
|
||||||
if (!isset($output[$fecha][$row['Proyecto']])) {
|
|
||||||
$output[$fecha][$row['Proyecto']] = 0;
|
|
||||||
}
|
|
||||||
$output[$fecha][$row['Proyecto']] += $row['Cantidad'];
|
|
||||||
}
|
|
||||||
foreach ($output as $fecha => $day) {
|
|
||||||
uksort($day, function($a, $b) {
|
|
||||||
return strcmp($a, $b);
|
|
||||||
});
|
|
||||||
$output[$fecha] = $day;
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
protected function getCierresVigentes(Repository\Venta\Cierre $cierreRepository): array
|
|
||||||
{
|
|
||||||
$cierres = $cierreRepository->fetchDatosVigentes();
|
|
||||||
$output = [];
|
|
||||||
$estados = [
|
|
||||||
'revisado' => 'pendientes',
|
|
||||||
'rechazado' => 'rechazados',
|
|
||||||
'aprobado' => 'pendientes',
|
|
||||||
'vendido' => 'promesados',
|
|
||||||
'abandonado' => 'rechazados',
|
|
||||||
'promesado' => 'promesados',
|
|
||||||
'resciliado' => 'rechazados'
|
|
||||||
];
|
|
||||||
foreach ($cierres as $row) {
|
|
||||||
if (!isset($output[$row['Proyecto']])) {
|
|
||||||
$output[$row['Proyecto']] = [
|
|
||||||
'promesados' => 0,
|
|
||||||
'pendientes' => 0,
|
|
||||||
'rechazados' => 0,
|
|
||||||
'total' => 0
|
|
||||||
];
|
|
||||||
}
|
|
||||||
$estado = $estados[$row['Estado']];
|
|
||||||
$output[$row['Proyecto']][$estado] += $row['Cantidad'];
|
|
||||||
$output[$row['Proyecto']]['total'] += $row['Cantidad'];
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user