v0.8.0-rc

This commit is contained in:
2020-03-27 02:59:53 -03:00
parent 00f9a10cbf
commit 723040358b
51 changed files with 792 additions and 492 deletions

View File

@ -4,9 +4,20 @@ namespace ProVM\NotariaRaby\Common\Controller\Web\Admin;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Slim\Views\Blade as View;
use ProVM\Common\Service\Filemanager;
class Admin {
public function __invoke(Request $request, Response $response, View $view): Response {
return $view->render($response, 'admin.admin');
public function __invoke(Request $request, Response $response, Filemanager $filemanager, View $view): Response {
$filename = 'aviso.yml';
$aviso = $filemanager->folder('data')->load($filename);
if (!$aviso) {
$aviso = (object) [
'titulo' => '',
'contenido' => '',
'activo' => false
];
}
$transparencia = $filemanager->folder('data')->load('transparencia.yml')->activo;
return $view->render($response, 'admin.admin', compact('aviso', 'transparencia'));
}
}

View File

@ -3,43 +3,36 @@ namespace ProVM\NotariaRaby\Common\Controller\Web\Admin;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Slim\Views\Blade as View;
use ProVM\Common\Service\Filemanager;
class Notificacion {
public function __invoke(Request $request, Response $response, View $view, Filemanager $filemanager): Response {
$filename = 'notificacion.yml';
$notificacion = $filemanager->load($filename);
if (!$notificacion) {
$notificacion = (object) [
'title' => '',
'text' => '',
'active' => false
];
}
return $view->render($response, 'admin.notificacion.show', compact('notificacion'));
}
public function do_edit(Request $request, Response $response, View $view, Filemanager $filemanager): Response {
public function do_edit(Request $request, Response $response, Filemanager $filemanager): Response {
$post = $request->getParsedBody();
$filename = 'notificacion.yml';
$notificacion = $filemanager->load($filename);
$filename = 'aviso.yml';
$notificacion = $filemanager->folder('data')->load($filename);
if (!$notificacion) {
$notificacion = (object) [
'title' => '',
'text' => '',
'active' => false
'titulo' => '',
'contenido' => '',
'activo' => false
];
}
$notificacion->title = $post['title'];
$notificacion->text = $post['text'];
$notificacion->active = (isset($post['active']) and $post['active'] == 'on') ? true : false;
$filemanager->save($filename, $notificacion);
if (isset($post['titulo'])) {
$notificacion->titulo = trim($post['titulo']);
$notificacion->contenido = trim($post['contenido']);
}
if (isset($post['activo'])) {
$notificacion->activo = json_decode($post['activo']);
}
$filemanager->folder('data')->save($filename, $notificacion);
$output = [
'informacion' => $post,
'editado' => $notificacion
];
$response->getBody()->write(json_encode($output));
return $response
->withHeader('Location', implode('/', [
$container->get('urls.base'),
'admin',
'notificacion'
]))
->withStatus(302);
->withHeader('Content-Type', 'application/json')
->withStatus(201);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace ProVM\NotariaRaby\Common\Controller\Web\Admin;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use ProVM\Common\Service\Filemanager;
class Transparencia {
public function do_edit(Request $request, Response $response, Filemanager $filemanager): Response {
$post = $request->getParsedBody();
$filename = 'transparencia.yml';
$transparencia = $filemanager->folder('data')->load($filename);
if (!$transparencia) {
$transparencia = (object) [
'descripcion' => '',
'funciones' => '',
'activo' => false
];
}
if (isset($post['activo'])) {
$transparencia->activo = json_decode($post['activo']);
}
$filemanager->folder('data')->save($filename, $transparencia);
$output = [
'informacion' => $post,
'editado' => $transparencia
];
$response->getBody()->write(json_encode($output));
return $response
->withHeader('Content-Type', 'application/json')
->withStatus(201);
}
}

View File

@ -7,6 +7,26 @@ use Slim\Views\Blade as View;
class Contacto {
public function __invoke(Request $request, Response $response, View $view): Response {
return $view->render($response, 'contacto');
$google = (object) [
'api' => ''
];
$map = (object) [
'lat' => -33.415938,
'long' => -70.591688
];
$url = 'https://www.google.com/maps/embed/v1/place?q=notaria+patricio+raby&key=AIzaSyBFw0Qbyq9zTFTd-tUY6dZWTgaQzuU17R8';
$url = 'https://maps.google.com/maps?hl=es&amp;q=Notaria%20Patricio%20Raby+(Notaria%20Patricio%20Raby)&amp;ie=UTF8&amp;z=16&amp;iwloc=B&amp;output=embed';
return $view->render($response, 'contacto', compact('url'));
}
public function formulario(Request $request, Response $response): Response {
$post = $request->getParsedBody();
$output = [
'informacion' => $post
];
$response->getBody()->write(json_encode($output));
return $response
->withHeader('Content-Type', 'application/json')
->withStatus(201);
}
}

View File

@ -5,39 +5,24 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Container\ContainerInterface as Container;
use Slim\Views\Blade as View;
use ProVM\Common\Service\Filemanager;
class Home {
public function __invoke(Request $request, Response $response, View $view, Container $container): Response {
public function __invoke(Request $request, Response $response, View $view, Filemanager $manager, Container $container): Response {
$banner = (object) [
'titulo' => "5° NOTARÍA DE SANTIAGO\nPATRICIO RABY BENAVENTE",
'contenido' => "Gertrudis Echenique 30, of. 32, El Golf\n<span class=\"icon-metro\"></span> Metro Alcantara"
];
$suplente = (object) [
'datos' => (object) [
'fechas' => "DEL 1 DE ABRIL AL 15 DE MAYO",
'nombre' => "MARIA VIRGINIA\nWIELANDT COVARRUBIAS"
]
];
$links = (object) [
'documentos' => [
new Documento($container, 'Autorizaciones'),
new Documento($container, 'Declaraciones'),
new Documento($container, 'Certificados'),
new Documento($container, 'Poderes'),
new Documento($container, 'Contratos'),
new Documento($container, 'Otros')
],
'consulta' => [
new Link('Servicios de Impuestos Internos', 'http://www.sii.cl'),
new Link('Registro Civil', 'http://www.registrocivil.cl'),
new Link('Conservador de Bienes Raices', ''),
new Link('Diario Oficial', ''),
new Link('Tesorería General de la República', ''),
new Link('Fojas', '')
]
];
return $view->render($response, 'home', compact('banner', 'suplente', 'links'));
$links = $manager->folder('data')->load('documentos.yml');
array_walk($links->documentos, function(&$item) use ($container) {
$item = new Documento($container, $item->texto, $item->uri);
});
array_walk($links->consulta, function(&$item) {
$item = new Link($item->texto, $item->uri);
});
$aviso = $manager->folder('data')->load('aviso.yml');
return $view->render($response, 'home', compact('banner', 'aviso', 'links'));
}
}
@ -46,16 +31,18 @@ class Documento {
protected $texto;
protected $uri;
public function __construct(Container $container, string $nombre) {
public function __construct(Container $container, string $nombre, string $uri = '') {
$this->icono = implode('/', [$container->get('urls.images'), $nombre . '.png']);
$this->texto = $nombre;
$this->uri = implode('/', [$container->get('urls.base'), 'documentos', strtolower($nombre)]);
$this->uri = $uri;
if ($uri == '') {
$this->uri = implode('/', [$container->get('urls.base'), 'documentos', strtolower($nombre)]);
}
}
public function show(): string {
return '<a href="' . $this->uri . '"><img src="' . $this->icono . '" /> ' . $this->texto . '</a>';
}
}
class Link {
protected $uri;
protected $texto;

View File

@ -10,6 +10,8 @@ class Notaria {
public function __invoke(Request $request, Response $response, View $view, Filemanager $filemanager): Response {
$filename = 'equipos.yml';
$equipos = $filemanager->folder('data')->load($filename);
return $view->render($response, 'notaria', compact('equipos'));
$filename = 'transparencia.yml';
$transparencia = $filemanager->folder('data')->load($filename);
return $view->render($response, 'notaria', compact('equipos', 'transparencia'));
}
}