mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajadno en guardar
This commit is contained in:
@ -0,0 +1,75 @@
|
||||
import ClassSelect from '../../components/select2.js';
|
||||
import Ajax from '../../components/ajax.js';
|
||||
|
||||
class PresupuestoAdminAdd{
|
||||
|
||||
constructor(){
|
||||
|
||||
this.inc_rei = $('#incRei');
|
||||
this.cliente = new ClassSelect($('#clienteId'), '/clientes/cliente/getSelect2', 'Seleccione cliente');
|
||||
this.pais = new ClassSelect($('#paisId'), '/paises/menuitems2', 'Seleccione País');
|
||||
|
||||
$('#solapas').addClass('d-none');
|
||||
$('#solapas_sobrecubierta').addClass('d-none');
|
||||
$('#div_solapas_ancho').addClass('d-none');
|
||||
$('#div_solapas_ancho_sobrecubierta').addClass('d-none');
|
||||
|
||||
this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language.Presupuestos.formatoLibro);
|
||||
this.tamanioPersonalizado = $('#papelFormatoPersonalizado');
|
||||
this.anchoPersonalizado = $('#papelFormatoAncho');
|
||||
this.altoPersonalizado = $('#papelFormatoAlto');
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
init(){
|
||||
|
||||
this.cliente.init();
|
||||
this.pais.init();
|
||||
|
||||
this.tamanio.init();
|
||||
|
||||
this.inc_rei.select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this));
|
||||
}
|
||||
|
||||
changeTipoTamanio() {
|
||||
|
||||
if (this.tamanioPersonalizado.prop('checked')) {
|
||||
$('.tamanio-personalizado').removeClass('d-none');
|
||||
$('.tamanio-estandar').addClass('d-none');
|
||||
this.tamanio.setVal('');
|
||||
$("#label_papelFormatoId").text(
|
||||
window.language.Presupuestos.papelFormatoId + " (" +
|
||||
window.language.Presupuestos.papelFormatoAncho + " x " + window.language.Presupuestos.papelFormatoAncho + ")*");
|
||||
}
|
||||
else {
|
||||
this.anchoPersonalizado.val("");
|
||||
this.altoPersonalizado.val("");
|
||||
$('.tamanio-personalizado').addClass('d-none');
|
||||
$('.tamanio-estandar').removeClass('d-none');
|
||||
$("#label_papelFormatoId").text(
|
||||
window.language.Presupuestos.papelFormatoId + '*');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
|
||||
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Presupuestos', 'PresupuestosDirecciones'] }, {},
|
||||
function (translations) {
|
||||
window.language = JSON.parse(translations);
|
||||
new PresupuestoAdminAdd().init();
|
||||
},
|
||||
function (error) {
|
||||
console.log("Error getting translations:", error);
|
||||
}
|
||||
).post();
|
||||
});
|
||||
@ -118,13 +118,95 @@ class PresupuestoAdminEdit {
|
||||
|
||||
async guardarPresupuesto() {
|
||||
|
||||
await this.servicios.guardar();
|
||||
await this.envios.guardarEnvios();
|
||||
await this.lineasPresupuesto.guardarLineasPresupuesto();
|
||||
$('#loader').modal('show');
|
||||
|
||||
try {
|
||||
|
||||
let formData = $('#presupuestoForm').serialize()
|
||||
|
||||
await this.servicios.guardar();
|
||||
await this.envios.guardarEnvios();
|
||||
await this.lineasPresupuesto.guardarLineasPresupuesto();
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
$('#loader').modal('hide');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getFormData() {
|
||||
|
||||
let datos = {};
|
||||
|
||||
datos.id = window.location.href.split("/").pop();
|
||||
datos.cliente_id = this.datosGenerales.cliente.getVal();
|
||||
datos.tipo_impresion_id = this.tipo_impresion.val();
|
||||
|
||||
datos = {
|
||||
...datos, ...{
|
||||
inc_rei = this.datosGenerales.inc_rei.val();
|
||||
titulo: this.datosGenerales.titulo.val(),
|
||||
autor: this.datosGenerales.autor.val(),
|
||||
isbn: this.datosGenerales.isbn.val(),
|
||||
coleccion: this.datosGenerales.coleccion.val(),
|
||||
numero_edicion: this.datosGenerales.numeroEdicion.val(),
|
||||
referencia_cliente: this.datosGenerales.referenciaCliente.val(),
|
||||
updated_at: new Date().toISOString().slice(0, 19).replace('T', ' '),
|
||||
}
|
||||
}
|
||||
|
||||
datos = {
|
||||
...datos, ...{
|
||||
paginas: this.datosLibro.paginas.val(),
|
||||
tirada: this.datosLibro.tirada.val(),
|
||||
papel_formato_id: this.datosLibro.papelFormatoId.hasClass('d-none') ? 0 : this.datosLibro.papelFormatoId.val(),
|
||||
/////////////////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
datos.selectedTirada = this.datosLibro.tirada.val();
|
||||
|
||||
datos.servicios = {
|
||||
'prototipo': this.datosLibro.prototipo.is(':checked') ? 1 : 0,
|
||||
'ferro': this.datosLibro.ferro.is(':checked') ? 1 : 0,
|
||||
'ferroDigital': this.datosLibro.ferroDigital.is(':checked') ? 1 : 0,
|
||||
'marcapaginas': this.datosLibro.marcapaginas.is(':checked') ? 1 : 0,
|
||||
'retractilado': this.datosLibro.retractilado.is(':checked') ? 1 : 0,
|
||||
'retractilado5': this.datosLibro.retractilado5.is(':checked') ? 1 : 0,
|
||||
};
|
||||
|
||||
if (this.comparador.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) {
|
||||
datos.lomoRedondo = this.comparador.lomoRedondo.select2('data')[0].id;
|
||||
}
|
||||
else {
|
||||
datos.lomoRedondo = 0;
|
||||
}
|
||||
|
||||
this.datos.entrega_taller = this.envios.entrega_taller.is(':checked') ? 1 : 0;
|
||||
if (parseInt(this.cosido.val())) {
|
||||
|
||||
let paginas_por_cuadernillo = "";
|
||||
|
||||
this.servicios.ServiciosEncuadernacion.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
var rowData = this.data();
|
||||
if (rowData.paginas_por_cuadernillo != null) {
|
||||
paginas_por_cuadernillo = rowData.paginas_por_cuadernillo;
|
||||
}
|
||||
});
|
||||
|
||||
datos.paginas_por_cuadernillo = paginas_por_cuadernillo;
|
||||
}
|
||||
|
||||
datos.comentarios_cliente = $('#comentariosCliente').val();
|
||||
datos.comentarios_safekat = $('#comentariosSafekat').val();
|
||||
datos.comentarios_presupuesto = $('#comentariosPdf').val();
|
||||
datos.comentarios_produccion = $('#comentariosProduccion').val();
|
||||
|
||||
}
|
||||
|
||||
|
||||
async updatePresupuesto(event, {
|
||||
|
||||
update_lineas = true,
|
||||
update_servicios = true,
|
||||
update_envios = true,
|
||||
@ -244,7 +326,7 @@ class PresupuestoAdminEdit {
|
||||
cantidad_total += parseInt(rowData.paginas)
|
||||
})
|
||||
htmlString = ''
|
||||
|
||||
|
||||
if (cantidad_total != parseInt($('#paginas').val())) {
|
||||
htmlString = `
|
||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||
|
||||
@ -1468,125 +1468,6 @@ class Comparador {
|
||||
'tarifa_impresion_id': linea.fields.tarifa_impresion_id,
|
||||
}
|
||||
}
|
||||
|
||||
generateCompJSON() {
|
||||
|
||||
data = {}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
try {
|
||||
bn_obj = {
|
||||
"bn": {
|
||||
'paginas': $('#compPaginasNegro').val(),
|
||||
'papel_id': $('#compPapelNegro').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
bn_obj = {}
|
||||
}
|
||||
$.extend(data, bn_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
try {
|
||||
bnhq_obj = {
|
||||
"bnhq": {
|
||||
'paginas': $('#compPaginasNegrohq').val(),
|
||||
'papel_id': $('#compPapelNegrohq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
bnhq_obj = {}
|
||||
}
|
||||
$.extend(data, bnhq_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
try {
|
||||
color_obj = {
|
||||
"color": {
|
||||
'paginas': $('#compPaginasColor').val(),
|
||||
'papel_id': $('#compPapelColor').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
color_obj = {}
|
||||
}
|
||||
$.extend(data, color_obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
try {
|
||||
colorhq_obj = {
|
||||
"colorhq": {
|
||||
'paginas': $('#compPaginasColorhq').val(),
|
||||
'papel_id': $('#compPapelColorhq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
colorhq_obj = {}
|
||||
}
|
||||
$.extend(data, colorhq_obj);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
cubierta_obj = {
|
||||
"cubierta": {
|
||||
'paginas': $('#compCarasCubierta option:selected').val(),
|
||||
'papel_id': $('#compPapelCubierta').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
cubierta_obj = {}
|
||||
}
|
||||
$.extend(data, cubierta_obj);
|
||||
|
||||
try {
|
||||
sobrecubierta_obj = {
|
||||
"sobrecubierta": {
|
||||
'imprimir': $('#compSobrecubierta option:selected').val(),
|
||||
'papel_id': $('#compPapelSobrecubierta').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeSobrecubierta').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
sobrecubierta_obj = {}
|
||||
}
|
||||
$.extend(data, sobrecubierta_obj);
|
||||
|
||||
if ($('#compCarasGuardas').length > 0) {
|
||||
try {
|
||||
guardas_obj = {
|
||||
"guardas": {
|
||||
'paginas_impresion': $('#compCarasGuardas option:selected').val(),
|
||||
'papel_id': $('#compPapelGuardas').select2('data')[0].id,
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
guardas_obj = {}
|
||||
}
|
||||
$.extend(data, guardas_obj);
|
||||
|
||||
}
|
||||
|
||||
data_str = JSON.stringify(data)
|
||||
$('#comparador_json_data').val(data_str)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -135,6 +135,12 @@ class TiradasAlernativas {
|
||||
}
|
||||
}
|
||||
|
||||
generate_json_tiradas() {
|
||||
|
||||
const data = this.table.rows().data().toArray();
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
|
||||
|
||||
addTiradaAlt(tiradaExterna = null) {
|
||||
|
||||
|
||||
@ -769,7 +769,6 @@ class PresupuestoCliente {
|
||||
referenciaCliente: this.datosGenerales.referenciaCliente.val(),
|
||||
}
|
||||
this.datos.selectedTirada = this.direcciones.getSelectedTirada();
|
||||
this.datos
|
||||
}
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
|
||||
Reference in New Issue
Block a user