mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en los envios
This commit is contained in:
@ -552,6 +552,7 @@ $routes->group('serviciospreimpresiones', ['namespace' => 'App\Controllers\Presu
|
||||
|
||||
$routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
$routes->post('datatable', 'Presupuestodirecciones::datatable', ['as' => 'dataTableOfPresupuestoDirecciones']);
|
||||
$routes->post('datatable_2', 'Presupuestodirecciones::datatable_2', ['as' => 'processDataDirecciones']);
|
||||
});
|
||||
|
||||
$routes->group('presupuestotiradasalternativas', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
|
||||
@ -33,5 +33,17 @@ class Js_loader extends BaseController
|
||||
return view('themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js');
|
||||
}
|
||||
|
||||
function datosServicios_js()
|
||||
{
|
||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||
return view('themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js');
|
||||
}
|
||||
|
||||
function datosEnvios_js()
|
||||
{
|
||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||
return view('themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.js');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -140,5 +140,32 @@ class Presupuestodirecciones extends \App\Controllers\GoBaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable_2(){
|
||||
|
||||
$reqData = $this->request->getJSON();
|
||||
|
||||
if($reqData->tipo=='get_tarifa'){
|
||||
$peso = $reqData->peso ?? 0;
|
||||
$paisId = $reqData->paisId ?? 0;
|
||||
$cp = $reqData->cp ?? 0;
|
||||
$tipo_envio = $reqData->tipo_envio ?? 'cajas';
|
||||
|
||||
$model = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$values = $model->getTarifaEnvio($paisId, $cp, $peso, $tipo_envio);
|
||||
$data = [
|
||||
'data' => count($values)>0?$values[0]:[],
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
else if($reqData->tipo=='clear_lineas'){
|
||||
|
||||
$presupuesto_id = $reqData->presupuesto_id ?? 0;
|
||||
return $this->respond($this->model->where('presupuesto_id', $presupuesto_id)->delete());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -77,174 +77,176 @@ class Presupuestotiradasalternativas extends \App\Controllers\GoBaseResourceCont
|
||||
public function datatable_2()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$json_data = $reqData['json_tiradas'] ?? null;
|
||||
$cliente_id = $reqData['cliente_id'] ?? 0;
|
||||
|
||||
$json_data = $reqData['json_tiradas'] ?? null;
|
||||
$cliente_id = $reqData['cliente_id'] ?? 0;
|
||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
||||
|
||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
||||
$values = [];
|
||||
|
||||
$values = [];
|
||||
if ($json_data) {
|
||||
|
||||
if ($json_data) {
|
||||
$data = json_decode($json_data, true);
|
||||
|
||||
$data = json_decode($json_data, true);
|
||||
foreach ($data as $linea) {
|
||||
// Se obtienen los valores de cada linea para el calculo del precio
|
||||
$datosPedido = (object)array(
|
||||
'paginas' => intval($linea['paginas']) ?? 0,
|
||||
'tirada' => intval($reqData['tirada']) ?? 0,
|
||||
'merma' => intval($reqData['merma']) ?? 0,
|
||||
'ancho' => intval($reqData['ancho']) ?? 100000,
|
||||
'alto' => intval($reqData['alto']) ?? 100000,
|
||||
'a_favor_fibra' => $linea['aFavorFibra'] ?? 1,
|
||||
'isCosido' => (new \App\Models\Configuracion\TipoPresupuestoModel())->get_isCosido($tipo_impresion_id), // JJO esto es custom por cada tipo de presupuesto
|
||||
);
|
||||
|
||||
foreach ($data as $linea) {
|
||||
// Se obtienen los valores de cada linea para el calculo del precio
|
||||
$datosPedido = (object)array(
|
||||
'paginas' => intval($linea['paginas']) ?? 0,
|
||||
'tirada' => intval($reqData['tirada']) ?? 0,
|
||||
'merma' => intval($reqData['merma']) ?? 0,
|
||||
'ancho' => intval($reqData['ancho']) ?? 100000,
|
||||
'alto' => intval($reqData['alto']) ?? 100000,
|
||||
'a_favor_fibra' => $linea['aFavorFibra'] ?? 1,
|
||||
'isCosido' => (new \App\Models\Configuracion\TipoPresupuestoModel())->get_isCosido($tipo_impresion_id), // JJO esto es custom por cada tipo de presupuesto
|
||||
);
|
||||
|
||||
if ($linea['row_id'] == 'lp_guardas') {
|
||||
$datosPedido->paginas_impresion = intval($linea['paginas_impresion']) ?? 0;
|
||||
// Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico
|
||||
// y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral
|
||||
// o wire-o tapa dura, las guardas se imprimen como hojas sueltas
|
||||
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
||||
$datosPedido->isCosido = true;
|
||||
} else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
|
||||
$datosPedido->isCosido = false;
|
||||
}
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta' || $linea['row_id'] == 'lp_cubierta') {
|
||||
$datosPedido->solapas =
|
||||
$linea['row_id'] == 'lp_cubierta' ? $reqData['solapas_cubierta'] : $reqData['solapas_sobrecubierta'];
|
||||
$datosPedido->solapas_ancho =
|
||||
$linea['row_id'] == 'lp_cubierta' ? $reqData['solapas_cubierta_ancho'] : $reqData['solapas_sobrecubierta_ancho'];
|
||||
$datosPedido->lomo = $reqData['lomo'];
|
||||
|
||||
$type = $linea['row_id'] == 'lp_cubierta' ? 'cubierta' : 'sobrecubierta';
|
||||
|
||||
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($type, $tipo_impresion_id, $datosPedido);
|
||||
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($type, $tipo_impresion_id, $datosPedido);
|
||||
if ($linea['row_id'] == 'lp_guardas') {
|
||||
$datosPedido->paginas_impresion = intval($linea['paginas_impresion']) ?? 0;
|
||||
// Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico
|
||||
// y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral
|
||||
// o wire-o tapa dura, las guardas se imprimen como hojas sueltas
|
||||
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
||||
$datosPedido->isCosido = true;
|
||||
} else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
|
||||
$datosPedido->isCosido = false;
|
||||
}
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta' || $linea['row_id'] == 'lp_cubierta') {
|
||||
$datosPedido->solapas =
|
||||
$linea['row_id'] == 'lp_cubierta' ? $reqData['solapas_cubierta'] : $reqData['solapas_sobrecubierta'];
|
||||
$datosPedido->solapas_ancho =
|
||||
$linea['row_id'] == 'lp_cubierta' ? $reqData['solapas_cubierta_ancho'] : $reqData['solapas_sobrecubierta_ancho'];
|
||||
$datosPedido->lomo = $reqData['lomo'];
|
||||
|
||||
$type = $linea['row_id'] == 'lp_cubierta' ? 'cubierta' : 'sobrecubierta';
|
||||
|
||||
$maquina = (new \App\Models\Configuracion\MaquinaModel())->find($linea['maquina_id']);
|
||||
$papel = (new \App\Models\Configuracion\PapelImpresionModel())->find($linea['papel_impresion_id']);
|
||||
$pg = (new \App\Models\Configuracion\PapelGenericoModel())->find($linea['papel']);
|
||||
|
||||
$papel_generico['id'] = $pg->id;
|
||||
$papel_generico['nombre'] = $pg->nombre;
|
||||
|
||||
$maquina->maquina_id = $maquina->id;
|
||||
unset($maquina->id);
|
||||
|
||||
switch ($linea['row_id']) {
|
||||
case 'lp_rot_bn':
|
||||
case 'lp_rot_color':
|
||||
$uso = 'rotativa';
|
||||
$tipo = strpos($linea['row_id'], "_bn") !== false ? 'negro' : 'color';
|
||||
break;
|
||||
case 'lp_cubierta':
|
||||
$uso = 'cubierta';
|
||||
break;
|
||||
case 'lp_sobrecubierta':
|
||||
$uso = 'sobrecubierta';
|
||||
break;
|
||||
case 'lp_guardas':
|
||||
$uso = 'guardas';
|
||||
break;
|
||||
default:
|
||||
$uso = 'interior';
|
||||
$isHq = strpos($linea['row_id'], "hq") !== false ? true : false;
|
||||
$isColor = strpos($linea['row_id'], "_color") !== false ? true : false;
|
||||
$tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro');
|
||||
break;
|
||||
}
|
||||
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'guardas') {
|
||||
$isColor = true;
|
||||
$isHq = true;
|
||||
$tipo = 'colorhq';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$opciones_papel = PresupuestoService::get_opciones_papel($uso, $isColor);
|
||||
|
||||
$datosTipolog = $linea['gotaNegro'] ?? null;
|
||||
if (!is_null($datosTipolog)) {
|
||||
$datosTipolog = [];
|
||||
$data = (object)array(
|
||||
'negro' => intval($linea['cobNegro']) ?? 0,
|
||||
'cyan' => intval($linea['cobCyan']) ?? 0,
|
||||
'magenta' => intval($linea['cobMagenta']) ?? 0,
|
||||
'amarillo' => intval($linea['cobAmarillo']) ?? 0,
|
||||
'cg' => intval($linea['cobCG']) ?? 0,
|
||||
'gota_negro' => intval($linea['gotaNegro']) ?? 0,
|
||||
'gota_color' => intval($linea['gotaColor']) ?? 0,
|
||||
);
|
||||
array_push($datosTipolog, $data);
|
||||
}
|
||||
|
||||
$data['uso'] = $uso;
|
||||
$data['tipo'] = $tipo;
|
||||
$data['datosPedido'] = $datosPedido;
|
||||
$data['cliente_id'] = $cliente_id;
|
||||
$data['papel'] = $papel;
|
||||
$data['opciones_papel'] = $opciones_papel;
|
||||
$data['maquina'] = $maquina;
|
||||
$data['papel_generico'] = $papel_generico;
|
||||
$data['isColor'] = $isColor;
|
||||
$data['a_favor_fibra'] = $linea['aFavorFibra'] ?? null;
|
||||
$data['datosTipolog'] = $datosTipolog;
|
||||
$data['gramaje'] = $linea['gramaje'] ?? 0;
|
||||
|
||||
if ($linea['row_id'] != 'lp_rot_bn' && $linea['row_id'] != 'lp_rot_color') {
|
||||
$linea_coste = PresupuestoService::getLineaPresupuestoPlana($data);
|
||||
} else {
|
||||
$linea_coste = [0];
|
||||
}
|
||||
|
||||
if (empty($linea))
|
||||
continue;
|
||||
|
||||
if ($linea['check_papel_total'] == 0) {
|
||||
$linea_coste['fields']['precio_pedido'] = 0;
|
||||
}
|
||||
if ($linea['check_impresion_total'] == 0) {
|
||||
$linea_coste['fields']['precio_impresion_horas'] = 0;
|
||||
$linea_coste['fields']['precio_click_pedido'] = 0;
|
||||
if ($linea_coste['fields']['tipo_maquina'] == 'inkjet') {
|
||||
$linea_coste['fields']['precio_tinta'] = 0;
|
||||
$linea_coste['fields']['totalCorte'] = 0;
|
||||
}
|
||||
}
|
||||
$linea_coste['total_coste'] = $linea_coste['fields']['precio_pedido'] +
|
||||
$linea_coste['fields']['precio_impresion_horas'] +
|
||||
$linea_coste['fields']['precio_click_pedido'];
|
||||
if ($linea_coste['fields']['tipo_maquina'] == 'inkjet') {
|
||||
$linea_coste['total_coste'] +=
|
||||
$linea_coste['fields']['precio_tinta'] +
|
||||
$linea_coste['fields']['totalCorte'];
|
||||
}
|
||||
array_push($values, $linea_coste);
|
||||
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($type, $tipo_impresion_id, $datosPedido);
|
||||
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($type, $tipo_impresion_id, $datosPedido);
|
||||
}
|
||||
} else {
|
||||
$values = [];
|
||||
|
||||
|
||||
$maquina = (new \App\Models\Configuracion\MaquinaModel())->find($linea['maquina_id']);
|
||||
$papel = (new \App\Models\Configuracion\PapelImpresionModel())->find($linea['papel_impresion_id']);
|
||||
$pg = (new \App\Models\Configuracion\PapelGenericoModel())->find($linea['papel']);
|
||||
|
||||
$papel_generico['id'] = $pg->id;
|
||||
$papel_generico['nombre'] = $pg->nombre;
|
||||
|
||||
$maquina->maquina_id = $maquina->id;
|
||||
unset($maquina->id);
|
||||
|
||||
switch ($linea['row_id']) {
|
||||
case 'lp_rot_bn':
|
||||
case 'lp_rot_color':
|
||||
$uso = 'rotativa';
|
||||
$tipo = strpos($linea['row_id'], "_bn") !== false ? 'negro' : 'color';
|
||||
break;
|
||||
case 'lp_cubierta':
|
||||
$uso = 'cubierta';
|
||||
break;
|
||||
case 'lp_sobrecubierta':
|
||||
$uso = 'sobrecubierta';
|
||||
break;
|
||||
case 'lp_guardas':
|
||||
$uso = 'guardas';
|
||||
break;
|
||||
default:
|
||||
$uso = 'interior';
|
||||
$isHq = strpos($linea['row_id'], "hq") !== false ? true : false;
|
||||
$isColor = strpos($linea['row_id'], "_color") !== false ? true : false;
|
||||
$tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro');
|
||||
break;
|
||||
}
|
||||
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'guardas') {
|
||||
$isColor = true;
|
||||
$isHq = true;
|
||||
$tipo = 'colorhq';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$opciones_papel = PresupuestoService::get_opciones_papel($uso, $isColor);
|
||||
|
||||
$datosTipolog = $linea['gotaNegro'] ?? null;
|
||||
if (!is_null($datosTipolog)) {
|
||||
$datosTipolog = [];
|
||||
$data = (object)array(
|
||||
'negro' => intval($linea['cobNegro']) ?? 0,
|
||||
'cyan' => intval($linea['cobCyan']) ?? 0,
|
||||
'magenta' => intval($linea['cobMagenta']) ?? 0,
|
||||
'amarillo' => intval($linea['cobAmarillo']) ?? 0,
|
||||
'cg' => intval($linea['cobCG']) ?? 0,
|
||||
'gota_negro' => intval($linea['gotaNegro']) ?? 0,
|
||||
'gota_color' => intval($linea['gotaColor']) ?? 0,
|
||||
);
|
||||
array_push($datosTipolog, $data);
|
||||
}
|
||||
|
||||
$data['uso'] = $uso;
|
||||
$data['tipo'] = $tipo;
|
||||
$data['datosPedido'] = $datosPedido;
|
||||
$data['cliente_id'] = $cliente_id;
|
||||
$data['papel'] = $papel;
|
||||
$data['opciones_papel'] = $opciones_papel;
|
||||
$data['maquina'] = $maquina;
|
||||
$data['papel_generico'] = $papel_generico;
|
||||
$data['isColor'] = $isColor;
|
||||
$data['a_favor_fibra'] = $linea['aFavorFibra'] ?? null;
|
||||
$data['datosTipolog'] = $datosTipolog;
|
||||
$data['gramaje'] = $linea['gramaje'] ?? 0;
|
||||
|
||||
if ($linea['row_id'] != 'lp_rot_bn' && $linea['row_id'] != 'lp_rot_color') {
|
||||
$linea_coste = PresupuestoService::getLineaPresupuestoPlana($data);
|
||||
} else {
|
||||
$linea_coste = [0];
|
||||
}
|
||||
|
||||
if (empty($linea))
|
||||
continue;
|
||||
|
||||
if ($linea['check_papel_total'] == 0) {
|
||||
$linea_coste['fields']['precio_pedido'] = 0;
|
||||
}
|
||||
if ($linea['check_impresion_total'] == 0) {
|
||||
$linea_coste['fields']['precio_impresion_horas'] = 0;
|
||||
$linea_coste['fields']['precio_click_pedido'] = 0;
|
||||
if ($linea_coste['fields']['tipo_maquina'] == 'inkjet') {
|
||||
$linea_coste['fields']['precio_tinta'] = 0;
|
||||
$linea_coste['fields']['totalCorte'] = 0;
|
||||
}
|
||||
}
|
||||
$linea_coste['total_coste'] = $linea_coste['fields']['precio_pedido'] +
|
||||
$linea_coste['fields']['precio_impresion_horas'] +
|
||||
$linea_coste['fields']['precio_click_pedido'];
|
||||
if ($linea_coste['fields']['tipo_maquina'] == 'inkjet') {
|
||||
$linea_coste['total_coste'] +=
|
||||
$linea_coste['fields']['precio_tinta'] +
|
||||
$linea_coste['fields']['totalCorte'];
|
||||
}
|
||||
|
||||
$linea_coste['total_margen'] = $linea_coste['fields']['margen_papel_pedido'] +
|
||||
$linea_coste['fields']['margen_impresion_horas'] +
|
||||
$linea_coste['fields']['margen_click_pedido'];
|
||||
|
||||
unset($linea_coste['fields']);
|
||||
array_push($values, $linea_coste);
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
$response['lineas'] = $values;
|
||||
|
||||
return $this->respond($response);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
$values = [];
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
$response['lineas'] = $values;
|
||||
|
||||
return $this->respond($response);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'total'=> 0,
|
||||
'marge'=> 0,
|
||||
'margen'=> 0,
|
||||
];
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
// 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]);
|
||||
console.log(values.data);
|
||||
return values.data;
|
||||
}
|
||||
|
||||
async function get_coste_envio_tiradasAlternativas(tirada){
|
||||
|
||||
var peso_libro = get_peso_libro();
|
||||
var tirada_inicial = parseInt($('#tirada').val());
|
||||
var precio_envio = 0.0;
|
||||
var margen_envio = 0.0;
|
||||
|
||||
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
const rowData = this.data();
|
||||
const porcentaje = parseInt(rowData.cantidad)/tirada_inicial*100.0;
|
||||
const cantidad = Math.floor(tirada*porcentaje/100.0);
|
||||
const precio_linea = get_precio_envio(cantidad*peso_libro/1000.0, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
|
||||
console.log(precio_linea);
|
||||
precio_envio += parseFloat(precio_linea.precio);
|
||||
margen_envio += parseFloat(precio_linea.precio*precio_linea.margen/100.0);
|
||||
})
|
||||
return {precio_envio, margen_envio};
|
||||
|
||||
}
|
||||
@ -90,89 +90,74 @@ const actionBtns_direcciones = function(data) {
|
||||
`;
|
||||
};
|
||||
|
||||
function updateTablaEnvios(){
|
||||
async function updateTablaEnvios(){
|
||||
|
||||
var peso_total_libro = 0
|
||||
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
var rowData = this.data();
|
||||
peso_total_libro += parseFloat(rowData.peso)
|
||||
|
||||
})
|
||||
var peso_total_libro = get_peso_libro();
|
||||
|
||||
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
|
||||
var rowData = this.data();
|
||||
const peso_envio = peso_total_libro*parseInt(rowData.cantidad)/1000.0
|
||||
const peso_envio = peso_total_libro*parseInt(rowData.cantidad)/1000.0;
|
||||
|
||||
const data = get_precio_envio(peso_envio, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
|
||||
|
||||
$.post( '<?= route_to('dataTableOfPresupuestoDirecciones') ?>',
|
||||
{
|
||||
tipo: "get_tarifa",
|
||||
peso: peso_envio,
|
||||
paisId: rowData.paisId,
|
||||
cp: rowData.cp,
|
||||
tipo_envio: parseInt(rowData.entregaPieCalle)==1?'palets':'cajas',
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
})
|
||||
.done(function( data ) {
|
||||
if(data.length >0){
|
||||
|
||||
var precios = []
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if(peso_envio>data[i].peso_max){
|
||||
data[i].precio = (data[i].peso_min + (peso_envio-data[i].peso_min)*data[i].precio_adicional).toFixed(2);
|
||||
}
|
||||
// si no se calcula linealmente
|
||||
else{
|
||||
m=((data[i].precio_max-data[i].precio_min)/(data[i].peso_max-data[i].peso_min))
|
||||
b=data[i].precio_max-m*data[i].peso_max
|
||||
data[i].precio = (m*peso_envio+b).toFixed(2);
|
||||
}
|
||||
data[i].margen = data[i].margen
|
||||
}
|
||||
|
||||
const tarifa_final = data.reduce((previous, current) => {
|
||||
return current.precio < previous.precio ? current : previous;
|
||||
});
|
||||
tarifa_final.cantidad=parseInt($('#add_cantidad').val())
|
||||
tarifa_final.peso=peso_envio
|
||||
|
||||
|
||||
tableEnvios.row(rowIdx)
|
||||
.data({
|
||||
'tarifa_id': tarifa_final.id,
|
||||
'cantidad': rowData.cantidad,
|
||||
'peso': tarifa_final.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': tarifa_final.proveedor,
|
||||
'proveedor_id': tarifa_final.proveedor_id,
|
||||
'precio': tarifa_final.precio,
|
||||
'margen': tarifa_final.margen,
|
||||
'entregaPieCalle': rowData.entregaPieCalle,
|
||||
'actionBtns_direcciones': actionBtns_direcciones,
|
||||
})
|
||||
.draw();
|
||||
|
||||
|
||||
checkInsertar()
|
||||
updateTotales(false, false, true)
|
||||
if(data.length >0){
|
||||
|
||||
var precios = []
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if(peso_envio>data[i].peso_max){
|
||||
data[i].precio = (data[i].peso_min + (peso_envio-data[i].peso_min)*data[i].precio_adicional).toFixed(2);
|
||||
}
|
||||
else{
|
||||
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
|
||||
// si no se calcula linealmente
|
||||
else{
|
||||
m=((data[i].precio_max-data[i].precio_min)/(data[i].peso_max-data[i].peso_min))
|
||||
b=data[i].precio_max-m*data[i].peso_max
|
||||
data[i].precio = (m*peso_envio+b).toFixed(2);
|
||||
}
|
||||
|
||||
data[i].margen = data[i].margen
|
||||
}
|
||||
|
||||
const tarifa_final = data.reduce((previous, current) => {
|
||||
return current.precio < previous.precio ? current : previous;
|
||||
});
|
||||
})
|
||||
tarifa_final.cantidad=parseInt($('#add_cantidad').val())
|
||||
tarifa_final.peso=peso_envio
|
||||
|
||||
|
||||
|
||||
|
||||
tableEnvios.row(rowIdx)
|
||||
.data({
|
||||
'tarifa_id': tarifa_final.id,
|
||||
'cantidad': rowData.cantidad,
|
||||
'peso': tarifa_final.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': tarifa_final.proveedor,
|
||||
'proveedor_id': tarifa_final.proveedor_id,
|
||||
'precio': tarifa_final.precio,
|
||||
'margen': tarifa_final.margen,
|
||||
'entregaPieCalle': rowData.entregaPieCalle,
|
||||
'actionBtns_direcciones': actionBtns_direcciones,
|
||||
})
|
||||
.draw();
|
||||
|
||||
|
||||
checkInsertar()
|
||||
updateTotales(false, false, true)
|
||||
|
||||
}
|
||||
else{
|
||||
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
|
||||
}
|
||||
/**
|
||||
* @var mixed })
|
||||
*/
|
||||
})
|
||||
}
|
||||
|
||||
$(document).on('click', '.delete-add-row', function(e) {
|
||||
@ -411,5 +396,6 @@ function load_datos_envios(){
|
||||
}
|
||||
|
||||
|
||||
window.url_get_precio_envio = '<?= route_to('processDataDirecciones') ?>';
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,266 @@
|
||||
/****************************************************************************************
|
||||
* Seccion para los servicios de acabado
|
||||
***************************************************************************************/
|
||||
function get_datos_acabado(){
|
||||
|
||||
var datosAcabado = []
|
||||
if($('#tableOfServiciosAcabado').DataTable().rows().count()>0){
|
||||
$("#tableOfServiciosAcabado tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 1:
|
||||
if($(this).text().includes(' '+ lang_text_cubierta))
|
||||
values['cubierta'] = 1
|
||||
else
|
||||
values['cubierta'] = 0
|
||||
if($(this).text().includes(' '+ lang_text_sobrecubierta))
|
||||
values['sobrecubierta'] = 1
|
||||
else
|
||||
values['sobrecubierta'] = 0
|
||||
break
|
||||
case 2:
|
||||
values['precio_unidad'] = $(this).text()
|
||||
break
|
||||
case 3:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
case 4:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosAcabado.push(values)
|
||||
})
|
||||
}
|
||||
return datosAcabado
|
||||
}
|
||||
|
||||
|
||||
async function get_servAcabados_tiradasAlternativas(tirada){
|
||||
serviciosAcabados ={
|
||||
coste: 0.0,
|
||||
margen: 0.0,
|
||||
}
|
||||
json_data = {
|
||||
datos: get_datos_acabado(),
|
||||
tirada: parseInt(tirada),
|
||||
POD: $('#POD').val()
|
||||
}
|
||||
json_data = Object.assign(json_data, window.token_ajax);
|
||||
|
||||
const response = await fetch(window.location.origin + "/presupuestos/presupuestoacabados/update/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify(json_data),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
const values = await response.json();
|
||||
yeniden(values[window.csrf_token]);
|
||||
values.lines.forEach((line) => {
|
||||
|
||||
serviciosAcabados.coste += parseFloat(line[0].total);
|
||||
serviciosAcabados.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
|
||||
});
|
||||
return serviciosAcabados;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Seccion para los servicios de encuadernación
|
||||
***************************************************************************************/
|
||||
function get_datos_encuadernacion(){
|
||||
|
||||
var datosEnc = []
|
||||
if($("#tableOfServiciosEncuadernacion").DataTable().rows().count()>0){
|
||||
$("#tableOfServiciosEncuadernacion tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 2:
|
||||
values['proveedor_id'] = $(this).children(":first").select2('data')[0].id
|
||||
break
|
||||
case 3:
|
||||
values['precio_unidad'] = $(this).text()
|
||||
break
|
||||
case 4:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
case 5:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosEnc.push(values)
|
||||
})
|
||||
}
|
||||
|
||||
return datosEnc
|
||||
}
|
||||
|
||||
|
||||
async function get_servEncuadernacion_tiradasAlternativas(tirada, paginas, ancho, alto){
|
||||
serviciosEncuadernacion ={
|
||||
coste: 0.0,
|
||||
margen: 0.0,
|
||||
}
|
||||
json_data = {
|
||||
datos: get_datos_encuadernacion(),
|
||||
tirada: parseInt(tirada),
|
||||
paginas: parseInt(paginas),
|
||||
ancho: ancho,
|
||||
alto: alto,
|
||||
POD: $('#POD').val()
|
||||
}
|
||||
json_data = Object.assign(json_data, window.token_ajax);
|
||||
|
||||
const response = await fetch(window.location.origin + "/presupuestos/presupuestoencuadernaciones/update/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify(json_data),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
const values = await response.json();
|
||||
yeniden(values[window.csrf_token]);
|
||||
values.lines.forEach((line) => {
|
||||
serviciosEncuadernacion.coste += parseFloat(line[0].total);
|
||||
serviciosEncuadernacion.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
|
||||
});
|
||||
return serviciosEncuadernacion;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Seccion para los servicios de manipulado
|
||||
***************************************************************************************/
|
||||
function get_datos_manipulado(){
|
||||
|
||||
var datosManipulado = []
|
||||
if($("#tableOfServiciosManipulado").DataTable().rows().count()>0){
|
||||
|
||||
$("#tableOfServiciosManipulado tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 2:
|
||||
values['precio_unidad'] = $(this).text()
|
||||
break
|
||||
case 3:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
case 4:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosManipulado.push(values)
|
||||
})
|
||||
}
|
||||
|
||||
return datosManipulado
|
||||
}
|
||||
|
||||
|
||||
async function get_servManipulado_tiradasAlternativas(tirada){
|
||||
serviciosManipulado ={
|
||||
coste: 0.0,
|
||||
margen: 0.0,
|
||||
}
|
||||
json_data = {
|
||||
datos: get_datos_manipulado(),
|
||||
tirada: parseInt(tirada),
|
||||
POD: $('#POD').val()
|
||||
}
|
||||
json_data = Object.assign(json_data, window.token_ajax);
|
||||
|
||||
const response = await fetch(window.location.origin + "/presupuestos/presupuestomanipulados/update/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify(json_data),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
const values = await response.json();
|
||||
yeniden(values[window.csrf_token]);
|
||||
values.lines.forEach((line) => {
|
||||
serviciosManipulado.coste += parseFloat(line[0].total);
|
||||
serviciosManipulado.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
|
||||
});
|
||||
return serviciosManipulado;
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
* Seccion para los servicios de preimpresión
|
||||
***************************************************************************************/
|
||||
function get_datos_preimpresion(){
|
||||
|
||||
var datosPreimpresion = []
|
||||
if($("#tableOfServiciosPreimpresion").DataTable().rows().count()>0){
|
||||
|
||||
$("#tableOfServiciosPreimpresion tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 2:
|
||||
values['precio'] = $(this).children(":first").val()
|
||||
break
|
||||
case 3:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosPreimpresion.push(values)
|
||||
})
|
||||
}
|
||||
|
||||
return datosPreimpresion
|
||||
}
|
||||
|
||||
async function get_servPreimpresion_tiradasAlternativas(){
|
||||
serviciosPreimpresion ={
|
||||
coste: 0.0,
|
||||
margen: 0.0,
|
||||
}
|
||||
json_data = {
|
||||
datos: get_datos_preimpresion(),
|
||||
POD: $('#POD').val()
|
||||
}
|
||||
json_data = Object.assign(json_data, window.token_ajax);
|
||||
|
||||
const response = await fetch(window.location.origin + "/presupuestos/presupuestopreimpresiones/update/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify(json_data),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
const values = await response.json();
|
||||
yeniden(values[window.csrf_token]);
|
||||
values.lines.forEach((line) => {
|
||||
serviciosPreimpresion.coste += parseFloat(line[0].total);
|
||||
serviciosPreimpresion.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
|
||||
});
|
||||
return serviciosPreimpresion;
|
||||
}
|
||||
@ -710,47 +710,7 @@
|
||||
}
|
||||
|
||||
|
||||
function get_datos_acabado(){
|
||||
|
||||
var datosAcabado = []
|
||||
if(tableServiciosAcabado.rows().count()>0){
|
||||
$("#tableOfServiciosAcabado tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 1:
|
||||
if($(this).text().includes(' (<?= lang("Presupuestos.cubierta") ?>)'))
|
||||
values['cubierta'] = 1
|
||||
else
|
||||
values['cubierta'] = 0
|
||||
if($(this).text().includes(' (<?= lang("Presupuestos.sobrecubierta") ?>)'))
|
||||
values['sobrecubierta'] = 1
|
||||
else
|
||||
values['sobrecubierta'] = 0
|
||||
break
|
||||
case 2:
|
||||
values['precio_unidad'] = $(this).text()
|
||||
break
|
||||
case 3:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
case 4:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosAcabado.push(values)
|
||||
})
|
||||
}
|
||||
|
||||
return datosAcabado
|
||||
}
|
||||
|
||||
|
||||
init_servicio_acabado()
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -1026,41 +986,6 @@
|
||||
check_serv_enc_error()
|
||||
})
|
||||
|
||||
function get_datos_encuadernacion(){
|
||||
|
||||
var datosEnc = []
|
||||
if(tableServiciosEnc.rows().count()>0){
|
||||
$("#tableOfServiciosEncuadernacion tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 2:
|
||||
values['proveedor_id'] = $(this).children(":first").select2('data')[0].id
|
||||
break
|
||||
case 3:
|
||||
values['precio_unidad'] = $(this).text()
|
||||
break
|
||||
case 4:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
case 5:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosEnc.push(values)
|
||||
})
|
||||
}
|
||||
|
||||
return datosEnc
|
||||
}
|
||||
|
||||
|
||||
init_servicio_encuadernado()
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -1200,38 +1125,7 @@
|
||||
check_serv_manipulado_error()
|
||||
})
|
||||
|
||||
function get_datos_manipulado(){
|
||||
|
||||
var datosManipulado = []
|
||||
if(tableServiciosManipulado.rows().count()>0){
|
||||
|
||||
$("#tableOfServiciosManipulado tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 2:
|
||||
values['precio_unidad'] = $(this).text()
|
||||
break
|
||||
case 3:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
case 4:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosManipulado.push(values)
|
||||
})
|
||||
}
|
||||
|
||||
return datosManipulado
|
||||
}
|
||||
|
||||
|
||||
function servicioGuardas(add_service = false){
|
||||
if(add_service){
|
||||
$('#add_servicio_manipulado_list').val(<?php echo $serviciosAutomaticos['plegadoGuardas'] ?>)
|
||||
@ -1403,35 +1297,12 @@
|
||||
check_serv_preimpresion_error()
|
||||
})
|
||||
|
||||
function get_datos_preimpresion(){
|
||||
|
||||
var datosPreimpresion = []
|
||||
if(tableServiciosPreimpresion.rows().count()>0){
|
||||
|
||||
$("#tableOfServiciosPreimpresion tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 2:
|
||||
values['precio'] = $(this).children(":first").val()
|
||||
break
|
||||
case 3:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosPreimpresion.push(values)
|
||||
})
|
||||
}
|
||||
|
||||
return datosPreimpresion
|
||||
}
|
||||
|
||||
|
||||
init_servicio_preimpresion()
|
||||
|
||||
|
||||
// Definición de varibles para el js (actualizar el lang)
|
||||
lang_text_cubierta = '<?= lang("Presupuestos.cubierta") ?>';
|
||||
lang_text_sobrecubierta = '<?= lang("Presupuestos.sobrecubierta") ?>';
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
@ -14,6 +14,7 @@ const actionBtns_tiradasAlt = function (data) {
|
||||
var tableTiradas;
|
||||
|
||||
|
||||
// Espera a que todas las variables necesarias estén definidas
|
||||
(async () => {
|
||||
|
||||
while (!window.hasOwnProperty("datatable_lang_url") && !window.hasOwnProperty("datatable_TA_url"))
|
||||
@ -29,16 +30,18 @@ var tableTiradas;
|
||||
total_pedido: 0,
|
||||
precio_unidad: 0
|
||||
}).draw(false);
|
||||
|
||||
})();
|
||||
|
||||
|
||||
// Evento de añadir una tirada alternativa
|
||||
$('#add_tirada_alt').on('click', function () {
|
||||
|
||||
const dimension = getDimensionLibro();
|
||||
|
||||
let datos = {
|
||||
tirada: $('#tirada_alt').val(),
|
||||
merma: 20, ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>calcular merma
|
||||
merma: get_merma_tirada_alternativa($('#tirada_alt').val()),
|
||||
tipo_impresion_id: $('#tipo_impresion_id').val(),
|
||||
json_tiradas: generate_json_tiradas(),
|
||||
ancho: dimension.ancho,
|
||||
@ -53,32 +56,66 @@ $('#add_tirada_alt').on('click', function () {
|
||||
|
||||
datos = Object.assign(datos, window.token_ajax);
|
||||
|
||||
// Se realiza la petición AJAX
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: window.get_tirada_url,
|
||||
data: datos,
|
||||
success: function (data) {
|
||||
success: async function (data) {
|
||||
|
||||
var coste_total = 0.0;
|
||||
var margen_total = 0.0;
|
||||
|
||||
var costes_servicios = 0.0;
|
||||
var margen_servicios = 0.0;
|
||||
|
||||
if(data.lineas.length >0){
|
||||
// Se cogen los valores de la linea con los datos correspondientes
|
||||
$.each(data.lineas, function(key, value) {
|
||||
|
||||
console.log(value);
|
||||
coste_total += value.total_coste;
|
||||
margen_total += value.total_margen;
|
||||
});
|
||||
|
||||
// Se obtiene el precio de los servicios
|
||||
const valueAcabados = await get_servAcabados_tiradasAlternativas(parseInt(datos.tirada));
|
||||
costes_servicios += valueAcabados.coste;
|
||||
margen_servicios += valueAcabados.margen;
|
||||
|
||||
}
|
||||
else{
|
||||
const valueEncuadernacion = await get_servEncuadernacion_tiradasAlternativas(
|
||||
parseInt(datos.tirada), parseInt( $('#paginas').val()), parseInt(dimension.ancho), parseInt(dimension.alto));
|
||||
costes_servicios += valueEncuadernacion.coste;
|
||||
margen_servicios += valueEncuadernacion.margen;
|
||||
|
||||
const valueManipulado = await get_servManipulado_tiradasAlternativas(parseInt(datos.tirada));
|
||||
costes_servicios += valueManipulado.coste;
|
||||
margen_servicios += valueManipulado.margen;
|
||||
|
||||
const valuePreimpresion = await get_servPreimpresion_tiradasAlternativas(parseInt(datos.tirada));
|
||||
costes_servicios += valuePreimpresion.coste;
|
||||
margen_servicios += valuePreimpresion.margen;
|
||||
|
||||
const valueTransporte = await get_coste_envio_tiradasAlternativas(parseInt(datos.tirada));
|
||||
|
||||
console.log(coste_total);
|
||||
console.log(margen_total);
|
||||
console.log(costes_servicios);
|
||||
console.log(margen_servicios);
|
||||
console.log(valueTransporte);
|
||||
}
|
||||
|
||||
yeniden(data[window.csrf_token]);
|
||||
|
||||
},
|
||||
error: function(e){
|
||||
|
||||
}
|
||||
error: function(e){}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Función para obtener el lomo exterior
|
||||
function getLomoExterior(){
|
||||
let lomoTotal = 0
|
||||
try{
|
||||
@ -94,6 +131,7 @@ function getLomoExterior(){
|
||||
return lomoTotal
|
||||
}
|
||||
|
||||
|
||||
// Inicialización de la tabla de tiradas
|
||||
function initTableTiradas() {
|
||||
tableTiradas = $('#tableTiradas').DataTable({
|
||||
@ -185,4 +223,35 @@ function filterData(data, keys) {
|
||||
});
|
||||
return newObj;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Función para obtener la merma de la tirada alternativa
|
||||
function get_merma_tirada_alternativa(tirada){
|
||||
|
||||
var merma = 0
|
||||
|
||||
if(tirada>parseInt($('#POD').val())){
|
||||
|
||||
merma = tirada*0.1<=30 ? tirada*0.1 : 30
|
||||
}
|
||||
else{
|
||||
merma_lineas = []
|
||||
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
var rowData = this.data();
|
||||
if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){
|
||||
const formas_linea = $('#isCosido').val()==0?parseInt(rowData.formas):parseInt(rowData.formas)/2
|
||||
if(formas_linea > tirada)
|
||||
merma_lineas.push(formas_linea-tirada)
|
||||
else
|
||||
merma_lineas.push(tirada%formas_linea)
|
||||
}
|
||||
})
|
||||
|
||||
if(merma_lineas.length>0)
|
||||
merma = Math.max(...merma_lineas)
|
||||
else
|
||||
merma = 0
|
||||
}
|
||||
return merma;
|
||||
}
|
||||
@ -54,11 +54,7 @@
|
||||
|
||||
window.datatable_TA_url = "<?= route_to('dataTableOfPresupuestoTiradasAlternativas') ?>";
|
||||
window.get_tirada_url = "<?= route_to('getTiradaData') ?>";
|
||||
|
||||
window.token_ajax= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
|
||||
|
||||
window.csrf_token = '<?= csrf_token() ?>';
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
@ -15,6 +15,10 @@
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<input type="hidden" name="tipo_impresion_id" id="tipo_impresion_id" class="form-control"
|
||||
value="<?= $tipo_impresion_id ?>"></input>
|
||||
<input type="hidden" name="isCosido" id="isCosido" class="form-control"
|
||||
value="<?= $isCosido ?>"></input>
|
||||
<input type="hidden" name="POD" id="POD" class="form-control"
|
||||
value="<?= $POD ?>"></input>
|
||||
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems") ?>
|
||||
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems") ?>
|
||||
<?php if (str_contains($formAction, 'edit')): ?>
|
||||
@ -227,9 +231,22 @@ const url_parts = url.split('/');
|
||||
return false; //stop the actual form post !important!
|
||||
});
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?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; ?>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -251,6 +268,8 @@ const url_parts = url.split('/');
|
||||
<script src="<?= site_url('js_loader/comparadorCosidoTapaBlanda_js') ?>"></script>
|
||||
<script src="<?= site_url('js_loader/previsualizador_js') ?>"></script>
|
||||
<script src="<?= site_url('js_loader/tiradasAlternativas_js') ?>"></script>
|
||||
<script src="<?= site_url('js_loader/datosServicios_js') ?>"></script>
|
||||
<script src="<?= site_url('js_loader/datosEnvios_js') ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
|
||||
<?php endif; ?>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
Reference in New Issue
Block a user