terminado. mejorado update de resumenes. quitado bug rotativa color (siempre tarifa negro)

This commit is contained in:
2024-03-05 20:48:58 +01:00
parent eb38a12c6d
commit a7df1975a9
10 changed files with 304 additions and 197 deletions

View File

@ -11,7 +11,7 @@
<div id='alert-envios'></div>
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_presupuestoDireccionesForm") ?>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvio" class="table dt-responsive dataTable px-2" style="width: 95%;">
<table id="tableOfDireccionesEnvio" class="table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;">
<thead>
<tr>
<th class="lp-header">Tarifa_id</th>
@ -86,7 +86,7 @@ const lastColNr_direcciones = $('#tableOfDireccionesEnvio').find("tr:first th").
const actionBtns_direcciones = function(data) {
return `
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-add mx-2" data-id="${data.id}"></i></a></span>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm delete-add-row mx-2"></i></a>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas delete-add-row mx-2"></i></a>
`;
};
@ -117,8 +117,7 @@ function updateTablaEnvios(){
datos_tarifa.cantidad = parseInt($('#add_cantidad').val());
datos_tarifa.peso = peso_envio;
console.log(datos_tarifa.precio)
tableEnvios.row(rowIdx)
.data({
'tarifa_id': datos_tarifa.id,
@ -141,9 +140,7 @@ function updateTablaEnvios(){
})
.draw();
checkInsertar()
updateTotales(false, false, true)
checkInsertar()
}
else{
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
@ -157,7 +154,6 @@ $(document).on('click', '.delete-add-row', function(e) {
.remove()
.draw();
checkInsertar()
updateTotales(false, false, true)
})
$(document).on('click', '.btn-edit-add', function(e) {
@ -279,6 +275,7 @@ var tableEnvios = $('#tableOfDireccionesEnvio').DataTable( {
} );
function checkInsertar(){
cantidad_total = 0
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
@ -382,7 +379,9 @@ function load_datos_envios(){
})
.draw();
checkInsertar()
});
$('#tableOfDireccionesEnvio').bind('draw.dt', update_tiradas_alternativas);
})
}

View File

@ -259,8 +259,8 @@ async function get_servPreimpresion_tiradasAlternativas(){
const values = await response.json();
yeniden(values[window.csrf_token]);
values.lines.forEach((line) => {
serviciosPreimpresion.coste += parseFloat(line[0].total);
serviciosPreimpresion.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
serviciosPreimpresion.coste += parseFloat(line[0].precio);
serviciosPreimpresion.margen += parseFloat(line[0].precio)*parseFloat(line[0].margen)/100.0;
});
return serviciosPreimpresion;
}

View File

