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:
@ -19,7 +19,7 @@
|
||||
</div><!--//.mb-3 -->
|
||||
<div class="mb-3">
|
||||
<label for="add_email" class="form-label">
|
||||
<?= lang('ClienteDirecciones.email') ?>*
|
||||
<?= lang('ClienteDirecciones.email') ?>
|
||||
</label>
|
||||
<input type="text" id="add_email" tabindex="2" maxLength="100" class="form-control">
|
||||
</div><!--//.mb-3 -->
|
||||
@ -65,7 +65,7 @@
|
||||
<div class="col-md-12 col-lg-6 pl-4 spain-data" style="display: none;">
|
||||
<div class="mb-3">
|
||||
<label for="add_provincia" class="form-label">
|
||||
<?=lang('ClienteDirecciones.provincia') ?>*
|
||||
<?=lang('ClienteDirecciones.provincia') ?>
|
||||
</label>
|
||||
<input type="text" id="add_provincia" tabindex="7" maxLength="100" class="form-control">
|
||||
</div><!--//.mb-3 -->
|
||||
@ -87,7 +87,7 @@
|
||||
<div class="col-md-12 col-lg-6 pl-4">
|
||||
<div class="mb-3">
|
||||
<label for="add_telefono" class="form-label">
|
||||
<?=lang('ClienteDirecciones.telefono') ?>*
|
||||
<?=lang('ClienteDirecciones.telefono') ?>
|
||||
</label>
|
||||
<input type="text" id="add_telefono" tabindex="9" maxLength="100" class="form-control"></input>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
@ -36,5 +36,7 @@
|
||||
|
||||
window.routes_direcciones = {
|
||||
direcciones: "<?= route_to('getDirecciones') ?>",
|
||||
getDatos: "<?= route_to('getDatosDireccion') ?>",
|
||||
nuevaDireccion: "<?= route_to('nuevaDireccion') ?>",
|
||||
}
|
||||
<?= $this->endSection() ?>
|
||||
@ -10,12 +10,10 @@ function initDirecciones() {
|
||||
data: data,
|
||||
success: function(response) {
|
||||
$("#direcciones").empty();
|
||||
$.each(response.menu, function(key, value) {
|
||||
$('#direcciones')
|
||||
.append($('<option>', { value : key })
|
||||
.text(value));
|
||||
$.each(response.menu, function(index, value) {
|
||||
$("#direcciones").append('<option value="' + value.id + '">' + value.text + '</option>');
|
||||
});
|
||||
$('#direcciones').val();
|
||||
$("#direcciones").val('');
|
||||
},
|
||||
error: function() {
|
||||
$("#direcciones").empty();
|
||||
@ -23,8 +21,6 @@ function initDirecciones() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function initTiradasDirecciones() {
|
||||
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() {
|
||||
|
||||
//if( ('#direcciones').val() > 0 ) {
|
||||
if( $('#direcciones').val() > 0 ) {
|
||||
|
||||
let unidades = $('#unidadesEnvio').val();
|
||||
if(unidades == '' || isNaN(unidades) || parseInt(unidades) <= 0){
|
||||
@ -133,30 +123,48 @@ $('#insertarDireccion').on('click', function() {
|
||||
|
||||
if(total + unidades <= tirada) {
|
||||
|
||||
let html = '';
|
||||
html += '<div class="row mb-3">';
|
||||
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">';
|
||||
html += '<span class="custom-option-header mb-2">';
|
||||
html += '<h6 class="fw-semibold mb-0">Jaime Jiménez Ortega</h6>';
|
||||
html += '<span class="badge bg-label-primary">' + unidades + ' unidades</span>';
|
||||
html += '</span>';
|
||||
html += '<span class="custom-option-body">';
|
||||
html += '<small>Circunvalacion La Encina, 20, 5A</small><br>';
|
||||
html += '<small>18200</small><br>';
|
||||
html += '<small>Granada, España</small><br>';
|
||||
html += '<small>600620238</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>';
|
||||
data = {
|
||||
id: $('#direcciones').val()
|
||||
},
|
||||
data = Object.assign(data, window.token_ajax)
|
||||
|
||||
$.ajax({
|
||||
url: window.routes_direcciones.getDatos,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response) {
|
||||
if(response.data.length > 0) {
|
||||
let html = '';
|
||||
html += '<div id="envioId' + response.data[0].id + '" class="row mb-3">';
|
||||
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">';
|
||||
html += '<span class="custom-option-header mb-2">';
|
||||
html += '<h6 class="fw-semibold mb-0">' + response.data[0].att + '</h6>';
|
||||
html += '<span class="badge bg-label-primary">' + unidades + ' unidades</span>';
|
||||
html += '</span>';
|
||||
html += '<span class="custom-option-body">';
|
||||
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);
|
||||
$('#errorDirecciones').hide();
|
||||
$('#divDirecciones').append(html);
|
||||
$('#errorDirecciones').hide();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#direcciones").empty();
|
||||
},
|
||||
});
|
||||
}
|
||||
else{
|
||||
$('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
|
||||
@ -164,14 +172,91 @@ $('#insertarDireccion').on('click', function() {
|
||||
}
|
||||
|
||||
|
||||
//}
|
||||
}
|
||||
return false;
|
||||
})
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.eliminar-direccion', function(e) {
|
||||
console.log("eliminar2");
|
||||
|
||||
$(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;
|
||||
});
|
||||
|
||||
|
||||
$('#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
|
||||
if (isColor) {
|
||||
$('#pagColorDiv').show();
|
||||
$('#paginasColor').val('0');
|
||||
if($('#paginasColor').val() == '')
|
||||
$('#paginasColor').val('0');
|
||||
}
|
||||
else {
|
||||
$('#pagColorDiv').hide();
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
<?= $this->section("content") ?>
|
||||
|
||||
<?= view("themes/backend/vuexy/form/clientes/cliente/_clienteDireccionesForm") ?>
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
<div class="col-12">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
|
||||
Reference in New Issue
Block a user