mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en totales
This commit is contained in:
@ -134,29 +134,13 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"lomo" => null,
|
||||
"isDig" => false,
|
||||
"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,
|
||||
"margen" => null,
|
||||
"margen_extra" => 0.0,
|
||||
"margen_manual" => null,
|
||||
"descuento" => 0.0,
|
||||
"base_imponible" => null,
|
||||
"total_margen" => null,
|
||||
"total_margen_extra" => null,
|
||||
"total_descuento" => null,
|
||||
"total" => null,
|
||||
"forzar_total" => 0,
|
||||
"total_calculado" => null,
|
||||
"total_confirmado" => null,
|
||||
"total_confirmado_user_id" => null,
|
||||
"total_confirmado_update_at" => null,
|
||||
"tirada_alternativa_json_data" => null,
|
||||
"aprobado_user_id" => null,
|
||||
"aprobado_at" => null,
|
||||
@ -177,6 +161,23 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"updated_at" => null,
|
||||
"comp_tipo_impresion" => 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 = [
|
||||
"version" => "int",
|
||||
@ -291,31 +292,33 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"lomo" => "?int",
|
||||
"isDig" => "boolean",
|
||||
"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",
|
||||
"margen" => "?float",
|
||||
"margen_extra" => "float",
|
||||
"margen_manual" => "?float",
|
||||
"descuento" => "float",
|
||||
"base_imponible" => "?float",
|
||||
"total_margen" => "?float",
|
||||
"total_margen_extra" => "?float",
|
||||
"total_descuento" => "?float",
|
||||
"total" => "?float",
|
||||
"forzar_total" => "float",
|
||||
"total_calculado" => "?float",
|
||||
"total_confirmado" => "?float",
|
||||
"total_confirmado_user_id" => "?int",
|
||||
"aprobado_user_id" => "?int",
|
||||
"fecha_entrega_real_aviso" => "?boolean",
|
||||
"pedido_espera_user_id" => "?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",
|
||||
"isDig",
|
||||
"total_presupuesto",
|
||||
"total_pedido",
|
||||
"total_peso",
|
||||
"total_click",
|
||||
"total_preimpresion",
|
||||
"total_preimpresion_margen",
|
||||
"total_manipulado",
|
||||
"total_acabado",
|
||||
"total_envios",
|
||||
"envios_recoge_cliente",
|
||||
"margen",
|
||||
"margen_extra",
|
||||
"margen_manual",
|
||||
"descuento",
|
||||
"base_imponible",
|
||||
"total_margen",
|
||||
"total_margen_extra",
|
||||
"total_descuento",
|
||||
"total",
|
||||
"forzar_total",
|
||||
"total_calculado",
|
||||
"total_confirmado",
|
||||
"total_confirmado_user_id",
|
||||
"total_confirmado_update_at",
|
||||
"tirada_alternativa_json_data",
|
||||
"aprobado_user_id",
|
||||
"aprobado_at",
|
||||
@ -194,6 +178,23 @@ class PresupuestoModel extends \App\Models\GoBaseModel
|
||||
"is_deleted",
|
||||
"comp_tipo_impresion",
|
||||
"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";
|
||||
|
||||
|
||||
@ -319,7 +319,6 @@ function load_datos_envios(){
|
||||
'actionBtns_direcciones': actionBtns_direcciones,
|
||||
})
|
||||
.draw();
|
||||
updateTotales()
|
||||
checkInsertar()
|
||||
});
|
||||
})
|
||||
@ -327,6 +326,4 @@ function load_datos_envios(){
|
||||
|
||||
|
||||
|
||||
load_datos_envios()
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -513,7 +513,7 @@
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"drawCallback": function(settings ) {
|
||||
updateTotales()
|
||||
updateTotales(false, true, false)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -555,7 +555,7 @@ $(document).on('click', '.btn-delete-lp', function(e) {
|
||||
tableLineasPresupuesto.row( row )
|
||||
.remove()
|
||||
.draw();
|
||||
updateTotales()
|
||||
updateTotales(true, false, false)
|
||||
})
|
||||
|
||||
|
||||
@ -1240,7 +1240,6 @@ function por_defecto_lp_bn(){
|
||||
|
||||
function fill_lp_bn(row, fromComparator=false){
|
||||
|
||||
console.log(row)
|
||||
if(fromComparator){
|
||||
|
||||
var input_data = {
|
||||
@ -1268,7 +1267,7 @@ function fill_lp_bn(row, fromComparator=false){
|
||||
eventos_lp_bn(data.maquinaTipo=='inkjet'?true:false)
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales()
|
||||
updateTotales(true, false, false)
|
||||
}
|
||||
|
||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||
@ -1550,7 +1549,7 @@ function fill_lp_color(row, fromComparator=false){
|
||||
eventos_lp_color(data.maquinaTipo=='inkjet'?true:false)
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales()
|
||||
updateTotales(true, false, false)
|
||||
}
|
||||
|
||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||
@ -1835,7 +1834,7 @@ function fill_lp_bnhq(row, fromComparator=false){
|
||||
eventos_lp_bnhq(data.maquinaTipo=='inkjet'?true:false)
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales()
|
||||
updateTotales(true, false, false)
|
||||
}
|
||||
|
||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||
@ -2120,7 +2119,7 @@ function fill_lp_colorhq(row, fromComparator=false){
|
||||
eventos_lp_colorhq(data.maquinaTipo=='inkjet'?true:false)
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales()
|
||||
updateTotales(true, false, false)
|
||||
}
|
||||
|
||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||
@ -2438,7 +2437,7 @@ function fill_lp_rot_bn(row, fromComparador=false){
|
||||
eventos_lp_rot_bn()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales()
|
||||
updateTotales(true, false, false)
|
||||
}
|
||||
|
||||
$('.lp_rot_bn').css('display', '')
|
||||
@ -2759,7 +2758,7 @@ function fill_lp_rot_color(row, fromComparador=false){
|
||||
eventos_lp_rot_color()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales()
|
||||
updateTotales(true, false, false)
|
||||
}
|
||||
|
||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||
@ -3022,7 +3021,7 @@ function fill_lp_cubierta(row, fromComparador=false){
|
||||
eventos_lp_cubierta()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -163,10 +163,9 @@ $('#saveDireccionEnvio').on('click', function(){
|
||||
}
|
||||
var peso_total_libro = 0
|
||||
|
||||
$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
|
||||
// No se incluyen las lineas de datos de rotativa
|
||||
if(!this.id.includes("_data") )
|
||||
peso_total_libro += parseFloat($('#' + this.id + '_peso').val())
|
||||
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
var rowData = this.data();
|
||||
peso_total_libro += rowData.peso
|
||||
})
|
||||
const peso_envio = peso_total_libro*parseInt($('#add_cantidad').val())/1000.0
|
||||
|
||||
@ -249,6 +248,7 @@ $('#saveDireccionEnvio').on('click', function(){
|
||||
})
|
||||
}
|
||||
checkInsertar()
|
||||
updateTotales(false, false, true)
|
||||
$('#addressForm').modal("hide");
|
||||
|
||||
|
||||
|
||||
@ -19,34 +19,34 @@
|
||||
<h6>Detalles del presupuesto</h6>
|
||||
<dl class="row mb-0">
|
||||
<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>
|
||||
<dd id="porcentajeMargenPapel" class="col-4 text-end py-1">NaN €</dd>
|
||||
<dd id="margenPapel" class="col-2 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"><?= old('0', $presupuestoEntity->total_margen_papel) ?>€</dd>
|
||||
|
||||
<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>
|
||||
<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="margenImpresion" class="col-2 py-1 text-end">NaN €</dd>
|
||||
<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"><?= old('0', $presupuestoEntity->total_margen_impresion) ?>€</dd>
|
||||
|
||||
<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>
|
||||
<dd id="porcentajeMargenServicios" class="col-4 text-end py-1">NaN €</dd>
|
||||
<dd id="margenServicios" class="col-2 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"><?= old('0', $presupuestoEntity->total_margen_servicios) ?>€</dd>
|
||||
|
||||
<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>
|
||||
<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">
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
@ -54,14 +54,14 @@
|
||||
|
||||
<dl class="row mb-0">
|
||||
<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>
|
||||
<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>
|
||||
<dd id="descuentoTotal" class="col-2 py-1 text-end">NaN €</dd>
|
||||
<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"><?= old('0', $presupuestoEntity->total_descuento) ?>€</dd>
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
<div class="d-grid float-end mb-4">
|
||||
@ -82,99 +82,114 @@
|
||||
<!------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
updateTotales()
|
||||
|
||||
function updateTotales(){
|
||||
|
||||
function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
|
||||
totalPapel = 0
|
||||
margenPapel = 0
|
||||
|
||||
totalImpresion = 0
|
||||
margenImpresion = 0
|
||||
|
||||
totalServicios = 0
|
||||
margenServicios = 0
|
||||
|
||||
$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
|
||||
if($('#' + this.id + '_checkPapel').prop('checked')){
|
||||
totalPapel += parseFloat($('#' + this.id + '_totalPapelPedido').val())
|
||||
margenPapel += parseFloat($('#' + this.id + '_margenPapelPedido').val())
|
||||
if(updateLP){
|
||||
if(typeof tableLineasPresupuesto !== 'undefined'){
|
||||
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
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){
|
||||
$('#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)
|
||||
})
|
||||
}
|
||||
|
||||
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){
|
||||
$('#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)
|
||||
})
|
||||
}
|
||||
|
||||
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(updateEnvio){
|
||||
|
||||
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) + '€')
|
||||
}
|
||||
|
||||
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 totalMargenes = margenPapel + margenImpresion + margenServicios + margenEnvios
|
||||
$('#totalCostes').text((totalCostes).toFixed(2) + '€')
|
||||
@ -189,11 +204,42 @@ function updateTotales(){
|
||||
$('#descuentoTotal').text((totalDescuento).toFixed(2) + '€')
|
||||
$('#totalDespuesDecuento').text((totalPresupuesto).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(){
|
||||
updateTotales()
|
||||
updateTotales(true, true, true)
|
||||
})
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
@ -135,6 +135,8 @@ $('#presupuestoForm').on( "submit", function( event ) {
|
||||
$.when(fill_bbdd_from_lp(id).then(function (data, textStatus, jqXHR){
|
||||
generateCompJSON()
|
||||
form = $('#presupuestoForm').serialize()
|
||||
form += getValuesResumenForm()
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo $formAction; ?>",
|
||||
|
||||
Reference in New Issue
Block a user