@ -73,7 +73,7 @@
</div>
<div id="serv-acabado-error">
</div>
<table id="tableOfServiciosAcabado" class="table table-striped table-hover" style="width: 100%;">
<table id="tableOfServiciosAcabado" class="table table-striped table-hover tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Presupuestos.id') ?></th>
@ -99,7 +99,7 @@
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
<button id="insertar_serv_acabado" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
<button id="insertar_serv_acabado" type="button" class="btn btn-secondary waves-effect waves-light float-start tiradas-alternativas"><?= lang("Presupuestos.insertar")?></button>
</div>
</div>
@ -111,7 +111,7 @@
</div>
<div id="serv-preimpresion-error">
</div>
<table id="tableOfServiciosPreimpresion" class="table table-striped table-hover" style="width: 100%;">
<table id="tableOfServiciosPreimpresion" class="table table-striped table-hover tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Presupuestos.id') ?></th>
@ -136,7 +136,7 @@
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
<button id="insertar_serv_preimpresion" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
<button id="insertar_serv_preimpresion" type="button" class="btn btn-secondary waves-effect waves-light float-start tiradas-alternativas"><?= lang("Presupuestos.insertar")?></button>
</div>
</div>
@ -148,7 +148,7 @@
<div id="serv-enc-error">
</div>
<table id="tableOfServiciosEncuadernacion" class="table dt-responsive dataTable" style="width: 100%;">
<table id="tableOfServiciosEncuadernacion" class="table dt-responsive dataTable tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Presupuestos.id') ?></th>
@ -176,7 +176,7 @@
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
<button id="insertar_serv_enc" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
<button id="insertar_serv_enc" type="button" class="btn btn-secondary waves-effect waves-light float-start tiradas-alternativas"><?= lang("Presupuestos.insertar")?></button>
</div>
</div>
@ -188,7 +188,7 @@
</div>
<div id="serv-manipulado-error">
</div>
<table id="tableOfServiciosManipulado" class="table table-striped table-hover" style="width: 100%;">
<table id="tableOfServiciosManipulado" class="table table-striped table-hover tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Presupuestos.id') ?></th>
@ -214,7 +214,7 @@
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
<button id="insertar_serv_manipulado" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
<button id="insertar_serv_manipulado" type="button" class="btn btn-secondary waves-effect waves-light float-start tiradas-alternativas"><?= lang("Presupuestos.insertar")?></button>
</div>
</div>
@ -521,9 +521,6 @@
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
"drawCallback": function(settings ) {
updateTotales(false, true, false)
}
});
function init_servicio_acabado(){
@ -612,7 +609,7 @@
'<span id="precio_unidad_acabado_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
'<input class="update-totales" id="precio_total_acabado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
'<span style="display: none;" class="update-totales" id="acabado_margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'" data-text="' + nombre +'"></i></a>'
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2 tiradas-alternativas" data-id="' + row.tarifa_id +'" data-text="' + nombre +'"></i></a>'
]).draw(false)
});
@ -730,10 +727,7 @@
select: false,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
"drawCallback": function(settings ) {
updateTotales(false, true, false)
}
},
});
@ -803,6 +797,7 @@
});
$('#proveedor_enc_' + element.tarifa_encuadernado_id).on('change', proveedor_enc_event)
});
check_serv_enc_error()
}
@ -1006,9 +1001,6 @@
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
"drawCallback": function(settings ) {
updateTotales(false, true, false)
}
});
function init_servicio_manipulado(){
@ -1163,9 +1155,6 @@
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
"drawCallback": function(settings ) {
updateTotales(false, true, false)
}
});

View File

