Venta->Listado->Cierres

This commit is contained in:
Juan Pablo Vial
2023-07-25 17:03:57 -04:00
parent 1a7b10ce3c
commit 43cd955061
12 changed files with 596 additions and 5 deletions

View File

@ -0,0 +1,24 @@
<?php
namespace Incoviba\Controller\Ventas;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Alias\View;
use Incoviba\Service;
class Cierres
{
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view): ResponseInterface
{
return $view->render($response, 'ventas.cierres.list');
}
public function proyecto(ServerRequestInterface $request, ResponseInterface $response, Service\Ventas\Cierre $service): ResponseInterface
{
$body = $request->getBody();
$json = json_decode($body->getContents());
$proyecto_id = $json->proyecto_id;
$cierres = $service->getByProyecto($proyecto_id);
$response->getBody()->write(json_encode(['cierres' => $cierres, 'total' => count($cierres)]));
return $response->withHeader('Content-Type', 'application/json');
}
}