mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Terminado direcciones
This commit is contained in:
@ -560,6 +560,8 @@ $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuest
|
|||||||
$routes->post('getgramaje', 'Presupuestocliente::getGramaje', ['as' => 'obtenerGramaje']);
|
$routes->post('getgramaje', 'Presupuestocliente::getGramaje', ['as' => 'obtenerGramaje']);
|
||||||
$routes->post('presupuesto', 'Presupuestocliente::presupuesto', ['as' => 'presupuestoCliente']);
|
$routes->post('presupuesto', 'Presupuestocliente::presupuesto', ['as' => 'presupuestoCliente']);
|
||||||
$routes->post('getDireccionesCliente', 'Presupuestocliente::getDireccionesCliente', ['as' => 'getDirecciones']);
|
$routes->post('getDireccionesCliente', 'Presupuestocliente::getDireccionesCliente', ['as' => 'getDirecciones']);
|
||||||
|
$routes->post('getDatosDireccion', 'Presupuestocliente::getDatosDireccion', ['as' => 'getDatosDireccion']);
|
||||||
|
$routes->post('getNuevaDireccion', 'Presupuestocliente::getNuevaDireccion', ['as' => 'nuevaDireccion']);
|
||||||
});
|
});
|
||||||
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);
|
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
|
|||||||
@ -147,7 +147,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||||
$clienteId = 999; // Fijo hasta desarollar clientes usuarios
|
$clienteId = 999; // Fijo hasta desarollar clientes usuarios
|
||||||
|
|
||||||
|
|
||||||
$presupuestoEntity = isset($sanitizedData) ? new PresupuestoEntity($sanitizedData) : new PresupuestoEntity();
|
$presupuestoEntity = isset($sanitizedData) ? new PresupuestoEntity($sanitizedData) : new PresupuestoEntity();
|
||||||
$presupuestoEntity->clienteId = $clienteId;
|
$presupuestoEntity->clienteId = $clienteId;
|
||||||
|
|
||||||
@ -172,6 +171,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$this->viewData['formAction'] = route_to('crearPresupuestoCliente');
|
$this->viewData['formAction'] = route_to('crearPresupuestoCliente');
|
||||||
|
|
||||||
|
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||||
|
|
||||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||||
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
|
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
|
||||||
|
|
||||||
@ -963,6 +964,65 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDatosDireccion(){
|
||||||
|
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
$direccionId = $reqData['id'] ?? 0;
|
||||||
|
$model = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||||
|
$data = $model->getDireccion($direccionId);
|
||||||
|
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'data'=>$data,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNuevaDireccion(){
|
||||||
|
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'cliente_id' => $reqData['cliente_id'] ?? 0,
|
||||||
|
'alias' => $reqData['alias'] ?? "",
|
||||||
|
'att' => $reqData['att'] ?? "",
|
||||||
|
'email' => $reqData['email'] ?? "",
|
||||||
|
'direccion' => $reqData['direccion'] ?? "",
|
||||||
|
'pais_id' => $reqData['pais_id'] ?? 0,
|
||||||
|
'municipio' => $reqData['municipio'] ?? "",
|
||||||
|
'provincia' => $reqData['provincia'] ?? "",
|
||||||
|
'cp' => $reqData['cp'] ?? "",
|
||||||
|
'telefono' => $reqData['telefono'] ?? ""
|
||||||
|
];
|
||||||
|
|
||||||
|
$model = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||||
|
$id = $model->nuevaDireccion($data);
|
||||||
|
|
||||||
|
$menu = $model->getMenuDirecciones($data['cliente_id']);
|
||||||
|
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'data'=>$menu,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************
|
/***********************
|
||||||
*
|
*
|
||||||
@ -1077,4 +1137,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
endif;
|
endif;
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getPaisListItems()
|
||||||
|
{
|
||||||
|
$paisModel = model('App\Models\Configuracion\PaisModel');
|
||||||
|
$onlyActiveOnes = true;
|
||||||
|
$data = $paisModel->getAllForMenu('id, nombre', 'nombre', $onlyActiveOnes);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -141,6 +141,7 @@ class ClienteDireccionesModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
return $builder->get()->getResultObject();
|
return $builder->get()->getResultObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getMenuDirecciones($cliente_id=-1){
|
public function getMenuDirecciones($cliente_id=-1){
|
||||||
|
|
||||||
@ -154,4 +155,11 @@ class ClienteDireccionesModel extends \App\Models\BaseModel
|
|||||||
return $builder->get()->getResultArray();
|
return $builder->get()->getResultArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function nuevaDireccion($data)
|
||||||
|
{
|
||||||
|
$builder = $this->db->table($this->table);
|
||||||
|
$builder->insert($data);
|
||||||
|
return $this->db->insertID();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_email" class="form-label">
|
<label for="add_email" class="form-label">
|
||||||
<?= lang('ClienteDirecciones.email') ?>*
|
<?= lang('ClienteDirecciones.email') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="add_email" tabindex="2" maxLength="100" class="form-control">
|
<input type="text" id="add_email" tabindex="2" maxLength="100" class="form-control">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
@ -65,7 +65,7 @@
|
|||||||
<div class="col-md-12 col-lg-6 pl-4 spain-data" style="display: none;">
|
<div class="col-md-12 col-lg-6 pl-4 spain-data" style="display: none;">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_provincia" class="form-label">
|
<label for="add_provincia" class="form-label">
|
||||||
<?=lang('ClienteDirecciones.provincia') ?>*
|
<?=lang('ClienteDirecciones.provincia') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="add_provincia" tabindex="7" maxLength="100" class="form-control">
|
<input type="text" id="add_provincia" tabindex="7" maxLength="100" class="form-control">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
@ -87,7 +87,7 @@
|
|||||||
<div class="col-md-12 col-lg-6 pl-4">
|
<div class="col-md-12 col-lg-6 pl-4">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_telefono" class="form-label">
|
<label for="add_telefono" class="form-label">
|
||||||
<?=lang('ClienteDirecciones.telefono') ?>*
|
<?=lang('ClienteDirecciones.telefono') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="add_telefono" tabindex="9" maxLength="100" class="form-control"></input>
|
<input type="text" id="add_telefono" tabindex="9" maxLength="100" class="form-control"></input>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
|
|||||||
@ -36,5 +36,7 @@
|
|||||||
|
|
||||||
window.routes_direcciones = {
|
window.routes_direcciones = {
|
||||||
direcciones: "<?= route_to('getDirecciones') ?>",
|
direcciones: "<?= route_to('getDirecciones') ?>",
|
||||||
|
getDatos: "<?= route_to('getDatosDireccion') ?>",
|
||||||
|
nuevaDireccion: "<?= route_to('nuevaDireccion') ?>",
|
||||||
}
|
}
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
@ -10,12 +10,10 @@ function initDirecciones() {
|
|||||||
data: data,
|
data: data,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
$("#direcciones").empty();
|
$("#direcciones").empty();
|
||||||
$.each(response.menu, function(key, value) {
|
$.each(response.menu, function(index, value) {
|
||||||
$('#direcciones')
|
$("#direcciones").append('<option value="' + value.id + '">' + value.text + '</option>');
|
||||||
.append($('<option>', { value : key })
|
|
||||||
.text(value));
|
|
||||||
});
|
});
|
||||||
$('#direcciones').val();
|
$("#direcciones").val('');
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
$("#direcciones").empty();
|
$("#direcciones").empty();
|
||||||
@ -23,8 +21,6 @@ function initDirecciones() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function initTiradasDirecciones() {
|
function initTiradasDirecciones() {
|
||||||
const _this = this
|
const _this = this
|
||||||
|
|
||||||
@ -88,16 +84,10 @@ function updateTiradasDireccionesCheck(el) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#direcciones').on('change', function() {
|
|
||||||
if( $('#direcciones').val() == 0 ) {
|
|
||||||
console.log("Nueva direccion")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
$('#insertarDireccion').on('click', function() {
|
$('#insertarDireccion').on('click', function() {
|
||||||
|
|
||||||
//if( ('#direcciones').val() > 0 ) {
|
if( $('#direcciones').val() > 0 ) {
|
||||||
|
|
||||||
let unidades = $('#unidadesEnvio').val();
|
let unidades = $('#unidadesEnvio').val();
|
||||||
if(unidades == '' || isNaN(unidades) || parseInt(unidades) <= 0){
|
if(unidades == '' || isNaN(unidades) || parseInt(unidades) <= 0){
|
||||||
@ -133,30 +123,48 @@ $('#insertarDireccion').on('click', function() {
|
|||||||
|
|
||||||
if(total + unidades <= tirada) {
|
if(total + unidades <= tirada) {
|
||||||
|
|
||||||
let html = '';
|
data = {
|
||||||
html += '<div class="row mb-3">';
|
id: $('#direcciones').val()
|
||||||
html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
|
},
|
||||||
html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">';
|
data = Object.assign(data, window.token_ajax)
|
||||||
html += '<span class="custom-option-header mb-2">';
|
|
||||||
html += '<h6 class="fw-semibold mb-0">Jaime Jiménez Ortega</h6>';
|
$.ajax({
|
||||||
html += '<span class="badge bg-label-primary">' + unidades + ' unidades</span>';
|
url: window.routes_direcciones.getDatos,
|
||||||
html += '</span>';
|
type: 'POST',
|
||||||
html += '<span class="custom-option-body">';
|
data: data,
|
||||||
html += '<small>Circunvalacion La Encina, 20, 5A</small><br>';
|
success: function(response) {
|
||||||
html += '<small>18200</small><br>';
|
if(response.data.length > 0) {
|
||||||
html += '<small>Granada, España</small><br>';
|
let html = '';
|
||||||
html += '<small>600620238</small><br>';
|
html += '<div id="envioId' + response.data[0].id + '" class="row mb-3">';
|
||||||
html += '<hr class="my-2">';
|
html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
|
||||||
html += '<span class="d-flex">';
|
html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">';
|
||||||
html += '<a class="eliminar-direccion" href="javascript:void(0)">Eliminar</a>';
|
html += '<span class="custom-option-header mb-2">';
|
||||||
html += '</span>';
|
html += '<h6 class="fw-semibold mb-0">' + response.data[0].att + '</h6>';
|
||||||
html += '</span>';
|
html += '<span class="badge bg-label-primary">' + unidades + ' unidades</span>';
|
||||||
html += '</label>';
|
html += '</span>';
|
||||||
html += '</div>';
|
html += '<span class="custom-option-body">';
|
||||||
html += '</div>';
|
html += '<small>' + response.data[0].direccion + '</small><br>';
|
||||||
|
html += '<small>' + response.data[0].cp + '</small><br>';
|
||||||
|
html += '<small>' + response.data[0].municipio +', ' + response.data[0].pais + '</small><br>';
|
||||||
|
html += '<small>' + response.data[0].telefono + '</small><br>';
|
||||||
|
html += '<small>' + response.data[0].email + '</small><br>';
|
||||||
|
html += '<hr class="my-2">';
|
||||||
|
html += '<span class="d-flex">';
|
||||||
|
html += '<a class="eliminar-direccion" href="javascript:void(0)">Eliminar</a>';
|
||||||
|
html += '</span>';
|
||||||
|
html += '</span>';
|
||||||
|
html += '</label>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
$('#divDirecciones').append(html);
|
$('#divDirecciones').append(html);
|
||||||
$('#errorDirecciones').hide();
|
$('#errorDirecciones').hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
$("#direcciones").empty();
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
|
$('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
|
||||||
@ -164,14 +172,91 @@ $('#insertarDireccion').on('click', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).on('click', '.eliminar-direccion', function(e) {
|
$(document).on('click', '.eliminar-direccion', function(e) {
|
||||||
console.log("eliminar2");
|
|
||||||
$(this).closest('.row.mb-3').remove();
|
$(this).closest('.row.mb-3').remove();
|
||||||
|
|
||||||
|
const seleccion = $('.custom-option-tiradasDirecciones.checked');
|
||||||
|
if(seleccion.length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const element_tirada =($(seleccion[0]).find('label input')[0]);
|
||||||
|
const number = element_tirada.id.match(/\d+$/);
|
||||||
|
if (number.length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
|
||||||
|
|
||||||
|
const elements = $('#divDirecciones').find('.row.mb-3');
|
||||||
|
|
||||||
|
let total = 0;
|
||||||
|
if(elements.length > 0) {
|
||||||
|
for (let index=0; index<elements.length; index++){
|
||||||
|
let unidades_direcciones = parseInt($(elements[index]).find('div label span span').text().split(' ')[0]);
|
||||||
|
total += unidades_direcciones;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(total <= tirada) {
|
||||||
|
$('#errorDirecciones').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('#direcciones').on('change', function() {
|
||||||
|
if( $('#direcciones').val() == 0 ) {
|
||||||
|
$("#addressForm").attr('action','create')
|
||||||
|
|
||||||
|
var $newAddDialog = $("#addressForm")
|
||||||
|
$newAddDialog.modal('show')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
function saveAdd_callback(){
|
||||||
|
if($('#addressForm').attr('action')=='create'){
|
||||||
|
let data = {
|
||||||
|
cliente_id: $('#clienteId').val(),
|
||||||
|
alias: $('#add_alias').val(),
|
||||||
|
att: $('#add_att').val(),
|
||||||
|
email: $('#add_email').val(),
|
||||||
|
direccion: $('#add_direccion').val(),
|
||||||
|
pais_id: $("#add_pais_id option:selected").val(),
|
||||||
|
municipio: $('#add_municipio').val(),
|
||||||
|
provincia: $('#add_provincia').val(),
|
||||||
|
cp: $('#add_cp').val(),
|
||||||
|
telefono: $('#add_telefono').val(),
|
||||||
|
}
|
||||||
|
console.log(data);
|
||||||
|
data = Object.assign(data, window.token_ajax)
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: window.routes_direcciones.nuevaDireccion,
|
||||||
|
type: 'POST',
|
||||||
|
data: data,
|
||||||
|
success: function(response) {
|
||||||
|
$("#direcciones").empty();
|
||||||
|
$.each(response.data, function(index, value) {
|
||||||
|
$("#direcciones").append('<option value="' + value.id + '">' + value.text + '</option>');
|
||||||
|
});
|
||||||
|
$("#direcciones").val('');
|
||||||
|
$('#addressForm').modal('hide');
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
$('#addressForm').modal('hide');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -170,7 +170,8 @@ $('.change-tipo-impresion').on('change', function () {
|
|||||||
//si es color hay que mostrar el numero de paginas a color
|
//si es color hay que mostrar el numero de paginas a color
|
||||||
if (isColor) {
|
if (isColor) {
|
||||||
$('#pagColorDiv').show();
|
$('#pagColorDiv').show();
|
||||||
$('#paginasColor').val('0');
|
if($('#paginasColor').val() == '')
|
||||||
|
$('#paginasColor').val('0');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#pagColorDiv').hide();
|
$('#pagColorDiv').hide();
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<?= $this->section("content") ?>
|
<?= $this->section("content") ?>
|
||||||
|
|
||||||
|
<?= view("themes/backend/vuexy/form/clientes/cliente/_clienteDireccionesForm") ?>
|
||||||
<div class="container-xxl flex-grow-1 container-p-y">
|
<div class="container-xxl flex-grow-1 container-p-y">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||||
|
|||||||
8104
xdebug.log
8104
xdebug.log
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user