Seccion para editar equipos
This commit is contained in:
58
common/Controller/Web/Admin/Equipos.php
Normal file
58
common/Controller/Web/Admin/Equipos.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
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 Equipos {
|
||||||
|
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, 'admin.equipos', compact('equipos'));
|
||||||
|
}
|
||||||
|
public function add(Request $request, Response $response, Filemanager $filemanager): Response {
|
||||||
|
$post = $request->getParsedBody();
|
||||||
|
|
||||||
|
$filename = 'equipos.yml';
|
||||||
|
$equipos = $filemanager->folder('data')->load($filename);
|
||||||
|
|
||||||
|
$miembro = (object) [
|
||||||
|
'nombre' => $post['nombre'],
|
||||||
|
'email' => $post['email']
|
||||||
|
];
|
||||||
|
$equipos[$post['equipo']]->miembros []= $miembro;
|
||||||
|
$status = $filemanager->folder('data')->save($filename, $equipos);
|
||||||
|
|
||||||
|
$output = [
|
||||||
|
'information' => $post,
|
||||||
|
'estado' => $status,
|
||||||
|
'equipos' => $equipos
|
||||||
|
];
|
||||||
|
|
||||||
|
$response->getBody()->write(json_encode($output));
|
||||||
|
return $response
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->withStatus(201);
|
||||||
|
}
|
||||||
|
public function remove(Request $request, Response $response, Filemanager $filemanager): Response {
|
||||||
|
$post = $request->getParsedBody();
|
||||||
|
|
||||||
|
$filename = 'equipos.yml';
|
||||||
|
$equipos = $filemanager->folder('data')->load($filename);
|
||||||
|
|
||||||
|
unset($equipos[$post['equipo']]->miembros[$post['id']]);
|
||||||
|
$status = $filemanager->folder('data')->save($filename, $equipos);
|
||||||
|
|
||||||
|
$output = [
|
||||||
|
'information' => $post,
|
||||||
|
'estado' => $status,
|
||||||
|
'equipos' => $equipos
|
||||||
|
];
|
||||||
|
$response->getBody()->write(json_encode($output));
|
||||||
|
return $response
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->withStatus(201);
|
||||||
|
}
|
||||||
|
}
|
3
public/assets/styles/admin.css
Normal file
3
public/assets/styles/admin.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#equipos {
|
||||||
|
background-color: grey;
|
||||||
|
}
|
@ -1,30 +1,47 @@
|
|||||||
- titulo: ESCRITURAS PÚBLICAS
|
-
|
||||||
|
titulo: ESCRITURAS PÚBLICAS
|
||||||
miembros:
|
miembros:
|
||||||
- nombre: Paola Díaz de Lartundo
|
-
|
||||||
|
nombre: Paola Díaz de Lartundo
|
||||||
email: pdiaz@notariaraby.cl
|
email: pdiaz@notariaraby.cl
|
||||||
- nombre: Roxana Muñoz Donoso
|
-
|
||||||
|
nombre: Roxana Muñoz Donoso
|
||||||
email: rmunozd@notariaraby.cl
|
email: rmunozd@notariaraby.cl
|
||||||
- nombre: Alejandro González Villalobos
|
-
|
||||||
|
nombre: Alejandro González Villalobos
|
||||||
email: agonzalez@notariaraby.cl
|
email: agonzalez@notariaraby.cl
|
||||||
- nombre: Elizabeth Ancamil Munizaga
|
-
|
||||||
|
nombre: Elizabeth Ancamil Munizaga
|
||||||
email: eancamil@notariaraby.cl
|
email: eancamil@notariaraby.cl
|
||||||
- titulo: INSTRUMENTOS PRIVADOS
|
-
|
||||||
|
titulo: INSTRUMENTOS PRIVADOS
|
||||||
miembros:
|
miembros:
|
||||||
- nombre: Massiel Guzmán Villalobos
|
-
|
||||||
|
nombre: Massiel Guzmán Villalobos
|
||||||
email: mguzman@notariaraby.cl
|
email: mguzman@notariaraby.cl
|
||||||
- titulo: ADMINISTRACIÓN CUENTAS-TRANSFERENCIAS
|
-
|
||||||
|
titulo: ADMINISTRACIÓN CUENTAS-TRANSFERENCIAS
|
||||||
miembros:
|
miembros:
|
||||||
- nombre: Juan Corrales Carrasco
|
-
|
||||||
|
nombre: Juan Corrales Carrasco
|
||||||
email: jcorrales@notariaraby.cl
|
email: jcorrales@notariaraby.cl
|
||||||
- titulo: REPERTORIO-INDICES
|
-
|
||||||
|
titulo: REPERTORIO-INDICES
|
||||||
miembros:
|
miembros:
|
||||||
- nombre: María Andreina Rojas Morales
|
-
|
||||||
|
nombre: María Andreina Rojas Morales
|
||||||
email: repertorio@notariaraby.cl
|
email: repertorio@notariaraby.cl
|
||||||
- titulo: ABOGADO
|
-
|
||||||
|
titulo: ABOGADO
|
||||||
miembros:
|
miembros:
|
||||||
- nombre: María Virginia Wielandt Covarrubias
|
-
|
||||||
|
nombre: María Virginia Wielandt Covarrubias
|
||||||
email: vwielandt@notariaraby.cl
|
email: vwielandt@notariaraby.cl
|
||||||
- titulo: RECEPCIÓN CORDINACIÓN EMPRESAS EN UN DÍA
|
-
|
||||||
|
titulo: >
|
||||||
|
RECEPCIÓN CORDINACIÓN EMPRESAS EN UN
|
||||||
|
DÍA
|
||||||
miembros:
|
miembros:
|
||||||
- telefono: (56) (2) 2599 2453
|
-
|
||||||
|
telefono: (56) (2) 2599 2453
|
||||||
email: recepcion@notariaraby.cl
|
email: recepcion@notariaraby.cl
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ip: localhost
|
ip: localhost
|
||||||
token: >
|
token: >
|
||||||
6386affcb3431a356ef46974:c16ce52735ec95255d450d57945cd35992d1b21f
|
3d68bf63cd4e58933e39054e:c38af934404691cccaa5d5f65a2e799f62530b15
|
||||||
time: 2020-04-22 22:42
|
time: 2020-05-21 13:11
|
||||||
|
8
resources/routes/web/admin/equipos.php
Normal file
8
resources/routes/web/admin/equipos.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
use ProVM\NotariaRaby\Common\Controller\Web\Admin\Equipos;
|
||||||
|
|
||||||
|
$app->group('/equipos', function($app) {
|
||||||
|
$app->post('/add', [Equipos::class, 'add']);
|
||||||
|
$app->post('/remove', [Equipos::class, 'remove']);
|
||||||
|
$app->get('[/]', Equipos::class);
|
||||||
|
});
|
@ -30,7 +30,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="center aligned">
|
<td class="center aligned">
|
||||||
<i class="trash alternate outline icon" data-file="{{$archivo->getBasename('.' . $archivo->getExtension())}}"></i>
|
<i class="remove icon" data-file="{{$archivo->getBasename('.' . $archivo->getExtension())}}"></i>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
@ -117,7 +117,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('.trash').css('cursor', 'pointer').click(function() {
|
$('.remove.icon').css('cursor', 'pointer').click(function() {
|
||||||
var file = $(this).attr('data-file')
|
var file = $(this).attr('data-file')
|
||||||
$.post('{{$urls->admin}}/documentos/delete', {archivo: file}, function(data) {
|
$.post('{{$urls->admin}}/documentos/delete', {archivo: file}, function(data) {
|
||||||
if (data.estado) {
|
if (data.estado) {
|
||||||
|
92
resources/views/admin/equipos.blade.php
Normal file
92
resources/views/admin/equipos.blade.php
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
@extends('admin.layout.base')
|
||||||
|
|
||||||
|
@section('page_content')
|
||||||
|
<div id="equipos">
|
||||||
|
<div class="ui container">
|
||||||
|
<div class="ui header">
|
||||||
|
EQUIPOS NOTARÍA
|
||||||
|
</div>
|
||||||
|
<div class="ui grid">
|
||||||
|
@foreach ($equipos as $i => $equipo)
|
||||||
|
<div class="row">
|
||||||
|
<div class="nine wide column">
|
||||||
|
<div class="ui top attached segment">
|
||||||
|
<div class="ui header">
|
||||||
|
{{$equipo->titulo}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table class="ui bottom attached celled table">
|
||||||
|
<tbody>
|
||||||
|
@foreach ($equipo->miembros as $j => $miembro)
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@if (isset($miembro->nombre))
|
||||||
|
{{$miembro->nombre}}
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@if (isset($miembro->email))
|
||||||
|
{{$miembro->email}}
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="center aligned">
|
||||||
|
<i class="remove icon" data-equipo="{{$i}}" data-id="{{$j}}"></i>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
<tfooter>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<form class="ui form" data-equipo="{{$i}}">
|
||||||
|
<div class="inline fields">
|
||||||
|
<div class="inline field">
|
||||||
|
<input type="text" name="nombre" placeholder="Nombre" />
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<input type="text" name="email" placeholder="Email" />
|
||||||
|
</div>
|
||||||
|
<button class="ui inverted dark-blue button">CREAR</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfooter>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(() => {
|
||||||
|
$('.remove.icon').css('cursor', 'pointer').click(function(e) {
|
||||||
|
var equipo = $(this).attr('data-equipo')
|
||||||
|
var id = $(this).attr('data-id')
|
||||||
|
$.post('{{$urls->admin}}/equipos/remove', {equipo: equipo, id: id}, (data) => {
|
||||||
|
if (data.estado) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
$('form').submit(function(e) {
|
||||||
|
var equipo = $(this).attr('data-equipo')
|
||||||
|
var nombre = $(this).find("input[name='nombre']").val()
|
||||||
|
var email = $(this).find("input[name='email']").val()
|
||||||
|
$.post('{{$urls->admin}}/equipos/add', {equipo: equipo, nombre: nombre, email: email}, (data) => {
|
||||||
|
if (data.estado) {
|
||||||
|
window.location.reload()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
e.preventDefault()
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
@endpush
|
@ -2,6 +2,7 @@
|
|||||||
<a class="left aligned item brand" href="{{$urls->admin}}">
|
<a class="left aligned item brand" href="{{$urls->admin}}">
|
||||||
NOTARÍA PATRICIO RABY BENAVENTE
|
NOTARÍA PATRICIO RABY BENAVENTE
|
||||||
</a>
|
</a>
|
||||||
|
<a class="item" href="{{$urls->admin}}/equipos">Editar Equipos</a>
|
||||||
<a class="item" href="{{$urls->admin}}/clave">Cambiar Clave</a>
|
<a class="item" href="{{$urls->admin}}/clave">Cambiar Clave</a>
|
||||||
<a class="item" href="{{$urls->admin}}/logout">Salir</a>
|
<a class="item" href="{{$urls->admin}}/logout">Salir</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
Reference in New Issue
Block a user