terminado a falta de pruebas las direcciones fp en admin

This commit is contained in:
2025-07-04 12:34:10 +02:00
parent 9aa7d2e0cb
commit 45ec831f8f
11 changed files with 895 additions and 147 deletions

View File

@ -325,6 +325,12 @@ class PresupuestoAdminEdit {
datos.tirada_alternativa_json_data = this.tiradasAlternativas.generate_json_tiradas();
datos.direcciones_fp_checks = JSON.stringify({
"addFP1isAddMain": $('#sameAddPrincipalFP1').prop('checked')? "1":"0",
"addFP2isAddMain": $('#sameAddPrincipalFP2').prop('checked')? "1":"0",
"addFP2isaddFP1": $('#sameAddFP1').prop('checked')? "1":"0",
});
return datos;
}
@ -423,7 +429,7 @@ class PresupuestoAdminEdit {
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
self.servicios.cargar(response.data.servicios);
self.envios.cargar(response.data.direcciones);
self.envios.cargar(response.data.direcciones, response.data.direccionesFP);
self.comparador.cargarDatos(response.data.comparador);

View File

@ -1,5 +1,5 @@
import ClassSelect from '../../../components/select2.js';
import { getToken } from '../../../common/common.js';
import ClassSelect from '../../../components/select2.js';
class DatosLibro {
@ -63,7 +63,9 @@ class DatosLibro {
this.retractilado = this.domItem.find('#retractilado');
this.retractilado5 = this.domItem.find('#retractilado5');
this.prototipo = this.domItem.find('#prototipo');
this.prototipo_2 = this.domItem.find('#prototipo_2');
this.ferro = this.domItem.find('#ferro');
this.ferro_2 = this.domItem.find('#ferro_2');
this.ferroDigital = this.domItem.find('#ferroDigital');
this.marcapaginas = this.domItem.find('#marcapaginas');
@ -157,7 +159,9 @@ class DatosLibro {
this.retractilado.on('change', this.checkRetractilado.bind(this));
this.retractilado5.on('change', this.checkRetractilado.bind(this));
this.ferro.on('change', this.changeFerro.bind(this));
this.ferro_2.on('change', this.changeFerro2.bind(this));
this.prototipo.on('change', this.changePrototipo.bind(this));
this.prototipo_2.on('change', this.changePrototipo2.bind(this));
this.ferroDigital.on('change', this.changeFerroDigital.bind(this));
this.tamanio.item.on('select2:select', this.changeFormato.bind(this));
@ -190,7 +194,7 @@ class DatosLibro {
changeFaja() {
if (this._bloqueoCambioFaja) return;
this._bloqueoCambioFaja = true;
this._bloqueoCambioFaja = true;
if (this.faja.prop('checked')) {
this.div_faja.removeClass('d-none');
@ -246,6 +250,20 @@ class DatosLibro {
if (this.ferro.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'ferro');
this.ferro_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro_2');
this.prototipo.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
this.prototipo_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$('.check-direccion-fp').prop('checked', false);
$('.check-direccion-fp-2').prop('checked', false);
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
@ -256,25 +274,63 @@ class DatosLibro {
}
else {
$(document).trigger('remove-servicio-lineas', 'ferro');
if (!this.prototipo.prop('checked')) {
const table = $('#tableOfDireccionesEnvio').DataTable();
const rows = table.rows().data();
for (let i = 0; i < rows.length; i++) {
const rowData = rows[i];
if (rowData.is_ferro_prototipo == 1) {
table.rows(i).remove();
table.draw();
break;
}
}
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.clear().draw();
$('.datos-envio-fp-1').addClass('d-none');
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
}
changeFerro2() {
if (this.cargando)
return;
if (this.ferro_2.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'ferro_2');
this.ferro.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro');
this.prototipo.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
this.prototipo_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').removeClass('d-none');
$('.check-direccion-fp').prop('checked', false);
$('.check-direccion-fp-2').prop('checked', false);
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.columns.adjust().draw();
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: false,
update_tiradas_alternativas: false
});
}
else {
$(document).trigger('remove-servicio-lineas', 'ferro_2');
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.clear().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
$('.datos-envio-fp-1').addClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
}
@ -298,6 +354,21 @@ class DatosLibro {
if (this.prototipo.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'prototipo');
this.ferro.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro');
this.ferro_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro_2');
this.prototipo_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$('.check-direccion-fp').prop('checked', false);
$('.check-direccion-fp-2').prop('checked', false);
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
table_2.columns.adjust().draw();
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
@ -308,28 +379,64 @@ class DatosLibro {
}
else {
$(document).trigger('remove-servicio-lineas', 'prototipo');
if (!this.ferro.prop('checked')) {
const table = $('#tableOfDireccionesEnvio').DataTable();
const rows = table.rows().data();
for (let i = 0; i < rows.length; i++) {
const rowData = rows[i];
if (rowData.is_ferro_prototipo == 1) {
table.rows(i).remove();
table.draw();
break;
}
}
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.clear().draw();
$('.datos-envio-fp-1').addClass('d-none');
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
}
changePrototipo2() {
if (this.cargando)
return;
if (this.prototipo_2.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'prototipo_2');
this.ferro.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro');
this.ferro_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro_2');
this.prototipo.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').removeClass('d-none');
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.columns.adjust().draw();
$('.check-direccion-fp-2').prop('checked', false);
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: false,
update_tiradas_alternativas: false
});
}
else {
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.clear().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
$('.datos-envio-fp-1').addClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
}
checkRetractilado(event) {
@ -765,7 +872,9 @@ class DatosLibro {
this.retractilado.prop('checked', datos.retractilado);
this.retractilado5.prop('checked', datos.retractilado5);
this.prototipo.prop('checked', datos.prototipo);
this.prototipo_2.prop('checked', datos.prototipo2);
this.ferro.prop('checked', datos.ferro);
this.ferro_2.prop('checked', datos.ferro2);
this.ferroDigital.prop('checked', datos.ferroDigital);
this.marcapaginas.prop('checked', datos.marcapaginas);
}

View File

@ -14,11 +14,15 @@ class Envios {
this.recogerTaller = $('#recoger_en_taller');
this.table = null;
this.tableFP1 = null;
this.tableFP2 = null;
this.direccionesClienteForm = new ClassSelect($('#add_clientedAdd'), '/misdirecciones/getSelect2', 'Seleccione una direccion', false, {});
this.paisesClienteForm = new ClassSelect($('#add_pais_id'), '/configuracion/paises/menuitems2', 'Seleccione país', false, {});
this.modalYesNo = null;
this.insertarEnvio = $('#insertar_direccion');
this.insertarEnvioFP1 = $('#insertar_direccion_fp1');
this.insertarEnvioFP2 = $('#insertar_direccion_fp2');
this.actionBtns_direcciones = function (data) {
return `
@ -78,7 +82,7 @@ class Envios {
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`;
},
className: 'row-edit dt-center'
className: 'row-edit'
}
],
columnDefs: [
@ -86,10 +90,12 @@ class Envios {
{
orderable: false,
searchable: false,
// all columns
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
//targets: [$('#tableOfDireccionesEnvio').find("tr:first th").length - 1]
},
{
targets: '_all', // Targets all columns
className: 'dt-center' // Adds the 'dt-center' class
}
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
@ -114,20 +120,188 @@ class Envios {
$("#costeEnvios").text(total.toFixed(2) + "€" || "0€");
self.check_unidades_enviadas(null, self.recogerTaller.prop('checked'));
this.api().columns.adjust();
}
});
this.tableFP1 = $('#tableOfDireccionesEnvioFP1').DataTable({
draw: 5,
serverSide: false,
processing: true,
autoWidth: true,
responsive: true,
pageLength: 20,
lengthChange: false,
searching: false,
paging: false,
info: false,
scrollX: true,
ordering: false,
columns: [
{ 'data': 'tarifa_id' },
{ 'data': 'cantidad' },
{ 'data': 'peso' },
{ 'data': 'att' },
{ 'data': 'email' },
{ 'data': 'direccion' },
{ 'data': 'cp' },
{ 'data': 'municipio' },
{ 'data': 'pais' },
{ 'data': 'pais_id', visible: false },
{ 'data': 'telefono' },
{ 'data': 'proveedor' },
{ 'data': 'proveedor_id', visible: false },
{
'data': 'precio', render: function (data, type, row) {
let coste = parseFloat(data).toFixed(2);
let precio = parseFloat(data * (1 + row.margen / 100.0)).toFixed(2);
return coste + "/" + precio;
}
},
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
{ 'data': 'entregaPieCalle' },
{
data: function (row, type, set, meta) {
return `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`;
},
className: 'row-edit'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
},
{
targets: '_all', // Targets all columns
className: 'dt-center' // Adds the 'dt-center' class
}
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
drawCallback: function (settings) {
const boolCols = [15];
for (let coln of boolCols) {
self.tableFP1.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
}
this.api().columns.adjust();
if (self.tableFP1.rows().count() > 0) {
$('#rowInsertarEnvioFP1').addClass('d-none');
} else {
$('#rowInsertarEnvioFP1').removeClass('d-none');
}
}
});
this.tableFP2 = $('#tableOfDireccionesEnvioFP2').DataTable({
draw: 5,
serverSide: false,
processing: true,
autoWidth: true,
responsive: true,
pageLength: 20,
lengthChange: false,
searching: false,
paging: false,
info: false,
scrollX: true,
ordering: false,
columns: [
{ 'data': 'tarifa_id' },
{ 'data': 'cantidad' },
{ 'data': 'peso' },
{ 'data': 'att' },
{ 'data': 'email' },
{ 'data': 'direccion' },
{ 'data': 'cp' },
{ 'data': 'municipio' },
{ 'data': 'pais' },
{ 'data': 'pais_id', visible: false },
{ 'data': 'telefono' },
{ 'data': 'proveedor' },
{ 'data': 'proveedor_id', visible: false },
{
'data': 'precio', render: function (data, type, row) {
let coste = parseFloat(data).toFixed(2);
let precio = parseFloat(data * (1 + row.margen / 100.0)).toFixed(2);
return coste + "/" + precio;
}
},
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
{ 'data': 'entregaPieCalle' },
{
data: function (row, type, set, meta) {
return `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`;
},
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
},
{
targets: '_all', // Targets all columns
className: 'dt-center' // Adds the 'dt-center' class
}
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
drawCallback: function (settings) {
const boolCols = [15];
for (let coln of boolCols) {
self.tableFP2.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
}
this.api().columns.adjust();
if (self.tableFP2.rows().count() > 0) {
$('#rowInsertarEnvioFP2').addClass('d-none');
} else {
$('#rowInsertarEnvioFP2').removeClass('d-none');
}
}
});
$(document).on('click', '.btn-delete-envio', function () {
const rowId = $(this).closest('td').parent()[0].sectionRowIndex;
self.table.row(rowId).remove().draw();
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
});
const table = $(this).closest('table').DataTable();
table.row(rowId).remove().draw();
if (table.table().node().id == 'tableOfDireccionesEnvios') {
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
});
}
else if (table.table().node().id == 'tableOfDireccionesEnvioFP1') {
$('#rowInsertarEnvioFP1').removeClass('d-none');
}
else if (table.table().node().id == 'tableOfDireccionesEnvioFP2') {
$('#rowInsertarEnvioFP2').removeClass('d-none');
}
});
$(document).on('click', '.btn-edit-envio', function () {
@ -164,7 +338,7 @@ class Envios {
$('#add_telefono').val(data.telefono)
$('#add_cantidad').val(data.cantidad)
$('#add_entregaPieCalle').prop('checked', data.entregaPieCalle == 1 ? true : false)
self.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
self.direccionesClienteForm.init();
@ -202,6 +376,8 @@ class Envios {
this.insertarEnvio.on('click', this.addEnvio.bind(this));
this.insertarEnvioFP1.on('click', this.addEnvio.bind(this, 'fp1'));
this.insertarEnvioFP2.on('click', this.addEnvio.bind(this, 'fp2'));
this.initFormularioDireccionEnvio();
@ -212,12 +388,17 @@ class Envios {
$(document).trigger('update-envios-completed');
});
$(document).on('ckeck-lineas-envios', this.check_unidades_enviadas.bind(this));
$('#sameAddPrincipalFP1').on('change', this.sameAddPrincipalFP1.bind(this));
$('#sameAddPrincipalFP2').on('change', this.sameAddPrincipalFP2.bind(this));
$('#sameAddFP1').on('change', this.sameAddFP1.bind(this));
}
addEnvio() {
addEnvio(table = '') {
$("#addressForm").attr('action', 'create');
let newAddDialog = $("#addressForm");
this.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
this.direccionesClienteForm.init();
@ -231,14 +412,26 @@ class Envios {
let cantidad_total = 0;
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
let data = this.data();
let data = this.data();
cantidad_total += parseInt(data.cantidad);
});
const restante = parseInt($('#tirada').val()) - cantidad_total;
$('#add_cantidad').attr('max-value', restante);
$('#add_cantidad').val(restante > 0 ? restante : 0);
if (table != '') {
$("#addressForm").attr('data-table', table);
$('#add_entregaPieCalle').prop('disabled', true);
$('#add_cantidad').val(1);
$('#add_cantidad').prop('disabled', true);
}
else {
$("#addressForm").attr('data-table', '');
$('#add_entregaPieCalle').prop('disabled', false);
$('#add_cantidad').prop('disabled', false);
}
newAddDialog.modal('show');
}
@ -287,14 +480,63 @@ class Envios {
})
});
})
await $('#tableOfDireccionesEnvioFP1').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) {
var data = this.data();
await $.post('/presupuestos/presupuestodirecciones/add',
{
presupuesto_id: id,
tarifa_id: data.tarifa_id,
cantidad: data.cantidad,
peso: data.peso,
att: data.att,
email: data.email,
direccion: data.direccion,
pais_id: data.pais_id,
provincia: data.provincia,
municipio: data.municipio,
cp: data.cp,
telefono: data.telefono,
precio: data.precio,
margen: data.margen,
proveedor: data.proveedor,
proveedor_id: data.proveedor_id,
entregaPieCalle: data.entregaPieCalle,
is_ferro_prototipo: 1,
num_ferro_prototipo: 1
})
});
await $('#tableOfDireccionesEnvioFP2').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) {
var data = this.data();
await $.post('/presupuestos/presupuestodirecciones/add',
{
presupuesto_id: id,
tarifa_id: data.tarifa_id,
cantidad: data.cantidad,
peso: data.peso,
att: data.att,
email: data.email,
direccion: data.direccion,
pais_id: data.pais_id,
provincia: data.provincia,
municipio: data.municipio,
cp: data.cp,
telefono: data.telefono,
precio: data.precio,
margen: data.margen,
proveedor: data.proveedor,
proveedor_id: data.proveedor_id,
entregaPieCalle: data.entregaPieCalle,
is_ferro_prototipo: 1,
num_ferro_prototipo: 2
})
});
});
}
async updateTiradaBase() {
if($('#noEnvioBase').val() == 1)
if ($('#noEnvioBase').val() == 1)
return;
const self = this;
@ -393,7 +635,7 @@ class Envios {
.draw();
self.check_unidades_enviadas(null,null);
self.check_unidades_enviadas(null, null);
$(document).trigger('update-presupuesto', {
update_lineas: false,
@ -494,6 +736,7 @@ class Envios {
$('#add_telefono').val("");
$('#add_saveDirection').prop('checked', false)
$('#add_entregaPieCalle').prop('checked', false)
$('#addressForm').attr('data-table', '');
});
$('#cancelAdd').on('click', function () {
@ -557,33 +800,86 @@ class Envios {
tarifa_final.cantidad = parseInt($('#add_cantidad').val())
tarifa_final.peso = peso_envio
self.table.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id,
'pais': $('#add_pais_id').select2('data')[0].text,
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': tarifa_final.precio,
'margen': tarifa_final.margen,
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked") ? 1 : 0,
'actionBtns_direcciones': `
const sourceTable = $('#addressForm').attr('data-table');
if (sourceTable === '') {
self.table.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id,
'pais': $('#add_pais_id').select2('data')[0].text,
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': tarifa_final.precio,
'margen': tarifa_final.margen,
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked") ? 1 : 0,
'actionBtns_direcciones': `
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-envio mx-2"></i></a></span>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`,
})
.draw();
})
.draw();
}
else if (sourceTable === 'fp1') {
self.tableFP1.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id,
'pais': $('#add_pais_id').select2('data')[0].text,
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': 0,
'margen': 0,
'entregaPieCalle': 0,
'actionBtns_direcciones': `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`,
})
.draw();
}
else {
self.tableFP2.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id,
'pais': $('#add_pais_id').select2('data')[0].text,
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': 0,
'margen': 0,
'entregaPieCalle': 0,
'actionBtns_direcciones': `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`,
})
.draw();
}
// Se guarda la dirección
if ($('#add_saveDirection').is(":checked") &&
@ -668,13 +964,26 @@ class Envios {
return returnValue
}
cargar(datos) {
cargar(datos, datosFP) {
if (datos.entrega_taller) {
this.recogerTaller.prop('checked', true);
}
else {
this.table.rows.add(datos).draw();
}
if (datosFP.fp1.length > 0) {
this.tableFP1.rows.add(datosFP.fp1).draw();
$('#rowInsertarEnvioFP1').addClass('d-none');
}
if (datosFP.fp2.length > 0) {
this.tableFP2.rows.add(datosFP.fp2).draw();
$('#rowInsertarEnvioFP2').addClass('d-none');
}
if(datosFP.checkboxes){
$('#sameAddPrincipalFP1').prop('checked', datosFP.checkboxes.addFP1isAddMain == "1"? true: false);
$('#sameAddPrincipalFP2').prop('checked', datosFP.checkboxes.addFP2isAddMain == "1"? true: false);
$('#sameAddFP1').prop('checked', datosFP.checkboxes.addFP2isaddFP1 == "1"? true: false);
}
}
check_unidades_enviadas(event, recogerTaller = null) {
@ -709,6 +1018,56 @@ class Envios {
$('#alert-envios').html(htmlString);
return true;
}
sameAddPrincipalFP1() {
this.tableFP1.clear().draw();
if ($('#sameAddPrincipalFP1').prop('checked')) {
if (this.table.rows().count() > 0) {
let data = this.table.row(0).data();
data.cantidad = 1; // Set unidades to 1
data.precio = 0;
data.margen = 0;
data.peso = this.get_peso_libro() / 1000;
this.tableFP1.row.add(data).draw();
}
}
}
sameAddPrincipalFP2() {
$('#sameAddFP1').prop('checked', false);
this.tableFP2.clear().draw();
if ($('#sameAddPrincipalFP2').prop('checked')) {
if (this.table.rows().count() > 0) {
let data = this.table.row(0).data();
data.cantidad = 1; // Set unidades to 1
data.precio = 0;
data.margen = 0;
data.peso = this.get_peso_libro() / 1000;
this.tableFP2.row.add(data).draw();
}
}
}
sameAddFP1() {
this.tableFP2.clear().draw();
$('#sameAddPrincipalFP2').prop('checked', false);
if ($('#sameAddFP1').prop('checked')) {
if (this.tableFP1.rows().count() > 0) {
let data = this.tableFP1.row(0).data();
data.cantidad = 1; // Set unidades to 1
data.precio = 0;
data.margen = 0;
data.peso = this.get_peso_libro() / 1000;
this.tableFP2.row.add(data).draw();
}
}
}
}
export default Envios;

View File

@ -119,6 +119,11 @@ class Servicios {
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'ferro_2') {
const id = $('#ferro_2').attr('service-id');
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'ferroDigital') {
const id = $('#ferroDigital').attr('service-id');
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
@ -129,6 +134,11 @@ class Servicios {
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'prototipo_2') {
const id = $('#prototipo_2').attr('service-id');
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'retractilado') {
const id = $('#retractilado').attr('service-id');
if (!this.checkServiceInTable(this.serviciosAcabado.table, id))
@ -201,8 +211,18 @@ class Servicios {
}
});
}
if (servicio == 'ferroDigital') {
else if (servicio == 'ferro_2') {
const id = $('#ferro_2').attr('service-id');
this.serviciosExtra.table.rows().every(function () {
let data = this.data();
if (data.tarifa_id == id) {
this.remove();
self.serviciosExtra.table.draw();
return;
}
});
}
else if (servicio == 'ferroDigital') {
const id = $('#ferroDigital').attr('service-id');
this.serviciosExtra.table.rows().every(function () {
let data = this.data();
@ -225,6 +245,17 @@ class Servicios {
}
});
}
else if (servicio == 'prototipo_2') {
const id = $('#prototipo_2').attr('service-id');
this.serviciosExtra.table.rows().every(function () {
var data = this.data();
if (data.tarifa_id == id) {
this.remove();
self.serviciosExtra.table.draw();
return;
}
});
}
else if (servicio == 'retractilado') {
const id = $('#retractilado').attr('service-id');
for (let i = this.serviciosAcabado.table.rows().count(); i >= 0; i--) {