From 7a27bf56a7fab84d3732d56c7c16ee21b4f6d131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 14 Dec 2023 15:34:45 +0100 Subject: [PATCH] totalizadores de servicios realizado --- .../Presupuestopreimpresiones.php | 28 ++++++ .../PresupuestoAcabadosEntity.php | 2 + .../PresupuestoManipuladosEntity.php | 2 + .../PresupuestoPreimpresionesEntity.php | 4 +- .../Presupuestos/PresupuestoAcabadosModel.php | 11 ++- .../PresupuestoEncuadernacionesModel.php | 6 +- .../PresupuestoManipuladosModel.php | 14 ++- .../PresupuestoPreimpresionesModel.php | 15 ++- .../cosidotapablanda/_datosServiciosItems.php | 91 ++++++++++++++----- .../_lineasPresupuestoItems.php | 23 ++--- .../_resumenPresupuestoItems.php | 72 ++++++++++----- 11 files changed, 190 insertions(+), 78 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php b/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php index 8c381705..75612c0a 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php @@ -58,6 +58,34 @@ class Presupuestopreimpresiones extends \App\Controllers\GoBaseResourceControlle 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'); + $result = []; + + if(count($tarifas)>0){ + foreach ($tarifas as $tarifa){ + $values = $this->model->getPrecioTarifa($tarifa); + 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/Entities/Presupuestos/PresupuestoAcabadosEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php index 8a4bf9ed..89c30ac9 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php @@ -11,6 +11,7 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity "tarifa_acabado_id" => null, "precio_unidad" => null, "precio_total" => null, + "margen" => null, "created_at" => null, "updated_at" => null, ]; @@ -19,5 +20,6 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity "tarifa_acabado_id" => "int", "precio_unidad" => "float", "precio_total" => "float", + "margen" => "float", ]; } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php index 8b2830c7..d7b3d752 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php @@ -11,6 +11,7 @@ class PresupuestoManipuladosEntity extends \CodeIgniter\Entity\Entity "tarifa_manipulado_id" => null, "precio_unidad" => null, "precio_total" => null, + "margen" => null, "created_at" => null, "updated_at" => null, ]; @@ -19,5 +20,6 @@ class PresupuestoManipuladosEntity extends \CodeIgniter\Entity\Entity "tarifa_manipulado_id" => "int", "precio_unidad" => "float", "precio_total" => "float", + "margen" => "float", ]; } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoPreimpresionesEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoPreimpresionesEntity.php index 8a56a8fc..7fa9cdb4 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoPreimpresionesEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoPreimpresionesEntity.php @@ -9,15 +9,15 @@ class PresupuestoPreimpresionesEntity extends \CodeIgniter\Entity\Entity "id" => null, "presupuesto_id" => null, "tarifa_preimpresion_id" => null, - "precio_unidad" => null, "precio_total" => null, + "margen" => null, "created_at" => null, "updated_at" => null, ]; protected $casts = [ "presupuesto_id" => "int", "tarifa_preimpresion_id" => "int", - "precio_unidad" => "float", "precio_total" => "float", + "margen" => "float", ]; } diff --git a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php index 510d1bd4..3bf50737 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php @@ -19,7 +19,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel 2 => "t1.precio_total" ]; - protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "nombre", "precio_total", "precio_unidad"]; + protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "nombre", "precio_total", "precio_unidad", "margen"]; protected $returnType = "App\Entities\Presupuestos\PresupuestoAcabadosEntity"; protected $useTimestamps = true; @@ -56,6 +56,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel 'tarifa_nombre'=> $tarifa_value[0]->tarifa_acabado_nombre, 'precio_unidad'=> $result_data[0], 'total'=> $result_data[1], + 'margen'=> $result_data[2], ]; return $ret_array; } @@ -64,6 +65,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel 'tarifa_id'=> $tarifa_acabado_id, 'tarifa_nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre, 'precio_unidad' => 0, + 'margen' => 0, 'total'=> 0, ]; return $ret_array; @@ -79,12 +81,13 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel $precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0); $total = $precio_unidad * $tirada; + $margen = floatval($tarifa->margen); if (!$is_POD){ $total += floatval($tarifa->tarifa_importe_fijo); } - return [$precio_unidad, $total]; + return [$precio_unidad, $total, $margen]; } public function deleteAllServicios($presupuesto_id){ @@ -123,6 +126,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel ->where('tarifa_acabado_id', $tarifa->tarifa_id) ->set('precio_unidad', $tarifa->precio_unidad) ->set('precio_total', $tarifa->precio_total) + ->set('margen', $tarifa->margen) ->update(); @@ -134,6 +138,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel ->set('tarifa_acabado_id', $tarifa->tarifa_id) ->set('precio_unidad', $tarifa->precio_unidad) ->set('precio_total', $tarifa->precio_total) + ->set('margen', $tarifa->margen) ->insert(); } } @@ -152,7 +157,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad, - t1.precio_total AS precio_total, t2.nombre AS nombre" + t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre" ); $builder->where('t1.presupuesto_id', $presupuesto_id); diff --git a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php index a2e0b46c..ae47dd9e 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php @@ -73,7 +73,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel $result_data[0] = floatval($precio_total / $tirada); // Precio/unidad $result_data[1] = $precio_total; - $result_data[2] = $precio_total * ($tarifa_value[0]->margen/100.0) ; // margen + $result_data[2] = $tarifa_value[0]->margen ; // margen array_push($tarifas, (object)[ @@ -206,7 +206,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel $result_data[0] = floatval($precio_total / $tirada); // Precio/unidad $result_data[1] = $precio_total; - $result_data[2] = $precio_total * ($tarifa_value[0]->margen/100.0) ; // margen + $result_data[2] = $tarifa_value[0]->margen; // margen $ret_array[] = (object)[ 'tarifa_id'=> $tarifa_encuadernacion_id, @@ -242,7 +242,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel $precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0); $total = $precio_unidad * $paginas; - $margen = $total * (floatval($tarifa->margen)/100.0); + $margen = floatval($tarifa->margen); if (!$is_POD){ $total += floatval($tarifa->tarifa_importe_fijo); diff --git a/ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php b/ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php index a6613f4d..10709065 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php @@ -19,7 +19,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel 2 => "t1.precio_total" ]; - protected $allowedFields = ["presupuesto_id", "tarifa_manipulado_id", "nombre", "precio_total", "precio_unidad"]; + protected $allowedFields = ["presupuesto_id", "tarifa_manipulado_id", "nombre", "precio_total", "precio_unidad", "margen"]; protected $returnType = "App\Entities\Presupuestos\PresupuestoManipuladosEntity"; protected $useTimestamps = true; @@ -57,6 +57,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel 'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre, 'precio_unidad'=> $result_data[0], 'total'=> $result_data[1], + 'margen' => $result_data[2], ]; return $ret_array; } @@ -66,6 +67,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel 'tarifa_nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre, 'precio_unidad' => 0, 'total'=> 0, + 'margen' => 0, ]; return $ret_array; } @@ -80,12 +82,13 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel $precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0); $total = $precio_unidad * $tirada; + $margen = floatval($tarifa->margen); if (!$is_POD){ $total += floatval($tarifa->tarifa_importe_fijo); } - return [$precio_unidad, $total]; + return [$precio_unidad, $total, $margen]; } public function deleteAllServicios($presupuesto_id){ @@ -124,6 +127,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel ->where('tarifa_manipulado_id', $tarifa->tarifa_id) ->set('precio_unidad', $tarifa->precio_unidad) ->set('precio_total', $tarifa->precio_total) + ->set('margen', $tarifa->margen) ->update(); @@ -135,6 +139,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel ->set('tarifa_manipulado_id', $tarifa->tarifa_id) ->set('precio_unidad', $tarifa->precio_unidad) ->set('precio_total', $tarifa->precio_total) + ->set('margen', $tarifa->margen) ->insert(); } } @@ -160,6 +165,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel 'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre, 'precio_unidad'=> $result_data[0], 'total'=> $result_data[1], + 'margen'=> $result_data[2], ]); } else{ @@ -169,6 +175,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel 'tarifa_nombre'=> $tarifa['tarifa_nombre'], 'precio_unidad' => 0, 'total'=> 0, + 'margen' => 0, ]); } @@ -189,7 +196,8 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre" + "t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_id, t1.precio_unidad AS precio_unidad, + t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre" ); $builder->where('t1.presupuesto_id', $presupuesto_id); diff --git a/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php index f5d2dd8a..33c49394 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php @@ -19,7 +19,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel 2 => "t1.precio_total" ]; - protected $allowedFields = ["presupuesto_id", "tarifa_preimpresion_id", "nombre", "precio_total", "precio_unidad"]; + protected $allowedFields = ["presupuesto_id", "tarifa_preimpresion_id", "nombre", "precio_total", "precio_unidad", "margen"]; protected $returnType = "App\Entities\Presupuestos\PresupuestoPreimpresionesEntity"; protected $useTimestamps = true; @@ -55,7 +55,8 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel $ret_array[] = (object)[ 'tarifa_id'=> $tarifa_value[0]->tarifa_preimpresion_id, 'tarifa_nombre'=> $tarifa_value[0]->tarifa_preimpresion_nombre, - 'precio'=> $result_data, + 'precio'=> $result_data[0], + 'margen'=> $result_data[1], ]; return $ret_array; } @@ -64,6 +65,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel 'tarifa_id'=> $tarifa_preimpresion_id, 'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_preimpresion_id)[0]->nombre, 'precio' => 0, + 'margen' => 0, ]; return $ret_array; } @@ -74,8 +76,9 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel $precio = floatval($tarifa->precio); $precio = $precio * (1+ floatval($tarifa->margen)/100.0); - - return $precio; + $margen = $tarifa->margen; + + return [$precio, $margen]; } public function deleteAllServicios($presupuesto_id){ @@ -114,6 +117,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel ->where('presupuesto_id', $presupuesto_id) ->where('tarifa_preimpresion_id', $tarifa->tarifa_id) ->set('precio', $tarifa->precio) + ->set('margen', $tarifa->margen) ->update(); @@ -124,6 +128,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel ->set('presupuesto_id', $presupuesto_id) ->set('tarifa_preimpresion_id', $tarifa->tarifa_id) ->set('precio', $tarifa->precio) + ->set('margen', $tarifa->margen) ->insert(); } } @@ -142,7 +147,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio AS precio, t2.nombre AS nombre" + "t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio AS precio, t1.margen AS margen, t2.nombre AS nombre" ); $builder->where('t1.presupuesto_id', $presupuesto_id); 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 82cee6d3..d9afca14 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 @@ -80,6 +80,7 @@ + @@ -116,6 +117,7 @@ + @@ -193,6 +195,7 @@ + @@ -398,6 +401,7 @@ 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)) + $('#acabado_margen_' + line[0].tarifa_id).text(parseFloat(line[0].margen).toFixed(2)) }); yeniden(data.); }).then( @@ -423,6 +427,7 @@ $('#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)) + $('#enc_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2)) $('#proveedor_enc_' + line[0].tarifa_id).on('change', proveedor_enc_event) }); yeniden(data.); @@ -444,10 +449,30 @@ 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)) + $('#manipulado_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2)) }); yeniden(data.); - }) - ) + }).then( + fetch(domain + "/presupuestos/presupuestopreimpresiones/update/" + id , { + method: "POST", + body: JSON.stringify({ + datos: datosPreimpresion, + : v + }), + headers: { + "Content-type": "application/json; charset=UTF-8" + } + }) + .then(response => response.json()) + .then(data => { + data.lines.forEach((line) => { + $('#precio_preimpresion_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2)) + $('#preimpresion_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2)) + }); + yeniden(data.); + }) + ) + ) ) } @@ -473,7 +498,9 @@ language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, - + "drawCallback": function(settings ) { + updateTotales() + } }); function init_servicio_acabado(){ @@ -491,7 +518,8 @@ element.tarifa_acabado_id, element.nombre, '' + parseFloat(element.precio_unidad).toFixed(2) + '', - '', + '', + '', '' ]).draw(false) @@ -548,7 +576,8 @@ row.tarifa_id, row.tarifa_nombre, '' + parseFloat(row.precio_unidad).toFixed(2) + '', - '', + '', + '', '' ]).draw(false) }); @@ -595,6 +624,9 @@ case 3: values['precio_total'] = $(this).children(":first").val() break + case 4: + values['margen'] = $(this).text() + break } }) if(Object.keys(values).length>0) @@ -624,12 +656,10 @@ select: false, language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - columnDefs: [{ - target: 5, - visible: false - }] - + }, + "drawCallback": function(settings ) { + updateTotales() + } }); @@ -657,7 +687,7 @@ '', '' + parseFloat(element.precio_unidad).toFixed(2) + '', '', - '' + parseFloat(element.margen).toFixed(2) + '', + '', '' ]).draw(false) @@ -731,7 +761,7 @@ $('#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)) - $('#margen_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].margen).toFixed(2)) + $('#enc_margen_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].margen).toFixed(2)) yeniden(data.); return true; }, @@ -796,6 +826,7 @@ tableServiciosEnc.clear().draw() data.values.forEach((row) => { + tableServiciosEnc.row.add([ row.tarifa_id, row.tarifa_nombre, @@ -806,7 +837,7 @@ '', '' + parseFloat(row.precio_unidad).toFixed(2) + '', '', - '' + parseFloat(row.margen).toFixed(2) + '', + '', '' ]).draw(false) @@ -932,7 +963,9 @@ language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, - + "drawCallback": function(settings ) { + updateTotales() + } }); function init_servicio_manipulado(){ @@ -951,6 +984,7 @@ element.nombre, '' + parseFloat(element.precio_unidad).toFixed(2) + '', '', + '', '' ]).draw(false) @@ -1016,7 +1050,8 @@ row.tarifa_id, row.tarifa_nombre, '' + parseFloat(row.precio_unidad).toFixed(2) + '', - '', + '', + '', '' ]).draw(false) }); @@ -1036,8 +1071,9 @@ const tarifa_text = $('#add_servicio_manipulado_list').select2('data')[0].text.trim() if( $('#add_servicio_manipulado_list').select2('data')[0].text.trim().length > 0){ - if($('#tableOfServiciosManipulado tr > td:contains(' + tarifa_text + ')').length == 0) - get_tarifas_manipulado($('#add_servicio_manipulado_list').select2('data')[0].id); + if($('#tableOfServiciosManipulado tr > td:contains(' + tarifa_text + ')').length == 0){ + get_tarifas_manipulado(null, $('#add_servicio_manipulado_list').select2('data')[0].id); + } else{ popErrorAlert("", 'serv-manipulado-alert') } @@ -1064,6 +1100,9 @@ case 3: values['precio_total'] = $(this).children(":first").val() break + case 4: + values['margen'] = $(this).text() + break } }) if(Object.keys(values).length>0) @@ -1095,9 +1134,12 @@ language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, - + "drawCallback": function(settings ) { + updateTotales() + } }); + function init_servicio_preimpresion(){ const serviciospreimpresionList = ; @@ -1112,7 +1154,8 @@ tableServiciosPreimpresion.row.add([ element.tarifa_preimpresion_id, element.nombre, - '', + '', + '', '' ]).draw(false) @@ -1156,11 +1199,12 @@ success: function (data) { data.values.forEach((row) => { - + tableServiciosPreimpresion.row.add([ row.tarifa_id, row.tarifa_nombre, - '', + '', + '', '' ]).draw(false) }); @@ -1205,6 +1249,9 @@ case 2: values['precio'] = $(this).children(":first").val() break + case 3: + values['margen'] = $(this).text() + break } }) if(Object.keys(values).length>0) diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index ff740623..16fc7132 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -75,7 +75,7 @@ - + @@ -120,7 +120,7 @@ - + @@ -165,7 +165,7 @@ - + @@ -211,7 +211,7 @@ - + @@ -256,7 +256,7 @@ - + @@ -508,7 +508,7 @@ - + @@ -768,7 +768,7 @@ - + @@ -813,7 +813,7 @@ - + @@ -2698,13 +2698,6 @@ var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{ language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, - columnDefs: [ - { - target: 12, - visible: false - } - ] - }); async function set_lp_cubierta_gramaje(){ diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php index d117abd4..e9e2accd 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php @@ -78,8 +78,6 @@ updateTotales() -$(".update-totales").on("change", updateTotales) - function updateTotales(){ totalPapel = 0 margenPapel = 0 @@ -89,14 +87,7 @@ function updateTotales(){ totalServicios = 0 margenServicios = 0 - tableLineasPresupuesto.rows({filter: 'applied'}).every( function ( rowIdx, tableLoop, rowLoop ) { - - /*totalServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 4).node().lastChild.value) - margenServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 5).node().lastChild.innerText) -*/ - }); - - /*$('#tableLineasPresupuesto tbody tr:visible ').each(function(){ + $('#tableLineasPresupuesto tbody tr:visible ').each(function(){ if($('#' + this.id + '_checkPapel').prop('checked')){ totalPapel += parseFloat($('#' + this.id + '_totalPapelPedido').val()) margenPapel += parseFloat($('#' + this.id + '_margenPapelPedido').val()) @@ -104,36 +95,67 @@ function updateTotales(){ if($('#' + this.id + '_checkClicks').prop('checked')){ totalImpresion += parseFloat($('#' + this.id + '_totalClicks').val()) } - })*/ + }) $('#totalCostePapel').text(totalPapel.toFixed(2) + '€') $('#margenPapel').text(margenPapel.toFixed(2) + '€') + $('#totalCosteImpresion').text(totalImpresion.toFixed(2) + '€') $('#margenImpresion').text((totalImpresion*$('#margenImpresionValue').val()/100.0).toFixed(2) + '€') - tableServiciosEnc.rows().every( function ( rowIdx, tableLoop, rowLoop ) { + if ( typeof tableServiciosEnc !== 'undefined' && tableServiciosEnc.rows().count() > 0){ + $('#tableOfServiciosEncuadernacion tbody tr').each(function(){ + var currentRow = $(this).closest("tr"); + var subId = $('#tableOfServiciosEncuadernacion').DataTable().cell(currentRow,0).node().innerHTML; + var total = parseFloat($('#precio_total_encuadernado_' + subId)[0].value) + totalServicios += total + margenServicios += (total*parseFloat($('#enc_margen_' + subId)[0].innerHTML)/100.0) + }) + } + + if ( typeof tableServiciosAcabado !== 'undefined' && tableServiciosAcabado.rows().count() > 0){ + $('#tableOfServiciosAcabado tbody tr').each(function(){ + var currentRow = $(this).closest("tr"); + var subId = $('#tableOfServiciosAcabado').DataTable().cell(currentRow,0).node().innerHTML; + var total = parseFloat($('#precio_total_acabado_' + subId)[0].value) + totalServicios += total + margenServicios += (total*parseFloat($('#acabado_margen_' + subId)[0].innerHTML)/100.0) + }) + } - totalServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 4).node().lastChild.value) - margenServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 5).node().lastChild.innerText) + if ( typeof tableServiciosPreimpresion !== 'undefined' && tableServiciosPreimpresion.rows().count() > 0){ + + $('#tableOfServiciosPreimpresion tbody tr').each(function(){ + var currentRow = $(this).closest("tr"); + var subId = $('#tableOfServiciosPreimpresion').DataTable().cell(currentRow,0).node().innerHTML; + var total = parseFloat($('#precio_preimpresion_' + subId)[0].value) + totalServicios += total + margenServicios += (total*parseFloat($('#preimpresion_margen_' + subId)[0].innerHTML)/100.0) + }) + } - }); + if ( typeof tableServiciosManipulado !== 'undefined' && tableServiciosManipulado.rows().count() > 0){ + + $('#tableOfServiciosManipulado tbody tr').each(function(){ + var currentRow = $(this).closest("tr"); + var subId = $('#tableOfServiciosManipulado').DataTable().cell(currentRow,0).node().innerHTML; + var total = parseFloat($('#precio_total_manipulado_' + subId)[0].value) + totalServicios += total + margenServicios += (total*parseFloat($('#manipulado_margen_' + subId)[0].innerHTML)/100.0) + }) + } - /*$('#tableOfServiciosEncuadernacion tbody tr').each(function(){ - console.log(this) - var currentRow = $(this).closest("tr"); - var data = $('#myTable').DataTable().row(currentRow).data(); - console.log(data) - //margenServicios += parseFloat(this.text()) - })*/ - /*$('#tableOfServiciosEncuadernacion tbody tr td:nth-child(4)').each(function(){ - totalServicios += parseFloat(this.text()) - })*/ totalServicios -= margenServicios; $('#totalServicios').text(totalServicios.toFixed(2) + '€') $('#margenServicios').text(margenServicios.toFixed(2) + '€') } + +$(".update-totales").on("change", function(){ + updateTotales() +}) + endSection() ?>