FIX: varias observaciones
This commit is contained in:
@ -11,49 +11,10 @@ use ProVM\KI\Producto;
|
|||||||
|
|
||||||
class Productos {
|
class Productos {
|
||||||
public function __invoke(Request $request, Response $response, View $view, ModelFactory $factory): Response {
|
public function __invoke(Request $request, Response $response, View $view, ModelFactory $factory): Response {
|
||||||
/*$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'productos.json'
|
|
||||||
]);
|
|
||||||
$productos = json_decode(trim(file_get_contents($filename)));*/
|
|
||||||
$productos = $factory->find(Producto::class)->many();
|
$productos = $factory->find(Producto::class)->many();
|
||||||
return $view->render($response, 'admin.productos', compact('productos'));
|
return $view->render($response, 'admin.productos', compact('productos'));
|
||||||
}
|
}
|
||||||
public function edit(Request $request, Response $response, View $view, Container $container, ModelFactory $factory, $producto): Response {
|
public function edit(Request $request, Response $response, View $view, Container $container, ModelFactory $factory, $producto): Response {
|
||||||
/*$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'productos.json'
|
|
||||||
]);
|
|
||||||
$id = $producto;
|
|
||||||
$productos = json_decode(trim(file_get_contents($filename)));
|
|
||||||
$producto = $productos[$id];
|
|
||||||
$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();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
$producto = $factory->find(Producto::class)->where([['id', $producto]])->one();
|
$producto = $factory->find(Producto::class)->where([['id', $producto]])->one();
|
||||||
|
|
||||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||||
@ -66,33 +27,8 @@ class Productos {
|
|||||||
}
|
}
|
||||||
public function do_edit(Request $request, Response $response, Container $container, ModelFactory $factory, $producto): Response {
|
public function do_edit(Request $request, Response $response, Container $container, ModelFactory $factory, $producto): Response {
|
||||||
$post = $request->getParsedBody();
|
$post = $request->getParsedBody();
|
||||||
/*$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'productos.json'
|
|
||||||
]);
|
|
||||||
$id = $producto;
|
|
||||||
$productos = json_decode(trim(file_get_contents($filename)));
|
|
||||||
$producto = $productos[$producto];*/
|
|
||||||
$producto = $factory->find(Producto::class)->where([['id', $producto]])->one();
|
$producto = $factory->find(Producto::class)->where([['id', $producto]])->one();
|
||||||
|
|
||||||
/*$fields = ['nombre', 'segmento', 'direccion', 'comuna', 'ciudad', 'bono', 'rentabilidad', 'estado',
|
|
||||||
'cuota', 'unidades', 'modelos', 'descripcion', 'entrega'];
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
if (!isset($producto->$field) or $post[$field] != $producto->$field) {
|
|
||||||
$producto->$field = $post[$field];
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$valor = number_format($post['valor'], 0, ',', '.');
|
|
||||||
if (!isset($producto->valor) or $producto->valor != $valor) {
|
|
||||||
$producto->valor = $valor;
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
$tamaño = $post['tamaño_min'] . ' - ' . $post['tamaño_max'] . ' m²';
|
|
||||||
if (!isset($producto->tamaño) or $producto->tamaño != $tamaño) {
|
|
||||||
$producto->tamaño = $tamaño;
|
|
||||||
$changed = true;
|
|
||||||
}*/
|
|
||||||
$f = Carbon::today();
|
$f = Carbon::today();
|
||||||
$post['publicacion'] = $producto->publicacion ?? implode(' ', [
|
$post['publicacion'] = $producto->publicacion ?? implode(' ', [
|
||||||
$f->day,
|
$f->day,
|
||||||
@ -103,37 +39,8 @@ class Productos {
|
|||||||
$post['id'] = $producto->id;
|
$post['id'] = $producto->id;
|
||||||
$producto->map((object) $post);
|
$producto->map((object) $post);
|
||||||
|
|
||||||
/*$status1 = false;
|
|
||||||
if ($changed) {
|
|
||||||
$productos[$id] = $producto;
|
|
||||||
$status1 = (file_put_contents($filename, json_encode($productos, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES)) !== false);
|
|
||||||
}*/
|
|
||||||
$producto->save();
|
$producto->save();
|
||||||
|
|
||||||
/*$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'destacados.json'
|
|
||||||
]);
|
|
||||||
$destacados = json_decode(trim(file_get_contents($filename)));
|
|
||||||
$changed = false;
|
|
||||||
if (isset($post['destacado']) and $post['destacado'] == 'on') {
|
|
||||||
if (array_search($producto->id, $destacados) === false) {
|
|
||||||
$destacados []= $producto->id;
|
|
||||||
sort($destacados);
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (($i = array_search($producto->id, $destacados)) !== false) {
|
|
||||||
unset($destacados[$i]);
|
|
||||||
$destacados = array_values($destacados);
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$status2 = false;
|
|
||||||
if ($changed) {
|
|
||||||
$status2 = (file_put_contents($filename, json_encode($destacados)) !== false);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return $response
|
return $response
|
||||||
->withHeader('Location', implode('/', [$container->get('urls')->admin, 'productos']));
|
->withHeader('Location', implode('/', [$container->get('urls')->admin, 'productos']));
|
||||||
}
|
}
|
||||||
@ -148,33 +55,6 @@ class Productos {
|
|||||||
public function do_add(Request $request, Response $response, Container $container, ModelFactory $factory): Response {
|
public function do_add(Request $request, Response $response, Container $container, ModelFactory $factory): Response {
|
||||||
$post = $request->getParsedBody();
|
$post = $request->getParsedBody();
|
||||||
|
|
||||||
/*$producto = (object) [];
|
|
||||||
$fields = ['nombre', 'segmento', 'direccion', 'comuna', 'ciudad', 'bono', 'rentabilidad', 'estado',
|
|
||||||
'cuota', 'unidades', 'modelos', 'descripcion', 'entrega'];
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
$producto->$field = $post[$field];
|
|
||||||
}
|
|
||||||
$valor = number_format($post['valor'], 0, ',', '.');
|
|
||||||
$producto->valor = $valor;
|
|
||||||
$tamaño = $post['tamaño_min'] . ' - ' . $post['tamaño_max'] . ' m²';
|
|
||||||
$producto->tamaño = $tamaño;
|
|
||||||
|
|
||||||
$f = Carbon::today();
|
|
||||||
$producto->publicacion = implode(' ', [
|
|
||||||
$f->day,
|
|
||||||
'de',
|
|
||||||
ucfirst($f->locale('es')->isoFormat('MMMM')) . ',',
|
|
||||||
$f->year
|
|
||||||
]);
|
|
||||||
|
|
||||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'productos.json'
|
|
||||||
]);
|
|
||||||
$productos = json_decode(trim(file_get_contents($filename)));
|
|
||||||
$productos []= $producto;
|
|
||||||
file_put_contents($filename, json_encode($productos, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES));*/
|
|
||||||
|
|
||||||
$f = Carbon::today();
|
$f = Carbon::today();
|
||||||
$post['publicacion'] = implode(' ', [
|
$post['publicacion'] = implode(' ', [
|
||||||
$f->day,
|
$f->day,
|
||||||
@ -188,54 +68,11 @@ class Productos {
|
|||||||
}
|
}
|
||||||
$producto->save();
|
$producto->save();
|
||||||
|
|
||||||
/*if (isset($post['destacado']) and $post['destacado'] == 'on') {
|
|
||||||
//$id = count($productos) - 1;
|
|
||||||
$id = $producto->id;
|
|
||||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'destacados.json'
|
|
||||||
]);
|
|
||||||
$destacados = json_decode(trim(file_get_contents($filename)));
|
|
||||||
$destacados []= $proyecto->id;
|
|
||||||
sort($destacados);
|
|
||||||
file_put_contents($filename, json_encode($destacados));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return $response
|
return $response
|
||||||
->withHeader('Location', implode('/', [$container->get('urls')->admin, 'productos']));
|
->withHeader('Location', implode('/', [$container->get('urls')->admin, 'productos']));
|
||||||
}
|
}
|
||||||
public function delete(Request $request, Response $response, ModelFactory $factory): Response {
|
public function delete(Request $request, Response $response, ModelFactory $factory): Response {
|
||||||
$post = $request->getParsedBody();
|
$post = $request->getParsedBody();
|
||||||
/*$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'productos.json'
|
|
||||||
]);
|
|
||||||
$id = $post['id'];
|
|
||||||
$productos = json_decode(trim(file_get_contents($filename)));
|
|
||||||
$producto = $productos[$id];
|
|
||||||
$folder = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.public'),
|
|
||||||
'assets',
|
|
||||||
'images',
|
|
||||||
mb_strtolower($producto->nombre)
|
|
||||||
]);
|
|
||||||
unset($productos[$id]);
|
|
||||||
$productos = array_values($productos);
|
|
||||||
$status = false;
|
|
||||||
$status |= (file_put_contents($filename, json_encode($productos, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES)) !== false);
|
|
||||||
if (file_exists($folder)) {
|
|
||||||
$status |= rmdir($folder);
|
|
||||||
}
|
|
||||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'destacados.json'
|
|
||||||
]);
|
|
||||||
$destacados = json_decode(trim(file_get_contents($filename)));
|
|
||||||
if (($i = array_search($id, $destacados)) !== false) {
|
|
||||||
unset($destacados[$i]);
|
|
||||||
$destacados = array_values($destacados);
|
|
||||||
$status |= (file_put_contents($filename, json_encode($destacados)) !== false);
|
|
||||||
}*/
|
|
||||||
$producto = $factory->find(Producto::class)->where([['id', $post['id']]])->one();
|
$producto = $factory->find(Producto::class)->where([['id', $post['id']]])->one();
|
||||||
$status = $producto->delete();
|
$status = $producto->delete();
|
||||||
|
|
||||||
@ -252,27 +89,6 @@ class Productos {
|
|||||||
$post = $request->getParsedBody();
|
$post = $request->getParsedBody();
|
||||||
$files = $request->getUploadedFiles();
|
$files = $request->getUploadedFiles();
|
||||||
$file = $files['imagen'];
|
$file = $files['imagen'];
|
||||||
/*$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'productos.json'
|
|
||||||
]);
|
|
||||||
$id = $producto;
|
|
||||||
$productos = json_decode(trim(file_get_contents($filename)));
|
|
||||||
$producto = $productos[$producto];
|
|
||||||
$folder = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.public'),
|
|
||||||
'assets',
|
|
||||||
'images',
|
|
||||||
mb_strtolower($producto->nombre)
|
|
||||||
]);
|
|
||||||
if (!file_exists($folder)) {
|
|
||||||
mkdir($folder);
|
|
||||||
}
|
|
||||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$folder,
|
|
||||||
$file->getClientFilename()
|
|
||||||
]);
|
|
||||||
$file->moveTo($filename);*/
|
|
||||||
$producto = $factory->find(Producto::class)->where([['id', $producto]])->one();
|
$producto = $factory->find(Producto::class)->where([['id', $producto]])->one();
|
||||||
$status = $producto->addImagen($file);
|
$status = $producto->addImagen($file);
|
||||||
|
|
||||||
@ -299,24 +115,6 @@ class Productos {
|
|||||||
}
|
}
|
||||||
public function delete_image(Request $request, Response $response, ModelFactory $factory, $producto): Response {
|
public function delete_image(Request $request, Response $response, ModelFactory $factory, $producto): Response {
|
||||||
$post = $request->getParsedBody();
|
$post = $request->getParsedBody();
|
||||||
/*$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.data'),
|
|
||||||
'productos.json'
|
|
||||||
]);
|
|
||||||
$id = $producto;
|
|
||||||
$productos = json_decode(trim(file_get_contents($filename)));
|
|
||||||
$producto = $productos[$producto];
|
|
||||||
$folder = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$container->get('folders.public'),
|
|
||||||
'assets',
|
|
||||||
'images',
|
|
||||||
mb_strtolower($producto->nombre)
|
|
||||||
]);
|
|
||||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$folder,
|
|
||||||
$post['imagen']
|
|
||||||
]);
|
|
||||||
$status = unlink($filename);*/
|
|
||||||
$producto = $factory->find(Producto::class)->where([['id', $producto]])->one();
|
$producto = $factory->find(Producto::class)->where([['id', $producto]])->one();
|
||||||
$status = $producto->deleteImagen($post['imagen']);
|
$status = $producto->deleteImagen($post['imagen']);
|
||||||
|
|
||||||
@ -344,7 +142,7 @@ class Productos {
|
|||||||
'ProVM',
|
'ProVM',
|
||||||
'KI',
|
'KI',
|
||||||
'Productos',
|
'Productos',
|
||||||
$post['segmento']
|
rtrim($post['segmento'], 's')
|
||||||
]);
|
]);
|
||||||
$obj = new $class;
|
$obj = new $class;
|
||||||
$properties = $obj->getProperties();
|
$properties = $obj->getProperties();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
use ProVM\KI\Common\Controller\Web\Admin\Productos;
|
use ProVM\KI\Common\Controller\Web\Admin\Productos;
|
||||||
|
|
||||||
$app->group('/productos', function($app) {
|
$app->group('/productos', function($app) {
|
||||||
|
$app->post('/campos', [Productos::class, 'fields']);
|
||||||
$app->group('/add', function($app) {
|
$app->group('/add', function($app) {
|
||||||
$app->get('[/]', [Productos::class, 'add']);
|
$app->get('[/]', [Productos::class, 'add']);
|
||||||
$app->post('[/]', [Productos::class, 'do_add']);
|
$app->post('[/]', [Productos::class, 'do_add']);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Segmento</label>
|
<label>Segmento</label>
|
||||||
<div class="ui selection dropdown">
|
<div class="ui selection dropdown" id="segmento">
|
||||||
<input type="hidden" name="segmento" />
|
<input type="hidden" name="segmento" />
|
||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
<div class="default text">Segmento</div>
|
<div class="default text">Segmento</div>
|
||||||
@ -67,12 +67,14 @@
|
|||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
<span id="end_campos"></span>
|
<span id="end_campos"></span>
|
||||||
|
<div class="row">
|
||||||
<div class="ten wide column">
|
<div class="ten wide column">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Descripción</label>
|
<label>Descripción</label>
|
||||||
<textarea rows="1" name="descripcion">{{$producto->descripcion ?? ''}}</textarea>
|
<textarea rows="1" name="descripcion">{{$producto->descripcion ?? ''}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Imágenes</label>
|
<label>Imágenes</label>
|
||||||
@ -80,25 +82,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="imagenes" class="ui list"></div>
|
<div id="imagenes" class="ui list"></div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
<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>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<button class="ui button">GUARDAR</button>
|
<button class="ui button">GUARDAR</button>
|
||||||
@ -150,24 +133,13 @@
|
|||||||
},
|
},
|
||||||
setup: () => {
|
setup: () => {
|
||||||
producto.setMonths()
|
producto.setMonths()
|
||||||
$('.selection.dropdown').dropdown()
|
$('#segmento').dropdown({
|
||||||
$('.selection.dropdown').dropdown('set selected', '{{$producto->segmento}}')
|
onChange: () => {
|
||||||
$('.calendar').calendar({
|
producto.changeSegmento()
|
||||||
type: 'month',
|
|
||||||
text: {
|
|
||||||
months: producto.months.long,
|
|
||||||
monthsShort: producto.months.short
|
|
||||||
},
|
|
||||||
formatInput: false,
|
|
||||||
onChange: function(a, b) {
|
|
||||||
if (typeof a == 'undefined') {
|
|
||||||
a = new Date()
|
|
||||||
}
|
|
||||||
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
var entrega = new Date('{{str_pad(implode('-', array_reverse(explode('/', $producto->entrega))), 7, '20', STR_PAD_LEFT)}}-01T01:00')
|
$('#segmento').dropdown('set selected', '{{$producto->segmento}}')
|
||||||
$('.calendar').calendar('set date', entrega)
|
producto.linkCalendar()
|
||||||
$('.checkbox').checkbox()
|
$('.checkbox').checkbox()
|
||||||
@if ($producto->destacado())
|
@if ($producto->destacado())
|
||||||
$('.checkbox').checkbox('set checked')
|
$('.checkbox').checkbox('set checked')
|
||||||
@ -192,45 +164,51 @@
|
|||||||
@foreach ($producto->imagenes() as $image)
|
@foreach ($producto->imagenes() as $image)
|
||||||
producto.listImage('{{$image}}')
|
producto.listImage('{{$image}}')
|
||||||
@endforeach
|
@endforeach
|
||||||
$("input[name='video']").change(function() {
|
},
|
||||||
var fData = new FormData()
|
linkCalendar: () => {
|
||||||
fData.append('video', $("input[name='video']")[0].files[0])
|
var div = $("input[name='entrega']").parent()
|
||||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/set'
|
div.find('input').remove()
|
||||||
$.ajax({
|
div.append(
|
||||||
url: url,
|
$('<div></div>').attr('class', 'ui calendar').append(
|
||||||
method: 'post',
|
$('<input />').attr('type', 'text').attr('name', 'entrega').attr('placeholder', 'Entrega')
|
||||||
data: fData,
|
)
|
||||||
contentType: false,
|
)
|
||||||
processData: false,
|
$('.calendar').calendar({
|
||||||
success: (data) => {
|
type: 'month',
|
||||||
if (data.estado) {
|
text: {
|
||||||
window.location.reload()
|
months: producto.months.long,
|
||||||
|
monthsShort: producto.months.short
|
||||||
|
},
|
||||||
|
formatInput: false,
|
||||||
|
onChange: function(a, b) {
|
||||||
|
if (typeof a == 'undefined') {
|
||||||
|
a = new Date()
|
||||||
}
|
}
|
||||||
|
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
var entrega = new Date('{{str_pad(implode('-', array_reverse(explode('/', $producto->entrega))), 7, '20', STR_PAD_LEFT)}}-01T01:00')
|
||||||
$('.trash.video').attr('cursor', 'pointer').click(() => {
|
$('.calendar').calendar('set date', entrega)
|
||||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/delete'
|
|
||||||
$.post(url, {}, (data) => {
|
|
||||||
if (data.estado) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
changeSegmento: () => {
|
changeSegmento: () => {
|
||||||
var segmento = $('#segmento').dropdown('get value')
|
var segmento = $('#segmento').dropdown('get value')
|
||||||
|
if (segmento == '{{$producto->segmento}}') {
|
||||||
|
return
|
||||||
|
}
|
||||||
var url = '{{$urls->admin}}/productos/campos'
|
var url = '{{$urls->admin}}/productos/campos'
|
||||||
$.post(url, {segmento: segmento}, (data) => {
|
$.post(url, {segmento: segmento}, (data) => {
|
||||||
var div = $('#campos')
|
var div = $('#campos')
|
||||||
var end = $('#end_campos')
|
var end = $('#end_campos')
|
||||||
var current = div.next()
|
var current = div.next()
|
||||||
var next = current.next()
|
var next = current.next()
|
||||||
while (next != end) {
|
if (current[0] == end[0] || next[0] == end[0]) {
|
||||||
|
} else {
|
||||||
|
while (next[0] != end[0] || next.length == 0) {
|
||||||
current.remove()
|
current.remove()
|
||||||
current = next
|
current = next
|
||||||
next = next.next()
|
next = next.next()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$.each(data.fields, (i, el) => {
|
$.each(data.fields, (i, el) => {
|
||||||
var campo = $('<div></div>').attr('class', 'column').append(
|
var campo = $('<div></div>').attr('class', 'column').append(
|
||||||
$('<div></div>').attr('class', 'field').append(
|
$('<div></div>').attr('class', 'field').append(
|
||||||
@ -241,6 +219,7 @@
|
|||||||
)
|
)
|
||||||
end.before(campo)
|
end.before(campo)
|
||||||
})
|
})
|
||||||
|
producto.linkCalendar()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,70 +58,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="campos"></div>
|
<div id="campos"></div>
|
||||||
@foreach ($properties as $property)
|
<div id="end_campos"></div>
|
||||||
<div class="column">
|
<div class="row">
|
||||||
<div class="field">
|
|
||||||
<label>{{$property->label}}</label>
|
|
||||||
<input type="text" name="{{$property->name}}" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endforeach
|
|
||||||
<!-- <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>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_min" />
|
|
||||||
</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="ten wide column">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Descripción</label>
|
<label>Descripción</label>
|
||||||
@ -129,6 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<button class="ui button">AGREGAR</button>
|
<button class="ui button">AGREGAR</button>
|
||||||
</form>
|
</form>
|
||||||
@ -161,12 +100,16 @@
|
|||||||
},
|
},
|
||||||
setup: () => {
|
setup: () => {
|
||||||
producto.setMonths()
|
producto.setMonths()
|
||||||
$('#segmento').dropdown()
|
$('#segmento').dropdown({
|
||||||
|
onChange: () => {
|
||||||
|
producto.changeSegmento()
|
||||||
|
}
|
||||||
|
})
|
||||||
$('.calendar').calendar({
|
$('.calendar').calendar({
|
||||||
type: 'month',
|
type: 'month',
|
||||||
text: {
|
text: {
|
||||||
months: months.long,
|
months: producto.months.long,
|
||||||
monthsShort: months.short
|
monthsShort: producto.months.short
|
||||||
},
|
},
|
||||||
formatInput: false,
|
formatInput: false,
|
||||||
onChange: function(a) {
|
onChange: function(a) {
|
||||||
@ -180,6 +123,17 @@
|
|||||||
var url = '{{$urls->admin}}/productos/campos'
|
var url = '{{$urls->admin}}/productos/campos'
|
||||||
$.post(url, {segmento: segmento}, (data) => {
|
$.post(url, {segmento: segmento}, (data) => {
|
||||||
var div = $('#campos')
|
var div = $('#campos')
|
||||||
|
var end = $('#end_campos')
|
||||||
|
var current = div.next()
|
||||||
|
var next = current.next()
|
||||||
|
if (current[0] == end[0] || next[0] == end[0]) {
|
||||||
|
} else {
|
||||||
|
while (next[0] != end[0] || next.length == 0) {
|
||||||
|
current.remove()
|
||||||
|
current = next
|
||||||
|
next = next.next()
|
||||||
|
}
|
||||||
|
}
|
||||||
$.each(data.fields, (i, el) => {
|
$.each(data.fields, (i, el) => {
|
||||||
var campo = $('<div></div>').attr('class', 'column').append(
|
var campo = $('<div></div>').attr('class', 'column').append(
|
||||||
$('<div></div>').attr('class', 'field').append(
|
$('<div></div>').attr('class', 'field').append(
|
||||||
@ -188,6 +142,7 @@
|
|||||||
$('<input />').attr('type', 'text').attr('name', el.name)
|
$('<input />').attr('type', 'text').attr('name', el.name)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
end.before(campo)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ use ProVM\KI\Producto;
|
|||||||
|
|
||||||
class Oficina extends Producto {
|
class Oficina extends Producto {
|
||||||
protected $properties = [
|
protected $properties = [
|
||||||
'arriendo',
|
|
||||||
'm2',
|
'm2',
|
||||||
'baños',
|
'baños',
|
||||||
'privados',
|
'privados',
|
||||||
@ -25,7 +24,7 @@ class Oficina extends Producto {
|
|||||||
$properties = [
|
$properties = [
|
||||||
[
|
[
|
||||||
'label' => 'Valor Arriendo',
|
'label' => 'Valor Arriendo',
|
||||||
'name' => 'arriendo',
|
'name' => 'valor',
|
||||||
'suffix' => ' UF'
|
'suffix' => ' UF'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
Reference in New Issue
Block a user