diff --git a/ui/common/Controller/Bancos.php b/ui/common/Controller/Bancos.php deleted file mode 100644 index d3c8e8d..0000000 --- a/ui/common/Controller/Bancos.php +++ /dev/null @@ -1,12 +0,0 @@ -render($response, 'bancos.add'); - } -} diff --git a/ui/common/Controller/Cuentas.php b/ui/common/Controller/Cuentas.php index b7b24b8..332096d 100644 --- a/ui/common/Controller/Cuentas.php +++ b/ui/common/Controller/Cuentas.php @@ -9,6 +9,9 @@ class Cuentas { public function __invoke(Request $request, Response $response, View $view): Response { return $view->render($response, 'cuentas.list'); } + public function show(Request $request, Response $response, View $view, $cuenta_id): Response { + return $view->render($response, 'cuentas.show', compact('cuenta_id')); + } public function add(Request $request, Response $response, View $view): Response { return $view->render($response, 'cuentas.add'); } diff --git a/ui/common/Controller/Fuentes.php b/ui/common/Controller/Fuentes.php deleted file mode 100644 index 8f7ebfe..0000000 --- a/ui/common/Controller/Fuentes.php +++ /dev/null @@ -1,12 +0,0 @@ -render($response, 'fuentes.show', compact('fuente_id')); - } -} diff --git a/ui/common/Controller/TiposFuentes.php b/ui/common/Controller/TiposFuentes.php deleted file mode 100644 index ed17d65..0000000 --- a/ui/common/Controller/TiposFuentes.php +++ /dev/null @@ -1,12 +0,0 @@ -render($response, 'tipos_fuentes.add'); - } -} diff --git a/ui/public/assets/scripts/cuentas.show.js b/ui/public/assets/scripts/cuentas.show.js new file mode 100644 index 0000000..bbea966 --- /dev/null +++ b/ui/public/assets/scripts/cuentas.show.js @@ -0,0 +1,143 @@ +const transacciones = { + id: '#transacciones', + cuenta_id: 0, + cuenta: null, + transacciones: [], + cuentas: [], + saldo: 0, + get: function() { + return { + transacciones: () => { + return $.ajax({ + url: _urls.api + '/cuenta/' + this.cuenta_id + '/transacciones', + method: 'GET', + dataType: 'json' + }).then((data) => { + if (data.cuenta === null) { + return + } + this.cuenta = data.cuenta + this.saldo = this.cuenta.saldo + $('#cuenta').html(this.cuenta.nombre + ' (' + this.cuenta.categoria.nombre + ')') + if (data.transacciones === null || data.transacciones.length == 0) { + return + } + this.transacciones = data.transacciones + }).then(() => { + this.draw() + }) + }, + cuentas: () => { + return $.ajax({ + url: _urls.api + '/cuentas', + method: 'GET', + dataType: 'json' + }).then((data) => { + if (data.cuentas === null || data.cuentas.length == 0) { + return + } + this.cuentas = data.cuentas + }).then(() => { + const select = this.modal.find("[name='cuenta']") + $.each(this.cuentas, (i, el) => { + select.append( + $('').attr('value', el.id).html(el.nombre + ' (' + el.categoria.nombre + ')') + ) + }) + }) + } + } + }, + draw: function() { + const format = Intl.NumberFormat('es-CL', {style: 'currency', currency: 'CLP'}) + const parent = $(this.id) + parent.html('') + $.each(this.transacciones, (i, el) => { + const fuente = (el.valor < 0) ? el.desde : el.hasta + parent.append( + $('
Fecha | - Cuenta - | -- Glosa + CategorÃa | Detalle | - Valor + Debe + | ++ Haber + | ++ Saldo |
---|