mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'mod/totales' into 'main'
trabajando en totales See merge request jjimenez/safekat!111
This commit is contained in:
@ -134,29 +134,13 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"lomo" => null,
|
"lomo" => null,
|
||||||
"isDig" => false,
|
"isDig" => false,
|
||||||
"total_presupuesto" => null,
|
"total_presupuesto" => null,
|
||||||
"total_pedido" => null,
|
|
||||||
"total_peso" => null,
|
|
||||||
"total_click" => null,
|
|
||||||
"total_preimpresion" => null,
|
|
||||||
"total_preimpresion_margen" => null,
|
|
||||||
"total_manipulado" => null,
|
|
||||||
"total_acabado" => null,
|
|
||||||
"total_envios" => null,
|
|
||||||
"envios_recoge_cliente" => false,
|
"envios_recoge_cliente" => false,
|
||||||
"margen" => null,
|
"margen" => null,
|
||||||
"margen_extra" => 0.0,
|
"margen_extra" => 0.0,
|
||||||
"margen_manual" => null,
|
"margen_manual" => null,
|
||||||
"descuento" => 0.0,
|
"descuento" => 0.0,
|
||||||
"base_imponible" => null,
|
"base_imponible" => null,
|
||||||
"total_margen" => null,
|
|
||||||
"total_margen_extra" => null,
|
|
||||||
"total_descuento" => null,
|
|
||||||
"total" => null,
|
|
||||||
"forzar_total" => 0,
|
"forzar_total" => 0,
|
||||||
"total_calculado" => null,
|
|
||||||
"total_confirmado" => null,
|
|
||||||
"total_confirmado_user_id" => null,
|
|
||||||
"total_confirmado_update_at" => null,
|
|
||||||
"tirada_alternativa_json_data" => null,
|
"tirada_alternativa_json_data" => null,
|
||||||
"aprobado_user_id" => null,
|
"aprobado_user_id" => null,
|
||||||
"aprobado_at" => null,
|
"aprobado_at" => null,
|
||||||
@ -177,6 +161,23 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"updated_at" => null,
|
"updated_at" => null,
|
||||||
"comp_tipo_impresion" => null,
|
"comp_tipo_impresion" => null,
|
||||||
"comp_pos_paginas_color" => null,
|
"comp_pos_paginas_color" => null,
|
||||||
|
"total_coste_papel" => null,
|
||||||
|
"total_margen_papel" => null,
|
||||||
|
"total_margenPercent_papel" => null,
|
||||||
|
"total_coste_impresion" => null,
|
||||||
|
"total_margen_impresion" => null,
|
||||||
|
"total_margenPercent_impresion" => null,
|
||||||
|
"total_coste_servicios" => null,
|
||||||
|
"total_margen_servicios" => null,
|
||||||
|
"total_margenPercent_servicios" => null,
|
||||||
|
"total_coste_envios" => null,
|
||||||
|
"total_margen_envios" => null,
|
||||||
|
"total_costes" => null,
|
||||||
|
"total_margenes" => null,
|
||||||
|
"total_antes_descuento" => null,
|
||||||
|
"total_descuento" => null,
|
||||||
|
"total_presupuesto" => null,
|
||||||
|
"total_precio_unidad" => null,
|
||||||
];
|
];
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
"version" => "int",
|
"version" => "int",
|
||||||
@ -291,31 +292,33 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"lomo" => "?int",
|
"lomo" => "?int",
|
||||||
"isDig" => "boolean",
|
"isDig" => "boolean",
|
||||||
"total_presupuesto" => "?float",
|
"total_presupuesto" => "?float",
|
||||||
"total_pedido" => "?float",
|
|
||||||
"total_peso" => "?float",
|
|
||||||
"total_click" => "?float",
|
|
||||||
"total_preimpresion" => "?float",
|
|
||||||
"total_preimpresion_margen" => "?float",
|
|
||||||
"total_manipulado" => "?float",
|
|
||||||
"total_acabado" => "?float",
|
|
||||||
"total_envios" => "?float",
|
|
||||||
"envios_recoge_cliente" => "boolean",
|
"envios_recoge_cliente" => "boolean",
|
||||||
"margen" => "?float",
|
"margen" => "?float",
|
||||||
"margen_extra" => "float",
|
"margen_extra" => "float",
|
||||||
"margen_manual" => "?float",
|
"margen_manual" => "?float",
|
||||||
"descuento" => "float",
|
"descuento" => "float",
|
||||||
"base_imponible" => "?float",
|
"base_imponible" => "?float",
|
||||||
"total_margen" => "?float",
|
|
||||||
"total_margen_extra" => "?float",
|
|
||||||
"total_descuento" => "?float",
|
|
||||||
"total" => "?float",
|
|
||||||
"forzar_total" => "float",
|
"forzar_total" => "float",
|
||||||
"total_calculado" => "?float",
|
|
||||||
"total_confirmado" => "?float",
|
|
||||||
"total_confirmado_user_id" => "?int",
|
|
||||||
"aprobado_user_id" => "?int",
|
"aprobado_user_id" => "?int",
|
||||||
"fecha_entrega_real_aviso" => "?boolean",
|
"fecha_entrega_real_aviso" => "?boolean",
|
||||||
"pedido_espera_user_id" => "?int",
|
"pedido_espera_user_id" => "?int",
|
||||||
"is_deleted" => "int",
|
"is_deleted" => "int",
|
||||||
|
"total_coste_papel" => "?float",
|
||||||
|
"total_margen_papel" => "?float",
|
||||||
|
"total_margenPercent_papel" => "?float",
|
||||||
|
"total_coste_impresion" => "?float",
|
||||||
|
"total_margen_impresion" => "?float",
|
||||||
|
"total_margenPercent_impresion" => "?float",
|
||||||
|
"total_coste_servicios" => "?float",
|
||||||
|
"total_margen_servicios" => "?float",
|
||||||
|
"total_margenPercent_servicios" => "?float",
|
||||||
|
"total_coste_envios" => "?float",
|
||||||
|
"total_margen_envios" => "?float",
|
||||||
|
"total_costes" => "?float",
|
||||||
|
"total_margenes" => "?float",
|
||||||
|
"total_antes_descuento" => "?float",
|
||||||
|
"total_descuento" => "?float",
|
||||||
|
"total_presupuesto" => "?float",
|
||||||
|
"total_precio_unidad" => "?float",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,29 +154,13 @@ class PresupuestoModel extends \App\Models\GoBaseModel
|
|||||||
"lomo",
|
"lomo",
|
||||||
"isDig",
|
"isDig",
|
||||||
"total_presupuesto",
|
"total_presupuesto",
|
||||||
"total_pedido",
|
|
||||||
"total_peso",
|
|
||||||
"total_click",
|
|
||||||
"total_preimpresion",
|
|
||||||
"total_preimpresion_margen",
|
|
||||||
"total_manipulado",
|
|
||||||
"total_acabado",
|
|
||||||
"total_envios",
|
|
||||||
"envios_recoge_cliente",
|
"envios_recoge_cliente",
|
||||||
"margen",
|
"margen",
|
||||||
"margen_extra",
|
"margen_extra",
|
||||||
"margen_manual",
|
"margen_manual",
|
||||||
"descuento",
|
"descuento",
|
||||||
"base_imponible",
|
"base_imponible",
|
||||||
"total_margen",
|
|
||||||
"total_margen_extra",
|
|
||||||
"total_descuento",
|
|
||||||
"total",
|
|
||||||
"forzar_total",
|
"forzar_total",
|
||||||
"total_calculado",
|
|
||||||
"total_confirmado",
|
|
||||||
"total_confirmado_user_id",
|
|
||||||
"total_confirmado_update_at",
|
|
||||||
"tirada_alternativa_json_data",
|
"tirada_alternativa_json_data",
|
||||||
"aprobado_user_id",
|
"aprobado_user_id",
|
||||||
"aprobado_at",
|
"aprobado_at",
|
||||||
@ -194,6 +178,23 @@ class PresupuestoModel extends \App\Models\GoBaseModel
|
|||||||
"is_deleted",
|
"is_deleted",
|
||||||
"comp_tipo_impresion",
|
"comp_tipo_impresion",
|
||||||
"comp_pos_paginas_color",
|
"comp_pos_paginas_color",
|
||||||
|
"total_coste_papel",
|
||||||
|
"total_margen_papel",
|
||||||
|
"total_margenPercent_papel",
|
||||||
|
"total_coste_impresion",
|
||||||
|
"total_margen_impresion",
|
||||||
|
"total_margenPercent_impresion",
|
||||||
|
"total_coste_servicios",
|
||||||
|
"total_margen_servicios",
|
||||||
|
"total_margenPercent_servicios",
|
||||||
|
"total_coste_envios",
|
||||||
|
"total_margen_envios",
|
||||||
|
"total_costes",
|
||||||
|
"total_margenes",
|
||||||
|
"total_antes_descuento",
|
||||||
|
"total_descuento",
|
||||||
|
"total_presupuesto",
|
||||||
|
"total_precio_unidad",
|
||||||
];
|
];
|
||||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
|
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
|
||||||
|
|
||||||
|
|||||||
@ -319,7 +319,6 @@ function load_datos_envios(){
|
|||||||
'actionBtns_direcciones': actionBtns_direcciones,
|
'actionBtns_direcciones': actionBtns_direcciones,
|
||||||
})
|
})
|
||||||
.draw();
|
.draw();
|
||||||
updateTotales()
|
|
||||||
checkInsertar()
|
checkInsertar()
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -327,6 +326,4 @@ function load_datos_envios(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
load_datos_envios()
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
@ -513,7 +513,7 @@
|
|||||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||||
},
|
},
|
||||||
"drawCallback": function(settings ) {
|
"drawCallback": function(settings ) {
|
||||||
updateTotales()
|
updateTotales(false, true, false)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -720,7 +720,7 @@
|
|||||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||||
},
|
},
|
||||||
"drawCallback": function(settings ) {
|
"drawCallback": function(settings ) {
|
||||||
updateTotales()
|
updateTotales(false, true, false)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1028,7 +1028,7 @@
|
|||||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||||
},
|
},
|
||||||
"drawCallback": function(settings ) {
|
"drawCallback": function(settings ) {
|
||||||
updateTotales()
|
updateTotales(false, true, false)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1199,7 +1199,7 @@
|
|||||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||||
},
|
},
|
||||||
"drawCallback": function(settings ) {
|
"drawCallback": function(settings ) {
|
||||||
updateTotales()
|
updateTotales(false, true, false)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -555,7 +555,7 @@ $(document).on('click', '.btn-delete-lp', function(e) {
|
|||||||
tableLineasPresupuesto.row( row )
|
tableLineasPresupuesto.row( row )
|
||||||
.remove()
|
.remove()
|
||||||
.draw();
|
.draw();
|
||||||
updateTotales()
|
updateTotales(true, false, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -1240,7 +1240,6 @@ function por_defecto_lp_bn(){
|
|||||||
|
|
||||||
function fill_lp_bn(row, fromComparator=false){
|
function fill_lp_bn(row, fromComparator=false){
|
||||||
|
|
||||||
console.log(row)
|
|
||||||
if(fromComparator){
|
if(fromComparator){
|
||||||
|
|
||||||
var input_data = {
|
var input_data = {
|
||||||
@ -1268,7 +1267,7 @@ function fill_lp_bn(row, fromComparator=false){
|
|||||||
eventos_lp_bn(data.maquinaTipo=='inkjet'?true:false)
|
eventos_lp_bn(data.maquinaTipo=='inkjet'?true:false)
|
||||||
|
|
||||||
calcular_mermas()
|
calcular_mermas()
|
||||||
updateTotales()
|
updateTotales(true, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||||
@ -1550,7 +1549,7 @@ function fill_lp_color(row, fromComparator=false){
|
|||||||
eventos_lp_color(data.maquinaTipo=='inkjet'?true:false)
|
eventos_lp_color(data.maquinaTipo=='inkjet'?true:false)
|
||||||
|
|
||||||
calcular_mermas()
|
calcular_mermas()
|
||||||
updateTotales()
|
updateTotales(true, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||||
@ -1835,7 +1834,7 @@ function fill_lp_bnhq(row, fromComparator=false){
|
|||||||
eventos_lp_bnhq(data.maquinaTipo=='inkjet'?true:false)
|
eventos_lp_bnhq(data.maquinaTipo=='inkjet'?true:false)
|
||||||
|
|
||||||
calcular_mermas()
|
calcular_mermas()
|
||||||
updateTotales()
|
updateTotales(true, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||||
@ -2120,7 +2119,7 @@ function fill_lp_colorhq(row, fromComparator=false){
|
|||||||
eventos_lp_colorhq(data.maquinaTipo=='inkjet'?true:false)
|
eventos_lp_colorhq(data.maquinaTipo=='inkjet'?true:false)
|
||||||
|
|
||||||
calcular_mermas()
|
calcular_mermas()
|
||||||
updateTotales()
|
updateTotales(true, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||||
@ -2438,7 +2437,7 @@ function fill_lp_rot_bn(row, fromComparador=false){
|
|||||||
eventos_lp_rot_bn()
|
eventos_lp_rot_bn()
|
||||||
|
|
||||||
calcular_mermas()
|
calcular_mermas()
|
||||||
updateTotales()
|
updateTotales(true, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.lp_rot_bn').css('display', '')
|
$('.lp_rot_bn').css('display', '')
|
||||||
@ -2759,7 +2758,7 @@ function fill_lp_rot_color(row, fromComparador=false){
|
|||||||
eventos_lp_rot_color()
|
eventos_lp_rot_color()
|
||||||
|
|
||||||
calcular_mermas()
|
calcular_mermas()
|
||||||
updateTotales()
|
updateTotales(true, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||||
@ -3022,7 +3021,7 @@ function fill_lp_cubierta(row, fromComparador=false){
|
|||||||
eventos_lp_cubierta()
|
eventos_lp_cubierta()
|
||||||
|
|
||||||
calcular_mermas()
|
calcular_mermas()
|
||||||
updateTotales()
|
updateTotales(true, false, false)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -163,10 +163,9 @@ $('#saveDireccionEnvio').on('click', function(){
|
|||||||
}
|
}
|
||||||
var peso_total_libro = 0
|
var peso_total_libro = 0
|
||||||
|
|
||||||
$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
|
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||||
// No se incluyen las lineas de datos de rotativa
|
var rowData = this.data();
|
||||||
if(!this.id.includes("_data") )
|
peso_total_libro += rowData.peso
|
||||||
peso_total_libro += parseFloat($('#' + this.id + '_peso').val())
|
|
||||||
})
|
})
|
||||||
const peso_envio = peso_total_libro*parseInt($('#add_cantidad').val())/1000.0
|
const peso_envio = peso_total_libro*parseInt($('#add_cantidad').val())/1000.0
|
||||||
|
|
||||||
@ -249,6 +248,7 @@ $('#saveDireccionEnvio').on('click', function(){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
checkInsertar()
|
checkInsertar()
|
||||||
|
updateTotales(false, false, true)
|
||||||
$('#addressForm').modal("hide");
|
$('#addressForm').modal("hide");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,34 +19,34 @@
|
|||||||
<h6>Detalles del presupuesto</h6>
|
<h6>Detalles del presupuesto</h6>
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-6 py-1 fw-normal text-end">Coste papel</dt>
|
<dt class="col-6 py-1 fw-normal text-end">Coste papel</dt>
|
||||||
<dd id="totalCostePapel" class="py-1 col-6 text-end">NaN €</dd>
|
<dd id="totalCostePapel" class="py-1 col-6 text-end"><?= old('0', $presupuestoEntity->total_coste_papel) ?>€</dd>
|
||||||
<dt class="col-6 py-1 fw-normal text-end">Margen papel</dt>
|
<dt class="col-6 py-1 fw-normal text-end">Margen papel</dt>
|
||||||
<dd id="porcentajeMargenPapel" class="col-4 text-end py-1">NaN €</dd>
|
<dd id="porcentajeMargenPapel" class="col-4 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_papel) ?>%</dd>
|
||||||
<dd id="margenPapel" class="col-2 text-end py-1">NaN €</dd>
|
<dd id="margenPapel" class="col-2 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_papel) ?>€</dd>
|
||||||
|
|
||||||
<dt class="col-6 fw-normal text-end">Coste impresión</dt>
|
<dt class="col-6 fw-normal text-end">Coste impresión</dt>
|
||||||
<dd id="totalCosteImpresion" class="col-6 text-end">NaN €</dd>
|
<dd id="totalCosteImpresion" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_coste_impresion) ?>€</dd>
|
||||||
<dt class="col-6 py-1 fw-normal text-end">Margen impresión</dt>
|
<dt class="col-6 py-1 fw-normal text-end">Margen impresión</dt>
|
||||||
<div class="d-flex col-4 flex-row-reverse"><input id="margenImpresionValue" type='number' value="15" class="update-totales form-control" style="width:50% !important;"></div>
|
<dd id="porcentajeMargenImpresion" class="col-4 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_impresion) ?>%</dd>
|
||||||
<dd id="margenImpresion" class="col-2 py-1 text-end">NaN €</dd>
|
<dd id="margenImpresion" class="col-2 py-1 text-end"><?= old('0', $presupuestoEntity->total_margen_impresion) ?>€</dd>
|
||||||
|
|
||||||
<dt class="col-6 fw-normal text-end">Coste servicios</dt>
|
<dt class="col-6 fw-normal text-end">Coste servicios</dt>
|
||||||
<dd id="totalServicios" class="col-6 text-end py-1">NaN €</dd>
|
<dd id="totalServicios" class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_coste_servicios) ?>€</dd>
|
||||||
<dt class="col-6 fw-normal text-end">Margen servicios</dt>
|
<dt class="col-6 fw-normal text-end">Margen servicios</dt>
|
||||||
<dd id="porcentajeMargenServicios" class="col-4 text-end py-1">NaN €</dd>
|
<dd id="porcentajeMargenServicios" class="col-4 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_servicios) ?>%</dd>
|
||||||
<dd id="margenServicios" class="col-2 text-end py-1">NaN €</dd>
|
<dd id="margenServicios" class="col-2 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_servicios) ?>€</dd>
|
||||||
|
|
||||||
<dt class="col-6 fw-normal text-end">Coste de envío</dt>
|
<dt class="col-6 fw-normal text-end">Coste de envío</dt>
|
||||||
<dd id="totalEnvios"class="col-6 text-end py-1">NaN€</dd>
|
<dd id="totalEnvios"class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_coste_envios) ?>€</dd>
|
||||||
<dt class="col-6 fw-normal text-end">Margen envío</dt>
|
<dt class="col-6 fw-normal text-end">Margen envío</dt>
|
||||||
<dd id="margenEnvios" class="col-6 text-end py-1">NaN €</dd>
|
<dd id="margenEnvios" class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_envios) ?>€</dd>
|
||||||
|
|
||||||
<hr class="mx-n4">
|
<hr class="mx-n4">
|
||||||
|
|
||||||
<dt class="col-6 fw-normal text-end">Total Costes</dt>
|
<dt class="col-6 fw-normal text-end">Total Costes</dt>
|
||||||
<dd id="totalCostes" class="col-6 text-end">NaN €</dd>
|
<dd id="totalCostes" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_costes) ?>€</dd>
|
||||||
<dt class="col-6 fw-normal text-end">Total Margen</dt>
|
<dt class="col-6 fw-normal text-end">Total Margen</dt>
|
||||||
<dd id="totalMargenes" class="col-6 text-end">NaN €</dd>
|
<dd id="totalMargenes" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_margenes) ?>€</dd>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
@ -54,14 +54,14 @@
|
|||||||
|
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-6 fw-normal text-end">Total</dt>
|
<dt class="col-6 fw-normal text-end">Total</dt>
|
||||||
<dd id="totalAntesDescuento" class="col-6 text-end">NaN €</dd>
|
<dd id="totalAntesDescuento" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_antes_descuento) ?>€</dd>
|
||||||
<dt class="col-6 py-1 fw-normal text-end">Descuento</dt>
|
<dt class="col-6 py-1 fw-normal text-end">Descuento</dt>
|
||||||
<div class="d-flex col-4 flex-row-reverse"><input id="descuento" type='number' value="0" class="update-totales form-control" style="width:50% !important;"></div>
|
<div class="d-flex col-4 flex-row-reverse"><input id="descuento" name="total_descuentoPercent" type='number' value="<?= old('0', $presupuestoEntity->total_descuentoPercent) ?>" class="update-totales form-control" style="width:50% !important;"></div>
|
||||||
<dd id="descuentoTotal" class="col-2 py-1 text-end">NaN €</dd>
|
<dd id="descuentoTotal" class="col-2 py-1 text-end"><?= old('0', $presupuestoEntity->total_descuento) ?>€</dd>
|
||||||
<dt class="col-6 text-end">Total presupuesto</dt>
|
<dt class="col-6 text-end">Total presupuesto</dt>
|
||||||
<dd id="totalDespuesDecuento" class="col-6 fw-semibold text-end">NaN €</dd>
|
<dd id="totalDespuesDecuento" class="col-6 fw-semibold text-end"><?= old('0', $presupuestoEntity->total_presupuesto) ?>€</dd>
|
||||||
<dt class="col-6 fw-normal text-end">Precio unidad</dt>
|
<dt class="col-6 fw-normal text-end">Precio unidad</dt>
|
||||||
<dd id="precioUnidadPresupuesto" class="col-6 text-end mb-0">NaN €</dd>
|
<dd id="precioUnidadPresupuesto" class="col-6 text-end mb-0"><?= old('0', $presupuestoEntity->total_precio_unidad) ?>€</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-grid float-end mb-4">
|
<div class="d-grid float-end mb-4">
|
||||||
@ -82,99 +82,114 @@
|
|||||||
<!------------------------------------------------------->
|
<!------------------------------------------------------->
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
|
|
||||||
updateTotales()
|
|
||||||
|
|
||||||
function updateTotales(){
|
|
||||||
|
function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
|
||||||
totalPapel = 0
|
totalPapel = 0
|
||||||
margenPapel = 0
|
margenPapel = 0
|
||||||
|
|
||||||
totalImpresion = 0
|
totalImpresion = 0
|
||||||
|
margenImpresion = 0
|
||||||
|
|
||||||
totalServicios = 0
|
totalServicios = 0
|
||||||
margenServicios = 0
|
margenServicios = 0
|
||||||
|
|
||||||
$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
|
if(updateLP){
|
||||||
if($('#' + this.id + '_checkPapel').prop('checked')){
|
if(typeof tableLineasPresupuesto !== 'undefined'){
|
||||||
totalPapel += parseFloat($('#' + this.id + '_totalPapelPedido').val())
|
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||||
margenPapel += parseFloat($('#' + this.id + '_margenPapelPedido').val())
|
var rowData = this.data();
|
||||||
|
if($('#' + rowData.row_id + '_checkPapel').prop('checked')){
|
||||||
|
totalPapel += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
|
||||||
|
margenPapel += parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
|
||||||
|
}
|
||||||
|
if($('#' + rowData.row_id + '_checkClicks').prop('checked')){
|
||||||
|
totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||||
|
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||||
|
if(!isNaN(parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())))
|
||||||
|
totalImpresion += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if($('#' + this.id + '_checkClicks').prop('checked')){
|
|
||||||
totalImpresion += parseFloat($('#' + this.id + '_totalClicks').val())
|
var porcentajeMargenPapel = isNaN(margenPapel/(totalPapel)*100)?0:margenPapel/(totalPapel)*100
|
||||||
|
$('#porcentajeMargenPapel').text(porcentajeMargenPapel.toFixed(0) + '%')
|
||||||
|
$('#totalCostePapel').text(totalPapel.toFixed(2)+ '€')
|
||||||
|
$('#margenPapel').text(margenPapel.toFixed(2) + '€')
|
||||||
|
|
||||||
|
var porcentajeMargenImpresion = isNaN(margenImpresion/(totalImpresion)*100)?0:margenImpresion/(totalImpresion)*100
|
||||||
|
$('#porcentajeMargenImpresion').text(porcentajeMargenImpresion.toFixed(0) + '%')
|
||||||
|
$('#totalCosteImpresion').text(totalImpresion.toFixed(2) + '€')
|
||||||
|
$('#margenImpresion').text(margenImpresion.toFixed(2) + '€')
|
||||||
|
}
|
||||||
|
|
||||||
|
if(updateServicios){
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
var porcentajeMargenPapel = margenPapel/(totalPapel)*100
|
|
||||||
$('#porcentajeMargenPapel').text(porcentajeMargenPapel.toFixed(0) + '%')
|
|
||||||
$('#totalCostePapel').text(totalPapel.toFixed(2) + '€')
|
|
||||||
$('#margenPapel').text(margenPapel.toFixed(2) + '€')
|
|
||||||
|
|
||||||
margenImpresion = totalImpresion*$('#margenImpresionValue').val()/100.0
|
|
||||||
$('#totalCosteImpresion').text(totalImpresion.toFixed(2) + '€')
|
|
||||||
$('#margenImpresion').text((totalImpresion*$('#margenImpresionValue').val()/100.0).toFixed(2) + '€')
|
|
||||||
|
|
||||||
if ( typeof tableServiciosEnc !== 'undefined' && tableServiciosEnc.rows().count() > 0){
|
if ( typeof tableServiciosAcabado !== 'undefined' && tableServiciosAcabado.rows().count() > 0){
|
||||||
$('#tableOfServiciosEncuadernacion tbody tr').each(function(){
|
$('#tableOfServiciosAcabado tbody tr').each(function(){
|
||||||
var currentRow = $(this).closest("tr");
|
var currentRow = $(this).closest("tr");
|
||||||
var subId = $('#tableOfServiciosEncuadernacion').DataTable().cell(currentRow,0).node().innerHTML;
|
var subId = $('#tableOfServiciosAcabado').DataTable().cell(currentRow,0).node().innerHTML;
|
||||||
var total = parseFloat($('#precio_total_encuadernado_' + subId)[0].value)
|
var total = parseFloat($('#precio_total_acabado_' + subId)[0].value)
|
||||||
totalServicios += total
|
totalServicios += total
|
||||||
margenServicios += (total*parseFloat($('#enc_margen_' + subId)[0].innerHTML)/100.0)
|
margenServicios += (total*parseFloat($('#acabado_margen_' + subId)[0].innerHTML)/100.0)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
totalServicios -= margenServicios;
|
||||||
|
var porcentajeMargenServicios = margenServicios/(margenServicios+totalServicios)*100
|
||||||
|
$('#porcentajeMargenServicios').text(porcentajeMargenServicios.toFixed(0) + '%')
|
||||||
|
$('#totalServicios').text(totalServicios.toFixed(2) + '€')
|
||||||
|
$('#margenServicios').text(margenServicios.toFixed(2) + '€')
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( typeof tableServiciosAcabado !== 'undefined' && tableServiciosAcabado.rows().count() > 0){
|
if(updateEnvio){
|
||||||
$('#tableOfServiciosAcabado tbody tr').each(function(){
|
|
||||||
var currentRow = $(this).closest("tr");
|
var totalEnvios = 0
|
||||||
var subId = $('#tableOfServiciosAcabado').DataTable().cell(currentRow,0).node().innerHTML;
|
var margenEnvios = 0
|
||||||
var total = parseFloat($('#precio_total_acabado_' + subId)[0].value)
|
if ( typeof tableEnvios !== 'undefined' && tableEnvios.rows().count() > 0){
|
||||||
totalServicios += total
|
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||||
margenServicios += (total*parseFloat($('#acabado_margen_' + subId)[0].innerHTML)/100.0)
|
var data = this.data()
|
||||||
})
|
totalEnvios += parseFloat(data.precio)
|
||||||
}
|
margenEnvios += parseFloat((data.precio)*data.margen/100)
|
||||||
|
} );
|
||||||
if ( typeof tableServiciosPreimpresion !== 'undefined' && tableServiciosPreimpresion.rows().count() > 0){
|
}
|
||||||
|
|
||||||
$('#tableOfServiciosPreimpresion tbody tr').each(function(){
|
totalEnvios -= margenEnvios
|
||||||
var currentRow = $(this).closest("tr");
|
$('#totalEnvios').text(totalEnvios.toFixed(2) + '€')
|
||||||
var subId = $('#tableOfServiciosPreimpresion').DataTable().cell(currentRow,0).node().innerHTML;
|
$('#margenEnvios').text(margenEnvios.toFixed(2) + '€')
|
||||||
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)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
totalServicios -= margenServicios;
|
|
||||||
var porcentajeMargenServicios = margenServicios/(margenServicios+totalServicios)*100
|
|
||||||
$('#porcentajeMargenServicios').text(porcentajeMargenServicios.toFixed(0) + '%')
|
|
||||||
$('#totalServicios').text(totalServicios.toFixed(2) + '€')
|
|
||||||
$('#margenServicios').text(margenServicios.toFixed(2) + '€')
|
|
||||||
|
|
||||||
|
|
||||||
var totalEnvios = 0
|
|
||||||
var margenEnvios = 0
|
|
||||||
if ( typeof tableEnvios !== 'undefined' && tableEnvios.rows().count() > 0){
|
|
||||||
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var data = this.data()
|
|
||||||
totalEnvios += parseFloat(data.precio)
|
|
||||||
margenEnvios += parseFloat((data.precio)*data.margen/100)
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
totalEnvios -= margenEnvios
|
|
||||||
$('#totalEnvios').text(totalEnvios.toFixed(2) + '€')
|
|
||||||
$('#margenEnvios').text(margenEnvios.toFixed(2) + '€')
|
|
||||||
|
|
||||||
var totalCostes = totalPapel + totalImpresion + totalServicios + totalEnvios
|
var totalCostes = totalPapel + totalImpresion + totalServicios + totalEnvios
|
||||||
var totalMargenes = margenPapel + margenImpresion + margenServicios + margenEnvios
|
var totalMargenes = margenPapel + margenImpresion + margenServicios + margenEnvios
|
||||||
$('#totalCostes').text((totalCostes).toFixed(2) + '€')
|
$('#totalCostes').text((totalCostes).toFixed(2) + '€')
|
||||||
@ -189,11 +204,42 @@ function updateTotales(){
|
|||||||
$('#descuentoTotal').text((totalDescuento).toFixed(2) + '€')
|
$('#descuentoTotal').text((totalDescuento).toFixed(2) + '€')
|
||||||
$('#totalDespuesDecuento').text((totalPresupuesto).toFixed(2) + '€')
|
$('#totalDespuesDecuento').text((totalPresupuesto).toFixed(2) + '€')
|
||||||
$('#precioUnidadPresupuesto').text((precioUnidad).toFixed(2) + '€')
|
$('#precioUnidadPresupuesto').text((precioUnidad).toFixed(2) + '€')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getValuesResumenForm(){
|
||||||
|
var formResumen = ""
|
||||||
|
formResumen += '&total_coste_papel=' + $('#totalCostePapel').text().replace('€', '')
|
||||||
|
formResumen += '&total_margen_papel=' + $('#margenPapel').text().replace('€', '')
|
||||||
|
formResumen += '&total_margenPercent_papel=' + $('#porcentajeMargenPapel').text().replace('%', '')
|
||||||
|
|
||||||
|
formResumen += '&total_coste_impresion=' + $('#totalCosteImpresion').text().replace('€', '')
|
||||||
|
formResumen += '&total_margen_impresion=' + $('#margenImpresion').text().replace('€', '')
|
||||||
|
formResumen += '&total_margenPercent_impresion=' + $('#porcentajeMargenImpresion').text().replace('%', '')
|
||||||
|
|
||||||
|
formResumen += '&total_coste_servicios=' + $('#totalServicios').text().replace('€', '')
|
||||||
|
formResumen += '&total_margen_servicios=' + $('#margenServicios').text().replace('€', '')
|
||||||
|
formResumen += '&total_margenPercent_servicios=' + $('#porcentajeMargenServicios').text().replace('%', '')
|
||||||
|
|
||||||
|
formResumen += '&total_coste_envios=' + $('#totalEnvios').text().replace('€', '')
|
||||||
|
formResumen += '&total_margen_envios=' + $('#margenEnvios').text().replace('€', '')
|
||||||
|
|
||||||
|
formResumen += '&total_costes=' + $('#totalCostes').text().replace('€', '')
|
||||||
|
formResumen += '&total_margenes=' + $('#totalMargenes').text().replace('€', '')
|
||||||
|
|
||||||
|
formResumen += '&total_antes_descuento=' + $('#totalAntesDescuento').text().replace('€', '')
|
||||||
|
formResumen += '&total_descuento=' + $('#descuentoTotal').text().replace('€', '')
|
||||||
|
formResumen += '&total_presupuesto=' + $('#totalDespuesDecuento').text().replace('€', '')
|
||||||
|
formResumen += '&total_precio_unidad=' + $('#precioUnidadPresupuesto').text().replace('€', '')
|
||||||
|
|
||||||
|
return formResumen
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(".update-totales").on("change", function(){
|
$(".update-totales").on("change", function(){
|
||||||
updateTotales()
|
updateTotales(true, true, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|||||||
@ -135,6 +135,8 @@ $('#presupuestoForm').on( "submit", function( event ) {
|
|||||||
$.when(fill_bbdd_from_lp(id).then(function (data, textStatus, jqXHR){
|
$.when(fill_bbdd_from_lp(id).then(function (data, textStatus, jqXHR){
|
||||||
generateCompJSON()
|
generateCompJSON()
|
||||||
form = $('#presupuestoForm').serialize()
|
form = $('#presupuestoForm').serialize()
|
||||||
|
form += getValuesResumenForm()
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?php echo $formAction; ?>",
|
url: "<?php echo $formAction; ?>",
|
||||||
|
|||||||
Reference in New Issue
Block a user