From 834aa185602c67a8183be3854ee51b78ca069d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 5 Dec 2023 12:26:31 +0100 Subject: [PATCH] acabados todos los servicios de presupuesto --- .../Presupuestos/Presupuestoacabados.php | 34 ++- .../Presupuestoencuadernaciones.php | 42 ++- .../Presupuestos/Presupuestomanipulados.php | 36 ++- .../Presupuestopreimpresiones.php | 4 +- ci4/app/Controllers/Test.php | 3 +- ci4/app/Language/es/Presupuestos.php | 3 +- .../PresupuestoPreimpresionesModel.php | 1 + .../Tarifas/TarifaEncuadernacionModel.php | 2 +- .../Models/Tarifas/TarifaManipuladoModel.php | 2 +- ci4/app/Models/Tarifas/TarifaacabadoModel.php | 2 +- .../cosidotapablanda/_datosLibroItems.php | 23 ++ .../cosidotapablanda/_datosServiciosItems.php | 285 ++++++++++++------ .../cosidotapablanda/comparador.js | 16 - 13 files changed, 334 insertions(+), 119 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php index 84c46feb..7cd46225 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php @@ -50,7 +50,9 @@ class Presupuestoacabados extends \App\Controllers\GoBaseResourceController $this->model->deleteAllServicios($requestedId); } - $this->model->updateTarifas($requestedId, $postData->datos); + if(count($tarifas)>0){ + $this->model->updateTarifas($requestedId, $postData->datos); + } $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -61,6 +63,36 @@ class Presupuestoacabados extends \App\Controllers\GoBaseResourceController return $this->respond($data); } + public function update($requestedId = null) + { + + if ($requestedId == null) : + return; + endif; + + $postData = $this->request->getJSON(); + $tarifas = array_column($postData->datos, 'tarifa_id'); + $tirada = $postData->tirada ?? 0; + $POD = $postData->POD ?? 0; + $result = []; + + if(count($tarifas)>0){ + foreach ($tarifas as $tarifa){ + $values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD); + array_push($result, $values); + } + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'lines' => $result, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } + public function datatable() { if ($this->request->isAJAX()) { diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoencuadernaciones.php b/ci4/app/Controllers/Presupuestos/Presupuestoencuadernaciones.php index 0ac177cf..9fdb714b 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestoencuadernaciones.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoencuadernaciones.php @@ -48,7 +48,9 @@ class Presupuestoencuadernaciones extends \App\Controllers\GoBaseResourceControl $this->model->deleteAllServicios($requestedId); } - $this->model->updateTarifas($requestedId, $postData->datos); + if(count($tarifas)>0){ + $this->model->updateTarifas($requestedId, $postData->datos); + } $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -59,6 +61,44 @@ class Presupuestoencuadernaciones extends \App\Controllers\GoBaseResourceControl return $this->respond($data); } + public function update($requestedId = null) + { + $tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel'); + + if ($requestedId == null) : + return; + endif; + + $postData = $this->request->getJSON(); + $tarifas = array_column($postData->datos, 'tarifa_id'); + $tirada = $postData->tirada ?? 0; + $paginas = $postData->paginas ?? 0; + $POD = $postData->POD ?? 0; + $ancho = $postData->ancho ?? 0; + $alto = $postData->alto ?? 0; + $result = []; + + if(count($tarifas)>0){ + foreach ($tarifas as $tarifa){ + if($tarifaModel->isTarifaPorHoras($tarifa)){ + $values = $this->model->getPrecioTarifaHoras($tarifa, $paginas, $tirada, -1, $POD); + }else{ + $values = $this->model->getPrecioTarifa($tarifa, $paginas, $tirada, $ancho, $alto, -1, $POD); + } + array_push($result, $values); + } + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'lines' => $result, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } + public function datatable() { diff --git a/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php b/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php index db77861b..18d490c8 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php @@ -42,6 +42,7 @@ class Presupuestomanipulados extends \App\Controllers\GoBaseResourceController $postData = $this->request->getJSON(); $tarifas = array_column($postData->datos, 'tarifa_id'); + if(count($tarifas)>0){ $this->model->deleteServiciosNotInArray($requestedId, $tarifas); } @@ -49,7 +50,9 @@ class Presupuestomanipulados extends \App\Controllers\GoBaseResourceController $this->model->deleteAllServicios($requestedId); } - $this->model->updateTarifas($requestedId, $postData->datos); + if(count($tarifas)>0){ + $this->model->updateTarifas($requestedId, $postData->datos); + } $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -60,6 +63,37 @@ class Presupuestomanipulados extends \App\Controllers\GoBaseResourceController return $this->respond($data); } + public function update($requestedId = null) + { + + if ($requestedId == null) : + return; + endif; + + $postData = $this->request->getJSON(); + $tarifas = array_column($postData->datos, 'tarifa_id'); + $tirada = $postData->tirada ?? 0; + $POD = $postData->POD ?? 0; + $result = []; + + if(count($tarifas)>0){ + foreach ($tarifas as $tarifa){ + $values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD); + array_push($result, $values); + } + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'lines' => $result, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } + + public function datatable() { if ($this->request->isAJAX()) { diff --git a/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php b/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php index 2c9a1e6f..8c381705 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php @@ -45,7 +45,9 @@ class Presupuestopreimpresiones extends \App\Controllers\GoBaseResourceControlle $this->model->deleteAllServicios($requestedId); } - $this->model->updateTarifas($requestedId, $postData->datos); + if(count($tarifas)>0){ + $this->model->updateTarifas($requestedId, $postData->datos); + } $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 58601ca6..1a28a3af 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -17,8 +17,9 @@ class Test extends BaseController public function index() { + $model = model('App\Models\Tarifas\TarifaManipuladoModel'); echo '
';
-        var_dump($this->get_precio_tarifa_acabado(1, 200, 30));
+        var_dump($model->getTarifaPresupuestoManipulado(21, 200));
         echo '
'; } diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index d1a3b96f..a5e761d9 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -192,7 +192,8 @@ return [ 'dimension' => 'La dimensión del libro tiene que ser mayor que 60mm', 'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto', 'errorRotColor' => 'Papeles y gramajes deben ser iguales en color y BN', - 'error_servicios_anadidos' => 'Hay servicios sin datos' + 'error_servicios_anadidos' => 'Hay servicios sin datos', + 'error_servicios_duplicados' => 'El servicio seleccionado ya está añadido' ], diff --git a/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php index 65089ebc..f5d2dd8a 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php @@ -108,6 +108,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel $builder->where('tarifa_preimpresion_id', $tarifa->tarifa_id); $result = $builder->get()->getResultObject(); if(count($result)>0){ + $this->db ->table($this->table . " t1") ->where('presupuesto_id', $presupuesto_id) diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php index 8dae8018..84a60339 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php @@ -156,7 +156,7 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel $builder->where('t1.id =', $tarifa_id); $builder->where('t2.tirada_min <=', $tirada); - $builder->where('t2.tirada_max >', $tirada); + $builder->where('t2.tirada_max >=', $tirada); $builder->where('t3.paginas_libro_min <=', $paginas); $builder->where('t3.paginas_libro_max >', $paginas); $builder->where('t4.ancho_min <=', $ancho); diff --git a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php index 320c43cf..f42f01bc 100755 --- a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php +++ b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php @@ -126,7 +126,7 @@ class TarifaManipuladoModel extends \App\Models\GoBaseModel $builder->where('t1.id =', $tarifa_id); $builder->where('t2.tirada_min <=', $tirada); - $builder->where('t2.tirada_max >', $tirada); + $builder->where('t2.tirada_max >=', $tirada); return $builder->get()->getResultObject(); } diff --git a/ci4/app/Models/Tarifas/TarifaacabadoModel.php b/ci4/app/Models/Tarifas/TarifaacabadoModel.php index ac94e90e..1821d331 100755 --- a/ci4/app/Models/Tarifas/TarifaacabadoModel.php +++ b/ci4/app/Models/Tarifas/TarifaacabadoModel.php @@ -127,7 +127,7 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel $builder->where('t1.id =', $tarifa_id); $builder->where('t2.tirada_min <=', $tirada); - $builder->where('t2.tirada_max >', $tirada); + $builder->where('t2.tirada_max >=', $tirada); return $builder->get()->getResultObject(); } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index 894b0d0c..faa7d422 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -271,6 +271,29 @@ section("additionalInlineJs") ?> + +$('#paginas').on("change", function () { + // Si es negro o color + if ($('#tipoImpresion').select2('data')[0].id == 'negro' || + $('#tipoImpresion').select2('data')[0].id == 'color') { + document.getElementById('compPaginasNegro').value = document.getElementById('paginas').value; + document.getElementById('compPaginasColor').value = 0; + } + // Si es negrohq o colorhq + if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || + $('#tipoImpresion').select2('data')[0].id == 'colorhq') { + document.getElementById('compPaginasNegrohq').value = document.getElementById('paginas').value; + document.getElementById('compPaginasColorhq').value = 0; + } + + update_servicios() +}); + +$('#tirada').on("change", function () { + + update_servicios() +}) + $('#papelFormatoId').select2({ allowClear: false, }); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php index 00ba3c86..9e005331 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php @@ -311,7 +311,7 @@ fetch(domain + "/presupuestos/presupuestomanipulados/edit/" + id , { method: "POST", body: JSON.stringify({ - datos: datosAcabado, + datos: datosManipulado, : v }), headers: { @@ -327,7 +327,7 @@ fetch(domain + "/presupuestos/presupuestoacabados/edit/" + id , { method: "POST", body: JSON.stringify({ - datos: datosManipulado, + datos: datosAcabado, : v }), headers: { @@ -355,7 +355,94 @@ yeniden(data.); }) ) + } + function update_servicios(){ + const domain = window.location.origin + const dimension = getDimensionLibro(); + + if(parseInt($('#tirada').val())>0){ + var tirada = parseInt($('#tirada').val()) + } + else{ + var tirada = 0 + } + var paginas = parseInt($('#paginas').val())>0?parseInt($('#paginas').val()):0 + + var datosAcabado = get_datos_acabado() + var datosEnc = get_datos_encuadernacion() + var datosManipulado = get_datos_manipulado() + var datosPreimpresion = get_datos_preimpresion() + + fetch(domain + "/presupuestos/presupuestoacabados/update/" + id , { + method: "POST", + body: JSON.stringify({ + datos: datosAcabado, + tirada: tirada, + POD: POD, + : v + }), + headers: { + "Content-type": "application/json; charset=UTF-8" + } + }) + .then(response => response.json()) + .then(data => { + data.lines.forEach((line) => { + $('#precio_unidad_acabado_' + line[0].tarifa_id).text(parseFloat(line[0].precio_unidad).toFixed(2)) + $('#precio_total_acabado_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2)) + }); + yeniden(data.); + }).then( + fetch(domain + "/presupuestos/presupuestoencuadernaciones/update/" + id , { + method: "POST", + body: JSON.stringify({ + datos: datosEnc, + tirada: tirada, + paginas: paginas, + ancho: dimension.ancho, + alto: dimension.alto, + POD: POD, + : v + }), + headers: { + "Content-type": "application/json; charset=UTF-8" + } + }) + .then(response => response.json()) + .then(data => { + data.lines.forEach((line) => { + $('#proveedor_enc_' + line[0].tarifa_id).off('change') + $('#proveedor_enc_' + line[0].tarifa_id).val(line[0].proveedor_id) + $('#precio_unidad_encuadernado_' + line[0].tarifa_id).text(parseFloat(line[0].precio_unidad).toFixed(2)) + $('#precio_total_encuadernado_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2)) + $('#proveedor_enc_' + line[0].tarifa_id).on('change', proveedor_enc_event) + }); + yeniden(data.); + }).then( + fetch(domain + "/presupuestos/presupuestomanipulados/update/" + id , { + method: "POST", + body: JSON.stringify({ + datos: datosManipulado, + tirada: tirada, + POD: POD, + : v + }), + headers: { + "Content-type": "application/json; charset=UTF-8" + } + }) + .then(response => response.json()) + .then(data => { + data.lines.forEach((line) => { + $('#precio_unidad_manipulado_' + line[0].tarifa_id).text(parseFloat(line[0].precio_unidad).toFixed(2)) + $('#precio_total_manipulado_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2)) + }); + yeniden(data.); + }) + ) + ) + } endSection() ?> @@ -396,8 +483,8 @@ tableServiciosAcabado.row.add([ element.tarifa_acabado_id, element.nombre, - '' + parseFloat(element.precio_unidad).toFixed(2) + '', - '', + '' + parseFloat(element.precio_unidad).toFixed(2) + '', + '', '' ]).draw(false) @@ -453,8 +540,8 @@ tableServiciosAcabado.row.add([ row.tarifa_id, row.tarifa_nombre, - '' + parseFloat(row.precio_unidad).toFixed(2) + '', - '', + '' + parseFloat(row.precio_unidad).toFixed(2) + '', + '', '' ]).draw(false) }); @@ -477,7 +564,7 @@ if($('#tableOfServiciosAcabado tr > td:contains(' + tarifa_text + ')').length == 0) get_tarifas_acabado($('#add_servicio_acabado_list').select2('data')[0].id); else{ - popErrorAlert("Ese servicio ya existe", 'serv-acabado-alert') + popErrorAlert("", 'serv-acabado-alert') } } check_serv_acabado_error() @@ -486,25 +573,27 @@ function get_datos_acabado(){ var datosAcabado = [] - $("#tableOfServiciosAcabado tr").each(function (index,tr) { - var values = {} - $(this).find("td").each(function (index2) { - - switch (index2) { - case 0: - values['tarifa_id'] = $(this).text() - break - case 2: - values['precio_unidad'] = $(this).text() - break - case 3: - values['precio_total'] = $(this).children(":first").val() - break - } + if(tableServiciosAcabado.rows().count()>0){ + $("#tableOfServiciosAcabado tr").each(function (index,tr) { + var values = {} + $(this).find("td").each(function (index2) { + + switch (index2) { + case 0: + values['tarifa_id'] = $(this).text() + break + case 2: + values['precio_unidad'] = $(this).text() + break + case 3: + values['precio_total'] = $(this).children(":first").val() + break + } + }) + if(Object.keys(values).length>0) + datosAcabado.push(values) }) - if(Object.keys(values).length>0) - datosAcabado.push(values) - }) + } return datosAcabado } @@ -555,8 +644,8 @@ proveedor_nombre + '' + '', - '' + parseFloat(element.precio_unidad).toFixed(2) + '', - '', + '' + parseFloat(element.precio_unidad).toFixed(2) + '', + '', '' ]).draw(false) @@ -628,8 +717,8 @@ data: datos, success: function (data) { - $('#precio_unidad_' + datos.tarifa_encuadernacion_id).text(parseFloat(data.values[0].precio_unidad).toFixed(2)) - $('#precio_total_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].total).toFixed(2)) + $('#precio_unidad_encuadernado_' + datos.tarifa_encuadernacion_id).text(parseFloat(data.values[0].precio_unidad).toFixed(2)) + $('#precio_total_encuadernado_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].total).toFixed(2)) yeniden(data.); return true; }, @@ -702,8 +791,8 @@ row.proveedor + '' + '', - '' + parseFloat(row.precio_unidad).toFixed(2) + '', - '', + '' + parseFloat(row.precio_unidad).toFixed(2) + '', + '', '' ]).draw(false) @@ -772,7 +861,7 @@ if($('#tableOfServiciosEncuadernacion tr > td:contains(' + tarifa_text + ')').length == 0) get_tarifas_enc('tarifa', $('#add_servicio_enc_list').select2('data')[0].id); else{ - popErrorAlert("Ese servicio ya existe", 'serv-enc-alert') + popErrorAlert("", 'serv-enc-alert') } } check_serv_enc_error() @@ -781,28 +870,30 @@ function get_datos_encuadernacion(){ var datosEnc = [] - $("#tableOfServiciosEncuadernacion tr").each(function (index,tr) { - var values = {} - $(this).find("td").each(function (index2) { - - switch (index2) { - case 0: - values['tarifa_id'] = $(this).text() - break - case 2: - values['proveedor_id'] = $(this).children(":first").select2('data')[0].id - break - case 3: - values['precio_unidad'] = $(this).text() - break - case 4: - values['precio_total'] = $(this).children(":first").val() - break - } + if(tableServiciosEnc.rows().count()>0){ + $("#tableOfServiciosEncuadernacion tr").each(function (index,tr) { + var values = {} + $(this).find("td").each(function (index2) { + + switch (index2) { + case 0: + values['tarifa_id'] = $(this).text() + break + case 2: + values['proveedor_id'] = $(this).children(":first").select2('data')[0].id + break + case 3: + values['precio_unidad'] = $(this).text() + break + case 4: + values['precio_total'] = $(this).children(":first").val() + break + } + }) + if(Object.keys(values).length>0) + datosEnc.push(values) }) - if(Object.keys(values).length>0) - datosEnc.push(values) - }) + } return datosEnc } @@ -845,8 +936,8 @@ tableServiciosManipulado.row.add([ element.tarifa_manipulado_id, element.nombre, - '' + parseFloat(element.precio_unidad).toFixed(2) + '', - '', + '' + parseFloat(element.precio_unidad).toFixed(2) + '', + '', '' ]).draw(false) @@ -902,8 +993,8 @@ tableServiciosManipulado.row.add([ row.tarifa_id, row.tarifa_nombre, - '' + parseFloat(row.precio_unidad).toFixed(2) + '', - '', + '' + parseFloat(row.precio_unidad).toFixed(2) + '', + '', '' ]).draw(false) }); @@ -926,7 +1017,7 @@ if($('#tableOfServiciosManipulado tr > td:contains(' + tarifa_text + ')').length == 0) get_tarifas_manipulado($('#add_servicio_manipulado_list').select2('data')[0].id); else{ - popErrorAlert("Ese servicio ya existe", 'serv-manipulado-alert') + popErrorAlert("", 'serv-manipulado-alert') } } check_serv_manipulado_error() @@ -935,25 +1026,28 @@ function get_datos_manipulado(){ var datosManipulado = [] - $("#tableOfServiciosManipulado tr").each(function (index,tr) { - var values = {} - $(this).find("td").each(function (index2) { - - switch (index2) { - case 0: - values['tarifa_id'] = $(this).text() - break - case 2: - values['precio_unidad'] = $(this).text() - break - case 3: - values['precio_total'] = $(this).children(":first").val() - break - } + if(tableServiciosManipulado.rows().count()>0){ + + $("#tableOfServiciosManipulado tr").each(function (index,tr) { + var values = {} + $(this).find("td").each(function (index2) { + + switch (index2) { + case 0: + values['tarifa_id'] = $(this).text() + break + case 2: + values['precio_unidad'] = $(this).text() + break + case 3: + values['precio_total'] = $(this).children(":first").val() + break + } + }) + if(Object.keys(values).length>0) + datosManipulado.push(values) }) - if(Object.keys(values).length>0) - datosManipulado.push(values) - }) + } return datosManipulado } @@ -996,7 +1090,7 @@ tableServiciosPreimpresion.row.add([ element.tarifa_preimpresion_id, element.nombre, - '', + '', '' ]).draw(false) @@ -1044,7 +1138,7 @@ tableServiciosPreimpresion.row.add([ row.tarifa_id, row.tarifa_nombre, - '', + '', '' ]).draw(false) }); @@ -1067,7 +1161,7 @@ if($('#tableOfServiciosPreimpresion tr > td:contains(' + tarifa_text + ')').length == 0) get_tarifas_preimpresion($('#add_servicio_preimpresion_list').select2('data')[0].id); else{ - popErrorAlert("Ese servicio ya existe", 'serv-preimpresion-alert') + popErrorAlert("", 'serv-preimpresion-alert') } } check_serv_preimpresion_error() @@ -1076,22 +1170,25 @@ function get_datos_preimpresion(){ var datosPreimpresion = [] - $("#tableOfServiciosPreimpresion tr").each(function (index,tr) { - var values = {} - $(this).find("td").each(function (index2) { - - switch (index2) { - case 0: - values['tarifa_id'] = $(this).text() - break - case 2: - values['precio_total'] = $(this).children(":first").val() - break - } + if(tableServiciosPreimpresion.rows().count()>0){ + + $("#tableOfServiciosPreimpresion tr").each(function (index,tr) { + var values = {} + $(this).find("td").each(function (index2) { + + switch (index2) { + case 0: + values['tarifa_id'] = $(this).text() + break + case 2: + values['precio'] = $(this).children(":first").val() + break + } + }) + if(Object.keys(values).length>0) + datosPreimpresion.push(values) }) - if(Object.keys(values).length>0) - datosPreimpresion.push(values) - }) + } return datosPreimpresion } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js index 42722358..008f9db8 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js @@ -71,22 +71,6 @@ $('#compPaginasColorhq').on("change", function () { } }); -$('#paginas').on("change", function () { - // Si es negro o color - if ($('#tipoImpresion').select2('data')[0].id == 'negro' || - $('#tipoImpresion').select2('data')[0].id == 'color') { - document.getElementById('compPaginasNegro').value = document.getElementById('paginas').value; - document.getElementById('compPaginasColor').value = 0; - } - // Si es negrohq o colorhq - if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || - $('#tipoImpresion').select2('data')[0].id == 'colorhq') { - document.getElementById('compPaginasNegrohq').value = document.getElementById('paginas').value; - document.getElementById('compPaginasColorhq').value = 0; - } -}); - - $('#compRetractilado').on("change", function () { checkRetractiladoComparador(this);