Merge branch 'develop'
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
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): Response {
|
||||
$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 img {
|
||||
max-height: 20rem !important;
|
||||
min-height: 10rem !important;
|
||||
min-height: 20rem !important;
|
||||
}
|
||||
#indice .contenido {
|
||||
padding-top: 5rem !important;
|
||||
|
@ -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']);
|
||||
});
|
||||
|
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']);
|
||||
});
|
147
resources/views/admin/archivos/list.blade.php
Normal file
147
resources/views/admin/archivos/list.blade.php
Normal file
@ -0,0 +1,147 @@
|
||||
@extends('admin.layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">
|
||||
{{str_replace('_', ' ', mb_strtoupper($titulo))}}
|
||||
</h1>
|
||||
<div class="ui grid">
|
||||
<div class="row">
|
||||
<div class="nine wide column">
|
||||
<a href="{{$urls->admin}}">Volver</a>
|
||||
<div class="ui top attached right aligned segment">
|
||||
<button class="ui inverted dark-blue button form_link">
|
||||
NUEVO
|
||||
</button>
|
||||
</div>
|
||||
<table class="ui bottom attached celled table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Documento</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($archivos as $archivo)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{$urls->uploads}}/{{$archivo->getFilename()}}" target="_blank">
|
||||
{{str_replace([$titulo, '_'], ['', ' '], $archivo->getBasename('.' . $archivo->getExtension()))}}
|
||||
</a>
|
||||
</td>
|
||||
<td class="center aligned">
|
||||
<i class="trash alternate outline icon" data-file="{{$archivo->getBasename('.' . $archivo->getExtension())}}"></i>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui basic modal" id="doc_form">
|
||||
<i class="close icon"></i>
|
||||
<div class="inverted dark-blue header">
|
||||
</div>
|
||||
<div class="inverted dark-blue content">
|
||||
<form class="ui form" method="post" action="#">
|
||||
<input type="hidden" name="filename" />
|
||||
<div class="field">
|
||||
<input type="file" name="archivo" placeholder="Archivo" />
|
||||
</div>
|
||||
<div id="mod" class="field"></div>
|
||||
<button class="ui button">Subir</button>
|
||||
<div id="documento_message"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
function formulario(link, title, mod) {
|
||||
$('#doc_form').find('.header').html(title)
|
||||
$('#doc_form').find('form').find("[name='filename']").val(link)
|
||||
if (mod == 'fecha') {
|
||||
fecha()
|
||||
}
|
||||
$('#doc_form').modal('show')
|
||||
$('#doc_form').find('form').submit(function(e) {
|
||||
e.preventDefault()
|
||||
var form_data = new FormData(this)
|
||||
$.ajax({
|
||||
url: '{{$urls->admin}}/documentos',
|
||||
type: 'post',
|
||||
data: form_data,
|
||||
contentType: false,
|
||||
cache: false,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
if (data.estado == true) {
|
||||
$('#doc_form').find('.header').html('')
|
||||
$('#doc_form').find('form').find("[name='filename']").val('')
|
||||
$('#doc_form').modal('hide')
|
||||
$('#documento_message').html('')
|
||||
$('#documento_message').hide()
|
||||
location.reload()
|
||||
} else {
|
||||
$('#documento_message').html('Error al subir el archivo.')
|
||||
$('#documento_message').show()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
function fecha() {
|
||||
var fecha = $('<div></div>').attr('class', 'ui calendar').append(
|
||||
$('<div></div>').attr('class', 'ui input left icon').append(
|
||||
$('<i></i>').attr('class', 'calendar icon')
|
||||
).append(
|
||||
$('<input />').attr('type', 'text').attr('name', 'month').attr('placeholder', 'Mex / Año')
|
||||
)
|
||||
)
|
||||
$('#mod').append(fecha)
|
||||
$('#mod').find('.ui.calendar').calendar({
|
||||
type: 'month',
|
||||
text: {
|
||||
months: [
|
||||
'{!!implode("', '", $months->full)!!}'
|
||||
],
|
||||
monthsShort: [
|
||||
'{!!implode("', '", $months->short)!!}'
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
$(document).ready(function() {
|
||||
$('.trash').css('cursor', 'pointer').click(function() {
|
||||
var file = $(this).attr('data-file')
|
||||
$.post('{{$urls->admin}}/documentos/delete', {archivo: file}, function(data) {
|
||||
if (data.estado) {
|
||||
location.reload()
|
||||
return
|
||||
}
|
||||
alert('No se pudo borrar el archivo.')
|
||||
})
|
||||
})
|
||||
$('#doc_form').modal({
|
||||
onHidden: function() {
|
||||
$('#mod').html('')
|
||||
}
|
||||
})
|
||||
$('#documento_message').hide()
|
||||
$('.form_link').click(function() {
|
||||
var link = '{{$titulo}}'
|
||||
var title = '{{mb_strtoupper($titulo)}}'
|
||||
var mod = 'fecha'
|
||||
if (link == 'valores') {
|
||||
mod = ''
|
||||
}
|
||||
formulario(link, title, mod)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -3,7 +3,7 @@
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2>Cambiar Clave</h2>
|
||||
<form class="ui form" method="post" action="{{$urls->base}}/admin/clave" id="clave_form">
|
||||
<form class="ui form" method="post" action="{{$urls->admin}}/clave" id="clave_form">
|
||||
<div class="field">
|
||||
<label>Clave</label>
|
||||
<input type="password" name="clave" />
|
||||
|
@ -4,11 +4,7 @@
|
||||
{{$descripcion}}
|
||||
</div>
|
||||
<div class="column">
|
||||
<a href="#" data-link="{{$link}}" data-title="{{$descripcion}}"
|
||||
@if (isset($mod))
|
||||
data-mod="{{$mod}}"
|
||||
@endif
|
||||
class="form_link">
|
||||
<a href="{{$urls->admin}}/documentos/{{$link}}">
|
||||
@include('admin.uicon')
|
||||
</a>
|
||||
</div>
|
||||
|
@ -22,86 +22,15 @@
|
||||
/>
|
||||
</div>
|
||||
<div id="transparencia_message" class="ui message transition hidden"></div>
|
||||
<div class="ui basic modal" id="doc_form">
|
||||
<i class="close icon"></i>
|
||||
<div class="inverted dark-blue header">
|
||||
</div>
|
||||
<div class="inverted dark-blue content">
|
||||
<form class="ui form" method="post" action="#">
|
||||
<input type="hidden" name="filename" />
|
||||
<div class="field">
|
||||
<input type="file" name="archivo" placeholder="Archivo" />
|
||||
</div>
|
||||
<div id="mod" class="field"></div>
|
||||
<button class="ui button">Subir</button>
|
||||
<div id="documento_message"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
function formulario(link, title, mod) {
|
||||
$('#doc_form').find('.header').html(title)
|
||||
$('#doc_form').find('form').find("[name='filename']").val(link)
|
||||
if (mod == 'fecha') {
|
||||
fecha()
|
||||
}
|
||||
$('#doc_form').modal('show')
|
||||
$('#doc_form').find('form').submit(function(e) {
|
||||
e.preventDefault()
|
||||
var form_data = new FormData(this)
|
||||
$.ajax({
|
||||
url: '{{$urls->base}}/admin/documentos',
|
||||
type: 'post',
|
||||
data: form_data,
|
||||
contentType: false,
|
||||
cache: false,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
if (data.estado == true) {
|
||||
$('#doc_form').find('.header').html('')
|
||||
$('#doc_form').find('form').find("[name='filename']").val('')
|
||||
$('#doc_form').modal('hide')
|
||||
$('#documento_message').html('')
|
||||
$('#documento_message').hide()
|
||||
} else {
|
||||
$('#documento_message').html('Error al subir el archivo.')
|
||||
$('#documento_message').show()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
function fecha() {
|
||||
var fecha = $('<div></div>').attr('class', 'ui calendar').append(
|
||||
$('<div></div>').attr('class', 'ui input left icon').append(
|
||||
$('<i></i>').attr('class', 'calendar icon')
|
||||
).append(
|
||||
$('<input />').attr('type', 'text').attr('name', 'month').attr('placeholder', 'Mex / Año')
|
||||
)
|
||||
)
|
||||
$('#mod').append(fecha)
|
||||
$('#mod').find('.ui.calendar').calendar({
|
||||
type: 'month',
|
||||
text: {
|
||||
months: [
|
||||
'{!!implode("', '", $months->full)!!}'
|
||||
],
|
||||
monthsShort: [
|
||||
'{!!implode("', '", $months->short)!!}'
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
$(document).ready(function() {
|
||||
$('#transparencia_message').hide()
|
||||
$('#transparencia').checkbox()
|
||||
$('#transparencia').click(function() {
|
||||
var status = $(this).checkbox('is checked')
|
||||
$.post('{{$urls->base}}/admin/transparencia', {'activo': status}, function(data) {
|
||||
$.post('{{$urls->admin}}/transparencia', {'activo': status}, function(data) {
|
||||
var msg = ['<i class="close icon"></i>']
|
||||
if (data.estado == 'ok') {
|
||||
if (data.informacion.activo == 'true') {
|
||||
@ -131,19 +60,6 @@
|
||||
})
|
||||
}, 'json')
|
||||
})
|
||||
|
||||
$('#doc_form').modal({
|
||||
onHidden: function() {
|
||||
$('#mod').html('')
|
||||
}
|
||||
})
|
||||
$('#documento_message').hide()
|
||||
$('.form_link').click(function() {
|
||||
var link = $(this).attr('data-link')
|
||||
var title = $(this).attr('data-title')
|
||||
var mod = $(this).attr('data-mod')
|
||||
formulario(link, title, mod)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
@ -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) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
@extends('admin.layout.base')
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<form class="ui form" method="post" action="{{$urls->base}}/admin/login">
|
||||
<form class="ui form" method="post" action="{{$urls->admin}}/login">
|
||||
<div class="ui center aligned grid">
|
||||
<div class="left aligned five wide column">
|
||||
<h3>Ingresar</h3>
|
||||
@ -16,3 +16,11 @@
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("input[name='clave']").focus()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
@ -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
|
||||
})
|
||||
})
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user