Implemented repository mapper, and venta show

This commit is contained in:
Juan Pablo Vial
2023-08-08 23:53:49 -04:00
parent ef30ae67d2
commit 59825259b6
111 changed files with 2766 additions and 612 deletions

View File

@ -1,6 +1,7 @@
<?php
namespace Incoviba\Controller\Ventas;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Alias\View;
@ -12,19 +13,24 @@ class Cierres
{
return $view->render($response, 'ventas.cierres.list');
}
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Ventas\Cierre $service, int $cierre_id): ResponseInterface
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Venta\Cierre $service, int $cierre_id): ResponseInterface
{
$cierre = $service->getById($cierre_id);
return $view->render($response, 'ventas.cierres.show', compact('cierre'));
}
public function proyecto(ServerRequestInterface $request, ResponseInterface $response, Service\Ventas\Cierre $service): ResponseInterface
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;
$cierres = $service->getByProyecto($proyecto_id);
$response->getBody()->write(json_encode(['cierres' => $cierres, 'total' => count($cierres)]));
$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');
}
}