@ -13,7 +13,7 @@
<div id="divAlarmasLineasPresupuesto"></div>
<!----------------------------------------------------------------------------->
<table id="tableLineasPresupuesto" class="comparator-table table dt-responsive dataTable" style="width: 100%;">
<table id="tableLineasPresupuesto" class="comparator-table table dt-responsive dataTable tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
<thead>
<tr>
<th width="10px"></th>
@ -685,7 +685,7 @@ $(document).on('click', '.btn-delete-lp', function(e) {
tableLineasPresupuesto.row( row )
.remove()
.draw();
updateTotales(true, false, false)
updateTablaEnvios()
if(data.row_id == 'lp_guardas')
@ -1244,7 +1244,7 @@ $('#btn_addLinea').on("click", function (e) {
// de los checkboxes que esten seleccionados
function update_total_linea(e){
updateTotales(true, false, false)
}
<?= $this->endSection() ?>
@ -1548,7 +1548,7 @@ function fill_lp_bn(row, fromComparator=false){
$('#lp_bn_checkPapel').change()
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
@ -1877,7 +1877,7 @@ function fill_lp_color(row, fromComparator=false){
$('#lp_color_checkPapel').change()
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
@ -2203,7 +2203,7 @@ function fill_lp_bnhq(row, fromComparator=false){
$('#lp_bnhq_checkPapel').change()
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
@ -2532,7 +2532,7 @@ function fill_lp_colorhq(row, fromComparator=false){
$('#lp_colorhq_checkPapel').change()
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
@ -2871,7 +2871,7 @@ function fill_lp_rot_bn(row, fromComparador=false){
$('#lp_rot_bn_checkPapel').change()
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
@ -3214,7 +3214,7 @@ function fill_lp_rot_color(row, fromComparador=false){
$('#lp_rot_color_checkPapel').change()
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
@ -3491,7 +3491,7 @@ function fill_lp_cubierta(row, fromComparador=false){
check_update_sobrecubierta()
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
}
@ -3754,7 +3754,7 @@ function fill_lp_sobrecubierta(row, fromComparador=false){
$('#lp_sobrecubierta_checkPapel').change()
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
}
@ -3949,7 +3949,7 @@ function fill_lp_guardas(row, fromComparador=false){
$('#lp_guardas_checkPapel').change()
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
@ -4402,7 +4402,7 @@ function updateLineasPresupuesto(){
checkComparadorInt(false, false, false, true)
}
else if(this.id.endsWith('lp_rot_color')){
checkComparadorInt(false,true, false, true);
checkComparadorInt(true,false, false, true);
}
else if(this.id.endsWith('_cubierta')){
checkComparadorCubierta(true)

View File

@ -250,10 +250,8 @@ $('#saveDireccionEnvio').on('click', function(){
})
}
checkInsertar()
updateTotales(false, false, true)
$('#addressForm').modal("hide");
}
else{
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')

View File

@ -83,6 +83,17 @@
<?= $this->section("additionalInlineJs") ?>
$('.update-resumen-presupuesto').each(function() {
if ($(this).is('table')) {
if($(this).attr('id') == 'tableLineasPresupuesto')
$(this).bind('draw.dt',{updateLP:true, updateServicios:false, updateEnvio:false}, updateTotales);
else if ($(this).attr('id') == 'tableOfServiciosAcabado' || $(this).attr('id') == 'tableOfServiciosPreimpresion' ||
$(this).attr('id') == 'tableOfServiciosEncuadernacion' || $(this).attr('id') == 'tableOfServiciosManipulado')
$(this).bind('draw.dt',{updateLP:false, updateServicios:true, updateEnvio:false}, updateTotales);
else if ($(this).attr('id') == 'tableOfDireccionesEnvio')
$(this).bind('draw.dt',{updateLP:false, updateServicios:false, updateEnvio:true}, updateTotales);
}
});
function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
var totalPapel = 0

View File

@ -22,14 +22,49 @@ var tableTiradas;
initTableTiradas();
fill_tiradas_alternativas();
$('.tiradas-alternativas').each(function() {
if ($(this).is('input')) {
$(this).bind('change', update_tiradas_alternativas);
} else if ($(this).is('button')) {
$(this).bind('click', update_tiradas_alternativas);
} else if ($(this).is('table')) {
$(this).bind('draw.dt', update_tiradas_alternativas);
}
else{
// para los botones de borrar
$(this).bind('click', update_tiradas_alternativas);
}
});
})();
function update_tiradas_alternativas(){
// se obtiene la primera columna de la tabla de tiradas
const data = tableTiradas.rows().data().toArray();
// se borra la tabla de tiradas
tableTiradas.clear().draw();
const tiradas = data.map(row => row.tirada);
// por cada tirada, se añade una fila a la tabla de tiradas
tiradas.forEach(tirada => {
add_tirada_alternativa(tirada);
});
}
// Evento de añadir una tirada alternativa
$('#add_tirada_alt').on('click', function () {
// se comprueba que la tirada no existe ya en la tabla
const tirada_alt = parseInt($('#tirada_alt').val());
add_tirada_alternativa(tirada_alt);
});
// Funcion para añadir una tirada alternativa
function add_tirada_alternativa(tirada_alt) {
// se comprueba que la tirada no existe ya en la tabla
const exists = tableTiradas.rows().data().toArray().some(row => row.tirada == tirada_alt);
const isPOD = parseInt($('#tirada').val())<= parseInt($('#POD').val());
@ -40,8 +75,8 @@ $('#add_tirada_alt').on('click', function () {
const dimension = getDimensionLibro();
let datos = {
tirada: $('#tirada_alt').val(),
merma: get_merma_tirada_alternativa($('#tirada_alt').val()),
tirada: tirada_alt,
merma: get_merma_tirada_alternativa(tirada_alt),
tipo_impresion_id: $('#tipo_impresion_id').val(),
json_tiradas: generate_json_tiradas(),
ancho: dimension.ancho,
@ -75,7 +110,6 @@ $('#add_tirada_alt').on('click', function () {
if(data.lineas.length >0){
// Se cogen los valores de la linea con los datos correspondientes
$.each(data.lineas, function(key, value) {
coste_total += value.total_coste;
margen_total += value.total_margen;
});
@ -148,9 +182,10 @@ $('#add_tirada_alt').on('click', function () {
}
$('#alert-tiradas_alt').html(htmlString);
}
});
}
// Función para obtener el lomo exterior
function getLomoExterior(){
let lomoTotal = 0