Zona admin
This commit is contained in:
@ -13,7 +13,8 @@ return [
|
||||
'assets' => $c->get('urls.assets'),
|
||||
'images' => implode('/', [$c->get('urls.assets'), 'images']),
|
||||
'styles' => $c->get('urls.styles'),
|
||||
'scripts' => $c->get('urls.scripts')
|
||||
'scripts' => $c->get('urls.scripts'),
|
||||
'admin' => implode('/', [$c->get('urls.base'), 'admin'])
|
||||
];
|
||||
},
|
||||
'assets' => function(Container $c) {
|
||||
|
90
common/Controller/Web/Admin/Faq.php
Normal file
90
common/Controller/Web/Admin/Faq.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace ProVM\KI\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;
|
||||
|
||||
class Faq {
|
||||
public function __invoke(Request $request, Response $response, View $view, Container $container) {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'faqs.json'
|
||||
]);
|
||||
$faqs = json_decode(trim(file_get_contents($filename)));
|
||||
return $view->render($response, 'admin.faq', compact('faqs'));
|
||||
}
|
||||
public function add(Request $request, Response $response, Container $container) {
|
||||
$post = $request->getParsedBody();
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'faqs.json'
|
||||
]);
|
||||
$faqs = json_decode(trim(file_get_contents($filename)));
|
||||
|
||||
$faq = (object) [
|
||||
'titulo' => '',
|
||||
'contenido' => ''
|
||||
];
|
||||
if (isset($post['id']) and isset($faqs[$post['id']])) {
|
||||
$faq = $faqs[$post['id']];
|
||||
}
|
||||
|
||||
$changed = false;
|
||||
foreach ($faq as $k => $v) {
|
||||
if ($v != $post[$k]) {
|
||||
$faq->$k = $post[$k];
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($post['id'])) {
|
||||
$faqs[$post['id']] = $faq;
|
||||
} else {
|
||||
$faqs []= $faq;
|
||||
}
|
||||
|
||||
$status = false;
|
||||
if ($changed) {
|
||||
$faqs = array_values($faqs);
|
||||
$status = (file_put_contents($filename, json_encode($faqs, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES)) !== false);
|
||||
}
|
||||
|
||||
$output = [
|
||||
'informacion' => $post,
|
||||
'estado' => $status,
|
||||
'faqs' => $faqs
|
||||
];
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withStatus(201);
|
||||
}
|
||||
public function delete(Request $request, Response $response, Container $container) {
|
||||
$post = $request->getParsedBody();
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'faqs.json'
|
||||
]);
|
||||
$faqs = json_decode(trim(file_get_contents($filename)));
|
||||
|
||||
$status = false;
|
||||
if (isset($post['id']) and isset($faqs[$post['id']])) {
|
||||
unset($faqs[$post['id']]);
|
||||
|
||||
$faqs = array_values($faqs);
|
||||
$status = (file_put_contents($filename, json_encode($faqs, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES)) !== false);
|
||||
}
|
||||
|
||||
$output = [
|
||||
'informacion' => $post,
|
||||
'estado' => $status,
|
||||
'faqs' => $faqs
|
||||
];
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withStatus(201);
|
||||
}
|
||||
}
|
121
common/Controller/Web/Admin/Home.php
Normal file
121
common/Controller/Web/Admin/Home.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
namespace ProVM\KI\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;
|
||||
|
||||
class Home {
|
||||
public function __invoke(Request $request, Response $response, View $view, Container $container): Response {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'avisos.json'
|
||||
]);
|
||||
$avisos = json_decode(trim(file_get_contents($filename)));
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'resumen.json'
|
||||
]);
|
||||
$resumen = json_decode(trim(file_get_contents($filename)));
|
||||
return $view->render($response, 'admin.home', compact('avisos', 'resumen'));
|
||||
}
|
||||
public function add(Request $request, Response $response, Container $container): Response {
|
||||
$post = $request->getParsedBody();
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'avisos.json'
|
||||
]);
|
||||
$avisos = json_decode(trim(file_get_contents($filename)));
|
||||
|
||||
if (isset($post['estado'])) {
|
||||
$avisos->activo = (bool) $post['estado'];
|
||||
} else {
|
||||
$aviso = (object) [
|
||||
'titulo' => '',
|
||||
'contenido' => ''
|
||||
];
|
||||
if (isset($post['id'])) {
|
||||
$aviso = $avisos->avisos[$post['id']];
|
||||
}
|
||||
|
||||
foreach ($aviso as $k => $v) {
|
||||
if ($v != $post[$k]) {
|
||||
$aviso->$k = $post[$k];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($post['id'])) {
|
||||
$avisos->avisos[$post['id']] = $aviso;
|
||||
} else {
|
||||
$avisos->avisos []= $aviso;
|
||||
}
|
||||
}
|
||||
|
||||
$status = (file_put_contents($filename, json_encode($avisos, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES)) !== false);
|
||||
|
||||
$output = [
|
||||
'informacion' => $post,
|
||||
'estado' => $status,
|
||||
'avisos' => $avisos
|
||||
];
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response
|
||||
->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.data'),
|
||||
'avisos.json'
|
||||
]);
|
||||
$avisos = json_decode(trim(file_get_contents($filename)));
|
||||
|
||||
if (isset($avisos->avisos[$post['id']])) {
|
||||
unset($avisos->avisos[$post['id']]);
|
||||
$avisos->avisos = array_values($avisos->avisos);
|
||||
}
|
||||
|
||||
$status = (file_put_contents($filename, json_encode($avisos, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES)) !== false);
|
||||
|
||||
$output = [
|
||||
'informacion' => $post,
|
||||
'estado' => $status,
|
||||
'avisos' => $avisos
|
||||
];
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withStatus(201);
|
||||
}
|
||||
public function edit(Request $request, Response $response, Container $container): Response {
|
||||
$post = $request->getParsedBody();
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'resumen.json'
|
||||
]);
|
||||
$resumen = json_decode(trim(file_get_contents($filename)));
|
||||
|
||||
$ind = $resumen[$post['id']];
|
||||
|
||||
foreach ($ind as $k => $v) {
|
||||
if ($v != $post[$k]) {
|
||||
$ind->$k = $post[$k];
|
||||
}
|
||||
}
|
||||
$resumen[$post['id']] = $ind;
|
||||
|
||||
$status = (file_put_contents($filename, json_encode($resumen, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES)) !== false);
|
||||
|
||||
$output = [
|
||||
'informacion' => $post,
|
||||
'estado' => $status,
|
||||
'resumen' => $resumen
|
||||
];
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withStatus(201);
|
||||
}
|
||||
}
|
39
common/Controller/Web/Admin/Nosotros.php
Normal file
39
common/Controller/Web/Admin/Nosotros.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace ProVM\KI\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;
|
||||
|
||||
class Nosotros {
|
||||
public function __invoke(Request $request, Response $response, View $view, Container $container) {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'nosotros.json'
|
||||
]);
|
||||
$nosotros = trim(json_decode(trim(file_get_contents($filename))));
|
||||
return $view->render($response, 'admin.nosotros', compact('nosotros'));
|
||||
}
|
||||
public function guardar(Request $request, Response $response, Container $container) {
|
||||
$post = $request->getParsedBody();
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'nosotros.json'
|
||||
]);
|
||||
$nosotros = trim(json_decode(trim(file_get_contents($filename))));
|
||||
$data = trim(json_decode(json_encode($post['nosotros'])));
|
||||
|
||||
$status = false;
|
||||
if ($nosotros != $data) {
|
||||
$status = (file_put_contents($filename, json_encode($post['nosotros'])) !== false);
|
||||
}
|
||||
$code = 301;
|
||||
if ($status) {
|
||||
$code = 302;
|
||||
}
|
||||
return $response
|
||||
->withHeader('Location', implode('/', [$container->get('urls')->admin, 'nosotros']))
|
||||
->withStatus($code);
|
||||
}
|
||||
}
|
87
common/Controller/Web/Admin/Productos.php
Normal file
87
common/Controller/Web/Admin/Productos.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
namespace ProVM\KI\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;
|
||||
|
||||
class Productos {
|
||||
public function __invoke(Request $request, Response $response, View $view, Container $container): Response {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'productos.json'
|
||||
]);
|
||||
$productos = json_decode(trim(file_get_contents($filename)));
|
||||
return $view->render($response, 'admin.productos', compact('productos'));
|
||||
}
|
||||
public function edit(Request $request, Response $response, View $view, Container $container, $producto): Response {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'productos.json'
|
||||
]);
|
||||
$id = $producto;
|
||||
$productos = json_decode(trim(file_get_contents($filename)));
|
||||
$producto = $productos[$producto];
|
||||
$producto->id = $id;
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'destacados.json'
|
||||
]);
|
||||
$destacados = json_decode(trim(file_get_contents($filename)));
|
||||
$destacado = false;
|
||||
if (array_search($id, $destacados) !== false) {
|
||||
$destacado = true;
|
||||
}
|
||||
$producto->destacado = $destacado;
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.public'),
|
||||
'assets',
|
||||
'images',
|
||||
mb_strtolower($producto->nombre)
|
||||
]);
|
||||
$producto->images = [];
|
||||
if (file_exists($folder)) {
|
||||
$files = new \DirectoryIterator($folder);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
$producto->images []= $file->getFilename();
|
||||
}
|
||||
}
|
||||
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'segmentos.json'
|
||||
]);
|
||||
$segmentos = json_decode(trim(file_get_contents($filename)));
|
||||
return $view->render($response, 'admin.producto', compact('producto', 'segmentos'));
|
||||
}
|
||||
public function do_edit(Request $request, Response $response, Container $container, $producto): Response {
|
||||
$post = $request->getParsedBody();
|
||||
}
|
||||
public function add(Request $request, Response $response, View $view, Container $container): Response {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.data'),
|
||||
'segmentos.json'
|
||||
]);
|
||||
$segmentos = json_decode(trim(file_get_contents($filename)));
|
||||
return $view->render($response, 'admin.productos.add', compact('segmentos'));
|
||||
}
|
||||
public function do_add(Request $request, Response $response, Container $container): Response {
|
||||
$post = $request->getParsedBody();
|
||||
}
|
||||
public function add_image(Request $request, Response $response, Container $container, $producto): Response {
|
||||
$post = $request->getParsedBody();
|
||||
}
|
||||
public function set_video(Request $request, Response $response, Container $container, $producto): Response {
|
||||
$post = $request->getParsedBody();
|
||||
}
|
||||
public function delete_image(Request $request, Response $response, Container $container, $producto): Response {
|
||||
$post = $request->getParsedBody();
|
||||
}
|
||||
public function delete_video(Request $request, Response $response, Container $container, $producto): Response {
|
||||
$post = $request->getParsedBody();
|
||||
}
|
||||
}
|
19
public/assets/styles/admin.css
Normal file
19
public/assets/styles/admin.css
Normal file
@ -0,0 +1,19 @@
|
||||
/* line 3, ../../Workspace/git/provm/capitalinvestments/resources/assets/sass/admin.scss */
|
||||
#admin {
|
||||
background-color: #f4f4f4;
|
||||
padding-top: 3rem;
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* line 8, ../../Workspace/git/provm/capitalinvestments/resources/assets/sass/admin.scss */
|
||||
#admin .button {
|
||||
background-color: #429ab7;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* line 13, ../../Workspace/git/provm/capitalinvestments/resources/assets/sass/admin.scss */
|
||||
#admin .container > .header, #admin .container > .grid > .column > .header, #admin .container > .grid > .row > .column > .header {
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=admin.css.map */
|
14
public/assets/styles/admin.map
Normal file
14
public/assets/styles/admin.map
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": 3,
|
||||
"file": "admin.css",
|
||||
"sources": [
|
||||
"../../../resources/assets/sass/admin.scss",
|
||||
"../../../resources/assets/sass/_pallete.scss"
|
||||
],
|
||||
"sourcesContent": [
|
||||
"@import 'pallete';\r\n\r\n#admin {\r\n background-color: $gris-claro;\r\n padding-top: 3rem;\r\n padding-bottom: 2rem;\r\n\r\n .button {\r\n background-color: $marca;\r\n color: white;\r\n }\r\n\r\n .container>.header, .container>.grid>.column>.header, .container>.grid>.row>.column>.header {\r\n padding-bottom: 2rem;\r\n }\r\n}\r\n",
|
||||
"$marca: #429ab7;\r\n$gris-oscuro: #808284;\r\n$gris-medio: #a7a9ab;\r\n$gris-claro: #f4f4f4;\r\n$azul-oscuro: #0d103c;\r\n"
|
||||
],
|
||||
"names": [],
|
||||
"mappings": ";AAEA,AAAA,MAAM,CAAC;EACL,gBAAgB,ECAL,OAAO;EDClB,WAAW,EAAE,IAAI;EACjB,cAAc,EAAE,IAAI;CAUrB;;;AAbD,AAKE,MALI,CAKJ,OAAO,CAAC;EACN,gBAAgB,ECRZ,OAAO;EDSX,KAAK,EAAE,KAAK;CACb;;;AARH,AAUE,MAVI,CAUJ,UAAU,GAAC,OAAO,EAVpB,MAAM,CAUgB,UAAU,GAAC,KAAK,GAAC,OAAO,GAAC,OAAO,EAVtD,MAAM,CAUkD,UAAU,GAAC,KAAK,GAAC,IAAI,GAAC,OAAO,GAAC,OAAO,CAAC;EAC1F,cAAc,EAAE,IAAI;CACrB"
|
||||
}
|
16
resources/assets/sass/admin.scss
Normal file
16
resources/assets/sass/admin.scss
Normal file
@ -0,0 +1,16 @@
|
||||
@import 'pallete';
|
||||
|
||||
#admin {
|
||||
background-color: $gris-claro;
|
||||
padding-top: 3rem;
|
||||
padding-bottom: 2rem;
|
||||
|
||||
.button {
|
||||
background-color: $marca;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.container>.header, .container>.grid>.column>.header, .container>.grid>.row>.column>.header {
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
}
|
16
resources/routes/web/admin.php
Normal file
16
resources/routes/web/admin.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
$app->group('/admin', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [
|
||||
__DIR__,
|
||||
'admin'
|
||||
]);
|
||||
if (file_exists($folder)) {
|
||||
$files = new DirectoryIterator($folder);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
});
|
8
resources/routes/web/admin/faqs.php
Normal file
8
resources/routes/web/admin/faqs.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
use ProVM\KI\Common\Controller\Web\Admin\Faq;
|
||||
|
||||
$app->group('/faqs', function($app) {
|
||||
$app->post('/add', [Faq::class, 'add']);
|
||||
$app->post('/delete', [Faq::class, 'delete']);
|
||||
$app->get('[/]', Faq::class);
|
||||
});
|
13
resources/routes/web/admin/home.php
Normal file
13
resources/routes/web/admin/home.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
use ProVM\KI\Common\Controller\Web\Admin\Home;
|
||||
|
||||
$app->group('/home', function($app) {
|
||||
$app->group('/avisos', function($app) {
|
||||
$app->post('/add', [Home::class, 'add']);
|
||||
$app->post('/delete', [Home::class, 'delete']);
|
||||
});
|
||||
$app->group('/resumen', function($app) {
|
||||
$app->post('/edit', [Home::class, 'edit']);
|
||||
});
|
||||
$app->get('[/]', Home::class);
|
||||
});
|
7
resources/routes/web/admin/nosotros.php
Normal file
7
resources/routes/web/admin/nosotros.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
use ProVM\KI\Common\Controller\Web\Admin\Nosotros;
|
||||
|
||||
$app->group('/nosotros', function($app) {
|
||||
$app->post('[/]', [Nosotros::class, 'guardar']);
|
||||
$app->get('[/]', Nosotros::class);
|
||||
});
|
24
resources/routes/web/admin/productos.php
Normal file
24
resources/routes/web/admin/productos.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
use ProVM\KI\Common\Controller\Web\Admin\Productos;
|
||||
|
||||
$app->group('/productos', function($app) {
|
||||
$app->group('/add', function($app) {
|
||||
$app->get('[/]', [Productos::class, 'add']);
|
||||
$app->post('[/]', [Productos::class, 'do_add']);
|
||||
});
|
||||
$app->get('[/]', Productos::class);
|
||||
});
|
||||
$app->group('/producto/{producto}', function($app) {
|
||||
$app->group('/imagen', function($app) {
|
||||
$app->post('/delete', [Productos::class, 'delete_image']);
|
||||
});
|
||||
$app->group('/imagenes', function($app) {
|
||||
$app->post('/add', [Productos::class, 'add_image']);
|
||||
});
|
||||
$app->group('/video', function($app) {
|
||||
$app->post('/set', [Productos::class, 'set_video']);
|
||||
$app->post('/delete', [Productos::class, 'delete_video']);
|
||||
});
|
||||
$app->post('[/]', [Productos::class, 'do_edit']);
|
||||
$app->get('[/]', [Productos::class, 'edit']);
|
||||
});
|
97
resources/views/admin/faq.blade.php
Normal file
97
resources/views/admin/faq.blade.php
Normal file
@ -0,0 +1,97 @@
|
||||
@extends('admin.layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui grid">
|
||||
<div class="nine wide column">
|
||||
<div class="ui header">
|
||||
FAQ's
|
||||
</div>
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Pregunta</th>
|
||||
<th class="center aligned">Borrar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($faqs as $i => $faq)
|
||||
<tr>
|
||||
<td class="titulo" data-id="{{$i}}">{{$faq->titulo}}</td>
|
||||
<td class="center aligned"><i class="trash alternate outline icon" data-id="{{$i}}"></i>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<form class="ui form">
|
||||
<input type="hidden" name="id" />
|
||||
<div class="field">
|
||||
<label>Pregunta</label>
|
||||
<input type="text" name="titulo" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Respuesta</label>
|
||||
<textarea rows="1" name="contenido"></textarea>
|
||||
</div>
|
||||
<button class="ui button enviar">AGREGAR</button>
|
||||
<button class="ui button resetear" type="reset">BORRAR</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var edit = false
|
||||
var faqs = [
|
||||
@foreach ($faqs as $faq)
|
||||
{
|
||||
titulo: '{{$faq->titulo}}',
|
||||
contenido: '{{$faq->contenido}}'
|
||||
},
|
||||
@endforeach
|
||||
]
|
||||
$(document).ready(() => {
|
||||
$('.titulo').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
|
||||
$("input[name='id']").val(id)
|
||||
$("input[name='titulo']").val(faqs[id].titulo)
|
||||
$("textarea[name='contenido']").val(faqs[id].contenido)
|
||||
$('.button.enviar').html('EDITAR')
|
||||
edit = true
|
||||
})
|
||||
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
var url = '{{$urls->admin}}/faqs/delete'
|
||||
$.post(url, {id: id}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
$('.button.resetear').click(() => {
|
||||
$("input[name='id']").val('')
|
||||
$('.button.enviar').html('AGREGAR')
|
||||
edit = false
|
||||
})
|
||||
$('.form').trigger('reset')
|
||||
$('.form').submit((e) => {
|
||||
e.preventDefault()
|
||||
var input = {
|
||||
titulo: $("input[name='titulo']").val(),
|
||||
contenido: $("textarea[name='contenido']").val()
|
||||
}
|
||||
if (edit) {
|
||||
input['id'] = $("input[name='id']").val()
|
||||
}
|
||||
var url = '{{$urls->admin}}/faqs/add'
|
||||
$.post(url, input, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
173
resources/views/admin/home.blade.php
Normal file
173
resources/views/admin/home.blade.php
Normal file
@ -0,0 +1,173 @@
|
||||
@extends('admin.layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui grid">
|
||||
<div class="row">
|
||||
<div class="nine wide column">
|
||||
<div class="ui header">
|
||||
AVISOS
|
||||
</div>
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">Pregunta</th>
|
||||
<th class="center aligned">Borrar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($avisos->avisos as $i => $aviso)
|
||||
<tr>
|
||||
<td class="link titulo" data-id="{{$i}}">{{$aviso->titulo}}</td>
|
||||
<td class="link contenido" data-id="{{$i}}">{{$aviso->contenido}}</td>
|
||||
<td class="center aligned"><i class="trash alternate outline icon" data-id="{{$i}}"></i></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfooter>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<form class="ui form" id="avisos">
|
||||
<input type="hidden" name="id" />
|
||||
<div class="inline fields">
|
||||
<div class="field">
|
||||
<input type="text" name="titulo" placeholder="Título" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="text" name="contenido" placeholder="Bajada" />
|
||||
</div>
|
||||
<button class="ui button accion">CREAR</button>
|
||||
<button class="ui button" type="reset">BORRAR</button>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tfooter>
|
||||
</table>
|
||||
<div class="ui slider checkbox">
|
||||
<input type="checkbox" tabindex="0" class="hidden" value="{{$avisos->activo}}">
|
||||
<label>Activo</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="nine wide column">
|
||||
<div class="ui header">
|
||||
INDICADORES
|
||||
</div>
|
||||
<form class="ui form" id="resumen">
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Enunciado</th>
|
||||
<th>Cantidad</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($resumen as $i => $indicador)
|
||||
<tr>
|
||||
<td><input type="text" name="titulo{{$i}}" value="{{$indicador->titulo}}" /></td>
|
||||
<td><input type="text" name="cantidad{{$i}}" value="{{$indicador->cantidad}}" /></td>
|
||||
<td><button class="ui button guardar" data-id="{{$i}}">GUARDAR</button></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var edit = false
|
||||
function editAviso(id) {
|
||||
var titulo = $(".link.titulo[data-id='" + id + "']").html()
|
||||
var contenido = $(".link.contenido[data-id='" + id + "']").html()
|
||||
|
||||
$("input[name='id']").val(id)
|
||||
$("input[name='titulo']").val(titulo)
|
||||
$("input[name='contenido']").val(contenido)
|
||||
edit = true
|
||||
$('.accion').html('EDITAR')
|
||||
}
|
||||
function submitAviso(e) {
|
||||
e.preventDefault()
|
||||
input = {
|
||||
titulo: $("input[name='titulo']").val(),
|
||||
contenido: $("input[name='contenido']").val()
|
||||
}
|
||||
if (edit) {
|
||||
input['id'] = $("input[name='id']").val()
|
||||
}
|
||||
if (input['titulo'] == '') {
|
||||
return false
|
||||
}
|
||||
var url = '{{$urls->admin}}/home/avisos/add'
|
||||
$.post(url, input, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}, 'json')
|
||||
return false
|
||||
}
|
||||
function deleteAviso(id) {
|
||||
var url = '{{$urls->admin}}/home/avisos/delete'
|
||||
$.post(url, {id: id}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}, 'json')
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('.link').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
editAviso(id)
|
||||
})
|
||||
$('#avisos').trigger('reset')
|
||||
$('#avisos').submit((e) => {
|
||||
submitAviso(e)
|
||||
})
|
||||
$(".button[type='reset']").click((e) => {
|
||||
$("input[name='id']").val('')
|
||||
$('.accion').html('CREAR')
|
||||
edit = false
|
||||
})
|
||||
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
deleteAviso(id)
|
||||
})
|
||||
$('.checkbox').checkbox({
|
||||
onChange: function() {
|
||||
var state = $(this).is(':checked')
|
||||
var url = '{{$urls->admin}}/home/avisos/add'
|
||||
$.post(url, {estado: state}, (data) => {
|
||||
console.debug(data)
|
||||
})
|
||||
}
|
||||
})
|
||||
@if ($avisos->activo)
|
||||
$('.checkbox').checkbox('set checked')
|
||||
@endif
|
||||
$('#resumen').submit((e) => {
|
||||
e.preventDefault()
|
||||
return false
|
||||
})
|
||||
$('.guardar').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
var url = '{{$urls->admin}}/home/resumen/edit'
|
||||
input = {
|
||||
id: id,
|
||||
titulo: $("input[name='titulo" + id + "']").val(),
|
||||
cantidad: $("input[name='cantidad" + id + "']").val()
|
||||
}
|
||||
$.post(url, input, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
5
resources/views/admin/layout/base.blade.php
Normal file
5
resources/views/admin/layout/base.blade.php
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{$page_language}}">
|
||||
@include('admin.layout.head')
|
||||
@include('admin.layout.body')
|
||||
</html>
|
10
resources/views/admin/layout/body.blade.php
Normal file
10
resources/views/admin/layout/body.blade.php
Normal file
@ -0,0 +1,10 @@
|
||||
<body>
|
||||
@include('admin.layout.header')
|
||||
<div id="admin">
|
||||
<div class="ui container">
|
||||
@yield('page_content')
|
||||
</div>
|
||||
</div>
|
||||
@include('admin.layout.footer')
|
||||
@include('layout.scripts')
|
||||
</body>
|
10
resources/views/admin/layout/footer.blade.php
Normal file
10
resources/views/admin/layout/footer.blade.php
Normal file
@ -0,0 +1,10 @@
|
||||
<footer>
|
||||
<div class="ui container">
|
||||
<div class="ui tiny text menu">
|
||||
<div class="item">
|
||||
Copyright
|
||||
Todos los derechos reservados 2020 ProVM<i class="copyright outline icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
7
resources/views/admin/layout/head.blade.php
Normal file
7
resources/views/admin/layout/head.blade.php
Normal file
@ -0,0 +1,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>
|
||||
Capital Investments
|
||||
</title>
|
||||
@include('admin.layout.styles')
|
||||
</head>
|
7
resources/views/admin/layout/header.blade.php
Normal file
7
resources/views/admin/layout/header.blade.php
Normal file
@ -0,0 +1,7 @@
|
||||
<header>
|
||||
@include('admin.layout.header.menu')
|
||||
</header>
|
||||
|
||||
@push('styles')
|
||||
<link rel="stylesheet" type="text/css" href="{{$urls->styles}}/admin.css" />
|
||||
@endpush
|
26
resources/views/admin/layout/header/menu.blade.php
Normal file
26
resources/views/admin/layout/header/menu.blade.php
Normal file
@ -0,0 +1,26 @@
|
||||
<div class="ui container">
|
||||
<nav class="ui massive text menu">
|
||||
<a class="item logo" href="{{$urls->admin}}">
|
||||
<div class="ui title image">
|
||||
<img src="{{$urls->images}}/logo.png" alt="Capital Investments" title="Capital Investments" />
|
||||
</div>
|
||||
</a>
|
||||
<div class="right menu">
|
||||
<a class="item" href="{{$urls->admin}}/home">
|
||||
HOME
|
||||
</a>
|
||||
<a class="item" href="{{$urls->admin}}/nosotros">
|
||||
NOSOTROS
|
||||
</a>
|
||||
<a class="item" href="{{$urls->admin}}/productos">
|
||||
PRODUCTOS
|
||||
</a>
|
||||
<a class="item" href="{{$urls->admin}}/faqs">
|
||||
FAQs
|
||||
</a>
|
||||
<a class="item" href="{{$urls->base}}">
|
||||
Salir
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
14
resources/views/admin/layout/styles.blade.php
Normal file
14
resources/views/admin/layout/styles.blade.php
Normal file
@ -0,0 +1,14 @@
|
||||
@if (isset($assets->styles))
|
||||
@foreach ($assets->styles as $style)
|
||||
<link rel="stylesheet" type="text/css" href="{{$style}}" />
|
||||
@endforeach
|
||||
@endif
|
||||
<link rel="stylesheet" type="text/css" href="{{$urls->styles}}/admin.css" />
|
||||
@if (isset($assets->fonts))
|
||||
@foreach ($assets->fonts as $type => $fonts)
|
||||
@foreach ($fonts as $font)
|
||||
<link type="{{$type}}" href="{{$font}}" />
|
||||
@endforeach
|
||||
@endforeach
|
||||
@endif
|
||||
@stack('styles')
|
18
resources/views/admin/nosotros.blade.php
Normal file
18
resources/views/admin/nosotros.blade.php
Normal file
@ -0,0 +1,18 @@
|
||||
@extends('admin.layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui grid">
|
||||
<div class="ten wide column">
|
||||
<div class="ui header">
|
||||
NOSOTROS
|
||||
</div>
|
||||
<form class="ui form" method="post" action="{{$urls->admin}}/nosotros">
|
||||
<div class="field">
|
||||
<label>Descripción</label>
|
||||
<textarea name="nosotros">{{$nosotros}}</textarea>
|
||||
</div>
|
||||
<button class="ui button">GUARDAR</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
250
resources/views/admin/producto.blade.php
Normal file
250
resources/views/admin/producto.blade.php
Normal file
@ -0,0 +1,250 @@
|
||||
@extends('admin.layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui header">
|
||||
PRODUCTO
|
||||
</div>
|
||||
<form class="ui form" method="post" action="{{$urls->admin}}/producto/{{$producto->id}}" enctype="multipart/form-data">
|
||||
<div class="ui three columns grid">
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Nombre</label>
|
||||
<input type="text" name="nombre" value="{{$producto->nombre ?? ''}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label>Dirección</label>
|
||||
<input type="text" name="direccion" value="{{$producto->direccion ?? ''}}" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Comuna</label>
|
||||
<input type="text" name="comuna" value="{{$producto->comuna ?? ''}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Segmento</label>
|
||||
<div class="ui selection dropdown">
|
||||
<input type="hidden" name="segmento" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Segmento</div>
|
||||
<div class="menu">
|
||||
@foreach ($segmentos as $segmento)
|
||||
<div class="item" data-value="{{$segmento->titulo}}">{{$segmento->titulo}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Valor en UF</label>
|
||||
<input type="text" name="valor" value="{{str_replace('.', '', $producto->valor ?? '')}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Bono Pie en UF</label>
|
||||
<input type="text" name="bono" value="{{$producto->bono ?? ''}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Rentabilidad %</label>
|
||||
<input type="text" name="rentabilidad" value="{{$producto->rentabilidad ?? ''}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Valor Cuota en UF</label>
|
||||
<input type="text" name="cuota" value="{{$producto->cuota ?? ''}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Entrega Estimada</label>
|
||||
<div class="ui calendar">
|
||||
<input type="text" name="entrega" placeholder="Entrega" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Destacado</label>
|
||||
<div class="ui toggle checkbox">
|
||||
<input type="checkbox" name="destacado" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Estado</label>
|
||||
<input type="text" name="estado" value="{{$producto->estado ?? ''}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Unidades</label>
|
||||
<input type="text" name="unidades" value="{{$producto->unidades ?? ''}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Modelos</label>
|
||||
<input type="text" name="modelos" value="{{$producto->modelos ?? ''}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label>Tamaño Mínimo</label>
|
||||
<input type="text" name="tamaño" value="{{(isset($producto->tamaño)) ? explode(' - ', rtrim($producto->tamaño, ' m²'))[0] : ''}}" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Tamaño Máximo</label>
|
||||
<input type="text" name="tamaño_max" value="{{(isset($producto->tamaño)) ? explode(' - ', rtrim($producto->tamaño, ' m²'))[1] : ''}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ten wide column">
|
||||
<div class="field">
|
||||
<label>Descripción</label>
|
||||
<textarea rows="1" name="descripcion">{{$producto->descripcion ?? ''}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Imágenes</label>
|
||||
<input type="file" name="imagen" />
|
||||
</div>
|
||||
<div id="imagenes" class="ui list"></div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Video</label>
|
||||
<input type="file" name="video" />
|
||||
</div>
|
||||
<div class="ui list">
|
||||
@if (isset($producto->video))
|
||||
<div class="item">
|
||||
<i class="trash alternate outline icon video"></i>
|
||||
<div class="content">
|
||||
{{$producto->video}}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<button class="ui button">GUARDAR</button>
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var months = {
|
||||
long: [],
|
||||
short: []
|
||||
}
|
||||
var date = new Date(2018, 0, 1)
|
||||
for (i = 0; i < 12; i ++) {
|
||||
date.setMonth(i)
|
||||
months.long.push(date.toLocaleString('es-ES', {month: "long"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
months.short.push(date.toLocaleString('es-ES', {month: "short"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
}
|
||||
function listImage(image) {
|
||||
var icon = $('<i></i>').attr('class', 'trash alternate outline icon')
|
||||
icon.css('cursor', 'pointer').click(function() {
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagen/delete'
|
||||
$.post(url, {imagen: image}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
$('#imagenes').append(
|
||||
$('<div></div>').attr('class', 'item').append(
|
||||
icon
|
||||
).append(
|
||||
$('<div></div>').attr('class', 'content').html(image)
|
||||
)
|
||||
)
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('.selection.dropdown').dropdown()
|
||||
$('.selection.dropdown').dropdown('set selected', '{{$producto->segmento}}')
|
||||
$('.calendar').calendar({
|
||||
type: 'month',
|
||||
text: {
|
||||
months: months.long,
|
||||
monthsShort: months.short
|
||||
}
|
||||
})
|
||||
var entrega = new Date('20{{implode('-', array_reverse(explode('/', $producto->entrega)))}}-01T01:00')
|
||||
$('.calendar').calendar('set date', entrega)
|
||||
$('.checkbox').checkbox()
|
||||
@if ($producto->destacado)
|
||||
$('.checkbox').checkbox('set checked')
|
||||
@endif
|
||||
$("input[name='imagen']").change(function() {
|
||||
var data = new FormData()
|
||||
data.append('imagen', $(this)[0].files[0])
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagenes/add'
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'post',
|
||||
data: data,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
@foreach ($producto->images as $image)
|
||||
listImage('{{$image}}')
|
||||
@endforeach
|
||||
$("input[name='video']").change(function() {
|
||||
var fData = new FormData()
|
||||
fData.append('video', $("input[name='video']")[0].files[0])
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/set'
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'post',
|
||||
data: fData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
$('.trash.video').attr('cursor', 'pointer').click(() => {
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/delete'
|
||||
$.post(url, {}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
60
resources/views/admin/productos.blade.php
Normal file
60
resources/views/admin/productos.blade.php
Normal file
@ -0,0 +1,60 @@
|
||||
@extends('admin.layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui grid">
|
||||
<div class="nine wide column">
|
||||
<div class="ui header">
|
||||
PRODUCTOS
|
||||
</div>
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="right aligned" colspan="3">
|
||||
<a href="{{$urls->admin}}/productos/add">
|
||||
<button class="ui button">NUEVO</button>
|
||||
</a>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Producto</th>
|
||||
<th class="center aligned">Editar</th>
|
||||
<th class="center aligned">Borrar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($productos as $i => $producto)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{$urls->admin}}/producto/{{$i}}">
|
||||
{{$producto->nombre}}
|
||||
</a>
|
||||
</td>
|
||||
<td class="center aligned">
|
||||
<a href="{{$urls->admin}}/producto/{{$i}}">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td class="center aligned"><i class="trash alternate outline icon" data-id="{{$i}}"></i></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(() => {
|
||||
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
var url = '{{$urls->admin}}/productos/delete'
|
||||
$.post(url, {id: id}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
158
resources/views/admin/productos/add.blade.php
Normal file
158
resources/views/admin/productos/add.blade.php
Normal file
@ -0,0 +1,158 @@
|
||||
@extends('admin.layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui header">
|
||||
AGREGAR PRODUCTO
|
||||
</div>
|
||||
<form class="ui form" method="post" action="{{$urls->admin}}/productos/add" enctype="multipart/form-data">
|
||||
<div class="ui three columns grid">
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Nombre</label>
|
||||
<input type="text" name="nombre" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label>Dirección</label>
|
||||
<input type="text" name="direccion" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Comuna</label>
|
||||
<input type="text" name="comuna" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Segmento</label>
|
||||
<div class="ui selection dropdown">
|
||||
<input type="hidden" name="segmento" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Segmento</div>
|
||||
<div class="menu">
|
||||
@foreach ($segmentos as $segmento)
|
||||
<div class="item" data-value="{{$segmento->titulo}}">{{$segmento->titulo}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Valor en UF</label>
|
||||
<input type="text" name="valor" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Bono Pie en UF</label>
|
||||
<input type="text" name="bono" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Rentabilidad %</label>
|
||||
<input type="text" name="rentabilidad" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Valor Cuota en UF</label>
|
||||
<input type="text" name="cuota" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Entrega Estimada</label>
|
||||
<div class="ui calendar">
|
||||
<input type="text" name="entrega" placeholder="Entrega" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Destacado</label>
|
||||
<div class="ui toggle checkbox">
|
||||
<input type="checkbox" name="destacado" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Estado</label>
|
||||
<input type="text" name="estado" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Unidades</label>
|
||||
<input type="text" name="unidades" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Modelos</label>
|
||||
<input type="text" name="modelos" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label>Tamaño Mínimo</label>
|
||||
<input type="text" name="tamaño" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Tamaño Máximo</label>
|
||||
<input type="text" name="tamaño_max" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ten wide column">
|
||||
<div class="field">
|
||||
<label>Descripción</label>
|
||||
<textarea rows="1" name="descripcion"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<button class="ui button">AGREGAR</button>
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var months = {
|
||||
long: [],
|
||||
short: []
|
||||
}
|
||||
var date = new Date(2018, 0, 1)
|
||||
for (i = 0; i < 12; i ++) {
|
||||
date.setMonth(i)
|
||||
months.long.push(date.toLocaleString('es-ES', {month: "long"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
months.short.push(date.toLocaleString('es-ES', {month: "short"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('.selection.dropdown').dropdown()
|
||||
$('.calendar').calendar({
|
||||
type: 'month',
|
||||
text: {
|
||||
months: months.long,
|
||||
monthsShort: months.short
|
||||
}
|
||||
})
|
||||
$('.checkbox').checkbox()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
Reference in New Issue
Block a user