Cambio a la forma de obtener los indices
This commit is contained in:
25
common/Controller/Web/Documentos.php
Normal file
25
common/Controller/Web/Documentos.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -129,7 +129,7 @@
|
|||||||
#indice .img,
|
#indice .img,
|
||||||
#indice .img img {
|
#indice .img img {
|
||||||
max-height: 20rem !important;
|
max-height: 20rem !important;
|
||||||
min-height: 10rem !important;
|
min-height: 20rem !important;
|
||||||
}
|
}
|
||||||
#indice .contenido {
|
#indice .contenido {
|
||||||
padding-top: 5rem !important;
|
padding-top: 5rem !important;
|
||||||
|
6
resources/routes/web/documentos.php
Normal file
6
resources/routes/web/documentos.php
Normal 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']);
|
||||||
|
});
|
@ -36,6 +36,7 @@
|
|||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
var file_url = ''
|
||||||
$('#indices_calendar').calendar({
|
$('#indices_calendar').calendar({
|
||||||
type: 'month',
|
type: 'month',
|
||||||
text: {
|
text: {
|
||||||
@ -51,12 +52,23 @@
|
|||||||
'{!!implode("', '", $months->full)!!}'
|
'{!!implode("', '", $months->full)!!}'
|
||||||
]
|
]
|
||||||
var date = arguments[0]
|
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'
|
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) {
|
$('#form_indices').submit(function(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
window.open(file_url, '_blank')
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user