diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php
index a7f3d0be..ca33d1d6 100755
--- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php
+++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php
@@ -22,6 +22,7 @@ use App\Services\PresupuestoClienteService;
use App\Services\PresupuestoService;
use Exception;
+use stdClass;
use function PHPUnit\Framework\containsOnly;
@@ -718,6 +719,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$reqData = $this->request->getPost();
+ $POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
+
$id = $reqData['id'] ?? 0;
$id = intval($id);
@@ -932,23 +935,24 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if ($id != 0) {
$borrar_antes = true;
}
-
+ $sobrecubierta_acabado_id = [];
if ($datos_presupuesto['sobrecubierta']) {
- $acabado_id = $this->obtenerTarifasAcabado(['plastificado' => $datos_presupuesto['sobrecubierta']['acabados']]);
- if (count($acabado_id) > 0) {
- $datos_presupuesto['sobrecubierta']['acabados'] = $acabado_id[0];
+ $sobrecubierta_acabado_id = $this->obtenerTarifasAcabado(['plastificado' => $datos_presupuesto['sobrecubierta']['acabados']]);
+ if (count($sobrecubierta_acabado_id) > 0) {
+ // la sobrecubierta sólo tiene plastificado
+ $datos_presupuesto['sobrecubierta']['acabados'] = $sobrecubierta_acabado_id['plastificado'];
}
}
- $acabado_id = $this->obtenerTarifasAcabado($datos_presupuesto['cubierta']['acabadosCubierta']);
- if (count($acabado_id) > 0) {
- if (array_key_exists('plastificado', $acabado_id)) {
- $datos_presupuesto['cubierta']['acabadosCubierta']['plastificado'] = $acabado_id['plastificado'];
+ $cubierta_acabado_id = $this->obtenerTarifasAcabado($datos_presupuesto['cubierta']['acabadosCubierta']);
+ if (count($cubierta_acabado_id) > 0) {
+ if (array_key_exists('plastificado', $cubierta_acabado_id)) {
+ $datos_presupuesto['cubierta']['acabadosCubierta']['plastificado'] = $cubierta_acabado_id['plastificado'];
}
- if (array_key_exists('barniz', $acabado_id)) {
- $datos_presupuesto['cubierta']['acabadosCubierta']['barniz'] = $acabado_id['barniz'];
+ if (array_key_exists('barniz', $cubierta_acabado_id)) {
+ $datos_presupuesto['cubierta']['acabadosCubierta']['barniz'] = $cubierta_acabado_id['barniz'];
}
- if (array_key_exists('estampado', $acabado_id)) {
- $datos_presupuesto['cubierta']['acabadosCubierta']['estampado'] = $acabado_id['estampado'];
+ if (array_key_exists('estampado', $cubierta_acabado_id)) {
+ $datos_presupuesto['cubierta']['acabadosCubierta']['estampado'] = $cubierta_acabado_id['estampado'];
}
} else {
$datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0;
@@ -991,6 +995,27 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['info']['guardas']);
// Servicios
+ foreach ($sobrecubierta_acabado_id as $acabado) {
+ $model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
+ $servicio = $model->getPrecioTarifa($acabado, intval($selected_tirada), -1, $POD);
+
+ if (count($servicio) > 0) {
+ if ($servicio[0]->total > 0) {
+ $this->guardarServicio($id, $servicio[0], 'acabado', false, true);
+ }
+ }
+ }
+ foreach ($cubierta_acabado_id as $acabado) {
+ $model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
+ $servicio = $model->getPrecioTarifa($acabado, intval($selected_tirada), -1, $POD);
+
+ if (count($servicio) > 0) {
+ if ($servicio[0]->total > 0) {
+ $this->guardarServicio($id, $servicio[0], 'acabado', true, false);
+ }
+ }
+
+ }
foreach ($resultado_presupuesto['info']['serviciosDefecto'] as $servicio) {
$this->guardarServicio($id, $servicio, 'encuadernacion');
}
@@ -1311,7 +1336,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
- protected function guardarServicio($presupuestoId, $servicio, $tipo)
+ protected function guardarServicio($presupuestoId, $servicio, $tipo, $cubierta = false, $sobrecubierta = false)
{
if ($tipo == 'encuadernacion') {
@@ -1349,9 +1374,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$data = [
'presupuesto_id' => $presupuestoId,
'tarifa_acabado_id' => $servicio->tarifa_id,
- 'precio_total' => $servicio->total,
- 'precio_unidad' => $servicio->precio_unidad,
+ 'precio_total' => round($servicio->total, 2),
+ 'precio_unidad' => round($servicio->precio_unidad, 2),
'margen' => $servicio->margen,
+ 'proveedor_id' => $servicio->proveedor_id,
+ 'cubierta' => $cubierta,
+ 'sobrecubierta' => $sobrecubierta,
];
$model->insert($data);
} else if ($tipo == 'manipulado') {
@@ -1790,7 +1818,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
foreach ($tarifaAcabadoSobrecubierta as $tarifa) {
// NONE
- if ($tarifaAcabadoSobrecubierta[0] == 0)
+ if ($tarifa == 0)
continue;
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
$acabadoSobrecubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD);
@@ -2590,10 +2618,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if ($value != 'NONE') {
$data = $model->where('code', $value)->first();
- $data = $data->id;
- array_push($tarifas, [$acabado => $data]);
- } else {
- array_push($tarifas, 0);
+ $tarifas[$acabado] = $data->id;
}
}
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/direcciones.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/direcciones.js
deleted file mode 100644
index 5a264add..00000000
--- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/direcciones.js
+++ /dev/null
@@ -1,387 +0,0 @@
-function initDirecciones() {
- data = {
- id: $('#clienteId').val()
- },
- data = Object.assign(data, window.token_ajax);
- $('#errorDirecciones').hide();
-
- $.ajax({
- url: window.routes_direcciones.direcciones,
- type: 'POST',
- data: data,
- success: function(response) {
- $("#direcciones").empty();
- $.each(response.menu, function(index, value) {
- $("#direcciones").append('');
- });
- $("#direcciones").val('');
- },
- error: function() {
- $("#direcciones").empty();
- },
- });
-}
-
-function initTiradasDirecciones() {
- const _this = this
- let sel_index = 1;
-
- $('#containerTiradasEnvios').empty();
-
- for (i = 1; i <= 4; i++) {
- let id = "tiradaPrecio" + i;
- if ($('#' + id).length > 0) {
-
- let tirada_id = "ud_tiradaPrecio" + i;
- let total_id = "tot_tiradaPrecio" + i;
- let precio_u_id = "pu_tiradaPrecio" + i;
- let peso = $('#' + id).attr('peso');
-
- let html = '';
- html += '
';
- html += '
';
- html += '';
- html += '
';
- html += '
';
-
- $('#containerTiradasEnvios').append(html);
-
- if(parseInt($('#' + tirada_id).text().split(' ')[0]) == window.direcciones_sel_tirada){
- sel_index = i;
- }
-
- $('#' + id).hide();
- }
- }
- $(('#env_tiradaPrecio' + sel_index)).trigger('click');
-
- cargarDirecciones();
-
- const tiradasDireccionesList = [].slice.call(document.querySelectorAll('.custom-option-tiradasDirecciones .form-check-input'))
- tiradasDireccionesList.map(function (customOptionEL) {
- // Update custom options check on page load
- _this.updateTiradasDireccionesCheck(customOptionEL)
-
- // Update custom options check on click
- customOptionEL.addEventListener('click', e => {
- _this.updateTiradasDireccionesCheck(customOptionEL)
- })
- })
-}
-
-function cargarDirecciones(){
- $('#loader').show();
- $('#divDirecciones').empty();
-
- if(window.direcciones == null){
- $('#loader').hide();
- return;
- }
- for(let i=0; i';
- html += '';
- html += '';
-
- $('#divDirecciones').append(html);
- $('#errorDirecciones').hide();
- $('#loader').hide();
- }
-}
-
-function updateTiradasDireccionesCheck(el) {
- if (el.checked) {
- // If custom option element is radio, remove checked from the siblings (closest `.row`)
- if (el.type === 'radio') {
- const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-tiradasDirecciones'))
- customRadioOptionList.map(function (customRadioOptionEL) {
- customRadioOptionEL.closest('.custom-option-tiradasDirecciones').classList.remove('checked')
- let id_temp = customRadioOptionEL.id.split('-')[1];
- $('#' + id_temp).prop('checked', false);
- })
- }
- const element = el.closest('.custom-option-tiradasDirecciones');
- element.classList.add('checked');
-
- let id = element.id.split('-')[1];
- $('#' + id).prop('checked', true);
-
- } else {
- el.closest('.custom-option-tiradasDirecciones').classList.remove('checked')
- }
-}
-
-
-function obtenerUnidadesEnvio(){
-
- const elements = $('#divDirecciones').find('.row.mb-3');
- let total = 0;
-
- if(elements.length > 0) {
- for (let index=0; index 0 ) {
-
- let unidades = $('#unidadesEnvio').val();
- if(unidades == '' || isNaN(unidades) || parseInt(unidades) <= 0){
- return false;
- }
- unidades = parseInt(unidades);
-
- const seleccion = $('.custom-option-tiradasDirecciones.checked');
- if(seleccion.length == 0) {
- return false;
- }
-
- const element_tirada =($(seleccion[0]).find('label input')[0]);
- const number = element_tirada.id.match(/\d+$/);
- if (number.length == 0) {
- return false;
- }
- let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
-
- let total = obtenerUnidadesEnvio();
-
- if($('#prototipo').is(':checked')) {
- tirada += 1;
- }
-
- if(total + unidades <= tirada) {
-
- data = {
- id: $('#direcciones').val(),
- peso: $('#env_tiradaPrecio' + number[0]).attr('peso'),
- unidades: unidades,
- entregaPieCalle: $('#entregaPieCalle').is(':checked')?1:0,
- },
- data = Object.assign(data, window.token_ajax)
-
- $('#loader').show();
-
- $.ajax({
- url: window.routes_direcciones.getDatos,
- type: 'POST',
- data: data,
- success: function(response) {
- if(response.data.length > 0) {
- let html = '';
- html += '';
- html += '
';
- html += '
';
-
- $('#divDirecciones').append(html);
- $('#errorDirecciones').hide();
- $('#loader').hide();
- }
- },
- error: function() {
- $("#direcciones").empty();
- $('#loader').hide();
- },
- });
- }
- else{
- $('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
- $('#errorDirecciones').show();
- }
- }
- return false;
-})
-
-
-
-$(document).on('click', '.eliminar-direccion', function(e) {
-
- $(this).closest('.row.mb-3').remove();
-
- const seleccion = $('.custom-option-tiradasDirecciones.checked');
- if(seleccion.length == 0) {
- return false;
- }
-
- const element_tirada =($(seleccion[0]).find('label input')[0]);
- const number = element_tirada.id.match(/\d+$/);
- if (number.length == 0) {
- return false;
- }
-
- let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
-
- const elements = $('#divDirecciones').find('.row.mb-3');
-
- let total = 0;
- if(elements.length > 0) {
- for (let index=0; index' + value.text + '');
- });
- $("#direcciones").val('');
- $('#addressForm').modal('hide');
- },
- error: function() {
- $('#addressForm').modal('hide');
- },
- });
-
- }
-}
-
-function validarEnvio(){
-
- const seleccion = $('.custom-option-tiradasDirecciones.checked');
- if(seleccion.length == 0) {
- return false;
- }
-
- const element_tirada =($(seleccion[0]).find('label input')[0]);
-
- const number = element_tirada.id.match(/\d+$/);
- if (number.length == 0) {
- return false;
- }
- let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
-
- let total = obtenerUnidadesEnvio();
-
- if($('#prototipo').is(':checked')) {
- tirada += 1;
- }
-
- if(total != tirada){
- return false;
- }
- return true;
-}
-
-function getDireccionesEnvio(){
-
- const elements = $('#divDirecciones').find('.row.mb-3');
-
- let direcciones = [];
-
- if(elements.length > 0) {
- for (let index=0; index {
- _this.updateTapaCheck(customOptionEL)
- })
- })
-}
-
-function updateTapaCheck(el) {
- if (el.checked) {
- // If custom option element is radio, remove checked from the siblings (closest `.row`)
- if (el.type === 'radio') {
- const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-tapa'))
- customRadioOptionList.map(function (customRadioOptionEL) {
- customRadioOptionEL.closest('.custom-option-tapa').classList.remove('checked')
- })
- }
- el.closest('.custom-option-tapa').classList.add('checked')
- if (el.closest('.custom-option-tapa').id == 'tapaBlandaInnerDiv') {
- $('#tapaBlanda').prop('checked', true);
- $('#tapaDura').prop('checked', false);
- }
- else {
- $('#tapaBlanda').prop('checked', false);
- $('#tapaDura').prop('checked', true);
- }
- } else {
- el.closest('.custom-option-tapa').classList.remove('checked')
- }
-}
-
-
-function initColorCheck() {
- const _this = this
-
- const custopOptionList = [].slice.call(document.querySelectorAll('.custom-option-color .form-check-input'))
- custopOptionList.map(function (customOptionEL) {
- // Update custom options check on page load
- _this.updateColorCheck(customOptionEL)
-
- // Update custom options check on click
- customOptionEL.addEventListener('click', e => {
- _this.updateColorCheck(customOptionEL)
- })
- })
-}
-
-function updateColorCheck(el) {
- if (el.checked) {
- // If custom option element is radio, remove checked from the siblings (closest `.row`)
- if (el.type === 'radio') {
- const customRadioOptionList = [].slice.call(el.closest('.row-color').querySelectorAll('.custom-option-color'))
- customRadioOptionList.map(function (customRadioOptionEL) {
- customRadioOptionEL.closest('.custom-option-color').classList.remove('checked')
- })
- }
- el.closest('.custom-option-color').classList.add('checked')
- if (el.closest('.custom-option-color').id == 'colorNegroDiv') {
- $('#colorNegro').prop('checked', true);
- $('#colorNegroHq').prop('checked', false);
- $('#colorColor').prop('checked', false);
- $('#colorColorHq').prop('checked', false);
- }
- else if (el.closest('.custom-option-color').id == 'colorNegroHqDiv') {
- $('#colorNegro').prop('checked', false);
- $('#colorNegroHq').prop('checked', true);
- $('#colorColor').prop('checked', false);
- $('#colorColorHq').prop('checked', false);
- }
- else if (el.closest('.custom-option-color').id == 'colorColorDiv') {
- $('#colorNegro').prop('checked', false);
- $('#colorNegroHq').prop('checked', false);
- $('#colorColor').prop('checked', true);
- $('#colorColorHq').prop('checked', false);
- }
- else {
- $('#colorNegro').prop('checked', false);
- $('#colorNegroHq').prop('checked', false);
- $('#colorColor').prop('checked', false);
- $('#colorColorHq').prop('checked', true);
- }
-
- } else {
- el.closest('.custom-option-color').classList.remove('checked')
- }
-}
-
-
-$('#enableSobrecubierta').on('change', function () {
- if ($(this).is(":checked")) {
- $('.enable-sobrecubierta').show();
- } else {
- $('#gramajeSobrecubierta').val('').trigger('change');
- $('#paperSobrecubierta').val('').trigger('change');
- $('#acabadosSobrecubierta').val('').trigger('change');
- $('#tamanioSolapasSobrecubierta').val();
- $('.enable-sobrecubierta').hide();
-
- }
-});
-
-
-function initDisenioLibro() {
- initTapaCheck();
- initColorCheck();
-
- $('.elementos-libro').trigger('change');
- $('.change-tipo-impresion').trigger('change');
-
- $('#papelInterior').trigger('change');
- $('#papelInterior').val(window.datosDisenioLibro.papel_interior);
- $('#gramajeInterior').append($('").val(this.id).text(this.nombre));
- });
- //Se quita la seleccion del dropdown
- dropdown.val('').trigger('change');
- $('#gramajeInterior').val('').trigger('change');
-
-
-
-});
-
-
-
-$('#tirada').on('change', function () {
-
- const valInterior = $('#gramajeInterior option:selected').val();
- const valCubierta = $('#gramajeCubierta option:selected').val();
- const valSobrecubierta = $('#gramajeSobrecubierta option:selected').val();
-
-
- $('#papelInterior').trigger('change');
- $('#papelCubierta').trigger('change');
- $('#papelSobrecubierta').trigger('change');
-});
-
-
-$('#papelInterior').on('change', function () {
-
- let isColor = false;
- if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
- isColor = true;
- let isHq = false;
- if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
- isHq = true;
-
- if ($('#papelInterior option:selected').val() != undefined) {
- var uso = 'bn';
-
- if (!isColor && !isHq) {
- uso = 'bn';
- }
- else if (!isColor && isHq) {
- uso = 'bnhq';
- }
- else if (isColor && !isHq) {
- uso = 'color';
- }
- else if (isColor && isHq) {
- uso = 'colorhq';
- }
- datos = {
- tirada: $('#tirada').val(),
- merma: 0,
- uso: uso,
- papel: $('#papelInterior option:selected').text()
- };
- datos = Object.assign(datos, window.token_ajax)
-
- const valInterior = $('#gramajeInterior option:selected').val();
-
- $.ajax({
- url: window.routes_disenio_libro.obtenerGramaje,
- type: 'POST',
- data: datos,
- success: function (response) {
-
- if(response.menu){
-
- $('#gramajeInterior').empty();
- $(response.menu).each(function (index, element) {
- $('#gramajeInterior').append($("").val(element.id).text(element.text));
- });
- }
-
-
- if (valInterior != undefined && valInterior != '')
- $('#gramajeInterior option[value=' + valInterior + ']').prop('selected', true).trigger('change');
- else
- $('#gramajeInterior').val('').trigger('change');
-
- }
- });
- }
-});
-
-
-$('#papelCubierta').on('change', function () {
- let isColor = true;
- let isHq = true;
-
- if ($('#papelCubierta option:selected').val() != undefined) {
- var uso = 'cubierta';
-
- datos = {
- tirada: $('#tirada').val(),
- merma: 0,
- uso: uso,
- papel: $('#papelCubierta option:selected').text().trim()
- };
- datos = Object.assign(datos, window.token_ajax)
-
- const valCubierta = $('#gramajeCubierta option:selected').val();
-
- $.ajax({
- url: window.routes_disenio_libro.obtenerGramaje,
- type: 'POST',
- data: datos,
- success: function (response) {
-
- $('#gramajeCubierta').empty();
- $(response.menu).each(function (index, element) {
- $('#gramajeCubierta').append($("").val(element.id).text(element.text));
- });
-
- if (valCubierta != undefined && valCubierta != '')
- $('#gramajeCubierta option[value=' + valCubierta + ']').prop('selected', true).trigger('change');
- else
- $('#gramajeCubierta').val('').trigger('change');
- }
- });
- }
-});
-
-
-$('#papelSobrecubierta').on('change', function () {
- let isColor = true;
- let isHq = true;
-
- if ($('#papelSobrecubierta option:selected').val() != undefined) {
- var uso = 'sobrecubierta';
-
- datos = {
- tirada: $('#tirada').val(),
- merma: 0,
- uso: uso,
- papel: $('#papelSobrecubierta option:selected').text().trim()
- };
- datos = Object.assign(datos, window.token_ajax)
-
- const valSobrecubierta = $('#gramajeSobrecubierta option:selected').val();
-
- $.ajax({
- url: window.routes_disenio_libro.obtenerGramaje,
- type: 'POST',
- data: datos,
- success: function (response) {
-
- $('#gramajeSobrecubierta').empty();
- $(response.menu).each(function (index, element) {
- $('#gramajeSobrecubierta').append($("").val(element.id).text(element.text));
- });
-
- if (valSobrecubierta != undefined)
- $('#gramajeSobrecubierta option[value=' + valSobrecubierta + ']').prop('selected', true).trigger('change');
- else
- $('#gramajeSobrecubierta').val('').trigger('change');
- }
- });
- }
-});
-
-
-$('#solapasCubierta').on('change', function () {
- if ($(this).is(":checked")) {
- $('#tamanioSolapasCubierta').show();
- } else {
- $('#tamanioSolapasCubierta').hide();
- }
-});
-
-
-// Funcion que comprueba que están rellenos todos los datos necesarios para calcular el presupuesto
-function checkValues() {
-
- const tirada = $('#tirada').val();
- const paginas = $('#paginas').val();
- const papelInterior = $('#papelInterior option:selected').val();
- const gramajeInterior = $('#gramajeInterior option:selected').text();
- const papelCubierta = $('#papelCubierta option:selected').val();
- const gramajeCubierta = $('#gramajeCubierta option:selected').text();
- const papelFormatoAlto = $('#papelFormatoAlto').val();
- const papelFormatoAncho = $('#papelFormatoAncho').val();
- const clienteId = $('#clienteId').val();
-
- if (paginas == '' || isNaN(paginas) || parseInt(paginas) <= 0) {
- return false;
- }
- if(parseInt(paginas)%2!=0){
- $('#paginas').val(parseInt(paginas)+1).trigger('change');
- return false;
- }
-
- if(clienteId == '' || isNaN(clienteId) || parseInt(clienteId) <= 0){
- return false;
- }
-
- if (tirada == '' || isNaN(tirada) || parseInt(tirada) <= 0) {
- return false;
- }
-
- if (papelInterior == '' || gramajeInterior == '') {
- return false;
- }
- if (papelCubierta == '' || gramajeCubierta == '') {
- return false;
- }
-
- if ($('#papelFormatoId').val() == null && !$('#papelFormatoPersonalizado').is(':checked')){
- return false;
- }
- if($('#papelFormatoPersonalizado').is(':checked')){
- if(papelFormatoAncho == '' || parseInt(papelFormatoAncho) <= 0 ||
- papelFormatoAlto == '' || parseInt(papelFormatoAlto) <= 0){
- return false;
- }
- }
-
- return true;
-}
-
-
-function getTiradas() {
- let tiradas = [];
- tiradas.push(parseInt($('#tirada').val()));
- if ($('#tirada2').val().length > 0 && parseInt($('#tirada2').val()) > 0)
- tiradas.push(parseInt($('#tirada2').val()));
- if ($('#tirada3').val().length > 0 && parseInt($('#tirada3').val()) > 0)
- tiradas.push(parseInt($('#tirada3').val()));
- if ($('#tirada4').val().length > 0 && parseInt($('#tirada4').val()) > 0)
- tiradas.push(parseInt($('#tirada4').val()));
- return tiradas;
-}
-
-
-function getDimensionLibro() {
-
- var ancho = 0;
- var alto = 0;
-
- if ($('#papelFormatoId option:selected').length > 0) {
- var selectedText = $('#papelFormatoId option:selected').text();
- if (selectedText.length > 0) {
- ancho = parseFloat(selectedText.trim().split(" x ")[0]);
- alto = parseFloat(selectedText.trim().split(" x ")[1]);
- }
- else if (document.getElementById('papelFormatoPersonalizado').checked) {
- ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
- alto = parseFloat(document.getElementById('papelFormatoAlto').value);
- }
- }
-
- else if (document.getElementById('papelFormatoPersonalizado').checked) {
- ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
- alto = parseFloat(document.getElementById('papelFormatoAlto').value);
- }
- return {
- ancho: ancho,
- alto: alto
- }
-}
-
-
-$('#retractilado').on('change', function () {
- if ($(this).is(':checked')) {
- if ($('#retractilado5').is(':checked'))
- $('#retractilado5').prop('checked', false);
- }
-});
-
-
-$('#retractilado5').on('change', function () {
- if ($(this).is(':checked')) {
- if ($('#retractilado').is(':checked'))
- $('#retractilado').prop('checked', false);
- }
-});
-
-$('.elementos-libro').on('change', function () {
- // Libro cosido
- if ($('#cosidoDiv').hasClass('checked')) {
- $('#tituloDisenioLibro').text("Rústica cosido");
- if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
- // Cosido tapa blanda
- $('.guardas').hide();
- $('.solapas-cubierta').show();
- $('.sobrecubierta').show();
- $('#enableSobrecubierta').trigger('change');
- }
- else {
- // Cosido tapa dura
- $('.guardas').show();
- numCarasGuardas(2);
- $('.solapas-cubierta').hide();
- $('.sobrecubierta').show();
- $('#enableSobrecubierta').trigger('change');
- }
- }
- // Libro fresado
- else if ($('#fresadoDiv').hasClass('checked')) {
- $('#tituloDisenioLibro').text("Rústica fresado");
- if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
- // fresado tapa blanda
- $('.guardas').hide();
- $('.solapas-cubierta').show();
- $('.sobrecubierta').show();
- $('#enableSobrecubierta').trigger('change');
- }
- else {
- // fresado tapa dura
- $('.guardas').show();
- numCarasGuardas(2);
- $('.solapas-cubierta').hide();
- $('.sobrecubierta').show();
- $('#enableSobrecubierta').trigger('change');
- }
- }
- // Libro grapado
- else if ($('#grapadoDiv').hasClass('checked')) {
- $('#tituloDisenioLibro').text("Cosido con grapas");
- if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
- // grapado tapa blanda
- $('.guardas').hide();
- $('.solapas-cubierta').show();
- $('.sobrecubierta').hide();
- $('#enableSobrecubierta').prop('checked', false);
- }
- }
- // Libro wire-o
- else if ($('#wireoDiv').hasClass('checked')) {
- $('#tituloDisenioLibro').text("Wire-O");
- if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
- // wire-o tapa blanda
- $('.guardas').hide();
- $('.solapas-cubierta').show();
- $('.sobrecubierta').hide();
- $('#enableSobrecubierta').prop('checked', false);
- }
- else {
- // wire-o tapa dura
- $('.guardas').show();
- numCarasGuardas(1);
- $('.solapas-cubierta').hide();
- $('.sobrecubierta').hide();
- $('#enableSobrecubierta').prop('checked', false);
- }
- }
- // Libro espiral
- else if ($('#espiralDiv').hasClass('checked')) {
- $('#tituloDisenioLibro').text("Espiral");
- if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
- // espiral tapa blanda
- $('.guardas').hide();
- $('.solapas-cubierta').show();
- $('.sobrecubierta').hide();
- $('#enableSobrecubierta').prop('checked', false);
- }
- else {
- // espiral tapa dura
- $('.espiral').show();
- numCarasGuardas(1);
- $('.solapas-cubierta').hide();
- $('.sobrecubierta').hide();
- $('#enableSobrecubierta').prop('checked', false);
- }
- }
-});
-
-
-function numCarasGuardas(numCaras) {
- if (numCaras == 1) {
- $("#impresionGuardas option[value='8']").remove();
- }
- else {
- if ($("#impresionGuardas option[value='8']").length == 0)
- $("#impresionGuardas").append('');
-
- }
-}
-
-
-$('.calcular-presupuesto').on('change', function () {
-
- // se obtiene el id del elemento que ha disparado el evento
- if($(this).hasClass('input-sobrecubierta')){
- if($('#papelSobrecubierta option:selected').val() == '' || $('#gramajeSobrecubierta option:selected').val() == ''){
- return;
- }
- }
- calcularPresupuesto();
-});
-
-function comprobarTiradasPOD(){
- const tiradas = getTiradas();
-
- //Comprobar que todos los elementos del array tiradas estan por encima de 30 o por debajo
- const tiradasPOD = tiradas.every(tirada => tirada <= 30);
- const tiradasNoPOD = tiradas.every(tirada => tirada > 30);
- if (tiradasPOD == !tiradasNoPOD) {
- return true;
- }
- return false;
-}
-
-$('#clienteId').on('select2:change', function () {
- calcularPresupuesto();
-});
-
-
-async function calcularPresupuesto() {
-
- let isColor = false;
- if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
- isColor = true;
- let isHq = false;
- if($('#colorNegroHqDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
- isHq = true;
-
- if(!comprobarTiradasPOD()){
- $('#errorTiradas').show();
- return;
- }
- $('#errorTiradas').hide();
-
- // se obtiene la propiedad serv_id de los checkboxes seleccionados de la clase .servicio-extra
- if (!checkValues()) {
- return;
- }
-
- let servicios = [];
- $('.servicio-extra:checked').each(function () {
- servicios.push($(this).attr('serv_id'));
- })
-
- let datos = {
- tamanio: getDimensionLibro(),
- tirada: getTiradas(),
- paginas: $('#paginas').val(),
- paginasColor: $('#paginasColor').val(),
- tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
- tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
- isColor: isColor ? 1 : 0,
- isHq: isHq ? 1 : 0,
- papelInterior: $('#papelInterior option:selected').val(),
- papelInteriorNombre: $('#papelInterior option:selected').text().trim(),
- gramajeInterior: $('#gramajeInterior option:selected').text(),
- excluirRotativa: $('#excluirRotativa').is(':checked')? 1 : 0,
- papelCubierta: $('#papelCubierta option:selected').val(),
- papelCubiertaNombre: $('#papelCubierta option:selected').text().trim(),
- gramajeCubierta: $('#gramajeCubierta option:selected').text(),
- carasCubierta: $('#carasCubierta').val(),
- acabadoCubierta: $('#acabadosCubierta').val(),
- clienteId: $('#clienteId').val(),
- servicios: servicios,
- }
-
- // Si es cosido, se añade el número de páginas del cuadernillo
- if ($('#cosidoDiv').hasClass('checked')) {
- datos.paginasCuadernillo = $('#paginasCuadernillo').val();
- }
- // Si hay solapas de cubierta
- if ($('#solapasCubierta').is(':checked')) {
- datos.solapasCubierta = $('#anchoSolapasCubierta').val()
- }
-
-
-
- // Si hay sobrecubierta
- if ($('#enableSobrecubierta').is(':checked')) {
- if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
-
- datos.sobrecubierta = {
- papel: $('#papelSobrecubierta option:selected').val(),
- papel_nombre: $('#papelSobrecubierta option:selected').text().trim(),
- gramaje: $('#gramajeSobrecubierta option:selected').text(),
- acabado: $('#acabadosSobrecubierta').val()
- }
-
- datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
- }
- }
-
- if ($('#divGuardas').is(':visible')) {
- datos.guardas = {
- papel: $('#papelGuardas option:selected').val(),
- papel_nombre: $('#papelGuardas option:selected').text().trim(),
- gramaje: 170,
- caras: $('#impresionGuardas option:selected').val()
- }
- }
-
- datos = Object.assign(datos, window.token_ajax)
-
- $('.divTiradasPrecio').empty();
- $('#loader').show();
-
- $.ajax({
- url: window.routes_disenio_libro.presupuestoCliente,
- type: 'POST',
- data: datos,
- success: function (response) {
- error = false;
- $('#errorGeneral').hide();
- try{
-
-
- if(response.errors.interior.length > 0){
- $('#errorInterior').show();
- error = true;
- }
- else
- $('#errorInterior').hide();
- if(response.errors.cubierta.length > 0){
- $('#errorCubierta').show();
- error = true;
- }
- else
- $('#errorCubierta').hide();
-
- if(response.errors.sobrecubierta.length > 0){
- $('#errorSobrecubierta').show();
- error = true;
- }
- else
- $('#errorSobrecubierta').hide();
-
-
- if(response.errors.guardas.length > 0){
- $('#errorGuardas').show();
- error = true;
- }
- else
- $('#errorGuardas').hide();
-
- if(response.errors.servicios.length > 0 || response.errors.serviciosDefecto.length > 0){
- error = true;
- $('#errorGeneral').show();
- }
- else{
- $('#errorGeneral').hide();
- }
- }
- catch(error){
- }
-
- //For debug only
- //console.log(response);
-
- $('#loader').hide();
-
- $('.divTiradasPrecio').empty();
-
- if(!error){
-
- $('#lomo_cubierta').val(response.info.lomo_cubierta);
-
- $('#precios').show();
-
- if(response.tiradas){
- for (i = 0; i < response.tiradas.length; i++) {
- const total = (parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2) ;
- const label = "tiradaPrecio" + parseInt(i+1);
-
- let html = '';
-
- html += '';
-
- $('.divTiradasPrecio').append(html);
- }
- }
-
- if($('#resumen-libro').hasClass('active')) {
- initDirecciones();
- initTiradasDirecciones();
- generarResumen();
- previewEsquemaCubierta(true);
- }
-
- }
- },
- error: function (error) {
- $('#loader').hide();
- $('.divTiradasPrecio').empty();
- }
- });
-}
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/presupuestoCliente.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/presupuestoCliente.js
deleted file mode 100644
index 6c79f0ee..00000000
--- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/presupuestoCliente.js
+++ /dev/null
@@ -1,356 +0,0 @@
-/**
- * Cliente presupuesto Wizard
- */
-
-'use strict';
-
-(function () {
-
-
- // Init custom option check
- //window.Helpers.initCustomOptionCheck();
- // Vertical Wizard
- // --------------------------------------------------------------------
-
- const clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente');
- if (typeof clientePresupuestoWizard !== undefined && clientePresupuestoWizard !== null ) {
- // Wizard form
- const clientePresupuestoWizardForm = clientePresupuestoWizard.querySelector('#presupuesto-cliente-form');
- // Wizard steps
- const clientePresupuestoWizardFormStep2 = clientePresupuestoWizardForm.querySelector('#tipo-libro');
- const clientePresupuestoWizardFormStep3 = clientePresupuestoWizardForm.querySelector('#disenio-libro');
- const clientePresupuestoWizardFormStep4 = clientePresupuestoWizardForm.querySelector('#direcciones-libro');
- const clientePresupuestoWizardFormStep5 = clientePresupuestoWizardForm.querySelector('#resumen-libro');
- // Wizard next prev button
- const clientePresupuestoWizardNext = [].slice.call(clientePresupuestoWizardForm.querySelectorAll('.btn-next'));
- const clientePresupuestoWizardPrev = [].slice.call(clientePresupuestoWizardForm.querySelectorAll('.btn-prev'));
-
- let FormValidation2;
- let FormValidation3;
- let FormValidation4;
- let FormValidation5;
-
- let validationStepper = new Stepper(clientePresupuestoWizard, {
- linear: true
- });
-
- if(clientePresupuestoWizardFormStep2 != null) {
- // select2 (clienteId)
- const clienteId = $('#clienteId');
-
- clienteId.on('change.select2', function () {
- // Revalidate the clienteId field when an option is chosen
- FormValidation2.revalidateField('clienteId');
- });
-
- // Deal Details
- FormValidation2 = FormValidation.formValidation(clientePresupuestoWizardFormStep2, {
- fields: {
- },
- plugins: {
- trigger: new FormValidation.plugins.Trigger(),
- bootstrap5: new FormValidation.plugins.Bootstrap5({
- // Use this for enabling/changing valid/invalid class
- // eleInvalidClass: '',
- eleValidClass: '',
- rowSelector: '.col-sm-3'
- }),
- autoFocus: new FormValidation.plugins.AutoFocus(),
- submitButton: new FormValidation.plugins.SubmitButton()
- }
- }).on('core.form.valid', function () {
- // Jump to the next step when all fields in the current step are valid
- validationStepper.next();
- });
-
-
- // Deal Usage
- FormValidation3 = FormValidation.formValidation(clientePresupuestoWizardFormStep3, {
- fields: {
- titulo: {
- validators: {
- notEmpty: {
- message: window.Presupuestos.validation.requerido_short
- },
- }
- },
- clienteId: {
- validators: {
- callback: {
- message: window.Presupuestos.validation.cliente,
- callback: function (input) {
- // Get the selected options
- const options = $("#clienteId").select2('data');
- const hasValidOption = options.some(option => parseInt(option.id) > 0);
- return options !== null && options.length > 0 && hasValidOption;
- },
- }
- }
- },
- tirada: {
- validators: {
- callback: {
- message: window.Presupuestos.validation.integer_greatherThan_0,
- callback: function (input) {
- const value = $("#tirada").val();
- return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
- },
- }
- }
- },
- paginas: {
- validators: {
- callback: {
- message: window.Presupuestos.validation.integer_greatherThan_0,
- callback: function (input) {
- const value = $("#paginas").val();
- return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
- },
- }
- }
- },
- paginasColor: {
- validators: {
- callback: {
- message: window.Presupuestos.validation.integer_greatherThan_0,
- callback: function (input) {
- if ($('#pagColorDiv').is(':hidden'))
- return true;
- else {
- const value = $("#paginasColor").val();
- return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
- }
- },
- }
- }
- },
- gramajeInterior: {
- validators: {
- callback: {
- callback: function (input) {
- const value = $("#tirada").val();
- if ($('#gramajeInterior option:selected').text().length == 0) {
- if(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0){
- return {
- valid: false,
- message: window.Presupuestos.validation.sin_gramaje,
- }
- }
- return {
- valid: value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0,
- message: window.Presupuestos.validation.tirada_no_valida,
- }
- }
- return true;
- },
- },
- }
- },
- gramajeCubierta: {
- validators: {
- callback: {
- message: window.Presupuestos.validation.tirada_no_valida,
- callback: function (input) {
- const value = $("#tirada").val();
- if ($('#gramajeCubierta option:selected').text().length == 0) {
- return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
- }
- return true;
- },
- },
- callback: {
- message: window.Presupuestos.validation.sin_gramaje,
- callback: function (input) {
- if ($('#gramajeCubierta option:selected').text().length == 0) {
- return false;
- }
- return true;
- },
- }
- }
- },
- gramajeSobrecubierta: {
- validators: {
- callback: {
- message: window.Presupuestos.validation.tirada_no_valida,
- callback: function (input) {
- const value = $("#tirada").val();
- if ($('#gramajeSobrecubierta option:selected').text().length == 0) {
- return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
- }
- return true;
- },
- }
- }
- },
- },
- plugins: {
- trigger: new FormValidation.plugins.Trigger(),
- bootstrap5: new FormValidation.plugins.Bootstrap5({
- // Use this for enabling/changing valid/invalid class
- // eleInvalidClass: '',
- eleValidClass: '',
- rowSelector: function (field, ele) {
- // field is the field name
- // ele is the field element
- switch (field) {
- case 'gramajeInterior':
- case 'gramajeCubierta':
- case 'gramajeSobrecubierta':
- return '.col-sm-2';
-
- case 'titulo':
- return '.col-sm-12';
-
- case 'clienteId':
- return '.col-sm-6';
-
- default:
- return '.col-sm-3';
- }
- }
- }),
- autoFocus: new FormValidation.plugins.AutoFocus(),
- submitButton: new FormValidation.plugins.SubmitButton()
- }
- }).on('core.form.valid', function () {
- if($('#tiradaPrecio1').length > 0) {
- validationStepper.next();
- initDirecciones();
- initTiradasDirecciones();
- }
- });
-
- const tirada = $('#tirada');
- tirada.on('change', function () {
- // Revalidate the clienteId field when an option is chosen
- FormValidation2.revalidateField('gramajeInterior');
- FormValidation2.revalidateField('gramajeCubierta');
- FormValidation2.revalidateField('gramajeSobrecubierta');
- });
-
- // Direcciones
- FormValidation4 = FormValidation.formValidation(clientePresupuestoWizardFormStep4, {
- fields: {
-
- },
- plugins: {
- trigger: new FormValidation.plugins.Trigger(),
- bootstrap5: new FormValidation.plugins.Bootstrap5({
- // Use this for enabling/changing valid/invalid class
- // eleInvalidClass: '',
- eleValidClass: '',
- rowSelector: '.col-md-12'
- }),
- autoFocus: new FormValidation.plugins.AutoFocus(),
- submitButton: new FormValidation.plugins.SubmitButton()
- }
- }).on('core.form.valid', function () {
- if(validarEnvio()){
- generarResumen();
- validationStepper.next();
- }
- else{
- let text = "El número de unidades enviadas no coincie con la tirada seleccionada.";
- if($('#prototipo').is(':checked')) {
- text += "
(Tenga en cuenta que se ha seleccionado la opción de prototipo)";
- }
- $('#errorDirecciones').text(text);
- $('#errorDirecciones').show();
- }
- });
- }
- // Deal Usage
- FormValidation5 = FormValidation.formValidation(clientePresupuestoWizardFormStep5, {
- fields: {
- // * Validate the fields here based on your requirements
- },
- plugins: {
- trigger: new FormValidation.plugins.Trigger(),
- bootstrap5: new FormValidation.plugins.Bootstrap5({
- // Use this for enabling/changing valid/invalid class
- // eleInvalidClass: '',
- eleValidClass: '',
- rowSelector: '.col-md-12'
- }),
- autoFocus: new FormValidation.plugins.AutoFocus(),
- submitButton: new FormValidation.plugins.SubmitButton()
- }
- }).on('core.form.valid', function () {
- // You can submit the form
- // clientePresupuestoWizardForm.submit()
- // or send the form data to server via an Ajax request
- // To make the demo simple, I just placed an alert
- //alert('Submitted..!!');
- });
-
- clientePresupuestoWizardNext.forEach(item => {
- item.addEventListener('click', event => {
- // When click the Next button, we will validate the current step
- switch (validationStepper._currentIndex) {
- case 0:
- FormValidation2.validate();
- break;
-
- case 1:
- FormValidation3.validate();
- break;
-
- case 2:
- FormValidation4.validate();
- break;
-
- case 3:
- FormValidation5.validate();
- break;
-
- default:
- validationStepper.next();
- break;
- }
- });
- });
-
- clientePresupuestoWizardPrev.forEach(item => {
- item.addEventListener('click', event => {
- switch (validationStepper._currentIndex) {
- case 4:
- validationStepper.previous();
- break;
-
- case 3:
- validationStepper.previous();
- break;
-
- case 2:
- for (let i = 0; i < 4; i++) {
- let id = "tiradaPrecio" + i;
- if ($('#' + id).length > 0) {
- $('#' + id).show();
- }
- }
- validationStepper.previous();
- break;
-
- case 1:
- validationStepper.previous();
- break;
-
- case 0:
- window.location.href = document.location.origin + '/presupuestocliente/list';
-
- default:
- break;
- }
- });
- });
-
- var url = $(location).attr('href'); // Obtener URL actual
- if (url.includes('/edit/')) { // Comprobar si la URL contiene 'edit'
- validationStepper.to(4);
- }
-
- }
-})();
-
-
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js
deleted file mode 100644
index 956eb8fa..00000000
--- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js
+++ /dev/null
@@ -1,311 +0,0 @@
-function generarResumen(){
- $('#tipoLibro').text($('#tituloDisenioLibro').text() + ' tapa ' + (($('#tapaBlandaInnerDiv').hasClass('checked'))?'blanda':'dura'));
- $('#resumenTamanio').text('Dimensiones: ' + getDimensionLibro().ancho + 'x' + getDimensionLibro().alto + 'mm');
- $('#resumenPaginas').text('Páginas: '+ $('#paginas').val() + ' páginas');
-
- const seleccion = $('.custom-option-tiradasDirecciones.checked');
- let tirada = 0;
- if(seleccion.length != 0) {
-
- const element_tirada =($(seleccion[0]).find('label input')[0]);
- const number = element_tirada.id.match(/\d+$/);
- if (number.length != 0) {
- tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
- }
- }
- $('#resumenTirada').text('Tirada: '+ tirada + ' unidades');
-
- $('#resumenPrototipo').text('Prototipo: ' + (($('#prototipo').is(':checked'))?'Sí':'No'));
- $('#resumenFerro').text('Ferro: ' + (($('#ferro').is(':checked'))?'Sí':'No'));
-
- $('#tipoImpresion').text('Impresión: ' +
- ($('#colorNegroDiv').hasClass('checked')?'Negro estándar':
- $('#colorNegroHqDiv').hasClass('checked')?'Negro premium':
- $('#colorColorDiv').hasClass('checked')?'Color estándar':'Color premium'));
-
- if($('#colorNegroDiv').hasClass('checked') || $('#colorNegroHqDiv').hasClass('checked')){
- $('#pResumenPaginasColor').hide();
- }
- else{
- $('#pResumenPaginasColor').show();
- $('#resumenPaginasColor').text($('#paginasColor').val());
- }
- $('#resumenPapelInterior').text($('#papelInterior option:selected').text().trim() + ' ' +
- $('#gramajeInterior option:selected').text() + 'gr/m²');
-
- let papelCubierta = $('#papelCubierta option:selected').text().trim() + ' ' +
- $('#gramajeCubierta option:selected').text();
- papelCubierta += 'gr/m²';
- $('#resumenPapelCubierta').text(papelCubierta);
- $('#resumenCarasCubierta').text('Impresión: ' + $('#carasCubierta option:selected').text())
- $('#resumenAcabadoCubierta').text('Acabado: ' + $('#acabadosCubierta option:selected').text())
- if ($('#solapasCubierta').is(':checked')) {
- $('#resumenSolapasCubierta').text('Solapas: ' + $('#anchoSolapasCubierta').val())
- }
- else{
- $('#resumenSolapasCubierta').text('Solapas: No')
- }
-
- if ($('#enableSobrecubierta').is(':checked')) {
- $(".resumen-sobrecubierta").show();
- $('#resumenPapelCubierta').text($('#papelSobrecubierta option:selected').text().trim() + ' ' +
- $('#gramajeSobrecubierta option:selected').text() + 'gr/m²');
- $('#resumenAcabadoSobrecubierta').text('Acabado: ' + $('#acabadosSobrecubierta option:selected').text())
- $('#resumenSolapasSobrecubierta').text('Solapas: ' + $('#anchoSolapasSobrecubierta').val())
-
- }
- else{
- $(".resumen-sobrecubierta").hide();
- }
-
- if ($('#divGuardas').css('display') != 'none') {
-
- $(".resumen-guardas").show();
- $('#resumenGuardasPapel').text($('#papelGuardas option:selected').text().trim() + ' ' + '170gr/m²');
- $('#resumenGuardasCaras').text('Impresión: ' + $('#impresionGuardas option:selected').text())
- }
- else{
- $(".resumen-guardas").hide();
- }
-
-
- if($('#retractilado').is(':checked') || $('#retractilado5').is(':checked') || $('#fajaColor').is(':checked')){
-
- $('.resumen-extras').show();
- $('#retractilado').is(':checked')?$('#resumenRetractilado1').show():$('#resumenRetractilado1').hide();
- $('#retractilado5').is(':checked')?$('#resumenRetractilado5').show():$('#resumenRetractilado5').hide();
- $('#fajaColor').is(':checked')?$('#resumenFajaColor').show():$('#resumenFajaColor').hide();
- }
- else{
- $('.resumen-extras').hide();
- }
-
- for (i = 1; i <= 4; i++) {
- let id = "tiradaPrecio" + i;
- if ($('#' + id).length > 0) {
-
- const envio = getTotalEnvio();
-
- let tirada_id = "ud_tiradaPrecio" + i;
- if(parseInt($('#' + tirada_id).text().replace(' ud.', '')) != tirada){
- continue;
- }
-
- let total_id = "tot_tiradaPrecio" + i;
-
- let total = parseFloat($('#' + total_id).text().replace('€', '').replace('Total: ', '')) + envio;
- let total_iva = 0.0;
- if($('#ivaReducido').val() == '1'){
- total_iva = total * 1.04;
- }
- else{
- total_iva = total * 1.21;
- }
- const precio_u = total_iva/tirada;
- $('#resumenTotalIVA').text('Total (I.V.A. ' + (($('#ivaReducido').val() == '1')?'4':'21') + '%): ' + total_iva.toFixed(2) + '€');
- $('#resumenPrecioU').text(precio_u.toFixed(4) + '€/ud');
- }
- }
-
-
-}
-
-function getTotalEnvio(){
- const elements = $('#divDirecciones').find('.row.mb-3');
- let total = 0.0;
-
- if(elements.length > 0) {
- for (let index=0; index path !== "");
- let id=0;
- if(paths.length > 0 && paths[paths.length - 2] == 'edit'){
- id=paths[paths.length - 1];
- }
- datos = {
- id: id,
- }
- datos = Object.assign(datos, window.token_ajax)
-
- $('#loader').show();
-
- $.ajax({
- url: window.routes_resumen.duplicarPresupuesto,
- type: 'POST',
- data: datos,
- success: function(response) {
-
- if(Object.keys(response).length > 0) {
- if(response.success){
- $('#loader').hide();
- window.location.href = document.location.origin + '/presupuestos/presupuestocliente/edit/' + response.id;
- }
- }
- $('#loader').hide();
-
- },
- error: function() {
- $('#loader').hide();
- },
- });
-});
-
-
-$('#btnBack').on('click', function() {
- window.location.href = document.location.origin + '/presupuestocliente/list';
-});
-
-function finalizarPresupuesto(confirmar){
-
- let isColor = false;
- if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
- isColor = true;
- let isHq = false;
- if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
- isHq = true;
-
- const paths = window.location.pathname.split("/").filter(path => path !== "");
- let id=0;
- if(paths.length > 0 && paths[paths.length - 2] == 'edit'){
- id=paths[paths.length - 1];
- }
-
- let servicios = [];
- $('.servicio-extra:checked').each(function () {
- servicios.push($(this).attr('serv_id'));
- })
-
- let datos_libro = {
- tamanio: getDimensionLibro(),
- tirada: getTiradas(),
- paginas: $('#paginas').val(),
- paginasColor: $('#paginasColor').val(),
- tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
- tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
- isColor: isColor,
- isHq: isHq,
- papelInterior: $('#papelInterior option:selected').val(),
- papelInteriorNombre: $('#papelInterior option:selected').text().trim(),
- gramajeInterior: $('#gramajeInterior option:selected').text(),
- excluirRotativa: $('#excluirRotativa').is(':checked')? 1 : 0,
- papelCubierta: $('#papelCubierta option:selected').val(),
- papelCubiertaNombre: $('#papelCubierta option:selected').text().trim(),
- gramajeCubierta: $('#gramajeCubierta option:selected').text(),
- carasCubierta: $('#carasCubierta').val(),
- acabadoCubierta: $('#acabadosCubierta').val(),
- clienteId: $('#clienteId').val(),
- servicios: servicios,
- };
-
- // Si es cosido, se añade el número de páginas del cuadernillo
- if ($('#cosidoDiv').hasClass('checked')) {
- datos_libro.paginasCuadernillo = $('#paginasCuadernillo').val();
- }
-
- // Si hay solapas de cubierta
- if ($('#solapasCubierta').is(':checked')) {
- datos_libro.solapasCubierta = $('#anchoSolapasCubierta').val()
- }
-
- // Si hay sobrecubierta
- if ($('#enableSobrecubierta').is(':checked')) {
- if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
-
- datos_libro.sobrecubierta = {
- papel: $('#papelSobrecubierta option:selected').val(),
- papel_nombre: $('#papelSobrecubierta option:selected').text().trim(),
- gramaje: $('#gramajeSobrecubierta option:selected').text(),
- acabado: $('#acabadosSobrecubierta').val()
- }
-
- datos_libro.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
- }
- }
-
- if ($('#divGuardas').css('display') != 'none') {
- datos_libro.guardas = {
- papel: $('#papelGuardas option:selected').val(),
- papel_nombre: $('#papelGuardas option:selected').text().trim(),
- gramaje: 170,
- caras: $('#impresionGuardas option:selected').val()
- }
- }
-
- let datos_cabecera = {
- titulo: $('#titulo').val(),
- referenciaCliente: $('#referenciaCliente').val(),
- }
-
- const seleccion = $('.custom-option-tiradasDirecciones.checked');
- let tirada = 0;
- let peso_libro = 0;
- if(seleccion.length != 0) {
-
- const element_tirada =($(seleccion[0]).find('label input')[0]);
- const number = element_tirada.id.match(/\d+$/);
- if (number.length != 0) {
- tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
- peso_libro = ($(seleccion[0])).find('label input').attr('peso');
- }
- }
-
-
- let direcciones = getDireccionesEnvio();
- datos = {
- id: id,
- datos_libro : datos_libro,
- datos_cabecera: datos_cabecera,
- direcciones: direcciones,
- tirada: tirada,
- peso: peso_libro,
- iva_reducido: $('#ivaReducido').val()==1?1:0,
- confirmar: confirmar?1:0,
- },
-
- datos = Object.assign(datos, window.token_ajax)
-
- $('#loader').show();
-
- $.ajax({
- url: window.routes_resumen.guardarPresupuesto,
- type: 'POST',
- data: datos,
- success: function(response) {
-
- if(Object.keys(response).length > 0) {
- if(response.status > 0){
- if(confirmar || window.location.href.includes("add"))
- window.location.href = response.url + '/' + response.status;
- }
-
- }
- $('#loader').hide();
-
- },
- error: function() {
- $('#loader').hide();
- },
- });
-}
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/tipoLibroItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/tipoLibroItems.js
deleted file mode 100644
index 11ee90da..00000000
--- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/tipoLibroItems.js
+++ /dev/null
@@ -1,58 +0,0 @@
-// Init custom option check
-function initTipoLibroCheck()
-{
- const _this = this
-
- const custopOptionList = [].slice.call(document.querySelectorAll('.custom-option-tipo .form-check-input'))
- custopOptionList.map(function (customOptionEL) {
- // Update custom options check on page load
- _this.updateTipoLibroCheck(customOptionEL)
-
- // Update custom options check on click
- customOptionEL.addEventListener('click', e => {
- _this.updateTipoLibroCheck(customOptionEL)
- })
- })
-}
-
-function updateTipoLibroCheck(el)
-{
- if (el.checked) {
- // If custom option element is radio, remove checked from the siblings (closest `.row`)
- if (el.type === 'radio') {
- const customRadioOptionList = [].slice.call(el.closest('.tipo_libro').querySelectorAll('.custom-option-tipo'))
- customRadioOptionList.map(function (customRadioOptionEL) {
- customRadioOptionEL.closest('.custom-option-tipo').classList.remove('checked')
- })
- }
- el.closest('.custom-option-tipo').classList.add('checked')
- if(el.closest('.custom-option-tipo').id == 'grapadoDiv') {
- $('#tapaDuraDiv').hide();
- $('#tapaBlanda').prop('checked', true);
- }
- else {
- $('#tapaDuraDiv').show();
- }
- if(el.closest('.custom-option-tipo').id == 'cosidoDiv') {
- $('#div_pagCuadernillo').show();
- }
- else {
- $('#div_pagCuadernillo').hide();
- }
- } else {
- el.closest('.custom-option-tipo').classList.remove('checked')
- }
-}
-
-initTipoLibroCheck();
-
-
-function getUpdatePapelInterior() {
- var impresionInterior = $('input[name="impresionInterior"]:checked').val();
- if(impresionInterior == 'color') {
- $('#colorInteriorDiv').show();
- }
- else {
- $('#colorInteriorDiv').hide();
- }
-}
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js
index 0b39cec9..d0240a60 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js
@@ -523,16 +523,12 @@ class DisenioCubierta {
acabados += ", Barniz UVI " + this.domItem.find("#barniz").children("option:selected").text();
if (this.domItem.find("#estampado").children("option:selected").val() != 'NONE')
acabados += ", Estampado " + this.domItem.find("#estampado").children("option:selected").text();
- if (this.domItem.find("#retractilado").hasClass('selected')) {
- acabados += ", Retractilado ";
- }
return acabados;
}
else {
acabados.plastificado = this.domItem.find("#plastificado ").children("option:selected").val();
acabados.barniz = this.domItem.find("#barniz").children("option:selected").val();
acabados.estampado = this.domItem.find("#estampado").children("option:selected").val();
- acabados.retractilado = this.domItem.find("#retractilado").hasClass('selected') ? 'RETR' : 'NONE';
}
return acabados;
} catch (e) {