diff --git a/common/Controller/Web/Admin/Documentos.php b/common/Controller/Web/Admin/Documentos.php index c72d730..0b19b05 100644 --- a/common/Controller/Web/Admin/Documentos.php +++ b/common/Controller/Web/Admin/Documentos.php @@ -4,9 +4,31 @@ namespace ProVM\NotariaRaby\Common\Controller\Web\Admin; use Psr\Container\ContainerInterface as Container; use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ResponseInterface as Response; +use Slim\Views\Blade as View; +use Carbon\Carbon; use ProVM\Common\Service\Filemanager; class Documentos { + public function __invoke(Request $request, Response $response, Container $container, View $view, $tipo): Response { + $glob = implode(DIRECTORY_SEPARATOR, [ + $container->get('folders.upload'), + $tipo . '*.pdf' + ]); + $files = glob($glob); + $archivos = []; + foreach ($files as $filename) { + $file = new \SplFileInfo($filename); + $archivos []= $file; + } + $titulo = $tipo; + $months = (object) ['full' => [], 'short' => []]; + $m = Carbon::createFromDate(0, 1, 1); + for ($i = 0; $i < 12; $i ++) { + $months->full []= ucwords($m->copy()->addMonths($i)->locale('es_ES')->isoFormat('MMMM')); + $months->short []= ucwords($m->copy()->addMonths($i)->locale('es_ES')->isoFormat('MMM')); + } + return $view->render($response, 'admin.archivos.list', compact('titulo', 'archivos', 'months')); + } public function upload(Request $request, Response $response, Filemanager $filemanager, Container $container): Response { $post = $request->getParsedBody(); $files = $request->getUploadedFiles(); @@ -33,4 +55,21 @@ class Documentos { ->withHeader('Content-Type', 'application/json') ->withStatus(201); } + public function delete(Request $request, Response $response, Container $container): Response { + $post = $request->getParsedBody(); + $filename = implode(DIRECTORY_SEPARATOR, [ + $container->get('folders.upload'), + $post['archivo'] . '.pdf' + ]); + $status = unlink($filename); + $output = [ + 'informacion' => $post, + 'estado' => $status, + 'archivo' => $filename + ]; + $response->getBody()->write(json_encode($output)); + return $response + ->withHeader('Content-Type', 'application/json') + ->withStatus(201); + } } diff --git a/common/Controller/Web/Documentos.php b/common/Controller/Web/Documentos.php new file mode 100644 index 0000000..1f50fd5 --- /dev/null +++ b/common/Controller/Web/Documentos.php @@ -0,0 +1,25 @@ +get('folders.upload'), + $documento . '.pdf' + ]); + $existe = file_exists($filename); + $output = [ + 'informacion' => $documento, + 'archivo' => $filename, + 'existe' => $existe + ]; + $response->getBody()->write(json_encode($output)); + return $response + ->withHeader('Content-Type', 'application/json') + ->withStatus(201); + } +} diff --git a/public/assets/styles/home.css b/public/assets/styles/home.css index ca6f9c6..656d336 100644 --- a/public/assets/styles/home.css +++ b/public/assets/styles/home.css @@ -129,7 +129,7 @@ #indice .img, #indice .img img { max-height: 20rem !important; - min-height: 10rem !important; + min-height: 20rem !important; } #indice .contenido { padding-top: 5rem !important; diff --git a/resources/routes/web/admin/documentos.php b/resources/routes/web/admin/documentos.php index 625887e..199f9e4 100644 --- a/resources/routes/web/admin/documentos.php +++ b/resources/routes/web/admin/documentos.php @@ -2,5 +2,7 @@ use ProVM\NotariaRaby\Common\Controller\Web\Admin\Documentos; $app->group('/documentos', function($app) { + $app->post('/delete', [Documentos::class, 'delete']); + $app->get('/{tipo}', Documentos::class); $app->post('[/]', [Documentos::class, 'upload']); }); diff --git a/resources/routes/web/documentos.php b/resources/routes/web/documentos.php new file mode 100644 index 0000000..3b4170b --- /dev/null +++ b/resources/routes/web/documentos.php @@ -0,0 +1,6 @@ +group('/documentos', function($app) { + $app->get('/existe/{documento}', [Documentos::class, 'existe']); +}); diff --git a/resources/views/admin/archivos/list.blade.php b/resources/views/admin/archivos/list.blade.php new file mode 100644 index 0000000..7473971 --- /dev/null +++ b/resources/views/admin/archivos/list.blade.php @@ -0,0 +1,147 @@ +@extends('admin.layout.base') + +@section('page_content') +
+

+ {{str_replace('_', ' ', mb_strtoupper($titulo))}} +

+
+
+
+ Volver +
+ +
+ + + + + + + + + @foreach ($archivos as $archivo) + + + + + @endforeach + +
Documento
+ + {{str_replace([$titulo, '_'], ['', ' '], $archivo->getBasename('.' . $archivo->getExtension()))}} + + + +
+
+
+
+
+ +@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/admin/clave.blade.php b/resources/views/admin/clave.blade.php index b92dd70..8d09867 100644 --- a/resources/views/admin/clave.blade.php +++ b/resources/views/admin/clave.blade.php @@ -3,7 +3,7 @@ @section('page_content')

Cambiar Clave

-
+
diff --git a/resources/views/admin/documento.blade.php b/resources/views/admin/documento.blade.php index 747b7ff..1d1c5d6 100644 --- a/resources/views/admin/documento.blade.php +++ b/resources/views/admin/documento.blade.php @@ -4,11 +4,7 @@ {{$descripcion}}
diff --git a/resources/views/admin/documentos.blade.php b/resources/views/admin/documentos.blade.php index d5c8be6..9a8ad99 100644 --- a/resources/views/admin/documentos.blade.php +++ b/resources/views/admin/documentos.blade.php @@ -22,86 +22,15 @@ />
- @push('scripts') @endpush diff --git a/resources/views/admin/formulario.blade.php b/resources/views/admin/formulario.blade.php index 208a3cd..2f9c9a0 100644 --- a/resources/views/admin/formulario.blade.php +++ b/resources/views/admin/formulario.blade.php @@ -51,7 +51,7 @@ var titulo = $(this).find("[name='titulo']").val() var contenido = $(this).find("[name='contenido']").val() - $.post('{{$urls->base}}/admin/notificacion', {titulo: titulo, contenido: contenido}, function(data) { + $.post('{{$urls->admin}}/notificacion', {titulo: titulo, contenido: contenido}, function(data) { var msg = '' if (data.estado == 'ok') { msg = 'Editado correctamente.' @@ -68,7 +68,7 @@ $('#activar').checkbox() $('#activar').click(function() { var status = $(this).checkbox('is checked') - $.post('{{$urls->base}}/admin/notificacion', {'activo': status}, function(data) { + $.post('{{$urls->admin}}/notificacion', {'activo': status}, function(data) { msg = [] if (data.estado == 'ok') { if (data.editado.activo) { diff --git a/resources/views/admin/login.blade.php b/resources/views/admin/login.blade.php index ae8651b..33bb63b 100644 --- a/resources/views/admin/login.blade.php +++ b/resources/views/admin/login.blade.php @@ -1,8 +1,8 @@ -@extends('admin.layout.base') +@extends('layout.base') @section('page_content')
-
+

Ingresar

@@ -16,3 +16,11 @@
@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/home/indice.blade.php b/resources/views/home/indice.blade.php index dee3668..e34e210 100644 --- a/resources/views/home/indice.blade.php +++ b/resources/views/home/indice.blade.php @@ -36,6 +36,7 @@ @push('scripts') @endpush