From 17f93dcd34e2fa8b34cb7587c9f746010472d030 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Wed, 29 Nov 2023 22:21:46 -0300 Subject: [PATCH] Edit Pie --- app/resources/routes/04_ventas.php | 1 + app/resources/routes/api/ventas/pies.php | 6 +++ .../views/ventas/pies/edit.blade.php | 46 +++++++++++++++++++ app/src/Controller/API/Ventas/Pies.php | 31 +++++++++++++ app/src/Controller/Ventas.php | 5 ++ app/src/Service/Venta/Pie.php | 4 ++ 6 files changed, 93 insertions(+) create mode 100644 app/resources/routes/api/ventas/pies.php create mode 100644 app/resources/views/ventas/pies/edit.blade.php create mode 100644 app/src/Controller/API/Ventas/Pies.php diff --git a/app/resources/routes/04_ventas.php b/app/resources/routes/04_ventas.php index 8e02291..7af89dc 100644 --- a/app/resources/routes/04_ventas.php +++ b/app/resources/routes/04_ventas.php @@ -26,6 +26,7 @@ $app->group('/venta/{venta_id:[0-9]+}', function($app) { $app->group('/cuotas', function($app) { $app->get('[/]', [Ventas::class, 'cuotas']); }); + $app->get('[/]', [Ventas::class, 'pie']); }); $app->get('/edit[/]', [Ventas::class, 'edit']); $app->get('[/]', [Ventas::class, 'show']); diff --git a/app/resources/routes/api/ventas/pies.php b/app/resources/routes/api/ventas/pies.php new file mode 100644 index 0000000..7b5abea --- /dev/null +++ b/app/resources/routes/api/ventas/pies.php @@ -0,0 +1,6 @@ +group('/pie/{pie_id}', function($app) { + $app->post('/edit[/]', [Pies::class, 'edit']); +}); diff --git a/app/resources/views/ventas/pies/edit.blade.php b/app/resources/views/ventas/pies/edit.blade.php new file mode 100644 index 0000000..34c2ca5 --- /dev/null +++ b/app/resources/views/ventas/pies/edit.blade.php @@ -0,0 +1,46 @@ +@extends('layout.base') + +@section('page_content') +
+

+ Pie - + {{$venta->proyecto()->descripcion}} - + {{$venta->propiedad()->summary()}} +

+
+
+ +
+ +
UF
+
+
+
+ + +
+ +
+
+@endsection + +@push('page_scripts') + +@endpush diff --git a/app/src/Controller/API/Ventas/Pies.php b/app/src/Controller/API/Ventas/Pies.php new file mode 100644 index 0000000..12a1b2a --- /dev/null +++ b/app/src/Controller/API/Ventas/Pies.php @@ -0,0 +1,31 @@ +getParsedBody(); + $output = [ + 'pie_id' => $pie_id, + 'input' => $body, + 'edited' => false + ]; + error_log(var_export($output,true).PHP_EOL,3,'/logs/pies'); + try { + $pie = $pieService->getById($pie_id); + $pieService->edit($pie, (array) $body); + $output['edited'] = true; + } catch (EmptyResult) {} + return $this->withJson($response, $output); + } +} diff --git a/app/src/Controller/Ventas.php b/app/src/Controller/Ventas.php index c0c7794..5bb5bf3 100644 --- a/app/src/Controller/Ventas.php +++ b/app/src/Controller/Ventas.php @@ -71,6 +71,11 @@ class Ventas } return $view->render($response, 'ventas.propiedades.edit', compact('propiedad', 'proyecto', 'tiposUnidades', 'unidades', 'venta')); } + public function pie(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Venta $service, int $venta_id): ResponseInterface + { + $venta = $service->getById($venta_id); + return $view->render($response, 'ventas.pies.edit', compact('venta')); + } public function add(ServerRequestInterface $request, ResponseInterface $response, View $view, Repository\Region $regionRepository, Repository\Proyecto $proyectoRepository): ResponseInterface { $regiones = $regionRepository->fetchAll(); diff --git a/app/src/Service/Venta/Pie.php b/app/src/Service/Venta/Pie.php index 3c07a0a..bdbacfc 100644 --- a/app/src/Service/Venta/Pie.php +++ b/app/src/Service/Venta/Pie.php @@ -27,4 +27,8 @@ class Pie { return $this->cuotaService->add($data); } + public function edit(Model\Venta\Pie $pie, array $data): Model\Venta\Pie + { + return $this->pieRepository->edit($pie, $data); + } }