Compare commits

..

2 Commits

5 changed files with 89 additions and 13 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 url = '{{$urls->uploads}}/indices_' + date.getFullYear() + '_' + months[date.getMonth()] + '.pdf'
$('#indices_descarga').attr('href', url)
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).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
})
})

View File

@ -44,7 +44,7 @@
</div>
</div>
<br />
<a href="#" target="_window" id="balances_descarga">
<a href="#" target="_blank" id="balances_descarga">
<button class="ui mini gray button">DESCARGA</button>
</a>
</div>
@ -60,7 +60,7 @@
</div>
</div>
<br />
<a href="#" target="_window" id="patrimonio_descarga">
<a href="#" target="_blank" id="patrimonio_descarga">
<button class="ui mini gray button">DESCARGA</button>
</a>
</div>
@ -76,12 +76,12 @@
</div>
</div>
<br />
<a href="#" target="_window" id="fiscalia_descarga">
<a href="#" target="_blank" id="fiscalia_descarga">
<button class="ui mini gray button">DESCARGA</button>
</a>
</div>
<div class="title">
<a target="_window" href="{{$urls->uploads}}/valores.pdf">
<a target="_blank" href="{{$urls->uploads}}/valores.pdf">
<i class="dropdown icon"></i>
Valores
</a>
@ -97,6 +97,11 @@
@push('scripts')
<script type="text/javascript">
$(document).ready(function() {
var urls = {
balances: '',
patrimonio: '',
fiscalia: ''
}
$('.accordion').accordion()
$('#balances_calendar').calendar({
type: 'month',
@ -113,8 +118,17 @@
'{!!implode("', '", $months->full)!!}'
]
var date = arguments[0]
var url = '{{$urls->uploads}}/balances_anuales_' + date.getFullYear() + '_' + months[date.getMonth()] + '.pdf'
$('#balances_descarga').attr('href', url)
var test = 'balances_anuales_' + date.getFullYear() + '_' + months[date.getMonth()]
$.getJSON('{{$urls->base}}/documentos/existe/' + test, function(data) {
if (data.existe) {
var url = '{{$urls->uploads}}/balances_anuales_' + date.getFullYear() + '_' + months[date.getMonth()] + '.pdf'
$('#balances_descarga').attr('href', url).show()
urls.balances = url
return
}
$('#balances_descarga').attr('href', '').hide()
urls.balances = ''
})
}
})
$('#patrimonio_calendar').calendar({
@ -132,8 +146,17 @@
'{!!implode("', '", $months->full)!!}'
]
var date = arguments[0]
var url = '{{$urls->uploads}}/intereses_y_patrimonio_' + date.getFullYear() + '_' + months[date.getMonth()] + '.pdf'
$('#patrimonio_descarga').attr('href', url)
var test = 'intereses_y_patrimonio_' + date.getFullYear() + '_' + months[date.getMonth()]
$.getJSON('{{$urls->base}}/documentos/existe/' + test, function(data) {
if (data.existe) {
var url = '{{$urls->uploads}}/intereses_y_patrimonio_' + date.getFullYear() + '_' + months[date.getMonth()] + '.pdf'
$('#patrimonio_descarga').attr('href', url).show()
urls.patrimonio = url
return
}
$('#patrimonio_descarga').attr('href', '').hide()
urls.patrimonio = ''
})
}
})
$('#fiscalia_calendar').calendar({
@ -151,10 +174,20 @@
'{!!implode("', '", $months->full)!!}'
]
var date = arguments[0]
var url = '{{$urls->uploads}}/informes_fiscalia_' + date.getFullYear() + '_' + months[date.getMonth()] + '.pdf'
$('#fiscalia_descarga').attr('href', url)
var test = 'informes_fiscalia_' + date.getFullYear() + '_' + months[date.getMonth()]
$.getJSON('{{$urls->base}}/documentos/existe/' + test, function(data) {
if (data.existe) {
var url = '{{$urls->uploads}}/informes_fiscalia_' + date.getFullYear() + '_' + months[date.getMonth()] + '.pdf'
$('#fiscalia_descarga').attr('href', url).show()
urls.fiscalia = url
return
}
$('#fiscalia_descarga').attr('href', '').hide()
urls.fiscalia = ''
})
}
})
$("[id$='_descarga']").hide()
})
</script>
@endpush