mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en guardar
This commit is contained in:
@ -523,66 +523,34 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
$data['comentarios_produccion'] = $presupuesto->comentarios_produccion;
|
$data['comentarios_produccion'] = $presupuesto->comentarios_produccion;
|
||||||
|
|
||||||
$data['tiradasAlternativas'] = json_decode($presupuesto->tirada_alternativa_json_data);
|
$data['tiradasAlternativas'] = json_decode($presupuesto->tirada_alternativa_json_data);
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$datos_papel = $this->obtenerDatosPapel($presupuesto->id);
|
|
||||||
$data['interior'] = $datos_papel['interior'] ? $datos_papel['interior'] : [];
|
|
||||||
|
|
||||||
$data['cubierta'] = $datos_papel['cubierta'] ? $datos_papel['cubierta'] : [];
|
|
||||||
$data['cubierta']['tapa'] = $this->obtenerTipoTapa($presupuesto->tipo_impresion_id ?? null);
|
|
||||||
$data['cubierta']['lomoRedondo'] = $presupuesto->lomo_redondo ? 1 : 0;
|
|
||||||
$data['cubierta']['solapas'] = $presupuesto->solapas ? 1 : 0;
|
|
||||||
$data['cubierta']['solapas_ancho'] = $presupuesto->solapas_ancho;
|
|
||||||
$data['cubierta']['cabezada'] = $presupuesto->cabezada;
|
|
||||||
$modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel");
|
|
||||||
$data['cubierta']['acabado']['id'] = $presupuesto->acabado_cubierta_id;
|
|
||||||
if ($presupuesto->acabado_cubierta_id == 0) {
|
|
||||||
$data['cubierta']['acabado']['text'] = "Ninguno";
|
|
||||||
} else {
|
|
||||||
$data['cubierta']['acabado']['text'] = $modelAcabado->find($presupuesto->acabado_cubierta_id)->nombre;
|
|
||||||
}
|
|
||||||
$data['cubierta']['retractilado'] = $presupuesto->retractilado ? 1 : 0;
|
|
||||||
|
|
||||||
$data['sobrecubierta'] = array_key_exists('sobrecubierta', $datos_papel) ? $datos_papel['sobrecubierta'] : [];
|
|
||||||
$data['sobrecubierta']['solapas'] = $presupuesto->solapas_sobrecubierta ? 1 : 0;
|
|
||||||
$data['sobrecubierta']['solapas_ancho'] = $presupuesto->solapas_ancho_sobrecubierta;
|
|
||||||
$data['sobrecubierta']['acabado']['id'] = $presupuesto->acabado_sobrecubierta_id;
|
|
||||||
if ($presupuesto->acabado_sobrecubierta_id == 0) {
|
|
||||||
$data['sobrecubierta']['acabado']['text'] = "Ninguno";
|
|
||||||
} else {
|
|
||||||
$data['sobrecubierta']['acabado']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['guardas'] = array_key_exists('guardas', $datos_papel) ? $datos_papel['guardas'] : [];
|
|
||||||
|
|
||||||
$modelLinea = new PresupuestoLineaModel();
|
|
||||||
$lineas = $modelLinea->where('presupuesto_id', $id)->findAll();
|
|
||||||
|
|
||||||
[$data['datosGenerales']['paginasNegro'], $data['datosGenerales']['paginasColor']] =
|
|
||||||
$this->getPaginas($lineas);
|
|
||||||
|
|
||||||
if (intval($presupuesto->envios_recoge_cliente) == 1) {
|
|
||||||
$data['direcciones']['entrega_taller'] = 1;
|
|
||||||
} else {
|
|
||||||
$data['direcciones']['entrega_taller'] = 0;
|
|
||||||
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (intval($presupuesto->estado_id) == 2) {
|
|
||||||
$data['resumen']['base'] = $presupuesto->total_aceptado;
|
|
||||||
$data['resumen']['precio_unidad'] = $presupuesto->total_precio_unidad;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data);
|
|
||||||
if (!is_null($tiradas_alternativas)) {
|
|
||||||
for ($i = 0; $i < count($tiradas_alternativas); $i++) {
|
|
||||||
$tirada = $tiradas_alternativas[$i];
|
|
||||||
$data['datosGenerales']['tirada' . ($i + 2)] = $tirada->tirada;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
$data['resumen']['total_coste_papel'] = $presupuesto->total_coste_papel;
|
||||||
|
$data['resumen']['total_margenPercent_papel'] = $presupuesto->total_margenPercent_papel;
|
||||||
|
$data['resumen']['total_margen_papel'] = $presupuesto->total_margen_papel;
|
||||||
|
$data['resumen']['total_coste_impresion'] = $presupuesto->total_coste_impresion;
|
||||||
|
$data['resumen']['total_margenPercent_impresion'] = $presupuesto->total_margenPercent_impresion;
|
||||||
|
$data['resumen']['total_margen_impresion'] = $presupuesto->total_margen_impresion;
|
||||||
|
$data['resumen']['total_coste_servicios'] = $presupuesto->total_coste_servicios;
|
||||||
|
$data['resumen']['total_margenPercent_servicios'] = $presupuesto->total_margenPercent_servicios;
|
||||||
|
$data['resumen']['total_margen_servicios'] = $presupuesto->total_margen_servicios;
|
||||||
|
$data['resumen']['total_coste_envios'] = $presupuesto->total_coste_envios;
|
||||||
|
$data['resumen']['total_margen_envios'] = $presupuesto->total_margen_envios;
|
||||||
|
$data['resumen']['total_costes'] = $presupuesto->total_costes;
|
||||||
|
$data['resumen']['porcentajeMargen'] =
|
||||||
|
round(($presupuesto->total_costes + $presupuesto->total_margenes) > 0 ?
|
||||||
|
100 * $presupuesto->total_margenes / ($presupuesto->total_costes + $presupuesto->total_margenes) :
|
||||||
|
0, 0);
|
||||||
|
$data['resumen']['total_margenes'] = $presupuesto->total_margenes;
|
||||||
|
$data['resumen']['total_antes_descuento'] = $presupuesto->total_antes_descuento;
|
||||||
|
$data['resumen']['total_descuentoPercent'] = $presupuesto->total_descuentoPercent;
|
||||||
|
$data['resumen']['total_descuento'] = $presupuesto->total_descuento;
|
||||||
|
$data['resumen']['total_presupuesto'] = $presupuesto->total_presupuesto;
|
||||||
|
$data['resumen']['total_precio_unidad'] = $presupuesto->total_precio_unidad;
|
||||||
|
$data['resumen']['total_factor'] = is_numeric($presupuesto->total_factor) ? $presupuesto->total_factor : 0;
|
||||||
|
$data['resumen']['total_factor_ponderado'] = is_numeric($presupuesto->total_factor_ponderado) ? $presupuesto->total_factor_ponderado : 0;
|
||||||
|
if($presupuesto->estado_id == 2){
|
||||||
|
$data['resumen']['total_aceptado'] = $presupuesto->total_aceptado;
|
||||||
|
}
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'data' => $data
|
'data' => $data
|
||||||
@ -604,8 +572,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
$papel_generico = $this->request->getPost('papel_generico');
|
$papel_generico = $this->request->getPost('papel_generico');
|
||||||
$gramaje = $this->request->getPost('gramaje');
|
$gramaje = $this->request->getPost('gramaje');
|
||||||
$paginas_color = $this->request->getPost('paginas_color');
|
$paginas_color = $this->request->getPost('paginas_color');
|
||||||
$isColor = $this->request->getPost('isColor')?1:0;
|
$isColor = $this->request->getPost('isColor') ? 1 : 0;
|
||||||
$isHq = $this->request->getPost('isHq')?1:0;
|
$isHq = $this->request->getPost('isHq') ? 1 : 0;
|
||||||
$tipo_impresion_id = $this->request->getPost('tipo_impresion_id');
|
$tipo_impresion_id = $this->request->getPost('tipo_impresion_id');
|
||||||
$uso = $this->request->getPost('uso');
|
$uso = $this->request->getPost('uso');
|
||||||
|
|
||||||
@ -849,7 +817,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(Collection::datatable(
|
return $this->respond(Collection::datatable(
|
||||||
$resourceData,
|
$resourceData,
|
||||||
@ -890,7 +858,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
'nombre' => $reqData['papel_generico'] ?? "",
|
'nombre' => $reqData['papel_generico'] ?? "",
|
||||||
];
|
];
|
||||||
|
|
||||||
if($papel_generico['id'] != 0 && $papel_generico['nombre'] == ""){
|
if ($papel_generico['id'] != 0 && $papel_generico['nombre'] == "") {
|
||||||
$modelPapelGenerico = new PapelGenericoModel();
|
$modelPapelGenerico = new PapelGenericoModel();
|
||||||
$papel_generico['nombre'] = $modelPapelGenerico->getNombre($papel_generico['id'])['nombre'];
|
$papel_generico['nombre'] = $modelPapelGenerico->getNombre($papel_generico['id'])['nombre'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,6 +145,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
|
|||||||
$reqData = $this->request->getJSON();
|
$reqData = $this->request->getJSON();
|
||||||
|
|
||||||
if($reqData->tipo=='get_tarifa'){
|
if($reqData->tipo=='get_tarifa'){
|
||||||
|
|
||||||
$peso = $reqData->peso ?? 0;
|
$peso = $reqData->peso ?? 0;
|
||||||
$paisId = $reqData->paisId ?? 0;
|
$paisId = $reqData->paisId ?? 0;
|
||||||
$cp = $reqData->cp ?? 0;
|
$cp = $reqData->cp ?? 0;
|
||||||
|
|||||||
@ -98,11 +98,13 @@ class TarifaEnvioModel extends \App\Models\BaseModel
|
|||||||
// Si el pais es españa se tienen que tener en cuenta los postales
|
// Si el pais es españa se tienen que tener en cuenta los postales
|
||||||
// Se busca primero la tarifa a la que corresponde
|
// Se busca primero la tarifa a la que corresponde
|
||||||
$builder = $this->db->table($this->table . " t1")
|
$builder = $this->db->table($this->table . " t1")
|
||||||
->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo")
|
->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo, t3.nombre as pais")
|
||||||
->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id")
|
->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id")
|
||||||
|
->join("lg_paises t3", "t1.pais_id = t3.id")
|
||||||
->where("t1.pais_id", $paisId)
|
->where("t1.pais_id", $paisId)
|
||||||
->where("t1.is_deleted", 0)
|
->where("t1.is_deleted", 0)
|
||||||
->where("t2.is_deleted", 0);
|
->where("t2.is_deleted", 0);
|
||||||
|
|
||||||
|
|
||||||
if ($paisId == 1) { // España
|
if ($paisId == 1) { // España
|
||||||
$builder->where("CAST(t2.cp_inicial AS UNSIGNED)<=", intval($cp))
|
$builder->where("CAST(t2.cp_inicial AS UNSIGNED)<=", intval($cp))
|
||||||
@ -117,10 +119,12 @@ class TarifaEnvioModel extends \App\Models\BaseModel
|
|||||||
$precio_tarifas = $model->getEnvioPrecio($tarifa->tarifa_envio_id, $peso, $tipo_envio);
|
$precio_tarifas = $model->getEnvioPrecio($tarifa->tarifa_envio_id, $peso, $tipo_envio);
|
||||||
foreach ($precio_tarifas as $precio_tarifa) {
|
foreach ($precio_tarifas as $precio_tarifa) {
|
||||||
$precio_tarifa->importe_fijo = $tarifa->importe_fijo;
|
$precio_tarifa->importe_fijo = $tarifa->importe_fijo;
|
||||||
|
$precio_tarifa->pais = $tarifa->pais;
|
||||||
array_push($resultado, $precio_tarifa);
|
array_push($resultado, $precio_tarifa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $resultado;
|
return $resultado;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,219 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
// Funcion para obtener el peso total del libro
|
|
||||||
function get_peso_libro(){
|
|
||||||
|
|
||||||
var peso_total_libro = 0.0
|
|
||||||
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
peso_total_libro += parseFloat(rowData.peso)
|
|
||||||
})
|
|
||||||
return peso_total_libro;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function get_precio_envio(peso, paisId, cp, tipo_envio){
|
|
||||||
|
|
||||||
data = {
|
|
||||||
tipo: 'get_tarifa',
|
|
||||||
peso: peso,
|
|
||||||
paisId: paisId,
|
|
||||||
cp: cp,
|
|
||||||
tipo_envio: tipo_envio,
|
|
||||||
}
|
|
||||||
data = Object.assign(data, window.token_ajax);
|
|
||||||
|
|
||||||
const response = await fetch(window.location.origin + window.url_get_precio_envio , {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify(data),
|
|
||||||
headers: {
|
|
||||||
"Content-type": "application/json; charset=UTF-8",
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const values = await response.json();
|
|
||||||
yeniden(values[window.csrf_token]);
|
|
||||||
return values.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function get_coste_envio_tiradasAlternativas(tirada){
|
|
||||||
|
|
||||||
var peso_libro = get_peso_libro();
|
|
||||||
var tirada_inicial = parseInt($('#tirada').val());
|
|
||||||
var coste = 0.0;
|
|
||||||
var margen = 0.0;
|
|
||||||
|
|
||||||
const table = $('#tableOfDireccionesEnvio').DataTable();
|
|
||||||
const rows = table.rows().nodes();
|
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; i++) {
|
|
||||||
const rowData = table.row(rows[i]).data();
|
|
||||||
const porcentaje = parseInt(rowData.cantidad)/tirada_inicial*100.0;
|
|
||||||
const cantidad = Math.floor(tirada*porcentaje/100.0);
|
|
||||||
const peso_envio = cantidad*peso_libro/1000.0;
|
|
||||||
const datos_tarifa = await get_precio_envio(peso_envio, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
|
|
||||||
|
|
||||||
if(datos_tarifa.id!=null){
|
|
||||||
|
|
||||||
if(peso_envio>parseFloat(datos_tarifa.peso_max)){
|
|
||||||
coste += (parseFloat(datos_tarifa.precio_min) + (peso_envio-parseFloat(datos_tarifa.peso_min)) * parseFloat(datos_tarifa.precio_adicional)).toFixed(2);
|
|
||||||
}
|
|
||||||
// si no se calcula linealmente
|
|
||||||
else{
|
|
||||||
m=((parseFloat(datos_tarifa.precio_max)-parseFloat(datos_tarifa.precio_min))/(parseFloat(datos_tarifa.peso_max)-parseFloat(datos_tarifa.peso_min)));
|
|
||||||
b=parseFloat(datos_tarifa.precio_max)-m*parseFloat(datos_tarifa.peso_max);
|
|
||||||
coste += parseFloat(m*peso_envio+b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
margen += coste*datos_tarifa.margen/100.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {coste, margen};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function updateTablaEnvios(tirada_inicial = null, tirada = null){
|
|
||||||
|
|
||||||
var peso_total_libro = get_peso_libro();
|
|
||||||
|
|
||||||
$('#tableOfDireccionesEnvio').DataTable().rows().every(async function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
|
|
||||||
var rowData = this.data();
|
|
||||||
|
|
||||||
if(tirada_inicial!=null && tirada!=null){
|
|
||||||
const porcentaje = parseInt(rowData.cantidad)/tirada_inicial*100.0;
|
|
||||||
const cantidad = Math.floor(tirada*porcentaje/100.0);
|
|
||||||
rowData.cantidad = cantidad
|
|
||||||
}
|
|
||||||
const peso_envio = peso_total_libro*parseInt(rowData.cantidad)/1000.0;
|
|
||||||
|
|
||||||
var datos_tarifa = await get_precio_envio(peso_envio, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
|
|
||||||
|
|
||||||
|
|
||||||
if(datos_tarifa.id!=null){
|
|
||||||
|
|
||||||
if(peso_envio>parseFloat(datos_tarifa.peso_max) || parseFloat(datos_tarifa.peso_max) == 0){
|
|
||||||
datos_tarifa.precio = parseFloat(datos_tarifa.peso_min) + (peso_envio-parseFloat(datos_tarifa.peso_min))*parseFloat(datos_tarifa.precio_adicional);
|
|
||||||
}
|
|
||||||
// si no se calcula linealmente
|
|
||||||
else{
|
|
||||||
m=((parseFloat(datos_tarifa.precio_max)-parseFloat(datos_tarifa.precio_min))/(parseFloat(datos_tarifa.peso_max)-parseFloat(datos_tarifa.peso_min)));
|
|
||||||
b=parseFloat(datos_tarifa.precio_max)-m*parseFloat(datos_tarifa.peso_max);
|
|
||||||
datos_tarifa.precio = parseFloat(m*peso_envio+b);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
datos_tarifa.cantidad = parseInt($('#add_cantidad').val());
|
|
||||||
datos_tarifa.peso = peso_envio;
|
|
||||||
|
|
||||||
$('#tableOfDireccionesEnvio').DataTable().row(rowIdx)
|
|
||||||
.data({
|
|
||||||
'tarifa_id': datos_tarifa.id,
|
|
||||||
'cantidad': rowData.cantidad,
|
|
||||||
'peso': datos_tarifa.peso.toFixed(3),
|
|
||||||
'att': rowData.att,
|
|
||||||
'email': rowData.email,
|
|
||||||
'direccion': rowData.direccion,
|
|
||||||
'cp': rowData.cp,
|
|
||||||
'municipio': rowData.municipio,
|
|
||||||
'provincia': rowData.provincia,
|
|
||||||
'paisId': rowData.paisId,
|
|
||||||
'telefono': rowData.telefono,
|
|
||||||
'proveedor': datos_tarifa.proveedor,
|
|
||||||
'proveedor_id': datos_tarifa.proveedor_id,
|
|
||||||
'precio': datos_tarifa.precio.toFixed(2),
|
|
||||||
'margen': datos_tarifa.margen,
|
|
||||||
'entregaPieCalle': rowData.entregaPieCalle,
|
|
||||||
'actionBtns_direcciones': actionBtns_direcciones,
|
|
||||||
})
|
|
||||||
.draw();
|
|
||||||
|
|
||||||
checkInsertar()
|
|
||||||
//updateTotales(false, false, true)
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: false,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
popErrorAlert(window.error_no_tarifa_envio, 'error-tarifa')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#insertar_direccion').on('click', function(){
|
|
||||||
|
|
||||||
$("#addressForm").attr('action','create')
|
|
||||||
var $newAddDialog = $("#addressForm")
|
|
||||||
var maximaCantidad = parseInt($('#tirada').val())
|
|
||||||
$("#add_cantidad").attr("max" , maximaCantidad);
|
|
||||||
$("#add_cantidad").val( maximaCantidad);
|
|
||||||
$("#add_cantidad").on('change', function(){
|
|
||||||
$("#add_cantidad").val(parseInt($("#add_cantidad").val())>maximaCantidad ? maximaCantidad : $("#add_cantidad").val())
|
|
||||||
})
|
|
||||||
|
|
||||||
cantidad_total = 0
|
|
||||||
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var data = this.data();
|
|
||||||
cantidad_total += parseInt(data.cantidad)
|
|
||||||
} );
|
|
||||||
$('#add_cantidad').attr('max-value', parseInt($('#tirada').val())-cantidad_total)
|
|
||||||
$('#add_cantidad').val(parseInt($('#tirada').val())-cantidad_total)
|
|
||||||
$newAddDialog.modal('show')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function save_datos_envios(){
|
|
||||||
|
|
||||||
var id = $('#presupuesto_id').val()
|
|
||||||
|
|
||||||
$.post( window.routes_envios.dataTableOfPresupuestoDirecciones,
|
|
||||||
Object.assign({tipo: "clear_lineas", presupuesto_id: id}, window.token_ajax))
|
|
||||||
.done(function( data ) {
|
|
||||||
|
|
||||||
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var data = this.data();
|
|
||||||
$.post( '/presupuestos/presupuestodirecciones/add',
|
|
||||||
Object.assign({
|
|
||||||
presupuesto_id : id,
|
|
||||||
tarifa_id : data.tarifa_id,
|
|
||||||
cantidad : data.cantidad,
|
|
||||||
peso : data.peso,
|
|
||||||
att : data.att,
|
|
||||||
email : data.email,
|
|
||||||
direccion : data.direccion,
|
|
||||||
paisId : data.paisId,
|
|
||||||
provincia : data.provincia,
|
|
||||||
municipio : data.municipio,
|
|
||||||
cp : data.cp,
|
|
||||||
telefono : data.telefono,
|
|
||||||
precio : data.precio,
|
|
||||||
margen : data.margen,
|
|
||||||
proveedor : data.proveedor,
|
|
||||||
proveedor_id : data.proveedor_id,
|
|
||||||
entregaPieCalle : data.entregaPieCalle}, window.token_ajax))
|
|
||||||
});
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
@ -1,91 +0,0 @@
|
|||||||
async function updatePresupuesto(
|
|
||||||
{
|
|
||||||
update_lineas = false,
|
|
||||||
update_servicios = false,
|
|
||||||
update_envios = false,
|
|
||||||
update_resumen = false,
|
|
||||||
update_tiradas_alternativas = false
|
|
||||||
}) {
|
|
||||||
|
|
||||||
new Promise(
|
|
||||||
async function(resolve, reject){
|
|
||||||
if(update_lineas){
|
|
||||||
await updateLineasPresupuesto()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
).then(function(){
|
|
||||||
new Promise(
|
|
||||||
async function(resolve, reject){
|
|
||||||
if(update_servicios){
|
|
||||||
await actualizar_servicios()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}).then(function(){
|
|
||||||
new Promise(
|
|
||||||
function(resolve, reject){
|
|
||||||
if(update_envios){
|
|
||||||
updateTablaEnvios()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}).then(function(){
|
|
||||||
new Promise(
|
|
||||||
function(resolve, reject){
|
|
||||||
if(update_resumen){
|
|
||||||
updateTotales()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}).then(function(){
|
|
||||||
new Promise(
|
|
||||||
async function(resolve, reject){
|
|
||||||
if(update_tiradas_alternativas){
|
|
||||||
await actualizar_tiradas_alternativas()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateLineasPresupuesto(){
|
|
||||||
|
|
||||||
$('#tableLineasPresupuesto tbody tr:visible ').each(async function(){
|
|
||||||
|
|
||||||
if(this.id.endsWith('lp_bn')){
|
|
||||||
await calcularPresupuesto_bn({}, true);
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_bnhq')){
|
|
||||||
await calcularPresupuesto_bnhq({}, true);
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_color')){
|
|
||||||
await calcularPresupuesto_color({}, true);
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_colorhq')){
|
|
||||||
await calcularPresupuesto_colorhq({}, true);
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_rot_bn')){
|
|
||||||
await calcularPresupuesto_rot_bn(false, true, {})
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_rot_color')){
|
|
||||||
await calcularPresupuesto_rot_color(false, true, {})
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('_cubierta')){
|
|
||||||
await calcularPresupuesto_cubierta(false, {})
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('_guardas')){
|
|
||||||
await calcularPresupuesto_guardas(false, {})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -18,55 +18,57 @@
|
|||||||
<!-- Price Details -->
|
<!-- Price Details -->
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-5 py-1 fw-normal text-end">Coste papel</dt>
|
<dt class="col-5 py-1 fw-normal text-end">Coste papel</dt>
|
||||||
<dd id="totalCostePapel" class="py-1 col-6 text-end"><?= old('0', $presupuestoEntity->total_coste_papel) ?>€</dd>
|
<dd id="totalCostePapel" class="py-1 col-6 text-end"></dd>
|
||||||
<dt class="col-5 py-1 fw-normal text-end">Margen papel</dt>
|
<dt class="col-5 py-1 fw-normal text-end">Margen papel</dt>
|
||||||
<dd id="porcentajeMargenPapel" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_papel) ?>%</dd>
|
<dd id="porcentajeMargenPapel" class="col-3 text-end py-1"></dd>
|
||||||
<dd id="margenPapel" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_papel) ?>€</dd>
|
<dd id="margenPapel" class="col-3 text-end py-1"></dd>
|
||||||
|
|
||||||
<dt class="col-5 fw-normal text-end">Coste impresión</dt>
|
<dt class="col-5 fw-normal text-end">Coste impresión</dt>
|
||||||
<dd id="totalCosteImpresion" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_coste_impresion) ?>€</dd>
|
<dd id="totalCosteImpresion" class="col-6 text-end"></dd>
|
||||||
<dt class="col-5 py-1 fw-normal text-end">Margen impresión</dt>
|
<dt class="col-5 py-1 fw-normal text-end">Margen impresión</dt>
|
||||||
<dd id="porcentajeMargenImpresion" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_impresion) ?>%</dd>
|
<dd id="porcentajeMargenImpresion" class="col-3 text-end py-1"></dd>
|
||||||
<dd id="margenImpresion" class="col-3 py-1 text-end"><?= old('0', $presupuestoEntity->total_margen_impresion) ?>€</dd>
|
<dd id="margenImpresion" class="col-3 py-1 text-end"></dd>
|
||||||
|
|
||||||
<dt class="col-5 fw-normal text-end">Coste servicios</dt>
|
<dt class="col-5 fw-normal text-end">Coste servicios</dt>
|
||||||
<dd id="totalServicios" class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_coste_servicios) ?>€</dd>
|
<dd id="totalServicios" class="col-6 text-end py-1"></dd>
|
||||||
<dt class="col-5 fw-normal text-end">Margen servicios</dt>
|
<dt class="col-5 fw-normal text-end">Margen servicios</dt>
|
||||||
<dd id="porcentajeMargenServicios" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_servicios) ?>%</dd>
|
<dd id="porcentajeMargenServicios" class="col-3 text-end py-1"></dd>
|
||||||
<dd id="margenServicios" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_servicios) ?>€</dd>
|
<dd id="margenServicios" class="col-3 text-end py-1"></dd>
|
||||||
|
|
||||||
<dt class="col-5 fw-normal text-end">Coste de envío</dt>
|
<dt class="col-5 fw-normal text-end">Coste de envío</dt>
|
||||||
<dd id="totalEnvios"class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_coste_envios) ?>€</dd>
|
<dd id="costeEnvios"class="col-6 text-end py-1"></dd>
|
||||||
|
<dt class="col-5 fw-normal text-end">Precio de envío</dt>
|
||||||
|
<dd id="totalEnvios"class="col-6 text-end py-1"></dd>
|
||||||
<dt class="col-5 fw-normal text-end">Margen envío</dt>
|
<dt class="col-5 fw-normal text-end">Margen envío</dt>
|
||||||
<dd id="margenEnvios" class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_envios) ?>€</dd>
|
<dd id="margenEnvios" class="col-6 text-end py-1"></dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<hr class="mx-n4">
|
<hr class="mx-n4">
|
||||||
|
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-5 fw-normal text-end">Total Costes</dt>
|
<dt class="col-5 fw-normal text-end">Total Costes</dt>
|
||||||
<dd id="totalCostes" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_costes) ?>€</dd>
|
<dd id="totalCostes" class="col-6 text-end"></dd>
|
||||||
<dt class="col-5 fw-normal text-end">Total Margen</dt>
|
<dt class="col-5 fw-normal text-end">Total Margen</dt>
|
||||||
<dd id="porcentajeMargen" class="col-3 text-end py-1"><?= old('0', round(($presupuestoEntity->total_costes+$presupuestoEntity->total_margenes)>0? 100*$presupuestoEntity->total_margenes/($presupuestoEntity->total_costes+$presupuestoEntity->total_margenes) : 0,0)) ?>%</dd>
|
<dd id="porcentajeMargen" class="col-3 text-end py-1"></dd>
|
||||||
<dd id="totalMargenes" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenes) ?>€</dd>
|
<dd id="totalMargenes" class="col-3 text-end py-1"></dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<hr class="mx-n4">
|
<hr class="mx-n4">
|
||||||
|
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-5 fw-normal text-end">Total</dt>
|
<dt class="col-5 fw-normal text-end">Total</dt>
|
||||||
<dd id="totalAntesDescuento" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_antes_descuento) ?>€</dd>
|
<dd id="totalAntesDescuento" class="col-6 text-end"></dd>
|
||||||
<dt class="col-5 py-1 fw-normal text-end">Descuento</dt>
|
<dt class="col-5 py-1 fw-normal text-end">Descuento</dt>
|
||||||
<dd id="dd" class="col-3 text-end py-1"><input id="total_descuentoPercent" type="number" value="<?= old('0', $presupuestoEntity->total_descuentoPercent) ?>" class="update-totales form-control" style="width:100% !important;"></dd>
|
<dd id="dd" class="col-3 text-end py-1"><input id="total_descuentoPercent" type="number" value="" class="update-totales form-control" style="width:100% !important;">%</dd>
|
||||||
<dd id="descuentoTotal" class="col-3 py-1 text-end"><?= old('0', $presupuestoEntity->total_descuento) ?>€</dd>
|
<dd id="descuentoTotal" class="col-3 py-1 text-end"></dd>
|
||||||
<dt class="col-5 text-end">Total presupuesto</dt>
|
<dt class="col-5 text-end">Total presupuesto</dt>
|
||||||
<dd id="totalDespuesDecuento" class="col-6 fw-semibold text-end"><?= old('0', $presupuestoEntity->total_presupuesto) ?>€</dd>
|
<dd id="totalDespuesDecuento" class="col-6 fw-semibold text-end"></dd>
|
||||||
<dt class="col-5 fw-normal text-end">Precio unidad</dt>
|
<dt class="col-5 fw-normal text-end">Precio unidad</dt>
|
||||||
<dd id="precioUnidadPresupuesto" class="col-6 text-end mb-2"><?= old('0', $presupuestoEntity->total_precio_unidad) ?>€</dd>
|
<dd id="precioUnidadPresupuesto" class="col-6 text-end mb-2"></dd>
|
||||||
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor</dt>
|
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor</dt>
|
||||||
<dd id="factor" class="col-6 text-end mb-2" style="font-size: smaller !important;"><?= old('0', is_numeric($presupuestoEntity->total_factor) ? $presupuestoEntity->total_factor : 0) ?></dd>
|
<dd id="factor" class="col-6 text-end mb-2" style="font-size: smaller !important;"></dd>
|
||||||
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor Ponderado</dt>
|
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor Ponderado</dt>
|
||||||
<dd id="factor_ponderado" class="col-6 text-end mb-0" style="font-size: smaller !important;"><?= old('0', is_numeric($presupuestoEntity->total_factor_ponderado) ? $presupuestoEntity->total_factor_ponderado : 0) ?></dd>
|
<dd id="factor_ponderado" class="col-6 text-end mb-0" style="font-size: smaller !important;"></dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-grid float-end mb-4">
|
<div class="d-grid float-end mb-4">
|
||||||
@ -83,7 +85,7 @@
|
|||||||
<label for="paginas" class="form-label">
|
<label for="paginas" class="form-label">
|
||||||
<?= lang('Presupuestos.totalAceptado') ?>
|
<?= lang('Presupuestos.totalAceptado') ?>
|
||||||
</label>
|
</label>
|
||||||
<input disabled type="text" id="totalAceptado" name="totalAceptado" class="form-control" value="<?= old('paginas', $presupuestoEntity->total_aceptado) ?>" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
|
<input disabled type="text" id="totalAceptado" name="totalAceptado" class="form-control" value="" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@ -231,21 +231,6 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function addSeparatorsNF(nStr, inD, outD, sep)
|
|
||||||
{
|
|
||||||
nStr += '';
|
|
||||||
var dpos = nStr.indexOf(inD);
|
|
||||||
var nStrEnd = '';
|
|
||||||
if (dpos != -1) {
|
|
||||||
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
|
|
||||||
nStr = nStr.substring(0, dpos);
|
|
||||||
}
|
|
||||||
var rgx = /(\d+)(\d{3})/;
|
|
||||||
while (rgx.test(nStr)) {
|
|
||||||
nStr = nStr.replace(rgx, '$1' + sep + '$2');
|
|
||||||
}
|
|
||||||
return nStr + nStrEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getValuesResumenForm(){
|
function getValuesResumenForm(){
|
||||||
var formResumen = "";
|
var formResumen = "";
|
||||||
@ -288,12 +273,3 @@ function getValuesResumenForm(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(".update-totales").on("change", function(){
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: false,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: false
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@ -1,244 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
// Evento de añadir una tirada alternativa
|
|
||||||
$('#add_tirada_alt').on('click', function () {
|
|
||||||
|
|
||||||
const tirada_alt = parseInt($('#tirada_alt').val());
|
|
||||||
add_tirada_alternativa(tirada_alt);
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Funcion para añadir una tirada alternativa
|
|
||||||
async function add_tirada_alternativa(tirada_alt) {
|
|
||||||
|
|
||||||
// se comprueba que la tirada no existe ya en la tabla
|
|
||||||
const exists = tableTiradas.rows().data().toArray().some(row => row.tirada == tirada_alt);
|
|
||||||
const isPOD = parseInt($('#tirada').val())<= parseInt($('#POD').val());
|
|
||||||
|
|
||||||
const typeIsOk = tirada_alt <= parseInt($('#POD').val()) && isPOD || tirada_alt > parseInt($('#POD').val()) && !isPOD;
|
|
||||||
|
|
||||||
if (!exists && typeIsOk) {
|
|
||||||
|
|
||||||
const dimension = getDimensionLibro();
|
|
||||||
|
|
||||||
let datos = {
|
|
||||||
tirada: tirada_alt,
|
|
||||||
merma: get_merma_tirada_alternativa(tirada_alt),
|
|
||||||
tipo_impresion_id: $('#tipo_impresion_id').val(),
|
|
||||||
json_tiradas: generate_json_tiradas(),
|
|
||||||
ancho: dimension.ancho,
|
|
||||||
alto: dimension.alto,
|
|
||||||
cliente_id: $('#clienteId').find(":selected").val(),
|
|
||||||
solapas_cubierta: $('#solapas').is(':checked')?1:0,
|
|
||||||
solapas_cubierta_ancho: $('#solapas').is(':checked')?parseInt($('#solapas_ancho').val()):0,
|
|
||||||
solapas_sobrecubierta: $('#solapas_sobrecubierta').is(':checked')?1:0,
|
|
||||||
solapas_sobrecubierta_ancho: $('#solapas_sobrecubierta').is(':checked')?parseInt($('#solapas_ancho_sobrecubierta').val()):0,
|
|
||||||
lomo: getLomoExterior(),
|
|
||||||
};
|
|
||||||
|
|
||||||
datos = Object.assign(datos, window.token_ajax);
|
|
||||||
|
|
||||||
// Se realiza la petición AJAX
|
|
||||||
await $.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: window.get_tirada_url,
|
|
||||||
data: datos,
|
|
||||||
success: async function (data) {
|
|
||||||
|
|
||||||
var coste_total = 0.0;
|
|
||||||
var margen_total = 0.0;
|
|
||||||
|
|
||||||
var costes_servicios = 0.0;
|
|
||||||
var margen_servicios = 0.0;
|
|
||||||
|
|
||||||
var coste_envio = 0.0;
|
|
||||||
var margen_envio = 0.0;
|
|
||||||
|
|
||||||
if(data.lineas.length >0){
|
|
||||||
// Se cogen los valores de la linea con los datos correspondientes
|
|
||||||
data.lineas.forEach(function(value) {
|
|
||||||
coste_total += value.total_coste;
|
|
||||||
margen_total += value.total_margen;
|
|
||||||
});
|
|
||||||
|
|
||||||
//console.log(datos.tirada);
|
|
||||||
|
|
||||||
// Se obtiene el precio de los servicios
|
|
||||||
const valueAcabados = await get_servAcabados_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
costes_servicios += parseFloat(valueAcabados.coste);
|
|
||||||
margen_servicios += parseFloat(valueAcabados.margen);
|
|
||||||
|
|
||||||
//console.log('coste acabados ('+ datos.tirada +'): ' + valueAcabados.coste);
|
|
||||||
|
|
||||||
const valueEncuadernacion = await get_servEncuadernacion_tiradasAlternativas(
|
|
||||||
parseInt(datos.tirada), parseInt( $('#paginas').val()), parseInt(dimension.ancho), parseInt(dimension.alto));
|
|
||||||
costes_servicios += parseFloat(valueEncuadernacion.coste);
|
|
||||||
margen_servicios += parseFloat(valueEncuadernacion.margen);
|
|
||||||
|
|
||||||
//console.log('coste encuadernacion ('+ datos.tirada +'): ' + valueEncuadernacion.coste);
|
|
||||||
|
|
||||||
const valueManipulado = await get_servManipulado_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
costes_servicios += parseFloat(valueManipulado.coste);
|
|
||||||
margen_servicios += parseFloat(valueManipulado.margen);
|
|
||||||
|
|
||||||
//console.log('coste manipulado ('+ datos.tirada +'): ' + valueManipulado.coste);
|
|
||||||
|
|
||||||
const valuePreimpresion = await get_servPreimpresion_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
costes_servicios += parseFloat(valuePreimpresion.coste);
|
|
||||||
margen_servicios += parseFloat(valuePreimpresion.margen);
|
|
||||||
|
|
||||||
const valueServiciosExtra = await get_servExtra_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
costes_servicios += parseFloat(valueServiciosExtra.coste);
|
|
||||||
margen_servicios += parseFloat(valueServiciosExtra.margen);
|
|
||||||
|
|
||||||
//console.log('coste preimpresion ('+ datos.tirada +'): ' + valuePreimpresion.coste);
|
|
||||||
|
|
||||||
const valueTransporte = await get_coste_envio_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
coste_envio = valueTransporte.coste;
|
|
||||||
margen_envio = valueTransporte.margen;
|
|
||||||
|
|
||||||
|
|
||||||
// Se añade la fila a la tabla de tiradas
|
|
||||||
tableTiradas.row.add({
|
|
||||||
tirada: datos.tirada,
|
|
||||||
coste_impresion: coste_total.toFixed(2),
|
|
||||||
coste_envio: coste_envio.toFixed(2),
|
|
||||||
margen: ((margen_total + margen_servicios + margen_envio)/(coste_total+coste_envio)*100.0).toFixed(2),
|
|
||||||
total_pedido: (coste_total + costes_servicios + coste_envio).toFixed(2),
|
|
||||||
precio_unidad: ((coste_total + costes_servicios + coste_envio) / datos.tirada).toFixed(4),
|
|
||||||
|
|
||||||
}).draw(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
yeniden(data[window.csrf_token]);
|
|
||||||
|
|
||||||
},
|
|
||||||
error: function(e){}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var htmlString = '';
|
|
||||||
if(typeIsOk){
|
|
||||||
htmlString = `
|
|
||||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
|
||||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
|
||||||
<i class="ti ti-bell ti-sm"></i>
|
|
||||||
</span>
|
|
||||||
<div class="d-flex flex-column ps-1">
|
|
||||||
<h5 class="alert-heading mb-2">` +
|
|
||||||
window.Presupuestos.errores.tirada_alt_duplicada +
|
|
||||||
`</h5>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
else{
|
|
||||||
htmlString = `
|
|
||||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
|
||||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
|
||||||
<i class="ti ti-bell ti-sm"></i>
|
|
||||||
</span>
|
|
||||||
<div class="d-flex flex-column ps-1">
|
|
||||||
<h5 class="alert-heading mb-2">` +
|
|
||||||
window.Presupuestos.errores.tirada_alt_tipo +
|
|
||||||
`</h5>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
$('#alert-tiradas_alt').hide().empty().html(htmlString).fadeIn("slow", function(){
|
|
||||||
setTimeout(function(){
|
|
||||||
$('#alert-tiradas_alt').fadeOut("slow");
|
|
||||||
}, 5000);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Función para obtener el lomo exterior
|
|
||||||
function getLomoExterior(){
|
|
||||||
let lomoTotal = 0
|
|
||||||
try{
|
|
||||||
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
if(rowData.row_id != 'lp_cubierta' && rowData.tipo != 'lp_sobrecubierta')
|
|
||||||
lomoTotal += parseFloat(rowData.lomo)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
catch(error){
|
|
||||||
lomoTotal = 0
|
|
||||||
}
|
|
||||||
return lomoTotal
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Función para usar la tirada alternativa como tirada principal
|
|
||||||
$(document).on('click', '.comfirm-tirada-alt', function (e) {
|
|
||||||
|
|
||||||
const row = $(this).closest('tr');
|
|
||||||
const data = tableTiradas.row(row).data();
|
|
||||||
|
|
||||||
updateTablaEnvios($('#tirada').val(), data.tirada).then(function(){
|
|
||||||
$('#tirada').val(data.tirada);
|
|
||||||
$('#tirada').trigger('change', [false]);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// Función para generar el JSON de las lineas de presupuesto para calcular las tiradas
|
|
||||||
function generate_json_tiradas() {
|
|
||||||
|
|
||||||
const data = $('#tableLineasPresupuesto').DataTable().data().toArray();
|
|
||||||
|
|
||||||
//return data; // For debugging purposes
|
|
||||||
json = filterData(data,
|
|
||||||
['paginas',
|
|
||||||
'numPagColor',
|
|
||||||
'paginas_impresion',
|
|
||||||
'papel', // papel generico
|
|
||||||
'papel_impresion_id',
|
|
||||||
'gramaje',
|
|
||||||
'maquina_id',
|
|
||||||
'aFavorFibra',
|
|
||||||
'row_id',
|
|
||||||
'check_papel_total',
|
|
||||||
'check_impresion_total',
|
|
||||||
'cobAmarillo', // tipologia de papel
|
|
||||||
'cobCyan',
|
|
||||||
'cobMagenta',
|
|
||||||
'cobNegro',
|
|
||||||
'cobCG',
|
|
||||||
'gotaColor',
|
|
||||||
'gotaNegro']);
|
|
||||||
|
|
||||||
json.forEach(element => {
|
|
||||||
element['check_papel_total'] = $('#' + element['row_id'] + '_checkPapel').is(':checked') ? 1 : 0;
|
|
||||||
element['check_impresion_total'] = $('#' + element['row_id'] + '_checkClicks').is(':checked') ? 1 : 0;
|
|
||||||
});
|
|
||||||
return JSON.stringify(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Función para filtrar las columnas de la tabla de tiradas
|
|
||||||
function filterData(data, keys) {
|
|
||||||
return data.map(obj => {
|
|
||||||
const newObj = {};
|
|
||||||
keys.forEach(key => {
|
|
||||||
if (obj.hasOwnProperty(key)) {
|
|
||||||
newObj[key] = obj[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return newObj;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -187,6 +187,7 @@
|
|||||||
<!------------------------------------------->
|
<!------------------------------------------->
|
||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
<?php if (str_contains($formAction, 'edit')): ?>
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
|
<?php /*
|
||||||
|
|
||||||
var submitButtonClicked; // Variable para almacenar el botón que fue clickeado
|
var submitButtonClicked; // Variable para almacenar el botón que fue clickeado
|
||||||
|
|
||||||
@ -235,7 +236,7 @@
|
|||||||
|
|
||||||
return false; //stop the actual form post !important!
|
return false; //stop the actual form post !important!
|
||||||
});
|
});
|
||||||
|
*/ ?>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
@ -271,17 +272,6 @@
|
|||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<!------------------------------------------->
|
|
||||||
<!-- Variables generales usadas en los ficheros js -->
|
|
||||||
<!------------------------------------------->
|
|
||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
|
|
||||||
window.token_ajax= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
|
|
||||||
window.csrf_token = '<?= csrf_token() ?>';
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import PreviewFormasAdmin from './sections/previewFormasAdmin.js';
|
|||||||
import Servicios from './sections/servicios.js';
|
import Servicios from './sections/servicios.js';
|
||||||
import Envios from './sections/envios.js';
|
import Envios from './sections/envios.js';
|
||||||
import TiradasAlernativas from './sections/tiradasAlternativas.js';
|
import TiradasAlernativas from './sections/tiradasAlternativas.js';
|
||||||
|
import Resumen from './sections/resumen.js';
|
||||||
|
|
||||||
class PresupuestoAdminEdit {
|
class PresupuestoAdminEdit {
|
||||||
|
|
||||||
@ -44,6 +45,10 @@ class PresupuestoAdminEdit {
|
|||||||
this.tiradasAlternativas = new TiradasAlernativas({
|
this.tiradasAlternativas = new TiradasAlernativas({
|
||||||
getDimensionLibro: this.getDimensionLibro,
|
getDimensionLibro: this.getDimensionLibro,
|
||||||
});
|
});
|
||||||
|
this.resumen = new Resumen();
|
||||||
|
|
||||||
|
this.guardar = $('#saveForm');
|
||||||
|
|
||||||
this.calcularPresupuesto = false;
|
this.calcularPresupuesto = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +94,7 @@ class PresupuestoAdminEdit {
|
|||||||
this.servicios.init();
|
this.servicios.init();
|
||||||
this.envios.init();
|
this.envios.init();
|
||||||
this.tiradasAlternativas.init();
|
this.tiradasAlternativas.init();
|
||||||
|
this.resumen.init();
|
||||||
|
|
||||||
if (window.location.href.includes("edit")) {
|
if (window.location.href.includes("edit")) {
|
||||||
|
|
||||||
@ -103,8 +109,62 @@ class PresupuestoAdminEdit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.downloadPreviewImage();
|
this.downloadPreviewImage();
|
||||||
|
|
||||||
|
$(document).on('update-presupuesto', this.updatePresupuesto.bind(this));
|
||||||
|
|
||||||
|
this.guardar.on('click', this.guardarPresupuesto.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
guardarPresupuesto() {
|
||||||
|
|
||||||
|
this.servicios.guardar();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async updatePresupuesto(event, {
|
||||||
|
update_lineas = true,
|
||||||
|
update_servicios = true,
|
||||||
|
update_envios = true,
|
||||||
|
update_resumen = true,
|
||||||
|
update_tiradas_alternativas = true
|
||||||
|
}) {
|
||||||
|
const waitForEvent = (eventName) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
$(document).one(eventName, () => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Ejecutar los pasos de forma secuencial si están habilitados
|
||||||
|
if (update_lineas) {
|
||||||
|
$(document).trigger('update-lineas-presupuesto');
|
||||||
|
await waitForEvent('update-lineas-presupuesto-completed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update_servicios) {
|
||||||
|
$(document).trigger('update-servicios');
|
||||||
|
await waitForEvent('update-servicios-completed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update_envios) {
|
||||||
|
$(document).trigger('update-envios');
|
||||||
|
await waitForEvent('update-envios-completed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update_resumen) {
|
||||||
|
$(document).trigger('update-totales');
|
||||||
|
await waitForEvent('update-totales-completed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update_tiradas_alternativas) {
|
||||||
|
$(document).trigger('update-tiradas-alternativas');
|
||||||
|
await waitForEvent('update-tiradas-alternativas-completed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#cargarPresupuesto() {
|
#cargarPresupuesto() {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
@ -140,14 +200,9 @@ class PresupuestoAdminEdit {
|
|||||||
$('#comentariosProduccion').val(response.data.comentarios_produccion);
|
$('#comentariosProduccion').val(response.data.comentarios_produccion);
|
||||||
|
|
||||||
self.tiradasAlternativas.cargar(response.data.tiradasAlternativas);
|
self.tiradasAlternativas.cargar(response.data.tiradasAlternativas);
|
||||||
|
|
||||||
/*self.direcciones.handleChangeCliente();
|
|
||||||
|
|
||||||
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
self.resumen.cargar(response.data.resumen);
|
||||||
|
|
||||||
self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
|
||||||
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
|
||||||
*/
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
$('#loader').modal('hide');
|
$('#loader').modal('hide');
|
||||||
@ -187,7 +242,7 @@ class PresupuestoAdminEdit {
|
|||||||
cantidad_total += parseInt(rowData.paginas)
|
cantidad_total += parseInt(rowData.paginas)
|
||||||
})
|
})
|
||||||
htmlString = ''
|
htmlString = ''
|
||||||
|
|
||||||
if (cantidad_total != parseInt($('#paginas').val())) {
|
if (cantidad_total != parseInt($('#paginas').val())) {
|
||||||
htmlString = `
|
htmlString = `
|
||||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||||
|
|||||||
@ -93,18 +93,6 @@ class DatosLibro {
|
|||||||
|
|
||||||
this.paginas.on('change', this.changePaginas.bind(this));
|
this.paginas.on('change', this.changePaginas.bind(this));
|
||||||
this.tirada.on('change', this.changeTirada.bind(this));
|
this.tirada.on('change', this.changeTirada.bind(this));
|
||||||
|
|
||||||
$('.formato-libro').on('change', function () {
|
|
||||||
$(document).trigger('update-lineas-presupuesto');
|
|
||||||
$(document).trigger('update-servicios');
|
|
||||||
|
|
||||||
/* TO-DO
|
|
||||||
updatePresupuesto({
|
|
||||||
update_envios: true,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true
|
|
||||||
})*/
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,14 +171,13 @@ class DatosLibro {
|
|||||||
|
|
||||||
this.checkPaginasPresupuesto();
|
this.checkPaginasPresupuesto();
|
||||||
|
|
||||||
$(document).trigger('update-lineas-presupuesto');
|
$(document).trigger('update-presupuesto', {
|
||||||
$(document).trigger('update-servicios');
|
update_lineas : true,
|
||||||
// TO-DO
|
update_servicios : true,
|
||||||
/*updatePresupuesto({
|
|
||||||
update_envios: true,
|
update_envios: true,
|
||||||
update_resumen: true,
|
update_resumen: true,
|
||||||
update_tiradas_alternativas: true
|
update_tiradas_alternativas: true
|
||||||
})*/
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -273,17 +260,15 @@ class DatosLibro {
|
|||||||
$('#compPaginasNegrohq').trigger('change');
|
$('#compPaginasNegrohq').trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).trigger('update-lineas-presupuesto');
|
|
||||||
$(document).trigger('update-servicios');
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas : true,
|
||||||
// TO-DO
|
update_servicios : true,
|
||||||
/*
|
|
||||||
updatePresupuesto({
|
|
||||||
update_envios: true,
|
update_envios: true,
|
||||||
update_resumen: true,
|
update_resumen: true,
|
||||||
update_tiradas_alternativas: true
|
update_tiradas_alternativas: true
|
||||||
})
|
});
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,29 +282,8 @@ class DatosLibro {
|
|||||||
|
|
||||||
if (url_parts2[url_parts2.length - 2] == 'edit') {
|
if (url_parts2[url_parts2.length - 2] == 'edit') {
|
||||||
$(document).trigger('update-lineas-presupuesto');
|
$(document).trigger('update-lineas-presupuesto');
|
||||||
//update_servicios(false)
|
|
||||||
//updateLineasPresupuesto()
|
$(document).trigger('ckeck-lineas-envios');
|
||||||
|
|
||||||
/* TO-DO
|
|
||||||
if(update_tiradas_alternativas)
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: true,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: false,
|
|
||||||
update_tiradas_alternativas: false
|
|
||||||
})
|
|
||||||
else
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: true,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: false,
|
|
||||||
update_tiradas_alternativas: false
|
|
||||||
})
|
|
||||||
|
|
||||||
checkInsertar()
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,16 @@ class Envios {
|
|||||||
this.modalYesNo = null;
|
this.modalYesNo = null;
|
||||||
|
|
||||||
this.insertarEnvio = $('#insertar_direccion');
|
this.insertarEnvio = $('#insertar_direccion');
|
||||||
|
|
||||||
|
this.actionBtns_direcciones = function (data) {
|
||||||
|
return `
|
||||||
|
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-add mx-2" data-id="${data.id}"></i></a></span>
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas delete-add-row mx-2"></i></a>
|
||||||
|
`;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
@ -91,6 +99,15 @@ class Envios {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// obtener la suma del precio de los envios
|
||||||
|
let total = 0;
|
||||||
|
self.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let data = this.data();
|
||||||
|
total += parseFloat(data.precio);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#costeEnvios").text(total.toFixed(2) + "€" || "0€");
|
||||||
|
|
||||||
self.check_unidades_enviadas();
|
self.check_unidades_enviadas();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +185,15 @@ class Envios {
|
|||||||
this.insertarEnvio.on('click', this.addEnvio.bind(this));
|
this.insertarEnvio.on('click', this.addEnvio.bind(this));
|
||||||
|
|
||||||
this.initFormularioDireccionEnvio();
|
this.initFormularioDireccionEnvio();
|
||||||
|
|
||||||
|
$(document).on('update-envios', async function () {
|
||||||
|
|
||||||
|
await self.updateTablaEnvios();
|
||||||
|
|
||||||
|
$(document).trigger('update-envios-completed');
|
||||||
|
|
||||||
|
});
|
||||||
|
$(document).on('ckeck-lineas-envios', this.check_unidades_enviadas.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
addEnvio() {
|
addEnvio() {
|
||||||
@ -193,6 +219,189 @@ class Envios {
|
|||||||
newAddDialog.modal('show');
|
newAddDialog.modal('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
get_peso_libro() {
|
||||||
|
|
||||||
|
var peso_total_libro = 0.0
|
||||||
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
peso_total_libro += parseFloat(rowData.peso)
|
||||||
|
})
|
||||||
|
return peso_total_libro;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
guardarEnvios() {
|
||||||
|
/* TO-DO
|
||||||
|
var id = $('#presupuesto_id').val()
|
||||||
|
|
||||||
|
$.post(window.routes_envios.dataTableOfPresupuestoDirecciones,
|
||||||
|
Object.assign({ tipo: "clear_lineas", presupuesto_id: id }, window.token_ajax))
|
||||||
|
.done(function (data) {
|
||||||
|
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var data = this.data();
|
||||||
|
$.post('/presupuestos/presupuestodirecciones/add',
|
||||||
|
Object.assign({
|
||||||
|
presupuesto_id: id,
|
||||||
|
tarifa_id: data.tarifa_id,
|
||||||
|
cantidad: data.cantidad,
|
||||||
|
peso: data.peso,
|
||||||
|
att: data.att,
|
||||||
|
email: data.email,
|
||||||
|
direccion: data.direccion,
|
||||||
|
paisId: data.paisId,
|
||||||
|
provincia: data.provincia,
|
||||||
|
municipio: data.municipio,
|
||||||
|
cp: data.cp,
|
||||||
|
telefono: data.telefono,
|
||||||
|
precio: data.precio,
|
||||||
|
margen: data.margen,
|
||||||
|
proveedor: data.proveedor,
|
||||||
|
proveedor_id: data.proveedor_id,
|
||||||
|
entregaPieCalle: data.entregaPieCalle
|
||||||
|
}, window.token_ajax))
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateTiradaBase() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
var peso_total_libro = this.get_peso_libro();
|
||||||
|
|
||||||
|
const tirada = parseInt($('#tirada').val());
|
||||||
|
const peso_envio = peso_total_libro * tirada / 1000.0;
|
||||||
|
|
||||||
|
let pais = 1;
|
||||||
|
let cp = 18000;
|
||||||
|
let entrega = 'cajas';
|
||||||
|
|
||||||
|
var datos_tarifa = await self.get_precio_envio(peso_envio, pais, cp, entrega);
|
||||||
|
|
||||||
|
if (datos_tarifa.id != null) {
|
||||||
|
|
||||||
|
if (peso_envio > parseFloat(datos_tarifa.peso_max) || parseFloat(datos_tarifa.peso_max) == 0) {
|
||||||
|
datos_tarifa.precio = parseFloat(datos_tarifa.peso_min) + (peso_envio - parseFloat(datos_tarifa.peso_min)) * parseFloat(datos_tarifa.precio_adicional);
|
||||||
|
}
|
||||||
|
// si no se calcula linealmente
|
||||||
|
else {
|
||||||
|
let m = ((parseFloat(datos_tarifa.precio_max) - parseFloat(datos_tarifa.precio_min)) / (parseFloat(datos_tarifa.peso_max) - parseFloat(datos_tarifa.peso_min)));
|
||||||
|
let b = parseFloat(datos_tarifa.precio_max) - m * parseFloat(datos_tarifa.peso_max);
|
||||||
|
datos_tarifa.precio = parseFloat(m * peso_envio + b);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#envio_base').val(datos_tarifa.precio.toFixed(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateTablaEnvios(event, input_data = {}) {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
var peso_total_libro = this.get_peso_libro();
|
||||||
|
|
||||||
|
await self.updateTiradaBase();
|
||||||
|
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
|
||||||
|
var rowData = this.data();
|
||||||
|
|
||||||
|
if (Object.keys(input_data).length > 0) {
|
||||||
|
const porcentaje = parseInt(rowData.cantidad) / input_data.tirada_inicial * 100.0;
|
||||||
|
const cantidad = Math.floor(input_data.tirada * porcentaje / 100.0);
|
||||||
|
rowData.cantidad = cantidad;
|
||||||
|
}
|
||||||
|
|
||||||
|
const peso_envio = peso_total_libro * parseInt(rowData.cantidad) / 1000.0;
|
||||||
|
const tirada = parseInt($('#tirada').val());
|
||||||
|
var datos_tarifa = await self.get_precio_envio(peso_envio, rowData.pais_id, rowData.cp, parseInt(rowData.entregaPieCalle) == 1 ? 'palets' : 'cajas');
|
||||||
|
|
||||||
|
|
||||||
|
if (datos_tarifa.id != null) {
|
||||||
|
|
||||||
|
if (peso_envio > parseFloat(datos_tarifa.peso_max) || parseFloat(datos_tarifa.peso_max) == 0) {
|
||||||
|
datos_tarifa.precio = parseFloat(datos_tarifa.peso_min) + (peso_envio - parseFloat(datos_tarifa.peso_min)) * parseFloat(datos_tarifa.precio_adicional);
|
||||||
|
}
|
||||||
|
// si no se calcula linealmente
|
||||||
|
else {
|
||||||
|
let m = ((parseFloat(datos_tarifa.precio_max) - parseFloat(datos_tarifa.precio_min)) / (parseFloat(datos_tarifa.peso_max) - parseFloat(datos_tarifa.peso_min)));
|
||||||
|
let b = parseFloat(datos_tarifa.precio_max) - m * parseFloat(datos_tarifa.peso_max);
|
||||||
|
datos_tarifa.precio = parseFloat(m * peso_envio + b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
datos_tarifa.cantidad = parseInt($('#add_cantidad').val());
|
||||||
|
datos_tarifa.peso = peso_envio;
|
||||||
|
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().row(rowIdx)
|
||||||
|
.data({
|
||||||
|
'tarifa_id': datos_tarifa.id,
|
||||||
|
'cantidad': rowData.cantidad,
|
||||||
|
'peso': datos_tarifa.peso.toFixed(3),
|
||||||
|
'att': rowData.att,
|
||||||
|
'email': rowData.email,
|
||||||
|
'direccion': rowData.direccion,
|
||||||
|
'cp': rowData.cp,
|
||||||
|
'municipio': rowData.municipio,
|
||||||
|
'provincia': rowData.provincia,
|
||||||
|
'pais_id': rowData.pais_id,
|
||||||
|
'pais': datos_tarifa.pais,
|
||||||
|
'telefono': rowData.telefono,
|
||||||
|
'proveedor': datos_tarifa.proveedor,
|
||||||
|
'proveedor_id': datos_tarifa.proveedor_id,
|
||||||
|
'precio': datos_tarifa.precio.toFixed(2),
|
||||||
|
'margen': datos_tarifa.margen,
|
||||||
|
'entregaPieCalle': rowData.entregaPieCalle,
|
||||||
|
'actionBtns_direcciones': self.actionBtns_direcciones,
|
||||||
|
})
|
||||||
|
.draw();
|
||||||
|
|
||||||
|
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas: false,
|
||||||
|
update_servicios: false,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
popErrorAlert(window.error_no_tarifa_envio, 'error-tarifa')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (Object.keys(input_data).length > 0) {
|
||||||
|
|
||||||
|
$('#tirada').val(input_data.tirada);
|
||||||
|
$('#tirada').trigger('change', [false]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async get_precio_envio(peso, paisId, cp, tipo_envio) {
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
tipo: 'get_tarifa',
|
||||||
|
peso: peso,
|
||||||
|
paisId: paisId,
|
||||||
|
cp: cp,
|
||||||
|
tipo_envio: tipo_envio,
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch('/presupuestodirecciones/datatable_2', {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const values = await response.json();
|
||||||
|
return values.data;
|
||||||
|
}
|
||||||
|
|
||||||
initFormularioDireccionEnvio() {
|
initFormularioDireccionEnvio() {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
@ -363,17 +572,16 @@ class Envios {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TO-DO
|
$(document).trigger('ckeck-lineas-envios');
|
||||||
checkInsertar()
|
|
||||||
//updateTotales(false, false, true)
|
$(document).trigger('update-presupuesto', {
|
||||||
updatePresupuesto({
|
update_lineas : false,
|
||||||
update_lineas: false,
|
update_servicios : true,
|
||||||
update_servicios: true,
|
|
||||||
update_envios: false,
|
update_envios: false,
|
||||||
update_resumen: true,
|
update_resumen: true,
|
||||||
update_tiradas_alternativas: true
|
update_tiradas_alternativas: true
|
||||||
})
|
});
|
||||||
*/
|
|
||||||
$('#addressForm').modal("hide");
|
$('#addressForm').modal("hide");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,12 +35,15 @@ class LineasPresupuesto {
|
|||||||
.remove()
|
.remove()
|
||||||
.draw();
|
.draw();
|
||||||
|
|
||||||
// TO-DO
|
$(document).trigger('update-presupuesto', {
|
||||||
/*updatePresupuesto({
|
update_lineas: false,
|
||||||
|
update_servicios: false,
|
||||||
update_envios: true,
|
update_envios: true,
|
||||||
update_resumen: true,
|
update_resumen: true,
|
||||||
update_tiradas_alternativas: true
|
update_tiradas_alternativas: true
|
||||||
})
|
});
|
||||||
|
// TO-DO
|
||||||
|
/*
|
||||||
if (data.row_id == 'lp_guardas')
|
if (data.row_id == 'lp_guardas')
|
||||||
servicioGuardas(false)
|
servicioGuardas(false)
|
||||||
*/
|
*/
|
||||||
@ -52,7 +55,12 @@ class LineasPresupuesto {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Evento para recalcular las lineas de presupuesto
|
// Evento para recalcular las lineas de presupuesto
|
||||||
$(document).on('update-lineas-presupuesto', this.updateLineasPresupuesto.bind(this));
|
$(document).on('update-lineas-presupuesto', async function () {
|
||||||
|
|
||||||
|
await self.updateLineasPresupuesto();
|
||||||
|
|
||||||
|
$(document).trigger('update-lineas-presupuesto-completed');
|
||||||
|
});
|
||||||
|
|
||||||
$('.insertarLinea').on("click", this.#insertarLineaComparador.bind(this));
|
$('.insertarLinea').on("click", this.#insertarLineaComparador.bind(this));
|
||||||
$('.paginas-lp').on('change', this.checkPaginasLineasPresupuesto.bind(this));
|
$('.paginas-lp').on('change', this.checkPaginasLineasPresupuesto.bind(this));
|
||||||
@ -355,8 +363,8 @@ class LineasPresupuesto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
updateLineasPresupuesto() {
|
async updateLineasPresupuesto() {
|
||||||
|
|
||||||
$('#tableLineasPresupuesto tbody tr:visible ').each(function () {
|
$('#tableLineasPresupuesto tbody tr:visible ').each(function () {
|
||||||
|
|
||||||
$('#' + this.id + '_maquina').trigger('change');
|
$('#' + this.id + '_maquina').trigger('change');
|
||||||
@ -1462,7 +1470,7 @@ class LineasPresupuesto {
|
|||||||
cliente_id: $('#clienteId').find(":selected").val(),
|
cliente_id: $('#clienteId').find(":selected").val(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if(datos.ancho==0 || datos.alto==0 || datos.ancho=='' || datos.alto=='' || isNaN(datos.ancho) || isNaN(datos.alto)){
|
if (datos.ancho == 0 || datos.alto == 0 || datos.ancho == '' || datos.alto == '' || isNaN(datos.ancho) || isNaN(datos.alto)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1522,7 +1530,7 @@ class LineasPresupuesto {
|
|||||||
borrar_linea = false;
|
borrar_linea = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let $i=0; $i<response.lineas.length; $i++){
|
for (let $i = 0; $i < response.lineas.length; $i++) {
|
||||||
|
|
||||||
// Se cogen los valores de la linea con los datos correspondientes
|
// Se cogen los valores de la linea con los datos correspondientes
|
||||||
if (response.lineas[$i].fields.maquina_id === input_data.maquina_id &&
|
if (response.lineas[$i].fields.maquina_id === input_data.maquina_id &&
|
||||||
@ -1546,7 +1554,7 @@ class LineasPresupuesto {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(borrar_linea){
|
if (borrar_linea) {
|
||||||
self.table.row('#' + linea).remove().draw();
|
self.table.row('#' + linea).remove().draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1602,13 +1610,16 @@ class LineasPresupuesto {
|
|||||||
|
|
||||||
/* TO-DO
|
/* TO-DO
|
||||||
calcular_mermas()
|
calcular_mermas()
|
||||||
|
*/
|
||||||
updatePresupuesto({
|
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas : false,
|
||||||
|
update_servicios : true,
|
||||||
update_envios: true,
|
update_envios: true,
|
||||||
update_resumen: true,
|
update_resumen: true,
|
||||||
update_tiradas_alternativas: true
|
update_tiradas_alternativas: true
|
||||||
})
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
// Si existe cubierta, hay que actualizar con el valor del lomo
|
// Si existe cubierta, hay que actualizar con el valor del lomo
|
||||||
if (linea != 'lp_cubierta' && linea != 'lp_sobrecubierta' && this.table.row('#lp_cubierta').length > 0) {
|
if (linea != 'lp_cubierta' && linea != 'lp_sobrecubierta' && this.table.row('#lp_cubierta').length > 0) {
|
||||||
@ -1886,17 +1897,15 @@ class LineasPresupuesto {
|
|||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
if (row.tipo == 'cubierta') {
|
if (row.tipo == 'cubierta') {
|
||||||
this.rellenarDatosLinea('lp_cubierta', row, true);
|
this.rellenarDatosLinea('lp_cubierta', row, true);
|
||||||
/* TO-DO
|
|
||||||
if ($('#acabado_cubierta_id').val() > 0)
|
if ($('#acabado_cubierta_id').val() > 0)
|
||||||
insertar_acabado_exterior($('#acabado_cubierta_id').val(), window.Presupuestos.cubierta)
|
$(document).trigger('add-servicio-lineas', 'acabadoCubierta');
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
if (row.tipo == 'sobrecubierta') {
|
if (row.tipo == 'sobrecubierta') {
|
||||||
this.rellenarDatosLinea('lp_sobrecubierta', row, true);
|
this.rellenarDatosLinea('lp_sobrecubierta', row, true);
|
||||||
/* TO-DO
|
|
||||||
if ($('#acabado_sobrecubierta_id').val() > 0)
|
if ($('#acabado_sobrecubierta_id').val() > 0)
|
||||||
insertar_acabado_exterior($('#acabado_sobrecubierta_id').val(), window.Presupuestos.sobrecubierta)
|
$(document).trigger('add-servicio-lineas', 'acabadoSobrecubierta');
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1920,15 +1929,14 @@ class LineasPresupuesto {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* TO-DO
|
$(document).trigger('update-presupuesto', {
|
||||||
updatePresupuesto({
|
update_lineas : false,
|
||||||
update_envios: false,
|
update_servicios : true,
|
||||||
|
update_envios: true,
|
||||||
update_resumen: true,
|
update_resumen: true,
|
||||||
update_tiradas_alternativas: true
|
update_tiradas_alternativas: true
|
||||||
})
|
});
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,311 @@
|
|||||||
|
class Resumen {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
$(".update-totales").on("change", function () {
|
||||||
|
self.updateTotales(true, true, true)
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('update-totales', async function () {
|
||||||
|
await self.updateTotales();
|
||||||
|
$(document).trigger('update-totales-completed');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cargar(resumen) {
|
||||||
|
|
||||||
|
// Mapear los valores a los elementos HTML por ID
|
||||||
|
$("#totalCostePapel").text(resumen.total_coste_papel + "€" || "0€");
|
||||||
|
$("#porcentajeMargenPapel").text(resumen.total_margenPercent_papel ? resumen.total_margenPercent_papel + "%" : "0%");
|
||||||
|
$("#margenPapel").text(resumen.total_margen_papel + "€" || "0€");
|
||||||
|
|
||||||
|
$("#totalCosteImpresion").text(resumen.total_coste_impresion + "€" || "0€");
|
||||||
|
$("#porcentajeMargenImpresion").text(resumen.total_margenPercent_impresion ? resumen.total_margenPercent_impresion + "%" : "0%");
|
||||||
|
$("#margenImpresion").text(resumen.total_margen_impresion + "€" || "0€");
|
||||||
|
|
||||||
|
$("#totalServicios").text(resumen.total_coste_servicios + "€" || "0€");
|
||||||
|
$("#porcentajeMargenServicios").text(resumen.total_margenPercent_servicios ? resumen.total_margenPercent_servicios + "%" : "0%");
|
||||||
|
$("#margenServicios").text(resumen.total_margen_servicios + "€" || "0€");
|
||||||
|
|
||||||
|
//$("#costeEnvios").text(resumen.total_coste_envios + "€" || "0€");
|
||||||
|
$("#totalEnvios").text(resumen.total_coste_envios + "€" || "0€");
|
||||||
|
$("#margenEnvios").text(resumen.total_margen_envios + "€" || "0€");
|
||||||
|
|
||||||
|
$("#totalCostes").text(resumen.total_costes + "€" || "0€");
|
||||||
|
$("#porcentajeMargen").text(resumen.porcentajeMargen ? resumen.porcentajeMargen + "%" : "0%");
|
||||||
|
$("#totalMargenes").text(resumen.total_margenes + "€" || "0€");
|
||||||
|
|
||||||
|
$("#totalAntesDescuento").text(resumen.total_antes_descuento + "€" || "0€");
|
||||||
|
$("#total_descuentoPercent").val(resumen.total_descuentoPercent + "€" || "0€");
|
||||||
|
$("#descuentoTotal").text(resumen.total_descuento + "€" || "0€");
|
||||||
|
$("#totalDespuesDecuento").text(resumen.total_presupuesto + "€" || "0€");
|
||||||
|
$("#precioUnidadPresupuesto").text(resumen.total_precio_unidad + "€" || "0€");
|
||||||
|
$("#factor").text(resumen.total_factor + "€" || "0€");
|
||||||
|
$("#factor_ponderado").text(resumen.total_factor_ponderado + "€" || "0€");
|
||||||
|
|
||||||
|
if (resumen.total_aceptado !== undefined) {
|
||||||
|
$("#totalAceptado").val(resumen.total_aceptado + "€" || "0€");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formatear agregando separadores de miles
|
||||||
|
addSeparatorsNF(nStr, inD, outD, sep) {
|
||||||
|
nStr += '';
|
||||||
|
let dpos = nStr.indexOf(inD);
|
||||||
|
let nStrEnd = '';
|
||||||
|
if (dpos != -1) {
|
||||||
|
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
|
||||||
|
nStr = nStr.substring(0, dpos);
|
||||||
|
}
|
||||||
|
let rgx = /(\d+)(\d{3})/;
|
||||||
|
while (rgx.test(nStr)) {
|
||||||
|
nStr = nStr.replace(rgx, '$1' + sep + '$2');
|
||||||
|
}
|
||||||
|
return nStr + nStrEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async updateTotales(event, data = {}) {
|
||||||
|
|
||||||
|
let updateLP = data.updateLP || true;
|
||||||
|
let updateServicios = data.updateServicios || true;
|
||||||
|
let updateEnvio = data.updateEnvio || true;
|
||||||
|
let totalPapel = 0;
|
||||||
|
let margenPapel = 0;
|
||||||
|
|
||||||
|
let totalImpresion = 0;
|
||||||
|
let totalImpresionforMargen = 0;
|
||||||
|
let margenImpresion = 0;
|
||||||
|
|
||||||
|
let totalServicios = 0;
|
||||||
|
let margenServicios = 0;
|
||||||
|
|
||||||
|
let totalEnvios = 0;
|
||||||
|
let margenEnvios = 0;
|
||||||
|
|
||||||
|
let sumForFactor = 0.0;
|
||||||
|
let sumForFactorPonderado = 0.0;
|
||||||
|
|
||||||
|
|
||||||
|
let margenPorHoras = 0.0;
|
||||||
|
|
||||||
|
if (updateLP) {
|
||||||
|
|
||||||
|
if (typeof $("#tableLineasPresupuesto").DataTable() !== 'undefined') {
|
||||||
|
$("#tableLineasPresupuesto").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
|
||||||
|
if (rowData.check_papel_total) {
|
||||||
|
totalPapel += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
|
||||||
|
margenPapel += parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
|
||||||
|
|
||||||
|
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
|
||||||
|
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
|
||||||
|
|
||||||
|
}
|
||||||
|
if (rowData.check_impresion_total) {
|
||||||
|
//totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||||
|
margenPorHoras += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||||
|
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||||
|
|
||||||
|
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||||
|
|
||||||
|
if (rowData.maquinaTipo == 'inkjet') {
|
||||||
|
totalImpresion += parseFloat(rowData.totalTinta)
|
||||||
|
totalImpresion += parseFloat(rowData.totalCorte)
|
||||||
|
|
||||||
|
sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
|
||||||
|
}
|
||||||
|
//margenImpresion += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||||
|
//margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||||
|
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||||
|
|
||||||
|
|
||||||
|
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||||
|
|
||||||
|
if (!isNaN(parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val()))) {
|
||||||
|
totalImpresion += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||||
|
sumForFactor += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
totalImpresion -= margenImpresion
|
||||||
|
totalPapel -= margenPapel
|
||||||
|
|
||||||
|
margenImpresion += margenPorHoras
|
||||||
|
|
||||||
|
let porcentajeMargenPapel = isNaN(margenPapel / (totalPapel) * 100.0) ? 0 : margenPapel / (totalPapel) * 100.0
|
||||||
|
$('#porcentajeMargenPapel').text(porcentajeMargenPapel.toFixed(0) + '%')
|
||||||
|
$('#totalCostePapel').text((this.addSeparatorsNF(totalPapel.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#margenPapel').text((this.addSeparatorsNF(margenPapel.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalCostePapel').attr('val', totalPapel.toFixed(2))
|
||||||
|
$('#margenPapel').attr('val', margenPapel.toFixed(2))
|
||||||
|
|
||||||
|
let porcentajeMargenImpresion = isNaN(margenImpresion / (totalImpresion) * 100.0) ? 0 : margenImpresion / (totalImpresion) * 100.0
|
||||||
|
$('#porcentajeMargenImpresion').text(porcentajeMargenImpresion.toFixed(0) + '%')
|
||||||
|
$('#totalCosteImpresion').text((this.addSeparatorsNF(totalImpresion.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#margenImpresion').text((this.addSeparatorsNF(margenImpresion.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalCosteImpresion').attr('val', totalImpresion.toFixed(2))
|
||||||
|
$('#margenImpresion').attr('val', margenImpresion.toFixed(2))
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
totalPapel = parseFloat($('#totalCostePapel').attr('val'))
|
||||||
|
margenPapel = parseFloat($('#margenPapel').attr('val'))
|
||||||
|
totalImpresion = parseFloat($('#totalCosteImpresion').attr('val'))
|
||||||
|
margenImpresion = parseFloat($('#margenImpresion').attr('val'))
|
||||||
|
}
|
||||||
|
|
||||||
|
sumForFactorPonderado = sumForFactor;
|
||||||
|
|
||||||
|
if (updateServicios) {
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosEncuadernacion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = rowData.precio_total;
|
||||||
|
let margen_servicio = rowData.margen;
|
||||||
|
totalServicios += total_servicio
|
||||||
|
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||||
|
margenServicios = total_servicio - base;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosAcabado").DataTable() !== 'undefined' && $("#tableOfServiciosAcabado").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosAcabado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = rowData.precio_total;
|
||||||
|
let margen_servicio = rowData.margen;
|
||||||
|
totalServicios += total_servicio
|
||||||
|
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||||
|
margenServicios = total_servicio - base;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosPreimpresion").DataTable() !== 'undefined' && $("#tableOfServiciosPreimpresion").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosPreimpresion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = rowData.precio;
|
||||||
|
let coste_servicio = rowData.coste;
|
||||||
|
totalServicios += total_servicio
|
||||||
|
margenServicios = total_servicio - coste_servicio;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosExtra").DataTable() !== 'undefined' && $("#tableOfServiciosExtra").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosExtra').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = rowData.precio;
|
||||||
|
let coste_servicio = rowData.coste;
|
||||||
|
totalServicios += total_servicio
|
||||||
|
margenServicios = total_servicio - coste_servicio;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosManipulado").DataTable() !== 'undefined' && $("#tableOfServiciosManipulado").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosManipulado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = rowData.precio_total;
|
||||||
|
let margen_servicio = rowData.margen;
|
||||||
|
totalServicios += total_servicio
|
||||||
|
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||||
|
margenServicios = total_servicio - base;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
totalServicios -= margenServicios;
|
||||||
|
|
||||||
|
sumForFactorPonderado += totalServicios;
|
||||||
|
|
||||||
|
let porcentajeMargenServicios = margenServicios / (totalServicios) * 100
|
||||||
|
$('#porcentajeMargenServicios').text(isNaN(porcentajeMargenServicios.toFixed(0)) ? 0 : porcentajeMargenServicios.toFixed(0) + '%')
|
||||||
|
$('#totalServicios').text((this.addSeparatorsNF(totalServicios.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#margenServicios').text((this.addSeparatorsNF(margenServicios.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalServicios').attr('val', totalServicios.toFixed(2) + '€')
|
||||||
|
$('#margenServicios').attr('val', margenServicios.toFixed(2) + '€')
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
totalServicios = parseFloat($('#totalServicios').attr('val'))
|
||||||
|
margenServicios = parseFloat($('#margenServicios').attr('val'))
|
||||||
|
|
||||||
|
sumForFactorPonderado += totalServicios;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateEnvio) {
|
||||||
|
|
||||||
|
totalEnvios = parseFloat($('#envio_base').val());
|
||||||
|
if (typeof $('#tableOfDireccionesEnvio').DataTable() !== 'undefined' && $('#tableOfDireccionesEnvio').DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
if (rowIdx == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let data = this.data()
|
||||||
|
totalEnvios += parseFloat(data.precio)
|
||||||
|
margenEnvios += parseFloat((data.precio) * data.margen / 100)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
totalEnvios -= margenEnvios
|
||||||
|
$('#totalEnvios').text((this.addSeparatorsNF(totalEnvios.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#margenEnvios').text((this.addSeparatorsNF(margenEnvios.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalEnvios').attr('val', totalEnvios.toFixed(2) + '€')
|
||||||
|
$('#margenEnvios').attr('val', margenEnvios.toFixed(2) + '€')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
totalEnvios = parseFloat($('#totalEnvios').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 totalMargenes = parseFloat(margenPapel.toFixed(2)) + parseFloat(margenImpresion.toFixed(2)) + parseFloat(margenServicios.toFixed(2)) + parseFloat(margenEnvios.toFixed(2))
|
||||||
|
let porcentajeMargen = totalCostes + totalMargenes > 0 ? (100 * totalMargenes / (totalCostes + totalMargenes)).toFixed(0) : 0
|
||||||
|
$('#totalCostes').text((this.addSeparatorsNF(totalCostes.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalMargenes').text((this.addSeparatorsNF(totalMargenes.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalCostes').attr('val', (totalCostes).toFixed(2) + '€')
|
||||||
|
$('#totalMargenes').attr('val', (totalMargenes).toFixed(2) + '€')
|
||||||
|
$('#porcentajeMargen').text(porcentajeMargen + '%')
|
||||||
|
$('#porcentajeMargen').attr('val', porcentajeMargen)
|
||||||
|
|
||||||
|
if ($('#total_descuentoPercent').val() < 0) {
|
||||||
|
$('#total_descuentoPercent').val(0)
|
||||||
|
}
|
||||||
|
let totalAntesDescuento = totalCostes + totalMargenes
|
||||||
|
let totalDescuento = totalAntesDescuento * parseInt($('#total_descuentoPercent').val() || 0) / 100
|
||||||
|
let totalPresupuesto = totalAntesDescuento - totalDescuento
|
||||||
|
let precioUnidad = totalPresupuesto / parseInt($('#tirada').val())
|
||||||
|
|
||||||
|
$('#totalAntesDescuento').text((this.addSeparatorsNF(totalAntesDescuento.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#descuentoTotal').text((this.addSeparatorsNF(totalDescuento.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalDespuesDecuento').text((this.addSeparatorsNF(totalPresupuesto.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#precioUnidadPresupuesto').text((this.addSeparatorsNF(precioUnidad.toFixed(4), ".", ",", ".")) + "€")
|
||||||
|
$('#totalAntesDescuento').attr('val', (totalAntesDescuento).toFixed(2))
|
||||||
|
$('#descuentoTotal').attr('val', (totalDescuento).toFixed(2))
|
||||||
|
$('#totalDespuesDecuento').attr('val', (totalPresupuesto).toFixed(2))
|
||||||
|
$('#precioUnidadPresupuesto').attr('val', (precioUnidad).toFixed(4))
|
||||||
|
|
||||||
|
|
||||||
|
$('#factor').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactor).toFixed(2), ".", ",", "."))
|
||||||
|
$('#factor').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactor).toFixed(2))
|
||||||
|
$('#factor_ponderado').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2), ".", ",", "."))
|
||||||
|
$('#factor_ponderado').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2))
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Resumen;
|
||||||
@ -71,7 +71,11 @@ class Servicios {
|
|||||||
showBreadCrumbSaveButton(true);
|
showBreadCrumbSaveButton(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('update-servicios', this.updateServicios.bind(this));
|
$(document).on('update-servicios', async function(){
|
||||||
|
await self.updateServicios()
|
||||||
|
|
||||||
|
$(document).trigger('update-servicios-completed');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cargar(datos) {
|
cargar(datos) {
|
||||||
@ -89,6 +93,15 @@ class Servicios {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async guardar(){
|
||||||
|
await this.serviciosAcabado.guardarServiciosAcabado();
|
||||||
|
await this.serviciosPreimpresion.guardarServiciosPreimpresion();
|
||||||
|
await this.ServiciosEncuadernacion.guardarServiciosEncuadernacion();
|
||||||
|
await this.ServiciosManipulado.guardarServiciosManipulado();
|
||||||
|
await this.serviciosExtra.guardarServiciosExtra();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
addServicio(event, servicio) {
|
addServicio(event, servicio) {
|
||||||
|
|
||||||
if (servicio == 'acabadoCubierta') {
|
if (servicio == 'acabadoCubierta') {
|
||||||
@ -110,7 +123,7 @@ class Servicios {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateServicios() {
|
async updateServicios() {
|
||||||
|
|
||||||
this.serviciosAcabado.updateServicios();
|
this.serviciosAcabado.updateServicios();
|
||||||
this.ServiciosEncuadernacion.updateServicios();
|
this.ServiciosEncuadernacion.updateServicios();
|
||||||
@ -243,12 +256,15 @@ class ServiciosAcabado {
|
|||||||
})
|
})
|
||||||
|
|
||||||
self.check_serv_acabado_error();
|
self.check_serv_acabado_error();
|
||||||
}
|
|
||||||
/* TO-DO
|
$(document).trigger('update-presupuesto', {
|
||||||
updatePresupuesto({
|
update_lineas : false,
|
||||||
update_resumen: true,
|
update_servicios : false,
|
||||||
update_tiradas_alternativas: true})
|
update_envios: false,
|
||||||
*/
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -260,15 +276,6 @@ class ServiciosAcabado {
|
|||||||
|
|
||||||
|
|
||||||
this.addServicio.on('click', this.addServicioAcabado.bind(this));
|
this.addServicio.on('click', this.addServicioAcabado.bind(this));
|
||||||
|
|
||||||
/*this.table.on('draw.dt', function () {
|
|
||||||
|
|
||||||
/* TO-DO
|
|
||||||
updatePresupuesto({
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true})
|
|
||||||
|
|
||||||
}); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateServicios() {
|
updateServicios() {
|
||||||
@ -413,17 +420,28 @@ class ServiciosAcabado {
|
|||||||
cargarServiciosAcabado(datos) {
|
cargarServiciosAcabado(datos) {
|
||||||
|
|
||||||
this.table.rows.add(datos).draw();
|
this.table.rows.add(datos).draw();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guardarServiciosAcabado() {
|
|
||||||
/* TO-DO
|
|
||||||
|
|
||||||
*/
|
async guardarServiciosAcabado() {
|
||||||
|
|
||||||
|
let datos = [];
|
||||||
|
this.table.rows().every(function () {
|
||||||
|
datos.push(this.data());
|
||||||
|
});
|
||||||
|
const domain = window.location.origin;
|
||||||
|
await fetch(domain + "/presupuestos/presupuestoacabados/edit/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({datos: datos}),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
check_serv_acabado_error() {
|
check_serv_acabado_error() {
|
||||||
|
|
||||||
var htmlString = '';
|
var htmlString = '';
|
||||||
@ -518,11 +536,14 @@ class ServiciosPreimpresion {
|
|||||||
drawCallback: function (settings) {
|
drawCallback: function (settings) {
|
||||||
|
|
||||||
self.check_serv_preimpresion_error();
|
self.check_serv_preimpresion_error();
|
||||||
/* TO-DO
|
|
||||||
updatePresupuesto({
|
$(document).trigger('update-presupuesto', {
|
||||||
update_resumen: true,
|
update_lineas : false,
|
||||||
update_tiradas_alternativas: true})
|
update_servicios : false,
|
||||||
*/
|
update_envios: false,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -537,15 +558,6 @@ class ServiciosPreimpresion {
|
|||||||
|
|
||||||
|
|
||||||
this.addServicio.on('click', this.addServicioPreimpresion.bind(this));
|
this.addServicio.on('click', this.addServicioPreimpresion.bind(this));
|
||||||
|
|
||||||
/*this.table.on('draw.dt', function () {
|
|
||||||
|
|
||||||
/* TO-DO
|
|
||||||
updatePresupuesto({
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true})
|
|
||||||
|
|
||||||
}); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPresupuestoPreimpresion(tarifa_id = -1) {
|
getPresupuestoPreimpresion(tarifa_id = -1) {
|
||||||
@ -628,11 +640,20 @@ class ServiciosPreimpresion {
|
|||||||
$('#serv-preimpresion-error').html(htmlString)
|
$('#serv-preimpresion-error').html(htmlString)
|
||||||
}
|
}
|
||||||
|
|
||||||
guardarServiciosPreimpresion() {
|
async guardarServiciosPreimpresion() {
|
||||||
/* TO-DO
|
|
||||||
|
let datos = [];
|
||||||
*/
|
this.table.rows().every(function () {
|
||||||
|
datos.push(this.data());
|
||||||
|
});
|
||||||
|
const domain = window.location.origin;
|
||||||
|
await fetch(domain + "/presupuestos/presupuestopreimpresiones/edit/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({datos: datos}),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -813,11 +834,13 @@ class ServiciosEncuadernacion {
|
|||||||
|
|
||||||
self.check_serv_enc_error();
|
self.check_serv_enc_error();
|
||||||
|
|
||||||
/* TO-DO
|
$(document).trigger('update-presupuesto', {
|
||||||
updatePresupuesto({
|
update_lineas : false,
|
||||||
update_resumen: true,
|
update_servicios : false,
|
||||||
update_tiradas_alternativas: true})
|
update_envios: false,
|
||||||
*/
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -826,18 +849,7 @@ class ServiciosEncuadernacion {
|
|||||||
self.table.row(rowId).remove().draw();
|
self.table.row(rowId).remove().draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.addServicio.on('click', this.addServicioEncuadernacion.bind(this));
|
this.addServicio.on('click', this.addServicioEncuadernacion.bind(this));
|
||||||
|
|
||||||
/*this.table.on('draw.dt', function () {
|
|
||||||
|
|
||||||
/* TO-DO
|
|
||||||
updatePresupuesto({
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true})
|
|
||||||
|
|
||||||
}); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateServicios() {
|
updateServicios() {
|
||||||
@ -1009,10 +1021,20 @@ class ServiciosEncuadernacion {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guardarServiciosEncuadernacion() {
|
async guardarServiciosEncuadernacion() {
|
||||||
/* TO-DO
|
|
||||||
|
let datos = [];
|
||||||
*/
|
this.table.rows().every(function () {
|
||||||
|
datos.push(this.data());
|
||||||
|
});
|
||||||
|
const domain = window.location.origin;
|
||||||
|
await fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({datos: datos}),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1155,11 +1177,13 @@ class ServiciosManipulado {
|
|||||||
|
|
||||||
self.check_serv_manipulado_error();
|
self.check_serv_manipulado_error();
|
||||||
|
|
||||||
/* TO-DO
|
$(document).trigger('update-presupuesto', {
|
||||||
updatePresupuesto({
|
update_lineas : false,
|
||||||
update_resumen: true,
|
update_servicios : false,
|
||||||
update_tiradas_alternativas: true})
|
update_envios: false,
|
||||||
*/
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1335,10 +1359,20 @@ class ServiciosManipulado {
|
|||||||
this.table.rows.add(datos).draw();
|
this.table.rows.add(datos).draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
guardarServiciosManipulado() {
|
async guardarServiciosManipulado() {
|
||||||
/* TO-DO
|
|
||||||
|
|
||||||
*/
|
let datos = [];
|
||||||
|
this.table.rows().every(function () {
|
||||||
|
datos.push(this.data());
|
||||||
|
});
|
||||||
|
const domain = window.location.origin;
|
||||||
|
await fetch(domain + "/presupuestos/presupuestomanipulados/edit/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({datos: datos}),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
check_serv_manipulado_error() {
|
check_serv_manipulado_error() {
|
||||||
@ -1437,14 +1471,14 @@ class ServiciosExtra {
|
|||||||
|
|
||||||
self.check_serv_extra_error();
|
self.check_serv_extra_error();
|
||||||
|
|
||||||
/* TO-DO
|
$(document).trigger('update-presupuesto', {
|
||||||
updatePresupuesto({
|
update_lineas : false,
|
||||||
update_resumen: true,
|
update_servicios : false,
|
||||||
update_tiradas_alternativas: true})
|
update_envios: false,
|
||||||
*/
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.btn-delete-servextra', function () {
|
$(document).on('click', '.btn-delete-servextra', function () {
|
||||||
@ -1482,10 +1516,20 @@ class ServiciosExtra {
|
|||||||
this.table.rows.add(datos).draw();
|
this.table.rows.add(datos).draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
guardarServiciosExtra() {
|
async guardarServiciosExtra() {
|
||||||
/* TO-DO
|
|
||||||
|
let datos = [];
|
||||||
*/
|
this.table.rows().every(function () {
|
||||||
|
datos.push(this.data());
|
||||||
|
});
|
||||||
|
const domain = window.location.origin;
|
||||||
|
await fetch(domain + "/presupuestos/presupuestoserviciosextra/edit/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({datos: datos}),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
getPresupuestoExtra(tarifa_id = -1) {
|
getPresupuestoExtra(tarifa_id = -1) {
|
||||||
|
|||||||
@ -83,13 +83,49 @@ class TiradasAlernativas {
|
|||||||
$(document).on('click', '.btn-delete-tirada', function (e) {
|
$(document).on('click', '.btn-delete-tirada', function (e) {
|
||||||
|
|
||||||
const row = $(this).closest('tr');
|
const row = $(this).closest('tr');
|
||||||
self.table.row(row)
|
$('#tableTiradas').DataTable().row(row)
|
||||||
.remove()
|
.remove()
|
||||||
.draw();
|
.draw();
|
||||||
showBreadCrumbSaveButton(true);
|
showBreadCrumbSaveButton(true);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$(document).on('click', '.comfirm-tirada-alt', function (e) {
|
||||||
|
|
||||||
|
const row = $(this).closest('tr');
|
||||||
|
const data = self.table.row(row).data();
|
||||||
|
|
||||||
|
self.table.row(row).remove().draw();
|
||||||
|
|
||||||
|
$(document).trigger('update-envios', {tirada_inicial:$('#tirada').val(), tirada: data.tirada});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('update-tiradas-alternativas', async function(){
|
||||||
|
|
||||||
|
await self.updateTiradasAlternativas();
|
||||||
|
|
||||||
|
$(document).trigger('update-tiradas-alternativas-completed');
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateTiradasAlternativas(){
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
if($('#tableTiradas').DataTable().rows().count() > 0){
|
||||||
|
// se obtiene la primera columna de la tabla de tiradas
|
||||||
|
const data = $('#tableTiradas').DataTable().rows().data().toArray();
|
||||||
|
// se borra la tabla de tiradas
|
||||||
|
$('#tableTiradas').DataTable().clear().draw();
|
||||||
|
const tiradas = data.map(row => row.tirada);
|
||||||
|
// por cada tirada, se añade una fila a la tabla de tiradas
|
||||||
|
tiradas.forEach(function(tirada){
|
||||||
|
self.addTiradaAlt(tirada);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cargar(datos) {
|
cargar(datos) {
|
||||||
|
|
||||||
@ -98,12 +134,12 @@ class TiradasAlernativas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addTiradaAlt() {
|
addTiradaAlt(tiradaExterna = null) {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
const id = window.location.href.split('/').pop();
|
const id = window.location.href.split('/').pop();
|
||||||
|
|
||||||
const tirada = parseInt(this.tirada.val());
|
const tirada = tiradaExterna===null?parseInt(this.tirada.val()):tiradaExterna;
|
||||||
const tirada_ejemplo = parseInt($('#tirada').val());
|
const tirada_ejemplo = parseInt($('#tirada').val());
|
||||||
const POD = parseInt($('#POD').val());
|
const POD = parseInt($('#POD').val());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user