mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
arreglados problemas al confirmar con direcciones. También se ha arreglado un problema al generar el resumen
This commit is contained in:
@ -974,13 +974,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['info']['guardas']);
|
||||
|
||||
// Servicios
|
||||
if (intval($sobrecubierta['acabado']) > 0) {
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$servicio = $model->getPrecioTarifa(intval($sobrecubierta['acabado']), intval($selected_tirada), -1, $POD);
|
||||
if ($sobrecubierta) {
|
||||
if (intval($sobrecubierta['acabado']) > 0) {
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$servicio = $model->getPrecioTarifa(intval($sobrecubierta['acabado']), intval($selected_tirada), -1, $POD);
|
||||
|
||||
if (count($servicio) > 0) {
|
||||
if ($servicio[0]->total > 0) {
|
||||
$this->guardarServicio($id, $servicio[0], 'acabado', false, true);
|
||||
if (count($servicio) > 0) {
|
||||
if ($servicio[0]->total > 0) {
|
||||
$this->guardarServicio($id, $servicio[0], 'acabado', false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2431,16 +2433,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
foreach ($data as $linea) {
|
||||
if ($linea->tipo == 'lp_bn' || $linea->tipo == 'lp_bnhq' || $linea->tipo == 'lp_rot_bn') {
|
||||
$return_data['interior']['negro']['tipo'] = $linea->tipo == 'lp_bn' || $linea->tipo == 'lp_rot_bn' ? 'negroEstandar' : 'negroPremium';
|
||||
$return_data['interior']['negro']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['interior']['negro']['papel'] = $modelPapelGenerico->getNombre($linea->papel_id);
|
||||
$return_data['interior']['negro']['papel']['id'] = $linea->papel_id;
|
||||
$return_data['interior']['negro']['gramaje'] = $linea->gramaje;
|
||||
} else if ($linea->tipo == 'lp_color' || $linea->tipo == 'lp_colorhq' || $linea->tipo == 'lp_rot_color') {
|
||||
$return_data['interior']['color']['tipo'] = $linea->tipo == 'lp_color' || $linea->tipo == 'lp_rot_color' ? 'colorEstandar' : 'colorPremium';
|
||||
$return_data['interior']['color']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['interior']['color']['papel'] = $modelPapelGenerico->getNombre($linea->papel_id);
|
||||
$return_data['interior']['color']['papel']['id'] = $linea->papel_id;
|
||||
$return_data['interior']['color']['gramaje'] = $linea->gramaje;
|
||||
} else if ($linea->tipo == 'lp_cubierta') {
|
||||
$return_data['cubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['cubierta']['papel'] = $modelPapelGenerico->getNombre($linea->papel_id);
|
||||
$return_data['cubierta']['papel']['id'] = $linea->papel_id;
|
||||
$return_data['cubierta']['gramaje'] = $linea->gramaje;
|
||||
$return_data['cubierta']['paginas'] = $linea->paginas;
|
||||
@ -2449,7 +2451,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$return_data['sobrecubierta']['gramaje'] = $linea->gramaje;
|
||||
$return_data['sobrecubierta']['paginas'] = $linea->paginas;
|
||||
} else if ($linea->tipo == 'lp_guardas') {
|
||||
$return_data['guardas']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['guardas']['papel'] = $modelPapelGenerico->getNombre($linea->papel_id);
|
||||
$return_data['guardas']['gramaje'] = $linea->gramaje;
|
||||
$return_data['guardas']['paginas'] = $linea->paginas;
|
||||
}
|
||||
|
||||
@ -94,6 +94,20 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getNombre($id = 0)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.nombre AS nombre"
|
||||
)
|
||||
->where("t1.id", $id)
|
||||
->where("t1.is_deleted", 0);
|
||||
$data = $builder->get()->getFirstRow();
|
||||
// se convierte a de stdClass a array
|
||||
$data = json_decode(json_encode($data), true);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<div id="loader" class="modal modal-transparent" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||
<div id="loader" class="modal modal-transparent" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" inert>
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
|
||||
@ -4,7 +4,7 @@ class tarjetaDireccion {
|
||||
|
||||
this.container = container;
|
||||
this.id = id;
|
||||
this.direccionId = direccion.direccionId;
|
||||
this.direccionId = direccion.id;
|
||||
this.card = this.#generateHTML(id, direccion);
|
||||
this.deleteBtn = this.card.find('.direccion-eliminar');
|
||||
this.editBtn = this.card.find('.direccion-editar');
|
||||
|
||||
@ -134,6 +134,10 @@ class DisenioCubierta {
|
||||
this.gramaje = null;
|
||||
|
||||
this.cargando = true;
|
||||
|
||||
this.presupuestoConfirmado = false;
|
||||
this.papelForResumen = "";
|
||||
this.gramajeForResumen = "";
|
||||
}
|
||||
|
||||
|
||||
@ -487,6 +491,9 @@ class DisenioCubierta {
|
||||
getPapel(forResumen = false) {
|
||||
|
||||
try {
|
||||
if (this.presupuestoConfirmado)
|
||||
return this.papelForResumen;
|
||||
|
||||
let checkedPapel = $('.custom-selector-papel-cubierta input[type="radio"]:checked');
|
||||
if (this.papelCubierta != null && checkedPapel != null && checkedPapel.length > 0) {
|
||||
if (forResumen) {
|
||||
@ -523,9 +530,12 @@ class DisenioCubierta {
|
||||
|
||||
try {
|
||||
|
||||
if (checkedGramaje.length == 0)
|
||||
return null;
|
||||
return checkedGramaje[0].id.split('_')[1];
|
||||
if (this.presupuestoConfirmado)
|
||||
return this.gramajeForResumen;
|
||||
|
||||
if (checkedGramaje.length == 0)
|
||||
return null;
|
||||
return checkedGramaje[0].id.split('_')[1];
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
@ -535,7 +545,7 @@ class DisenioCubierta {
|
||||
try {
|
||||
let acabado;
|
||||
if (forResumen) {
|
||||
acabado = 'Acabado: ' + this.acabadoCubierta.getText();
|
||||
acabado = this.acabadoCubierta.getText();
|
||||
}
|
||||
else {
|
||||
acabado = this.acabadoCubierta.getVal();
|
||||
@ -605,7 +615,7 @@ class DisenioCubierta {
|
||||
sobrecubierta.papel = papel.split(' ')[0] + ' ' + papel.split(' ')[1];
|
||||
sobrecubierta.gramaje = papel.split(' ')[2];
|
||||
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
|
||||
sobrecubierta.acabado = 'Acabado: ' + this.acabadoSobrecubierta.getText();
|
||||
sobrecubierta.acabado = this.acabadoSobrecubierta.getText();
|
||||
return sobrecubierta;
|
||||
}
|
||||
else {
|
||||
@ -873,20 +883,20 @@ class DisenioCubierta {
|
||||
const element = $(event.target);
|
||||
const papel = element[0].id.split('_')[1];
|
||||
this.papelCubierta = papel;
|
||||
|
||||
|
||||
$('#' + papel).prop('checked', true);
|
||||
|
||||
|
||||
if (element[0].id == 'papelEspecialCubierta') {
|
||||
|
||||
if(!this.cargando)
|
||||
if (!this.cargando)
|
||||
this.gramaje = null;
|
||||
this.divGramajeCubierta.empty();
|
||||
this.divPapelEspecial.removeClass("d-none");
|
||||
$('#papelEspecialCubiertaSel').off("change");
|
||||
this.papelEspecial.empty();
|
||||
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -79,9 +79,13 @@ class DisenioInterior {
|
||||
|
||||
this.cargando = true;
|
||||
|
||||
this.presupuestoConfirmado = false;
|
||||
this.papelNegroForResumen = "";
|
||||
this.gramajeNegroForResumen = "";
|
||||
this.papelColorForResumen = "";
|
||||
this.gramajeColorForResumen = "";
|
||||
|
||||
this.initValidation();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -350,7 +354,7 @@ class DisenioInterior {
|
||||
this.gramaje = datos.negro.gramaje;
|
||||
}
|
||||
}
|
||||
if(datos.paginasColorConsecutivas)
|
||||
if (datos.paginasColorConsecutivas)
|
||||
this.updatePapeles();
|
||||
else
|
||||
this.updatePapeles('negro');
|
||||
@ -666,6 +670,21 @@ class DisenioInterior {
|
||||
getPapel(forResumen = false) {
|
||||
|
||||
try {
|
||||
if (this.presupuestoConfirmado) {
|
||||
if (this.papelColorForResumen.length > 0 && this.papelNegroForResumen.length > 0)
|
||||
return {
|
||||
negro: this.papelNegroForResumen,
|
||||
color: this.papelColorForResumen
|
||||
}
|
||||
|
||||
else if (this.papelColorForResumen.length > 0) {
|
||||
return this.papelColorForResumen;
|
||||
}
|
||||
else {
|
||||
return this.papelNegroForResumen;
|
||||
}
|
||||
}
|
||||
|
||||
let checkedPapel = $('.custom-selector-papel input[type="radio"]:checked');
|
||||
|
||||
if (this.papelInterior != null && checkedPapel != null && checkedPapel.length > 0) {
|
||||
@ -748,6 +767,22 @@ class DisenioInterior {
|
||||
getGramaje() {
|
||||
|
||||
try {
|
||||
|
||||
if (this.presupuestoConfirmado) {
|
||||
if (this.gramajeColorForResumen.length > 0 && this.gramajeNegroForResumen.length > 0)
|
||||
return {
|
||||
negro: this.gramajeNegroForResumen,
|
||||
color: this.gramajeColorForResumen
|
||||
}
|
||||
|
||||
else if (this.gramajeColorForResumen.length > 0) {
|
||||
return this.gramajeColorForResumen;
|
||||
}
|
||||
else {
|
||||
return this.gramajeNegroForResumen;
|
||||
}
|
||||
}
|
||||
|
||||
let checkedGramaje = $('.custom-selector-gramaje input[type="radio"]:checked');
|
||||
|
||||
if (this.interiorColor.filter('.d-none').length == 0) {
|
||||
@ -830,14 +865,14 @@ class DisenioInterior {
|
||||
const element = $(event.target);
|
||||
const papel = element[0].id.split('_')[1];
|
||||
this.papelInterior = papel;
|
||||
|
||||
|
||||
$('#' + papel).prop('checked', true);
|
||||
|
||||
let tipo = this.getTipoImpresion();
|
||||
|
||||
if (element[0].id == 'papelEspecialInterior') {
|
||||
|
||||
if(!this.cargando)
|
||||
if (!this.cargando)
|
||||
this.gramaje = null;
|
||||
this.divGramajeInterior.empty();
|
||||
this.divPapelEspecialInterior.removeClass("d-none");
|
||||
|
||||
@ -415,13 +415,17 @@ class PresupuestoCliente {
|
||||
#confirmPresupuesto() {
|
||||
|
||||
let total_unidades = 0;
|
||||
this.direcciones.direcciones.forEach(element => {
|
||||
total_unidades += parseInt(element.tirada.val());
|
||||
});
|
||||
if (!this.direcciones.recogidaTaller.is(':checked')) {
|
||||
|
||||
if (total_unidades != parseInt(this.direcciones.getSelectedTirada())) {
|
||||
popErrorAlert("No se puede confirmar el presupuesto. La suma de las unidades enviadas no coincide con la tirada seleccionada.");
|
||||
return;
|
||||
this.direcciones.direcciones.forEach(element => {
|
||||
total_unidades += parseInt(element.getUnidades());
|
||||
});
|
||||
|
||||
|
||||
if (total_unidades != parseInt(this.direcciones.getSelectedTirada())) {
|
||||
popErrorAlert("No se puede confirmar el presupuesto. La suma de las unidades enviadas no coincide con la tirada seleccionada.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.#solicitudGuardarPresupuesto(true);
|
||||
@ -715,6 +719,8 @@ class PresupuestoCliente {
|
||||
|
||||
#cargarPresupuesto() {
|
||||
|
||||
const self = this;
|
||||
|
||||
$('#loader').modal('show');
|
||||
let id = window.location.href.split("/").pop()
|
||||
new Ajax('/presupuestocliente/cargar/' + id,
|
||||
@ -724,18 +730,18 @@ class PresupuestoCliente {
|
||||
|
||||
if (response.status === 1) {
|
||||
|
||||
this.lc.val(parseFloat(response.data.lc).toFixed(2));
|
||||
this.lsc.val(parseFloat(response.data.lsc).toFixed(2));
|
||||
self.lc.val(parseFloat(response.data.lc).toFixed(2));
|
||||
self.lsc.val(parseFloat(response.data.lsc).toFixed(2));
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
self.calcularPresupuesto = false;
|
||||
|
||||
this.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
this.direcciones.handleChangeCliente();
|
||||
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
self.direcciones.handleChangeCliente();
|
||||
|
||||
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||
|
||||
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||
self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
@ -744,14 +750,28 @@ class PresupuestoCliente {
|
||||
|
||||
if (response.data.state != 2) {
|
||||
|
||||
this.calcularPresupuesto = true;
|
||||
this.checkForm({ target: { id: 'tirada' } });
|
||||
self.calcularPresupuesto = true;
|
||||
self.checkForm({ target: { id: 'tirada' } });
|
||||
}
|
||||
else {
|
||||
self.disenioInterior.presupuestoConfirmado = true;
|
||||
if (response.data.interior.negro) {
|
||||
self.disenioInterior.papelNegroForResumen = response.data.interior.negro.papel.nombre;
|
||||
self.disenioInterior.gramajeNegroForResumen = response.data.interior.negro.gramaje;
|
||||
}
|
||||
if (response.data.interior.color) {
|
||||
self.disenioInterior.papelColorForResumen = response.data.interior.color.nombre;
|
||||
self.disenioInterior.gramajeColorForResumen = response.data.interior.color.gramaje;
|
||||
}
|
||||
|
||||
self.disenioCubierta.presupuestoConfirmado = true;
|
||||
self.disenioCubierta.papelForResumen = response.data.cubierta.papel.nombre;
|
||||
self.disenioCubierta.gramajeForResumen = response.data.cubierta.gramaje;
|
||||
|
||||
$('#menu_resumen_button').trigger('click');
|
||||
setTimeout(() => {
|
||||
this.resumen.init_dropzone();
|
||||
this.resumen.generate_total(response.data.resumen.base, response.data.resumen.precio_unidad);
|
||||
self.resumen.init_dropzone();
|
||||
self.resumen.generate_total(response.data.resumen.base, response.data.resumen.precio_unidad);
|
||||
}, 0);
|
||||
}
|
||||
}, 0);
|
||||
|
||||
@ -290,7 +290,7 @@ class Resumen {
|
||||
this.papelSobrecubierta.text(sobrecubierta.papel);
|
||||
this.gramajeSobrecubierta.text(sobrecubierta.gramaje);
|
||||
this.solapasSobrecubierta.text(sobrecubierta.solapas);
|
||||
this.plastificadoSobrecubierta.text(sobrecubierta.plastificado);
|
||||
this.plastificadoSobrecubierta.text(sobrecubierta.acabado);
|
||||
}
|
||||
else {
|
||||
this.divSobrecubierta.addClass('d-none');
|
||||
|
||||
Reference in New Issue
Block a user