mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en guardar presupuesto hasta las lineas de presupuesto
This commit is contained in:
@ -344,7 +344,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
$this->viewData['acabadosSobrecubierta'] = $this->getAcabadosSobrecubierta();
|
$this->viewData['acabadosSobrecubierta'] = $this->getAcabadosSobrecubierta();
|
||||||
|
|
||||||
// Lineas Presupuesto
|
// Lineas Presupuesto
|
||||||
[$cambios_lineas, $this->viewData['lineasPresupuesto']] = $this->getLineasPresupuesto($presupuestoEntity);
|
[$cambios_lineas, $this->viewData['lineasPresupuesto']] = $this->loadLineasPresupuesto($presupuestoEntity);
|
||||||
$this->viewData['presupuestoEntity']->cambios_lineas = $cambios_lineas;
|
$this->viewData['presupuestoEntity']->cambios_lineas = $cambios_lineas;
|
||||||
|
|
||||||
// Servicios
|
// Servicios
|
||||||
@ -542,6 +542,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
$data['comparador']['lomoRedondo'] = $presupuesto->lomo_redondo;
|
$data['comparador']['lomoRedondo'] = $presupuesto->lomo_redondo;
|
||||||
$data['comparador']['cabezada'] = $presupuesto->cabezada;
|
$data['comparador']['cabezada'] = $presupuesto->cabezada;
|
||||||
|
|
||||||
|
$data['lineasPresupuesto'] = $this->loadLineasPresupuesto($presupuesto);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -909,6 +911,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
'nombre' => $reqData['papel_generico'] ?? "",
|
'nombre' => $reqData['papel_generico'] ?? "",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if($papel_generico['id'] != 0 && $papel_generico['nombre'] == ""){
|
||||||
|
$modelPapelGenerico = new PapelGenericoModel();
|
||||||
|
$papel_generico['nombre'] = $modelPapelGenerico->getNombre($papel_generico['id'])['nombre'];
|
||||||
|
}
|
||||||
|
|
||||||
$gramaje = $reqData['gramaje'] ?? 0;
|
$gramaje = $reqData['gramaje'] ?? 0;
|
||||||
|
|
||||||
$cliente_id = $reqData['cliente_id'] ?? -1;
|
$cliente_id = $reqData['cliente_id'] ?? -1;
|
||||||
@ -1707,7 +1714,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
return model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
return model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getLineasPresupuesto($presupuestoEntity)
|
protected function loadLineasPresupuesto($presupuestoEntity)
|
||||||
{
|
{
|
||||||
$lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id);
|
$lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id);
|
||||||
|
|
||||||
|
|||||||
@ -330,8 +330,9 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"*"
|
"*, t2.nombre AS papel_generico"
|
||||||
)
|
)
|
||||||
|
->join("lg_papel_generico t2", "t1.papel_id = t2.id", "left")
|
||||||
->where("t1.presupuesto_id", $presupuesto_id);
|
->where("t1.presupuesto_id", $presupuesto_id);
|
||||||
|
|
||||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -88,7 +88,7 @@ class PresupuestoAdminEdit {
|
|||||||
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||||
self.datosLibro.cargarDatos(response.data.datosLibro);
|
self.datosLibro.cargarDatos(response.data.datosLibro);
|
||||||
self.comparador.cargarDatos(response.data.comparador);
|
self.comparador.cargarDatos(response.data.comparador);
|
||||||
|
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
|
||||||
/*self.direcciones.handleChangeCliente();
|
/*self.direcciones.handleChangeCliente();
|
||||||
|
|
||||||
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||||
|
|||||||
@ -1000,7 +1000,7 @@ class Comparador {
|
|||||||
lomoTotal += parseFloat(rowData.lomo);
|
lomoTotal += parseFloat(rowData.lomo);
|
||||||
}
|
}
|
||||||
else if (tipo_lomo == 'cubierta') {
|
else if (tipo_lomo == 'cubierta') {
|
||||||
if (rowData.row_id == 'lp_cubierta')
|
if (rowData.tipo != 'lp_sobrecubierta')
|
||||||
lomoTotal += parseFloat(rowData.lomo);
|
lomoTotal += parseFloat(rowData.lomo);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -18,6 +18,7 @@ class LineasPresupuesto {
|
|||||||
this.addLineaManual = this.domItem.find("#btn_addLinea");
|
this.addLineaManual = this.domItem.find("#btn_addLinea");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
@ -51,8 +52,12 @@ class LineasPresupuesto {
|
|||||||
self.obtenerLinea('lp_cubierta', false, false);
|
self.obtenerLinea('lp_cubierta', false, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.insertarLinea').on("click", this.#insertarLineaComparador.bind(this));
|
||||||
|
$('.paginas-lp').on('change', this.checkPaginasLineasPresupuesto.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#initTable() {
|
#initTable() {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
@ -338,6 +343,176 @@ class LineasPresupuesto {
|
|||||||
row.child(self.formatRow(row.data())).show();
|
row.child(self.formatRow(row.data())).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.table.on('draw', function () {
|
||||||
|
self.checkPaginasLineasPresupuesto();
|
||||||
|
self.mostrarTabsPreview();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cargarDatos(data) {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
data[1].forEach(function (lp) {
|
||||||
|
|
||||||
|
const formas = JSON.parse(lp.formas)
|
||||||
|
lp.dimensiones_maquina = [formas.maquina_ancho, formas.maquina_alto]
|
||||||
|
lp.dimensiones_maquina_impresion = [formas.maquina_impresion_ancho, formas.maquina_impresion_alto]
|
||||||
|
lp.num_formas = {
|
||||||
|
value: formas.formas,
|
||||||
|
num_formas_verticales: formas.formas_v,
|
||||||
|
num_formas_horizontales: formas.formas_h,
|
||||||
|
posicion_formas: formas.formas_orientacion
|
||||||
|
}
|
||||||
|
lp['tipo_maquina'] = lp['maquina_tipo']
|
||||||
|
lp['precio_impresion_horas'] = lp['precio_impresion']
|
||||||
|
lp['margen_impresion_horas'] = lp['margen_impresion']
|
||||||
|
lp['precio_libro'] = lp['libro']
|
||||||
|
lp['precio_pedido'] = lp['total_papel_pedido']
|
||||||
|
lp['total_impresion'] = lp['total_linea']
|
||||||
|
lp['precios_pliegos'] = lp['pliegos_precio']
|
||||||
|
lp['papel_generico_id'] = lp['papel_id']
|
||||||
|
|
||||||
|
let dateObj = new Date(lp['tiempo_maquina'] * 1000);
|
||||||
|
const hours = dateObj.getUTCHours();
|
||||||
|
const minutes = dateObj.getUTCMinutes();
|
||||||
|
const seconds = dateObj.getSeconds();
|
||||||
|
lp['tiempo_maquina'] = hours.toString().padStart(2, '0') + ':' +
|
||||||
|
minutes.toString().padStart(2, '0') + ':' +
|
||||||
|
seconds.toString().padStart(2, '0');
|
||||||
|
|
||||||
|
if (lp.maquina_tipo == 'inkjet') {
|
||||||
|
|
||||||
|
lp.datosTipologias = {
|
||||||
|
negro: lp.rotativa_negro,
|
||||||
|
cyan: lp.rotativa_cyan,
|
||||||
|
magenta: lp.rotativa_magenta,
|
||||||
|
amarillo: lp.rotativa_amarillo,
|
||||||
|
cg: lp.rotativa_cg,
|
||||||
|
gota_negro: lp.rotativa_gota_negro,
|
||||||
|
gota_color: lp.rotativa_gota_color,
|
||||||
|
}
|
||||||
|
|
||||||
|
lp['paginas_color'] = lp['rotativa_pag_color']
|
||||||
|
|
||||||
|
lp['totalImpresion'] = lp['rotativa_total_impresion']
|
||||||
|
lp['a_favor_fibra'] = lp['rotativa_a_favor_fibra']
|
||||||
|
|
||||||
|
lp['resolucion'] = lp['rotativa_resolucion']
|
||||||
|
lp['superficie'] = lp['rotativa_area_paginas']
|
||||||
|
|
||||||
|
lp['num_gotas_negro'] = lp['rotativa_num_gotas_negro']
|
||||||
|
lp['num_gotas_cyan'] = lp['rotativa_num_gotas_cyan']
|
||||||
|
lp['num_gotas_magenta'] = lp['rotativa_num_gotas_magenta']
|
||||||
|
lp['num_gotas_amarillo'] = lp['rotativa_num_gotas_amarillo']
|
||||||
|
lp['num_gotas_cg'] = lp['rotativa_num_gotas_cg']
|
||||||
|
|
||||||
|
lp['precio_pagina_negro'] = lp['rotativa_precio_pag_negro']
|
||||||
|
lp['precio_pagina_color'] = lp['rotativa_precio_pag_color']
|
||||||
|
lp['factor_altura'] = lp['rotativa_factor_altura']
|
||||||
|
lp['factor_anchura'] = lp['rotativa_factor_anchura']
|
||||||
|
lp['paginas_por_pliego'] = lp['rotativa_pag_por_pliego']
|
||||||
|
|
||||||
|
lp['clicks_libro'] = lp['rotativa_clicks_libro']
|
||||||
|
lp['peso_gotas_negro'] = lp['rotativa_peso_gotas_negro']
|
||||||
|
lp['peso_gotas_cyan'] = lp['rotativa_peso_gotas_cyan']
|
||||||
|
lp['peso_gotas_magenta'] = lp['rotativa_peso_gotas_magenta']
|
||||||
|
lp['peso_gotas_amarillo'] = lp['rotativa_peso_gotas_amarillo']
|
||||||
|
lp['peso_gotas_cg'] = lp['rotativa_peso_gotas_cg']
|
||||||
|
lp['clicks_pedido'] = lp['rotativa_clicks_total']
|
||||||
|
lp['precio_click_pedido'] = lp['precio_click_pedido']
|
||||||
|
lp['margen_click_pedido'] = lp['margen_click_pedido']
|
||||||
|
lp['precio_tinta'] = lp['rotativa_precio_tinta']
|
||||||
|
|
||||||
|
|
||||||
|
lp['peso_gotas_negro_pedido'] = lp['rotativa_peso_gotas_negro_pedido']
|
||||||
|
lp['peso_gotas_cyan_pedido'] = lp['rotativa_peso_gotas_cyan_pedido']
|
||||||
|
lp['peso_gotas_magenta_pedido'] = lp['rotativa_peso_gotas_magenta_pedido']
|
||||||
|
lp['peso_gotas_amarillo_pedido'] = lp['rotativa_peso_gotas_amarillo_pedido']
|
||||||
|
lp['peso_gotas_cg_pedido'] = lp['rotativa_peso_gotas_cg_pedido']
|
||||||
|
|
||||||
|
}
|
||||||
|
if (lp.tipo.includes('rot')) {
|
||||||
|
|
||||||
|
lp['maquina_velocidad'] = lp['rotativa_mxm']
|
||||||
|
lp['metros_papel_libro'] = lp['rotativa_metros_libro']
|
||||||
|
lp['metros_papel_total'] = lp['rotativa_metros_total']
|
||||||
|
lp['velocidad_corte'] = lp['rotativa_velocidad_corte']
|
||||||
|
lp['precio_hora_corte'] = lp['rotativa_precio_hora_corte']
|
||||||
|
lp['tiempo_corte'] = lp['rotativa_tiempo_corte']
|
||||||
|
lp['total_corte'] = lp['rotativa_total_corte']
|
||||||
|
}
|
||||||
|
|
||||||
|
lp['areaPaginas'] = lp['rotativa_superficie']
|
||||||
|
|
||||||
|
|
||||||
|
let rowData = self.#processRowData(lp, lp.tipo, lp.tipo.replace(/_/g, '-'));
|
||||||
|
|
||||||
|
let row = self.table.row("#" + lp.tipo);
|
||||||
|
|
||||||
|
self.table.row.add(rowData).draw()
|
||||||
|
row = self.table.row("#" + lp.tipo);
|
||||||
|
|
||||||
|
row.child(self.formatRow(row.data())).show();
|
||||||
|
|
||||||
|
self.#addEventosLineas(lp.tipo, lp.maquina_tipo == 'inkjet' ? true : false);
|
||||||
|
if (lp.tipo=='lp_guardas')
|
||||||
|
lp['paginas_impresion'] = lp.paginas_impresion;
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mostrarTabsPreview() {
|
||||||
|
|
||||||
|
const table = $('#tableLineasPresupuesto').DataTable();
|
||||||
|
|
||||||
|
// Clear all existing tabs
|
||||||
|
$('*[id*=tab-pv-]').hide().find('.active').removeClass('active');
|
||||||
|
$('*[id*=pv_]').removeClass('active show');
|
||||||
|
|
||||||
|
// Enable active tabs
|
||||||
|
table.rows().every(function () {
|
||||||
|
const lpName = this.data().row_id.replace('lp_', '');
|
||||||
|
const tabName = lpName.replace('_', '-');
|
||||||
|
|
||||||
|
if (['bn', 'bnhq', 'color', 'colorhq', 'rot_bn', 'rot_color', 'guardas', 'cubierta', 'sobrecubierta'].includes(lpName)) {
|
||||||
|
$(`#tab-pv-${tabName}`).show();
|
||||||
|
if (lpName === 'cubierta') {
|
||||||
|
$(`#tab-pv-${tabName}`).show();
|
||||||
|
$(`#tab-pv-esquema-${tabName}`).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
checkPaginasLineasPresupuesto() {
|
||||||
|
|
||||||
|
let cantidad_total = 0
|
||||||
|
|
||||||
|
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas')
|
||||||
|
cantidad_total += parseInt(rowData.paginas)
|
||||||
|
})
|
||||||
|
let htmlString = ''
|
||||||
|
|
||||||
|
if (cantidad_total != parseInt($('#paginas').val())) {
|
||||||
|
htmlString = `
|
||||||
|
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||||
|
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||||
|
<i class="ti ti-bell ti-sm"></i>
|
||||||
|
</span>
|
||||||
|
<div class="d-flex flex-column ps-1">
|
||||||
|
<h5 class="alert-heading mb-2">` +
|
||||||
|
window.Presupuestos.errores.paginasLP +
|
||||||
|
`</h5>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
$('#divAlarmasLineasPresupuesto').html(htmlString)
|
||||||
}
|
}
|
||||||
|
|
||||||
#insertLineaManual() {
|
#insertLineaManual() {
|
||||||
@ -807,7 +982,7 @@ class LineasPresupuesto {
|
|||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="col-md-12 col-lg-1" style="display: grid;" >' +
|
'<div class="col-md-12 col-lg-1" style="display: grid;" >' +
|
||||||
window.language.Presupuestos.aFavorFibra +
|
window.language.Presupuestos.aFavorFibra +
|
||||||
'<input type="checkbox" id="' + d.row_id +'_aFavorFibra" name="' + d.row_id +'_aFavorFibra" ' + (d.aFavorFibra==true?'checked':'') + '>' +
|
'<input type="checkbox" id="' + d.row_id + '_aFavorFibra" name="' + d.row_id + '_aFavorFibra" ' + ((d.aFavorFibra == true || d.aFavorFibra == "true") ? 'checked' : '') + '>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="col-md-12 col-lg-1">' +
|
'<div class="col-md-12 col-lg-1">' +
|
||||||
'<button id="' + d.row_id + '_vercalculos" name="' + d.row_id + '_vercalculos" type="button" class="btn btn-label-primary waves-effect lp-button">' + window.language.Presupuestos.verCalculos + '</button>' +
|
'<button id="' + d.row_id + '_vercalculos" name="' + d.row_id + '_vercalculos" type="button" class="btn btn-label-primary waves-effect lp-button">' + window.language.Presupuestos.verCalculos + '</button>' +
|
||||||
@ -1015,22 +1190,25 @@ class LineasPresupuesto {
|
|||||||
|
|
||||||
getLomoInterior() {
|
getLomoInterior() {
|
||||||
let lomo = 0;
|
let lomo = 0;
|
||||||
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
if (this.data().row_id != 'lp_cubierta' && this.data().row_id != 'lp_sobrecubierta' && this.data().row_id != 'lp_guardas' && this.data().row_id != 'lp_rot_bn' && this.data().row_id != 'lp_fajas') {
|
var rowData = this.data();
|
||||||
lomo += parseFloat(this.data().mano);
|
if (rowData.row_id != 'lp_cubierta' && rowData.tipo != 'lp_sobrecubierta')
|
||||||
|
lomo += parseFloat(rowData.lomo);
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
return lomo;
|
return lomo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getLomoCubierta() {
|
getLomoCubierta() {
|
||||||
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
let lomo = 0;
|
||||||
if (this.data().row_id == 'lp_cubierta') {
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
return parseFloat(this.data().mano);
|
var rowData = this.data();
|
||||||
|
if (rowData.row_id == 'lp_cubierta')
|
||||||
|
lomo += parseFloat(rowData.lomo);
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
return 0;
|
return lomo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1042,13 +1220,28 @@ class LineasPresupuesto {
|
|||||||
if (Object.keys(input_data).length == 0) {
|
if (Object.keys(input_data).length == 0) {
|
||||||
|
|
||||||
input_data = {
|
input_data = {
|
||||||
paginas: parseInt($('#' + linea + '_paginas').val()),
|
|
||||||
papel_generico_id: $('#' + linea + '_papel option:selected').val(),
|
papel_generico_id: $('#' + linea + '_papel option:selected').val(),
|
||||||
papel_generico: $('#' + linea + '_papel option:selected').text().trim(),
|
papel_generico: $('#' + linea + '_papel option:selected').text().trim(),
|
||||||
gramaje: $('#' + linea + '_gramaje option:selected').text().trim(),
|
gramaje: $('#' + linea + '_gramaje option:selected').text().trim(),
|
||||||
maquina_id: $('#' + linea + '_maquina option:selected').val(),
|
maquina_id: $('#' + linea + '_maquina option:selected').val(),
|
||||||
papel_impresion_id: $('#' + linea + '_papelImpresion option:selected').val()
|
papel_impresion_id: $('#' + linea + '_papelImpresion option:selected').val()
|
||||||
}
|
}
|
||||||
|
if (linea.includes('rot')) {
|
||||||
|
input_data.fibra = fromComparador == false ? ($('#lp_rot_color_aFavorFibra').prop('checked') ? 1 : 0) : 1;
|
||||||
|
}
|
||||||
|
if (linea == 'lp_cubierta') {
|
||||||
|
input_data.paginas = parseInt($('#lp_cubierta_paginas option:selected').val());
|
||||||
|
}
|
||||||
|
else if (linea == 'lp_sobrecubierta') {
|
||||||
|
input_data.paginas = 4;
|
||||||
|
}
|
||||||
|
else if (linea == 'lp_guardas') {
|
||||||
|
input_data.paginas = (parseInt($('#tipo_impresion_id').val()) == 1 || parseInt($('#tipo_impresion_id').val()) == 3) ? 8 : 4;
|
||||||
|
input_data.paginas_impresion = parseInt($('#lp_guardas_paginas option:selected').val());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
input_data.paginas = parseInt($('#' + linea + '_paginas').val());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1102,22 +1295,48 @@ class LineasPresupuesto {
|
|||||||
gramaje: input_data.gramaje,
|
gramaje: input_data.gramaje,
|
||||||
cliente_id: $('#clienteId').find(":selected").val(),
|
cliente_id: $('#clienteId').find(":selected").val(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (linea.includes('rot')) {
|
||||||
|
if (fromComparador) {
|
||||||
|
datos.paginas_negro = parseInt($('#compPaginasNegro').val())
|
||||||
|
datos.paginas_color = parseInt($('#compPaginasColor').val())
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let paginas_color = isNaN(parseInt($('#lp_rot_color_numPagColor').val())) ? input_data.paginas : parseInt($('#lp_rot_color_numPagColor').val())
|
||||||
|
datos.paginas_negro = input_data.paginas - paginas_color;
|
||||||
|
datos.paginas_color = paginas_color;
|
||||||
|
}
|
||||||
|
datos.a_favor_fibra = fromComparador == false ? ($('#lp_rot_color_aFavorFibra').prop('checked') ? 1 : 0) : 1;
|
||||||
|
}
|
||||||
|
else if (linea == 'lp_cubierta') {
|
||||||
|
datos.solapas = $('#solapas').is(':checked') ? 1 : 0;
|
||||||
|
datos.solapas_ancho = $('#solapas').is(':checked') ? parseInt($('#solapas_ancho').val()) : 0;
|
||||||
|
datos.lomo = this.getLomoInterior();
|
||||||
|
}
|
||||||
|
else if (linea == 'lp_sobrecubierta') {
|
||||||
|
datos.solapas = $('#solapas_sobrecubierta').is(':checked') ? 1 : 0;
|
||||||
|
datos.solapas_ancho = $('#solapas_sobrecubierta').is(':checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0;
|
||||||
|
datos.lomo = this.getLomoCubierta() + this.getLomoInterior();
|
||||||
|
}
|
||||||
|
else if (linea == 'lp_guardas') {
|
||||||
|
datos.paginas_impresion = input_data.paginas_impresion;
|
||||||
|
}
|
||||||
datos = Object.assign(datos, window.token_ajax);
|
datos = Object.assign(datos, window.token_ajax);
|
||||||
|
|
||||||
// Si es inkjet, existe este check
|
// Si es inkjet, existe este check
|
||||||
if ($('#lp_bn_aFavorFibra').length) {
|
if ($('#' + linea + '_aFavorFibra').length) {
|
||||||
datos.a_favor_fibra = $('#lp_bn_aFavorFibra').prop('checked')
|
datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updatedTipologias && $('#lp_bn_gotaNegro').length) {
|
if (updatedTipologias && $('#' + linea + '_gotaNegro').length) {
|
||||||
datos.gota_negro = $('#lp_bn_gotaNegro').val()
|
datos.gota_negro = $('#' + linea + '_gotaNegro').val()
|
||||||
datos.gota_color = $('#lp_bn_gotaColor').val()
|
datos.gota_color = $('#' + linea + '_gotaColor').val()
|
||||||
datos.negro = $('#lp_bn_cobNegro').val()
|
datos.negro = $('#' + linea + '_cobNegro').val()
|
||||||
datos.cyan = $('#lp_bn_cobCyan').val()
|
datos.cyan = $('#' + linea + '_cobCyan').val()
|
||||||
datos.magenta = $('#lp_bn_cobMagenta').val()
|
datos.magenta = $('#' + linea + '_cobMagenta').val()
|
||||||
datos.amarillo = $('#lp_bn_cobAmarillo').val()
|
datos.amarillo = $('#' + linea + '_cobAmarillo').val()
|
||||||
if ($('#lp_bn_cobCG').length) {
|
if ($('#' + linea + '_cobCG').length) {
|
||||||
datos.cg = $('#lp_bn_cobCG').val()
|
datos.cg = $('#' + linea + '_cobCG').val()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1175,7 +1394,7 @@ class LineasPresupuesto {
|
|||||||
papel_impresion_id: row.papelImpresionId,
|
papel_impresion_id: row.papelImpresionId,
|
||||||
maquina_id: row.maquinaId,
|
maquina_id: row.maquinaId,
|
||||||
}
|
}
|
||||||
this.obtenerLinea(linea, fromComparator, input_data)
|
this.obtenerLinea(linea, fromComparator, false, input_data)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Se guarda el estado de "ver calculos"
|
// Se guarda el estado de "ver calculos"
|
||||||
@ -1212,7 +1431,7 @@ class LineasPresupuesto {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Si existe cubierta, hay que actualizar con el valor del lomo
|
// Si existe cubierta, hay que actualizar con el valor del lomo
|
||||||
if (this.table.row('#lp_cubierta').length > 0) {
|
if (linea != 'lp_cubierta' && linea != 'lp_sobrecubierta' && this.table.row('#lp_cubierta').length > 0) {
|
||||||
this.obtenerLinea('lp_cubierta', false, false);
|
this.obtenerLinea('lp_cubierta', false, false);
|
||||||
}
|
}
|
||||||
if (mostrar_calculos) {
|
if (mostrar_calculos) {
|
||||||
@ -1321,7 +1540,7 @@ class LineasPresupuesto {
|
|||||||
uso_tarifa: uso == 'rotativa' ? 'interior' : uso,
|
uso_tarifa: uso == 'rotativa' ? 'interior' : uso,
|
||||||
is_rotativa: () => tipoLinea.includes('rot') ? 1 : 0,
|
is_rotativa: () => tipoLinea.includes('rot') ? 1 : 0,
|
||||||
lomo_redondo: () => (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) ? $('#compLomoRedondo').val() : 0,
|
lomo_redondo: () => (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) ? $('#compLomoRedondo').val() : 0,
|
||||||
lomo: () => uso == 'sobrecubierta' ? this.getLomoCubierta() : this.getLomoInterior(),
|
lomo: () => uso == 'sobrecubierta' ? this.getLomoCubierta() + this.getLomoInterior() : this.getLomoInterior(),
|
||||||
}, $('body'));
|
}, $('body'));
|
||||||
maquinas.init();
|
maquinas.init();
|
||||||
|
|
||||||
@ -1346,12 +1565,12 @@ class LineasPresupuesto {
|
|||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$('#' + tipoLinea + '_vercalculos').on("click", () => self.verCalculosInkjet(tipoLinea));
|
$('#' + tipoLinea + '_vercalculos').on("click", () => self.verCalculosInkjet(tipoLinea));
|
||||||
/* TO-DO
|
|
||||||
if (isInkjet) {
|
if (isInkjet) {
|
||||||
$('.' + tipoLinea + '-tipologia').on("change", change_lp_bn_tipologia);
|
$('.' + tipoLinea.replace('_', '-') + '-tipologia').on("change", () => { this.change_tipologia(tipoLinea); });
|
||||||
$('#' + tipoLinea + '_defecto').on("click", por_defecto_lp_bn);
|
$('#' + tipoLinea + '_defecto').on("click", () => { this.lp_por_defecto(tipoLinea); });
|
||||||
$('#' + tipoLinea + '_aFavorFibra').on("change", change_lp_bn_aFavorFibra);
|
$('#' + tipoLinea + '_aFavorFibra').on("change", () => { this.change_aFavorFibra(tipoLinea); });
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1361,7 +1580,175 @@ class LineasPresupuesto {
|
|||||||
else {
|
else {
|
||||||
$(".calculos_" + linea).css('display', 'none')
|
$(".calculos_" + linea).css('display', 'none')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
change_aFavorFibra(linea) {
|
||||||
|
|
||||||
|
let paginas_ok = true;
|
||||||
|
|
||||||
|
if (linea.includes('lp_bn') || linea.includes('lp_color') || linea.includes('lp_rot')) {
|
||||||
|
paginas_ok = parseInt($('#' + linea + '_paginas').val()) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paginas_ok &&
|
||||||
|
parseInt($('#' + linea + '_papel option:selected').val()) > 0 &&
|
||||||
|
$('#' + linea + '_gramaje option:selected').text().length > 0 &&
|
||||||
|
parseInt($('#' + linea + '_papelImpresion option:selected').val()) > 0
|
||||||
|
) {
|
||||||
|
var rowData = this.table.row('#' + linea).data()
|
||||||
|
rowData.aFavorFibra = $('#' + linea + '_aFavorFibra').prop('checked')
|
||||||
|
this.table.row('#' + linea).data(rowData).draw(false)
|
||||||
|
|
||||||
|
this.obtenerLinea(linea, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
change_tipologia(linea) {
|
||||||
|
|
||||||
|
let paginas_ok = true;
|
||||||
|
|
||||||
|
if (linea.includes('lp_bn') || linea.includes('lp_color') || linea.includes('lp_rot')) {
|
||||||
|
paginas_ok = parseInt($('#' + linea + '_paginas').val()) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paginas_ok &&
|
||||||
|
parseInt($('#' + linea + '_papel option:selected').val()) > 0 &&
|
||||||
|
$('#' + linea + '_gramaje option:selected').text().length > 0 &&
|
||||||
|
parseInt($('#' + linea + '_papelImpresion option:selected').val()) > 0
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.obtenerLinea(linea, false, true, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lp_por_defecto(linea) {
|
||||||
|
|
||||||
|
let paginas_ok = true;
|
||||||
|
|
||||||
|
if (linea.includes('lp_bn') || linea.includes('lp_color') || linea.includes('lp_rot')) {
|
||||||
|
paginas_ok = parseInt($('#' + linea + '_paginas').val()) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paginas_ok &&
|
||||||
|
parseInt($('#' + linea + '_papel option:selected').val()) > 0 &&
|
||||||
|
$('#' + linea + '_gramaje option:selected').text().length > 0 &&
|
||||||
|
parseInt($('#' + linea + '_papelImpresion option:selected').val()) > 0
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.obtenerLinea(linea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#insertarLineaComparador(e) {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
if (e.target.id.includes("Plana") || e.target.id.includes("Rotativa")) {
|
||||||
|
|
||||||
|
for (let i = self.table.rows().data().length - 1; i >= 0; i--) {
|
||||||
|
let row = self.table.row(i).data();
|
||||||
|
|
||||||
|
if (row.row_id.includes('lp_bn') || row.row_id.includes('lp_color') || row.row_id.includes('lp_rot')) {
|
||||||
|
self.table.row(i).remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.table.draw();
|
||||||
|
|
||||||
|
|
||||||
|
if (e.target.id.includes("Plana")) {
|
||||||
|
|
||||||
|
var rows = $("#tableCompIntPlana").DataTable().rows('.selected').data().toArray();
|
||||||
|
|
||||||
|
for (const row of rows) {
|
||||||
|
if (row['tipo'] == 'bn') {
|
||||||
|
this.rellenarDatosLinea('lp_bn', row, true);
|
||||||
|
}
|
||||||
|
else if (row['tipo'] == 'bnhq') {
|
||||||
|
this.rellenarDatosLinea('lp_bnhq', row, true);
|
||||||
|
}
|
||||||
|
else if (row['tipo'] == 'color') {
|
||||||
|
this.rellenarDatosLinea('lp_color', row, true);
|
||||||
|
}
|
||||||
|
else if (row['tipo'] == 'colorhq') {
|
||||||
|
this.rellenarDatosLinea('lp_colorhq', row, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (e.target.id.includes("Rotativa")) {
|
||||||
|
|
||||||
|
var rows = $("#tableCompIntRotativa").DataTable().rows('.selected').data().toArray();
|
||||||
|
for (const row of rows) {
|
||||||
|
if (row['paginasColor'] == 0) {
|
||||||
|
this.rellenarDatosLinea('lp_rot_bn', row, true);
|
||||||
|
}
|
||||||
|
else if (row['paginasColor'] > 0) {
|
||||||
|
this.rellenarDatosLinea('lp_rot_color', row, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.target.id.includes("Cubierta")) {
|
||||||
|
|
||||||
|
for (let i = self.table.rows().data().length - 1; i >= 0; i--) {
|
||||||
|
let row = self.table.row(i).data(); // Obtener datos de la fila actual
|
||||||
|
|
||||||
|
if (row.row_id.includes('lp_cubierta') || row.row_id.includes('lp_sobrecubierta')) {
|
||||||
|
self.table.row(i).remove(); // Eliminar fila
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.table.draw();
|
||||||
|
|
||||||
|
|
||||||
|
var rows = $("#tableCompCubierta").DataTable().rows('.selected').data().toArray();
|
||||||
|
for (const row of rows) {
|
||||||
|
if (row.tipo == 'cubierta') {
|
||||||
|
this.rellenarDatosLinea('lp_cubierta', row, true);
|
||||||
|
/* TO-DO
|
||||||
|
if ($('#acabado_cubierta_id').val() > 0)
|
||||||
|
insertar_acabado_exterior($('#acabado_cubierta_id').val(), window.Presupuestos.cubierta)
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
if (row.tipo == 'sobrecubierta') {
|
||||||
|
this.rellenarDatosLinea('lp_sobrecubierta', row, true);
|
||||||
|
/* TO-DO
|
||||||
|
if ($('#acabado_sobrecubierta_id').val() > 0)
|
||||||
|
insertar_acabado_exterior($('#acabado_sobrecubierta_id').val(), window.Presupuestos.sobrecubierta)
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.target.id.includes("Guardas")) {
|
||||||
|
|
||||||
|
self.table.rows().data().toArray().forEach((row, index) => {
|
||||||
|
const rowIdx = self.table.row(index).index(); // Obtener el índice actual de la fila
|
||||||
|
if (row.row_id.includes('lp_guardas')) {
|
||||||
|
self.table.row(rowIdx).remove(); // Eliminar fila por índice
|
||||||
|
}
|
||||||
|
});
|
||||||
|
self.table.draw();
|
||||||
|
|
||||||
|
var rows = $("#tableCompGuardas").DataTable().rows('.selected').data().toArray();
|
||||||
|
for (const row of rows) {
|
||||||
|
this.rellenarDatosLinea('lp_guardas', row, true);
|
||||||
|
}
|
||||||
|
/* TO-DO
|
||||||
|
servicioGuardas(true)
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TO-DO
|
||||||
|
updatePresupuesto({
|
||||||
|
update_lineas: false,
|
||||||
|
update_servicios: true,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LineasPresupuesto;
|
export default LineasPresupuesto;
|
||||||
Reference in New Issue
Block a user