Cambio a la forma de obtener los indices

This commit is contained in:
2020-05-04 12:58:53 -04:00
parent ac571273f5
commit cf18949409
4 changed files with 46 additions and 3 deletions

View File

@ -0,0 +1,25 @@
<?php
namespace ProVM\NotariaRaby\Common\Controller\Web;
use Psr\Container\ContainerInterface as Container;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
class Documentos {
public function existe(Request $request, Response $response, Container $container, $documento) {
$filename = implode(DIRECTORY_SEPARATOR, [
$container->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);
}
}

View File

@ -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;

View File

@ -0,0 +1,6 @@
<?php
use ProVM\NotariaRaby\Common\Controller\Web\Documentos;
$app->group('/documentos', function($app) {
$app->get('/existe/{documento}', [Documentos::class, 'existe']);
});

View File

@ -36,6 +36,7 @@
@push('scripts')
<script type="text/javascript">
$(document).ready(function() {
var file_url = ''
$('#indices_calendar').calendar({
type: 'month',
text: {
@ -51,12 +52,23 @@
'{!!implode("', '", $months->full)!!}'
]
var date = arguments[0]
var test = 'indices_' + date.getFullYear() + '_' + months[date.getMonth()]
$.getJSON('{{$urls->base}}/documentos/existe/' + test, function(data) {
if (data.existe) {
var url = '{{$urls->uploads}}/indices_' + date.getFullYear() + '_' + months[date.getMonth()] + '.pdf'
$('#indices_descarga').attr('href', url)
$('#indices_descarga').attr('href', url).show()
file_url = url
return
}
$('#indices_descarga').attr('href', '').hide()
file_url = ''
})
}
})
$('#indices_descarga').hide()
$('#form_indices').submit(function(e) {
e.preventDefault()
window.open(file_url, '_blank')
return false
})
})