mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando
This commit is contained in:
@ -232,12 +232,16 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
$postData = $this->request->getPost();
|
$postData = $this->request->getPost();
|
||||||
|
|
||||||
$postData['updated_at'] = gmdate('Y-m-d H:m:s', time());
|
$postData['updated_at'] = gmdate('Y-m-d H:m:s', time());
|
||||||
|
|
||||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||||
|
|
||||||
// JJO
|
|
||||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||||
|
|
||||||
|
if(isset($sanitizedData['total_aceptado_revisado']) && $sanitizedData['total_aceptado_revisado'] != 0
|
||||||
|
&& $sanitizedData['total_aceptado_revisado'] != null && $sanitizedData['total_aceptado_revisado'] != ""){
|
||||||
|
$sanitizedData['aprobado_at'] = $sanitizedData['updated_at'];
|
||||||
|
$sanitizedData['aprobado_by'] = $sanitizedData['user_updated_id'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->request->getPost('is_duplicado') == null) {
|
if ($this->request->getPost('is_duplicado') == null) {
|
||||||
$sanitizedData['is_duplicado'] = 0;
|
$sanitizedData['is_duplicado'] = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,10 +83,6 @@ class PresupuestoAdminEdit {
|
|||||||
// Autonumeric
|
// Autonumeric
|
||||||
AutoNumeric.multiple('.autonumeric-currency', { decimalPlaces: 2, currencySymbol: '€', currencySymbolPlacement: 's', digitGroupSeparator: '.', decimalCharacter: ',' });
|
AutoNumeric.multiple('.autonumeric-currency', { decimalPlaces: 2, currencySymbol: '€', currencySymbolPlacement: 's', digitGroupSeparator: '.', decimalCharacter: ',' });
|
||||||
|
|
||||||
$('#total_aceptado_revisado').on('change', function () {
|
|
||||||
AutoNumeric.getAutoNumericElement(this).set(this.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const impresion_id = $('#tipo_impresion_id').val();
|
const impresion_id = $('#tipo_impresion_id').val();
|
||||||
let tipoLibro = '';
|
let tipoLibro = '';
|
||||||
if (impresion_id == 1 || impresion_id == 2) {
|
if (impresion_id == 1 || impresion_id == 2) {
|
||||||
@ -124,6 +120,11 @@ class PresupuestoAdminEdit {
|
|||||||
this.tiradasAlternativas.init();
|
this.tiradasAlternativas.init();
|
||||||
this.resumen.init();
|
this.resumen.init();
|
||||||
|
|
||||||
|
$('#btn_aceptar_revisado').on('click', function () {
|
||||||
|
|
||||||
|
this.resumen.updateTotales({ updateLP: true, updateServicios: true, updateEnvio: true });
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
if (window.location.href.includes("edit")) {
|
if (window.location.href.includes("edit")) {
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ class Resumen {
|
|||||||
const self = this;
|
const self = this;
|
||||||
this.toastPresupuestoTotal = null
|
this.toastPresupuestoTotal = null
|
||||||
$(".update-totales").on("change", function () {
|
$(".update-totales").on("change", function () {
|
||||||
self.updateTotales(true, true, true)
|
self.updateTotales(null, { updateLP: true, updateServicios: true, updateEnvio: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('update-totales', async function () {
|
$(document).on('update-totales', async function () {
|
||||||
@ -52,7 +52,7 @@ class Resumen {
|
|||||||
$("#margenEnvios").html(resumen.total_margen_envios || 0);
|
$("#margenEnvios").html(resumen.total_margen_envios || 0);
|
||||||
$("#margenEnvios").val(resumen.total_margen_envios || 0);
|
$("#margenEnvios").val(resumen.total_margen_envios || 0);
|
||||||
|
|
||||||
$("#totalCostes").html(resumen.total_costes || 0);
|
$("#totalCostes").html(resumen.total_costes || 0).val();
|
||||||
$("#porcentajeMargen").html(resumen.porcentajeMargen ? resumen.porcentajeMargen: 0);
|
$("#porcentajeMargen").html(resumen.porcentajeMargen ? resumen.porcentajeMargen: 0);
|
||||||
$("#totalMargenes").html(resumen.total_margenes || 0);
|
$("#totalMargenes").html(resumen.total_margenes || 0);
|
||||||
$("#totalCostes").val(resumen.total_costes || 0);
|
$("#totalCostes").val(resumen.total_costes || 0);
|
||||||
@ -94,7 +94,7 @@ class Resumen {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
async updateTotales(event, data = {}) {
|
async updateTotales(data = {}) {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
@ -297,8 +297,20 @@ class Resumen {
|
|||||||
margenEnvios = parseFloat($('#margenEnvios').attr('val'))
|
margenEnvios = parseFloat($('#margenEnvios').attr('val'))
|
||||||
}
|
}
|
||||||
|
|
||||||
let totalCostes = parseFloat(totalPapel.toFixed(2)) + parseFloat(totalImpresion.toFixed(2)) + parseFloat(totalServicios.toFixed(2)) + parseFloat(totalEnvios.toFixed(2))
|
let totalCostes = parseFloat(totalPapel.toFixed(2)) + parseFloat(totalImpresion.toFixed(2))
|
||||||
|
+ parseFloat(totalServicios.toFixed(2)) + parseFloat(totalEnvios.toFixed(2))
|
||||||
|
|
||||||
let totalMargenes = parseFloat(margenPapel.toFixed(2)) + parseFloat(margenImpresion.toFixed(2)) + parseFloat(margenServicios.toFixed(2)) + parseFloat(margenEnvios.toFixed(2))
|
let totalMargenes = parseFloat(margenPapel.toFixed(2)) + parseFloat(margenImpresion.toFixed(2)) + parseFloat(margenServicios.toFixed(2)) + parseFloat(margenEnvios.toFixed(2))
|
||||||
|
|
||||||
|
let total_aceptado_revisado = AutoNumeric.getAutoNumericElement($('#total_aceptado_revisado')[0]).getNumber()
|
||||||
|
if(total_aceptado_revisado != '' && total_aceptado_revisado != undefined &&
|
||||||
|
total_aceptado_revisado != null && total_aceptado_revisado != 0){
|
||||||
|
if(total_aceptado_revisado < totalCostes){
|
||||||
|
total_aceptado_revisado = totalCoste ;
|
||||||
|
}
|
||||||
|
totalMargenes = parseFloat(total_aceptado_revisado)- totalCostes;
|
||||||
|
}
|
||||||
|
|
||||||
let porcentajeMargen = totalCostes + totalMargenes > 0 ? (100 * totalMargenes / (totalCostes + totalMargenes)).toFixed(0) : 0
|
let porcentajeMargen = totalCostes + totalMargenes > 0 ? (100 * totalMargenes / (totalCostes + totalMargenes)).toFixed(0) : 0
|
||||||
$('#totalCostes').html(totalCostes).val(totalCostes.toFixed(2))
|
$('#totalCostes').html(totalCostes).val(totalCostes.toFixed(2))
|
||||||
$('#totalMargenes').html(totalMargenes).val(totalMargenes.toFixed(2))
|
$('#totalMargenes').html(totalMargenes).val(totalMargenes.toFixed(2))
|
||||||
@ -307,7 +319,7 @@ class Resumen {
|
|||||||
if ($('#total_descuentoPercent').val() < 0) {
|
if ($('#total_descuentoPercent').val() < 0) {
|
||||||
$('#total_descuentoPercent').val(0)
|
$('#total_descuentoPercent').val(0)
|
||||||
}
|
}
|
||||||
let totalAntesDescuento = totalCostes + totalMargenes - parseFloat(totalEnvios.toFixed(2)) + totalEnvios_base;
|
let totalAntesDescuento = totalCostes + totalMargenes + parseFloat(totalEnvios.toFixed(2)) + totalEnvios_base;
|
||||||
let totalDescuento = totalAntesDescuento * parseInt($('#total_descuentoPercent').val() || 0) / 100
|
let totalDescuento = totalAntesDescuento * parseInt($('#total_descuentoPercent').val() || 0) / 100
|
||||||
let totalPresupuesto = totalAntesDescuento - totalDescuento; // para el calculo del precio_u solo se tiene en cuenta el base
|
let totalPresupuesto = totalAntesDescuento - totalDescuento; // para el calculo del precio_u solo se tiene en cuenta el base
|
||||||
let precioUnidad = totalPresupuesto / parseInt($('#tirada').val())
|
let precioUnidad = totalPresupuesto / parseInt($('#tirada').val())
|
||||||
@ -372,6 +384,9 @@ class Resumen {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFromTotalAceptadoRevisado() {
|
||||||
|
}
|
||||||
|
|
||||||
roundToTwoDecimals(num) {
|
roundToTwoDecimals(num) {
|
||||||
return parseFloat(num.toFixed(2));
|
return parseFloat(num.toFixed(2));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user