comprobando presupuestos

This commit is contained in:
2024-10-22 08:43:21 +02:00
parent 62a3706049
commit 2f83526d7e
20 changed files with 37035 additions and 223 deletions

View File

@ -101,6 +101,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$model_user = model('App\Models\Usuarios\UserModel'); $model_user = model('App\Models\Usuarios\UserModel');
$user = $model_user->find(auth()->user()->id); $user = $model_user->find(auth()->user()->id);
$clienteId = $user->cliente_id; $clienteId = $user->cliente_id;
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); $POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$this->viewData['breadcrumb'] = [ $this->viewData['breadcrumb'] = [
@ -138,50 +139,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$user = $model_user->find(auth()->user()->id); $user = $model_user->find(auth()->user()->id);
$clienteId = $user->cliente_id; $clienteId = $user->cliente_id;
$datosPresupuesto = (object) array();
$datosPresupuesto->POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$datosPresupuesto->paisList = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true);
$datosPresupuesto->papelFormatoList = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null);
$datosPresupuesto->papelInteriorNegro = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negro', false, false, false, false, true);
$datosPresupuesto->papelInteriorNegroHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negrohq', false, false, false, false, true);
$datosPresupuesto->papelInteriorColor = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('color', false, false, false, false, true);
$datosPresupuesto->papelInteriorColorHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, false, false, false, true);
$datosPresupuesto->papelCubierta = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', true, false, false, false, true);
$datosPresupuesto->papelSobrecubierta = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, true, false, false, true);
$datosPresupuesto->papelGuardas = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, false, false, true, false);
$datosPresupuesto->acabadosCubierta = $this->getAcabadosCubierta();
$datosPresupuesto->acabadosSobrecubierta = $this->getAcabadosSobrecubierta();
$datosPresupuesto->tipo_libro = $this->getTipoLibro($presupuestoEntity->tipo_impresion_id ?? null);
$datosPresupuesto->color_impresion =
$this->getTipoInterior($presupuestoEntity->id ?? null);
$datosPresupuesto->tapa = $this->getTapa($presupuestoEntity->tipo_impresion_id ?? null);
$datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
$this->obtenerTiradas($presupuestoEntity);
$this->obtenerDatosPapel($presupuestoEntity);
$this->obtenerPaginasColor($presupuestoEntity);
$this->obtenerDireccionesEnvio($presupuestoEntity);
// Si el presupuesto está confirmado, se generan los datos del resumen
if ($presupuestoEntity->estado_id == 2) {
$this->generarResumen($presupuestoEntity);
}
$datosPresupuesto->paginasCuadernillo = [32, 28, 24, 20, 16];
$presupuestoEntity->paginas_por_cuadernillo = $this->obtenerPaginasCuadernillo($presupuestoEntity);
$this->viewData['formAction'] = 'edit'; $this->viewData['formAction'] = 'edit';
$this->viewData['paisList'] = $this->getPaisListItems(); $this->viewData['paisList'] = $this->getPaisListItems();
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
$this->viewData['clienteId'] = $clienteId; $this->viewData['clienteId'] = $clienteId;
$this->viewData['POD'] = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); $this->viewData['POD'] = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto // Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
@ -323,6 +285,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$direcciones = $reqData['direcciones'] ?? []; $direcciones = $reqData['direcciones'] ?? [];
$tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']); $tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']);
$lomoRedondo = $cubierta['lomoRedondo'] ?? 0;
if ($papelInteriorDiferente) { if ($papelInteriorDiferente) {
$papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']); $papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']);
@ -351,6 +314,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0), 'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0),
'solapasCubierta' => intval($cubierta['solapas'] ?? 0), 'solapasCubierta' => intval($cubierta['solapas'] ?? 0),
'acabadosCubierta' => $cubierta['acabados'] ?? 0, 'acabadosCubierta' => $cubierta['acabados'] ?? 0,
'lomoRedondo' => $lomoRedondo,
]; ];
// Sobrecubierta // Sobrecubierta
@ -369,7 +333,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datos_guardas = [ $datos_guardas = [
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']), 'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
'gramaje' => intval($guardas['gramaje']), 'gramaje' => intval($guardas['gramaje']),
'caras' => intval($guardas['guardasImpresas']), 'caras' => intval($guardas['caras']),
]; ];
} else } else
$datos_guardas = false; $datos_guardas = false;
@ -393,6 +357,18 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
); );
$return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG $return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG
if(array_key_exists('errors', $return_data)){
if($return_data['errors']->status == 1){
$return_data = [
'errors' => (object) ([
'status' => 1
]),
];
return $return_data;
}
}
if (array_key_exists('exception', $return_data)) { if (array_key_exists('exception', $return_data)) {
return $this->failServerError( return $this->failServerError(
$return_data['exception'] . ' - ' . $return_data['exception'] . ' - ' .
@ -415,7 +391,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if (!property_exists($coste_direccion, 'coste')) { if (!property_exists($coste_direccion, 'coste')) {
$errorModel = new ErrorPresupuesto(); $errorModel = new ErrorPresupuesto();
$data['direccion'] = $direccion; $data['direccion'] = $direccion;
$data['peso'] = $return_data['peso'][$i]; $data['peso'] = $return_data['peso'][$i];
@ -432,7 +408,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
]), ]),
]; ];
return $return_data; return $return_data;
} else { } else {
$coste_envio += $coste_direccion->coste; $coste_envio += $coste_direccion->coste;
} }
@ -448,21 +424,21 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if (!property_exists($coste_direccion, 'coste')) { if (!property_exists($coste_direccion, 'coste')) {
$errorModel = new ErrorPresupuesto(); $errorModel = new ErrorPresupuesto();
$data['direccion'] = 'Sin direccion'; $data['direccion'] = 'Sin direccion';
$data['peso'] = $return_data['peso'][$i]; $data['peso'] = $return_data['peso'][$i];
$data['palets'] = 'Sin direccion'; $data['palets'] = 'Sin direccion';
$errorModel->insertError( $errorModel->insertError(
$id, $id,
auth()->user()->id, auth()->user()->id,
'No se ha podido calcular el coste de envío', 'No se ha podido calcular el coste de envío',
$data $data
); );
$return_data = [ $return_data = [
'errors' => (object) ([ 'errors' => (object) ([
'status' => 1 'status' => 1
]), ]),
]; ];
return $return_data; return $return_data;
} else { } else {
$coste_envio += $coste_direccion->coste; $coste_envio += $coste_direccion->coste;
} }
@ -662,6 +638,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$isColor = intval($reqData['isColor']) ?? 0; $isColor = intval($reqData['isColor']) ?? 0;
$isHq = intval($reqData['isHq']) ?? 0; $isHq = intval($reqData['isHq']) ?? 0;
$prototipo = intval($reqData['prototipo']) ?? 0;
$interior = $reqData['interior'] ?? []; $interior = $reqData['interior'] ?? [];
$cubierta = $reqData['cubierta'] ?? []; $cubierta = $reqData['cubierta'] ?? [];
$sobrecubierta = $reqData['sobrecubierta'] ?? []; $sobrecubierta = $reqData['sobrecubierta'] ?? [];
@ -704,6 +682,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0), 'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0),
'solapasCubierta' => intval($cubierta['solapas'] ?? 0), 'solapasCubierta' => intval($cubierta['solapas'] ?? 0),
'acabadosCubierta' => $cubierta['acabados'] ?? 0, 'acabadosCubierta' => $cubierta['acabados'] ?? 0,
'lomoRedondo' => $cubierta['lomoRedondo'] ?? 0,
'cabezada' => $cubierta['cabezada'] ?? 'WHI',
]; ];
// Sobrecubierta // Sobrecubierta
@ -722,7 +702,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datos_guardas = [ $datos_guardas = [
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']), 'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
'gramaje' => intval($guardas['gramaje']), 'gramaje' => intval($guardas['gramaje']),
'caras' => intval($guardas['guardasImpresas']), 'caras' => intval($guardas['caras']),
]; ];
} else } else
$datos_guardas = false; $datos_guardas = false;
@ -735,7 +715,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'isColor' => $isColor, 'isColor' => $isColor,
'isHq' => $isHq, 'isHq' => $isHq,
'paginasCuadernillo' => $paginasCuadernillo, 'paginasCuadernillo' => $paginasCuadernillo,
'interior' => $interior, 'interior' => $interior,
'cubierta' => $cubierta, 'cubierta' => $cubierta,
'sobrecubierta' => $sobrecubierta, 'sobrecubierta' => $sobrecubierta,
@ -855,6 +835,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0; $datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0;
} }
$datos_presupuesto['prototipo'] = $prototipo;
$id = $model_presupuesto->insertarPresupuestoCliente( $id = $model_presupuesto->insertarPresupuestoCliente(
$id, $id,
$selected_tirada, $selected_tirada,
@ -937,14 +919,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$presupuesto = $this->model->find($id); $presupuesto = $this->model->find($id);
$data = []; $data = [];
if ($presupuesto) { if ($presupuesto) {
$data['lc'] = $presupuesto->lomo_cubierta;
$data['lsc'] = $presupuesto->lomo_sobrecubierta;
$data['datosGenerales']['titulo'] = $presupuesto->titulo; $data['datosGenerales']['titulo'] = $presupuesto->titulo;
$data['datosGenerales']['autor'] = $presupuesto->autor; $data['datosGenerales']['autor'] = $presupuesto->autor;
$data['datosGenerales']['isbn'] = $presupuesto->isbn; $data['datosGenerales']['isbn'] = $presupuesto->isbn;
$data['datosGenerales']['coleccion'] = $presupuesto->coleccion; $data['datosGenerales']['coleccion'] = $presupuesto->coleccion;
$data['datosGenerales']['referenciaCliente'] = $presupuesto->referencia_cliente; $data['datosGenerales']['referenciaCliente'] = $presupuesto->referencia_cliente;
$data['datosGenerales']['paginas'] = $presupuesto->paginas; $data['datosGenerales']['paginas'] = $presupuesto->paginas;
$data['datosGenerales']['posPaginasColor'] = $presupuesto->paginas_color; $data['datosGenerales']['paginasCuadernillo'] = $presupuesto->paginasCuadernillo;
$data['datosGenerales']['paginasCuadernillo'] = $presupuesto->paginas_cuadernillo;
$data['datosGenerales']['tirada'] = $presupuesto->tirada; $data['datosGenerales']['tirada'] = $presupuesto->tirada;
$data['datosGenerales']['ivaReducido'] = $presupuesto->iva_reducido; $data['datosGenerales']['ivaReducido'] = $presupuesto->iva_reducido;
$data['datosGenerales']['excluirRotativa'] = $presupuesto->excluir_rotativa; $data['datosGenerales']['excluirRotativa'] = $presupuesto->excluir_rotativa;
@ -958,29 +941,34 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$data['datosGenerales']['papelFormatoAncho'] = $presupuesto->papel_formato_ancho; $data['datosGenerales']['papelFormatoAncho'] = $presupuesto->papel_formato_ancho;
$data['datosGenerales']['papelFormatoAlto'] = $presupuesto->papel_formato_alto; $data['datosGenerales']['papelFormatoAlto'] = $presupuesto->papel_formato_alto;
$data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color;
$data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente; $data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente;
$data['datosGenerales']['paginasColorConsecutivas'] = $presupuesto->paginas_color_consecutivas;
$data['tiradasPrecio'] = [ $data['datosGenerales']['tipo'] = $this->getTipoLibro($presupuesto->tipo_impresion_id ?? null);
(object) [ $data['datosGenerales']['prototipo'] = $presupuesto->prototipo;
'tirada' => $presupuesto->tirada,
'precio' => $presupuesto->total_confirmado,
'precio_u' => $presupuesto->total_precio_unidad,
]
];
$tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data); $datos_papel = $this->obtenerDatosPapel($presupuesto->id);
for ($i = 0; $i < count($tiradas_alternativas); $i++) { $data['interior'] = $datos_papel['interior'] ? $datos_papel['interior'] : [];
$tirada = $tiradas_alternativas[$i];
$data['datosGenerales']['tirada' . ($i + 2)] = $tirada->tirada; $data['cubierta'] = $datos_papel['cubierta'] ? $datos_papel['cubierta'] : [];
array_push($data['tiradasPrecio'], (object) [ $data['cubierta']['tapa'] = $this->obtenerTipoTapa($presupuesto->tipo_impresion_id ?? null);
'tirada' => intval($tirada->tirada), $data['cubierta']['lomoRedondo'] = $presupuesto->lomo_redondo ? 1 : 0;
'precio' => $tirada->total_pedido, $data['cubierta']['solapas'] = $presupuesto->solapas ? 1 : 0;
'precio_u' => $tirada->precio_unidad, $data['cubierta']['solapas_ancho'] = $presupuesto->solapas_ancho;
]); $data['cubierta']['cabezada'] = $presupuesto->cabezada;
} $modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel");
usort($data['tiradasPrecio'], function ($a, $b) { $data['cubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_cubierta_id);
return $a->tirada <=> $b->tirada; $data['cubierta']['barniz'] = $modelAcabado->getCodeFromId($presupuesto->barniz_cubierta_id);
}); $data['cubierta']['estampado'] = $modelAcabado->getCodeFromId($presupuesto->estampado_cubierta_id);
$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']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_sobrecubierta_id);
$data['guardas'] = array_key_exists('guardas', $datos_papel) ? $datos_papel['guardas'] : [];
$modelLinea = new PresupuestoLineaModel(); $modelLinea = new PresupuestoLineaModel();
$lineas = $modelLinea->where('presupuesto_id', $id)->findAll(); $lineas = $modelLinea->where('presupuesto_id', $id)->findAll();
@ -988,7 +976,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
[$data['datosGenerales']['paginasNegro'], $data['datosGenerales']['paginasColor']] = [$data['datosGenerales']['paginasNegro'], $data['datosGenerales']['paginasColor']] =
$this->getPaginas($lineas); $this->getPaginas($lineas);
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
$tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data);
for ($i = 0; $i < count($tiradas_alternativas); $i++) {
$tirada = $tiradas_alternativas[$i];
$data['datosGenerales']['tirada' . ($i + 2)] = $tirada->tirada;
}
return $this->respond([ return $this->respond([
'status' => 1, 'status' => 1,
'data' => $data 'data' => $data
@ -1382,6 +1378,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$carasCubierta = $datos_entrada['cubierta']['carasCubierta']; $carasCubierta = $datos_entrada['cubierta']['carasCubierta'];
$solapasCubierta = $datos_entrada['cubierta']['solapasCubierta']; $solapasCubierta = $datos_entrada['cubierta']['solapasCubierta'];
$acabadosCubierta = $datos_entrada['cubierta']['acabadosCubierta'] ?? []; $acabadosCubierta = $datos_entrada['cubierta']['acabadosCubierta'] ?? [];
$lomoRedondo = $datos_entrada['cubierta']['lomoRedondo'];
// Sobrecubierta // Sobrecubierta
$sobreCubierta = $datos_entrada["sobrecubierta"] ?? null; $sobreCubierta = $datos_entrada["sobrecubierta"] ?? null;
@ -1576,6 +1573,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$input_data['isColor'] = 1; $input_data['isColor'] = 1;
$input_data['isHq'] = 1; $input_data['isHq'] = 1;
$input_data['uso'] = 'cubierta'; $input_data['uso'] = 'cubierta';
$input_data['lomoRedondo'] = $lomoRedondo;
$cubierta = PresupuestoClienteService::obtenerCubierta($input_data); $cubierta = PresupuestoClienteService::obtenerCubierta($input_data);
$coste_cubierta = 0.0; $coste_cubierta = 0.0;
@ -2168,6 +2166,19 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} else } else
return ''; return '';
} }
protected function obtenerTipoTapa($tipo_impresion_id)
{
$model = model('App\Models\Configuracion\TipoPresupuestoModel');
$data = $model->get_isTapaDura($tipo_impresion_id);
if ($data) {
return 'dura';
} else {
return 'blanda';
}
}
protected function getTipoInterior($presupuestoId) protected function getTipoInterior($presupuestoId)
{ {
@ -2250,18 +2261,18 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
} }
protected function obtenerDireccionesEnvio($presupuestoEntity) protected function obtenerDireccionesEnvio($id, $cliente_id)
{ {
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
$model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel'); $model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel');
$model_pais = model('App\Models\Configuracion\PaisModel'); $model_pais = model('App\Models\Configuracion\PaisModel');
$direcciones = $model->where('presupuesto_id', $presupuestoEntity->id)->findAll(); $direcciones = $model->where('presupuesto_id', $id)->findAll();
$result = []; $result = [];
$temp = []; $temp = [];
for ($i = 0; $i < count($direcciones); $i++) { for ($i = 0; $i < count($direcciones); $i++) {
$direccion_id = $model_direcciones->getIdForPresupuestoCliente( $direccion_id = $model_direcciones->getIdForPresupuestoCliente(
$presupuestoEntity->cliente_id, $cliente_id,
$direcciones[$i]->att, $direcciones[$i]->att,
$direcciones[$i]->email, $direcciones[$i]->email,
$direcciones[$i]->direccion, $direcciones[$i]->direccion,
@ -2271,49 +2282,56 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
); );
if (count($direccion_id) > 0) { if (count($direccion_id) > 0) {
$temp = $direcciones[$i]->toArray(); $temp = $direcciones[$i]->toArray();
$temp['pais'] = $model_pais->where('id', $direcciones[$i]->pais_id)->first()->nombre; array_push($result, [
$temp['direccion_id'] = $direccion_id[0]->id; 'id' => $temp['id'],
array_push($result, $temp); 'unidades' => $temp['cantidad'],
'palets' => $temp['entregaPieCalle'],
]);
} }
} }
if (count($result) > 0) if (count($result) > 0)
$presupuestoEntity->direcciones_envio = $result; return $result;
else
return [];
} }
protected function obtenerDatosPapel($presupuestoEntity) protected function obtenerDatosPapel($presupuesto_id)
{ {
$id = $presupuestoEntity->id; $return_data = [];
$model = model('App\Models\Presupuestos\PresupuestoLineaModel'); $model = model('App\Models\Presupuestos\PresupuestoLineaModel');
$data = $model->where('presupuesto_id', $id)->findAll(); $data = $model->where('presupuesto_id', $presupuesto_id)->findAll();
$modelPapelGenerico = model('App\Models\Configuracion\PapelGenericoModel');
if (count($data) > 0) { if (count($data) > 0) {
foreach ($data as $linea) { foreach ($data as $linea) {
// Se coje el primer papel que se encuentre para el interior if ($linea->tipo == 'lp_bn' || $linea->tipo == 'lp_bnhq' || $linea->tipo == 'lp_rot_bn') {
// para presupuestos del cliente sólo se escoje un papel para el interior $return_data['interior']['negro']['tipo'] = $linea->tipo == 'lp_bn' || $linea->tipo == 'lp_rot_bn' ? 'negroEstandar' : 'negroPremium';
if (strpos($linea->tipo, "bn") !== false || strpos($linea->tipo, "color") !== false) { $return_data['interior']['negro']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
$presupuestoEntity->papel_interior = $linea->papel_id; $return_data['interior']['negro']['gramaje'] = $linea->gramaje;
$presupuestoEntity->gramaje_interior = $linea->gramaje; } else if ($linea->tipo == 'lp_color' || $linea->tipo == 'lp_colorhq' || $linea->tipo == 'lp_rot_color') {
} $return_data['interior']['color']['tipo'] = $linea->tipo == 'lp_color' || $linea->tipo == 'lp_rot_color' ? 'colorEstandar' : 'colorPremium';
// Si es cubierta $return_data['interior']['color']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
else if (strpos($linea->tipo, "cubierta") !== false && strpos($linea->tipo, "sobrecubierta") === false) { $return_data['interior']['color']['gramaje'] = $linea->gramaje;
$presupuestoEntity->papel_cubierta = $linea->papel_id; } else if ($linea->tipo == 'lp_cubierta') {
$presupuestoEntity->gramaje_cubierta = $linea->gramaje; $return_data['cubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
$presupuestoEntity->paginas_cubierta = $linea->paginas; $return_data['cubierta']['gramaje'] = $linea->gramaje;
} $return_data['cubierta']['paginas'] = $linea->paginas;
// Si es sobrecubierta } else if ($linea->tipo == 'lp_sobrecubierta') {
else if (strpos($linea->tipo, "sobrecubierta") !== false) { $return_data['sobrecubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
$presupuestoEntity->papel_sobrecubierta = $linea->papel_id; $return_data['sobrecubierta']['gramaje'] = $linea->gramaje;
$presupuestoEntity->gramaje_sobrecubierta = $linea->gramaje; $return_data['sobrecubierta']['paginas'] = $linea->paginas;
$presupuestoEntity->paginas_sobrecubierta = $linea->paginas; } else if ($linea->tipo == 'lp_guardas') {
} $return_data['guardas']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
// Si es guardas $return_data['guardas']['gramaje'] = $linea->gramaje;
else if (strpos($linea->tipo, "guardas") !== false) { $return_data['guardas']['paginas'] = $linea->paginas;
$presupuestoEntity->papel_guardas = $linea->papel_id;
$presupuestoEntity->paginas_guardas = $linea->paginas;
} }
} }
} }
return $return_data;
} }
protected function generarResumen($presupuestoEntity) protected function generarResumen($presupuestoEntity)
@ -2469,4 +2487,5 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
return [$paginasNegro, $paginasColor]; return [$paginasNegro, $paginasColor];
} }
} }

View File

@ -93,6 +93,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
'paginas_color_consecutivas' => null, 'paginas_color_consecutivas' => null,
'papel_interior_diferente' => null, 'papel_interior_diferente' => null,
'paginasCuadernillo' => null, 'paginasCuadernillo' => null,
'lomo_redondo' => null,
'cabezada' => null,
]; ];
protected $casts = [ protected $casts = [
"cliente_id" => "int", "cliente_id" => "int",
@ -161,5 +163,6 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
'paginas_color_consecutivas' => "boolean", 'paginas_color_consecutivas' => "boolean",
'papel_interior_diferente' => "boolean", 'papel_interior_diferente' => "boolean",
'paginasCuadernillo' => "int", 'paginasCuadernillo' => "int",
'lomo_redondo' => "boolean",
]; ];
} }

View File

@ -76,6 +76,22 @@ class PapelGenericoModel extends \App\Models\BaseModel
return $data; return $data;
} }
public function getCodeFromId($id=0){
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.code AS code"
)
->where("t1.id", $id)
->where("t1.is_deleted", 0);
$data = $builder->get()->getFirstRow();
// se convierte a de stdClass a array
$data = json_decode(json_encode($data), true);
return $data;
}
/** /**
* Get resource data. * Get resource data.
* *

View File

@ -322,4 +322,22 @@ class PapelImpresionModel extends \App\Models\BaseModel
return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
} }
public function getPapelGenericoCode($papel_id = 0){
$builder = $this->db
->table($this->table . " t1")
->select("t2.code AS code")
->join("lg_papel_generico t2", "t1.papel_generico_id = t2.id", "left")
->where("t1.id", $papel_id)
->where("t1.is_deleted", 0)
->where("t1.isActivo", 1)
->where("t2.is_deleted", 0);
$result = $builder->get()->getResultObject();
if(count($result) > 0){
return $result[0]->code;
}
else
return "";
}
} }

View File

@ -130,6 +130,8 @@ class PresupuestoModel extends \App\Models\BaseModel
'paginas_color_consecutivas', 'paginas_color_consecutivas',
'papel_interior_diferente', 'papel_interior_diferente',
'paginasCuadernillo', 'paginasCuadernillo',
'lomo_redondo',
'cabezada',
]; ];
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity"; protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
@ -407,7 +409,7 @@ class PresupuestoModel extends \App\Models\BaseModel
'guardas' => in_array(62, $data['servicios']) ? 1 : 0, 'guardas' => in_array(62, $data['servicios']) ? 1 : 0,
'faja_color' => in_array(16, $data['servicios']) ? 1 : 0, 'faja_color' => in_array(16, $data['servicios']) ? 1 : 0,
'ferro' => in_array(24, $data['servicios']) ? 1 : 0, 'ferro' => in_array(24, $data['servicios']) ? 1 : 0,
'prototipo' => in_array(9, $data['servicios']) ? 1 : 0, 'prototipo' => $data['prototipo'] ? 1 : 0,
'papel_formato_id' => is_null($papel_formato_id) ? 0 : $papel_formato_id->id, 'papel_formato_id' => is_null($papel_formato_id) ? 0 : $papel_formato_id->id,
'papel_formato_personalizado' => !$papel_formato_id ? 1 : 0, 'papel_formato_personalizado' => !$papel_formato_id ? 1 : 0,
'papel_formato_ancho' => !$papel_formato_id ? $data['tamanio']['ancho'] : null, 'papel_formato_ancho' => !$papel_formato_id ? $data['tamanio']['ancho'] : null,
@ -420,6 +422,8 @@ class PresupuestoModel extends \App\Models\BaseModel
'paginas' => $data['interior']['paginas'], 'paginas' => $data['interior']['paginas'],
'tirada' => $tirada, 'tirada' => $tirada,
'solapas' => $data['cubierta']['solapasCubierta'] == 0 ? 0 : 1, 'solapas' => $data['cubierta']['solapasCubierta'] == 0 ? 0 : 1,
'lomo_redondo' => $data['cubierta']['lomoRedondo'] == 0 ? 0 : 1,
'cabezada' => $data['cubierta']['cabezada'] == 0 ? 0 : 1,
'solapas_ancho' => $data['cubierta']['solapasCubierta'] == 0 ? $data['cubierta']['solapasCubierta'] : 0, 'solapas_ancho' => $data['cubierta']['solapasCubierta'] == 0 ? $data['cubierta']['solapasCubierta'] : 0,
'solapas_sobrecubierta' => !$data['sobrecubierta'] ? 0 : 1, 'solapas_sobrecubierta' => !$data['sobrecubierta'] ? 0 : 1,
'solapas_ancho_sobrecubierta' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['solapas'], 'solapas_ancho_sobrecubierta' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['solapas'],

View File

@ -90,7 +90,7 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
//JJO //JJO
$builder->where("t1.is_deleted", 0); $builder->where("t1.is_deleted", 0);
return empty($search) return empty($search)
? $builder ? $builder
: $builder : $builder
@ -115,8 +115,9 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
} }
public function getTarifaPresupuestoAcabado($tarifa_id, $tirada, $proveedor_id = -1){ public function getTarifaPresupuestoAcabado($tarifa_id, $tirada, $proveedor_id = -1)
{
$builder = $this->db $builder = $this->db
->table($this->table . " t1") ->table($this->table . " t1")
->select( ->select(
@ -129,18 +130,18 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
->where("t1.is_deleted", 0) ->where("t1.is_deleted", 0)
//->where("t1.mostrar_en_presupuesto", 1) //->where("t1.mostrar_en_presupuesto", 1)
->where("t2.is_deleted", 0); ->where("t2.is_deleted", 0);
$builder->where('t1.id =', $tarifa_id); $builder->where('t1.id =', $tarifa_id);
$builder->where('t2.tirada_min <=', $tirada); $builder->where('t2.tirada_min <=', $tirada);
$builder->where('t2.tirada_max >=', $tirada); $builder->where('t2.tirada_max >=', $tirada);
if($proveedor_id != -1){ if ($proveedor_id != -1) {
$builder->where('t2.proveedor_id', $proveedor_id); $builder->where('t2.proveedor_id', $proveedor_id);
} }
return $builder->get()->getResultObject(); return $builder->get()->getResultObject();
} }
public function getNombreTarifaAcabado($id=-1) public function getNombreTarifaAcabado($id = -1)
{ {
/* /*
Todos los servicios de encuadernacion activas que se pueden usar en presupuestos Todos los servicios de encuadernacion activas que se pueden usar en presupuestos
@ -185,4 +186,23 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
} }
public function getCodeFromId($id = 0)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.code AS code"
)
->where("t1.id", $id)
->where("t1.is_deleted", 0);
$data = $builder->get()->getResultObject();
if (count($data) > 0) {
return $data[0]->code;
} else {
return "";
}
}
} }

View File

@ -77,6 +77,7 @@ class PresupuestoClienteService extends BaseService
$isHq = $data['isHq']; $isHq = $data['isHq'];
$cliente_id = $data['cliente_id']; $cliente_id = $data['cliente_id'];
$paginas_color = $data['paginas_color']; $paginas_color = $data['paginas_color'];
$lomoRedondo = $data['lomoRedondo'];
$lineas_cubierta = []; $lineas_cubierta = [];
@ -91,7 +92,8 @@ class PresupuestoClienteService extends BaseService
'isColor' => $isColor, 'isColor' => $isColor,
'isHq' => $isHq, 'isHq' => $isHq,
'cliente_id' => $cliente_id, 'cliente_id' => $cliente_id,
'a_favor_fibra' => $i 'a_favor_fibra' => $i,
'lomoRedondo' => $lomoRedondo
]); ]);
if (count($lineas) > 0) { if (count($lineas) > 0) {

View File

@ -838,9 +838,13 @@ class PresupuestoService extends BaseService
* Devuelve el ancho de la cubierta/sobrecubierta, incluido el lomo. * Devuelve el ancho de la cubierta/sobrecubierta, incluido el lomo.
* El $uso tiene que ser "cubierta" o "sobrecubierta" * El $uso tiene que ser "cubierta" o "sobrecubierta"
*/ */
public static function getAnchoTotalExteriores($uso = "cubierta", $tipo_impresion_id = 1, $datosPedido = null, $maquina_id = -1) public static function getAnchoTotalExteriores($uso = "cubierta", $tipo_impresion_id = 1, $datosPedido = null, $maquina_id = -1, $lomoRedondo = 0)
{ {
$ancho_total = 0; $ancho_total = 0;
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
if($datosPedido->ancho > 210 || $datosPedido->alto > 297){
$sangre_cubierta = 15;
}
if ($datosPedido) { if ($datosPedido) {
// Tapa blanda (cosido y fresado) // Tapa blanda (cosido y fresado)
@ -861,8 +865,13 @@ class PresupuestoService extends BaseService
// si es cubierta // si es cubierta
// se añade 7mm del ancho del cartón (2*3.5mm) por cada lado del lomo // se añade 7mm del ancho del cartón (2*3.5mm) por cada lado del lomo
// más 7mm de vuelo+cajo por cada lado. Por último, 20mm de sangre por cada lado // más 7mm de vuelo+cajo por cada lado. Por último, 20mm de sangre por cada lado
if ($uso == "cubierta") if ($uso == "cubierta"){
$ancho_total += (2 * 7 + 2 * self::SANGRE_FORMAS_CUBIERTA + 7); $ancho_total += (2 * 7 + 2 * $sangre_cubierta + 6);
if($lomoRedondo){
$ancho_total += 6;
}
}
// si es sobrecubierta // si es sobrecubierta
// Se añaden 5mm de sangre por cada lado + 2 * 7mm de vuelo portada y contraportada -> total 52 // Se añaden 5mm de sangre por cada lado + 2 * 7mm de vuelo portada y contraportada -> total 52
else else
@ -893,7 +902,7 @@ class PresupuestoService extends BaseService
// Tapa dura // Tapa dura
else{ else{
// Se le suma 20mm de sangre por cada lado. Como son 2 hojas independientes, se multiplica por 4 // Se le suma 20mm de sangre por cada lado. Como son 2 hojas independientes, se multiplica por 4
$ancho_total += (4 * self::SANGRE_FORMAS_CUBIERTA); $ancho_total += (4 * $sangre_cubierta);
} }
} }
else { else {
@ -1716,6 +1725,7 @@ class PresupuestoService extends BaseService
$cliente_id = $input_data['cliente_id']; $cliente_id = $input_data['cliente_id'];
$datosTipolog = $input_data['datosTipolog'] ?? null; $datosTipolog = $input_data['datosTipolog'] ?? null;
$a_favor_fibra = $datosPedido->a_favor_fibra ?? false; $a_favor_fibra = $datosPedido->a_favor_fibra ?? false;
$lomoRedondo = $input_data['lomoRedondo'] ?? 0;
$tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro'); $tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro');
@ -1747,7 +1757,7 @@ class PresupuestoService extends BaseService
if ($uso == 'cubierta' || $uso == 'sobrecubierta') { if ($uso == 'cubierta' || $uso == 'sobrecubierta') {
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso, $tipo_impresion_id, $datosPedido, $maquina->maquina_id); $datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso, $tipo_impresion_id, $datosPedido, $maquina->maquina_id, $lomoRedondo);
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso, $tipo_impresion_id, $datosPedido); $datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso, $tipo_impresion_id, $datosPedido);
} }

View File

@ -101,7 +101,7 @@
<div class="col-sm-10 d-flex flex-column align-items-center justify-content-center"> <div class="col-sm-10 d-flex flex-column align-items-center justify-content-center">
<div class="col-sm-4 mb-1 d-flex flex-column align-items-center"> <div id="formatoEstandar" class="col-sm-4 mb-1 d-flex flex-column align-items-center">
<label id="label_papelFormatoId" for="papelFormatoId" class="form-label"> <label id="label_papelFormatoId" for="papelFormatoId" class="form-label">
Formato Libro* Formato Libro*
</label> </label>
@ -110,16 +110,16 @@
</select> </select>
</div> </div>
<div id="formatoPersonalizado" class="row col-sm-8 justify-content-center" style="display: none;"> <div id="formatoPersonalizado" class="row col-sm-8 justify-content-center d-none">
<div class="col-sm-3 mb-1 mx-1"> <div class="col-sm-3 mb-1 mx-1">
<label class="form-label" for="papelFormatoAncho">Ancho Libro</label> <label class="form-label" for="papelFormatoAncho">Ancho Libro*</label>
<input type="number" id="papelFormatoAncho" name="papel_formato_ancho" step="1" <input type="number" id="papelFormatoAncho" name="papel_formato_ancho" step="1"
class="form-control formato_libro calcular-presupuesto num-input" min="60" value="60"> class="form-control formato_libro calcular-presupuesto num-input" min="60" value="60">
</div> </div>
<div class="col-sm-3 mb-1 mx-1"> <div class="col-sm-3 mb-1 mx-1">
<label class="form-label" for="papelFormatoAlto">Alto Libro</label> <label class="form-label" for="papelFormatoAlto">Alto Libro*</label>
<input type="number" id="papelFormatoAlto" name="papel_formato_alto" step="1" <input type="number" id="papelFormatoAlto" name="papel_formato_alto" step="1"
class="form-control formato_libro calcular-presupuesto num-input" min="60" value="60"> class="form-control formato_libro calcular-presupuesto num-input" min="60" value="60">
</div> </div>

View File

@ -118,8 +118,8 @@
<select class="form-select select2bs2 calcular-presupuesto" id="guardasImpresas" <select class="form-select select2bs2 calcular-presupuesto" id="guardasImpresas"
name="guardas_impresas"> name="guardas_impresas">
<option value="0"><?= lang('Presupuestos.sinImpresion') ?></option> <option value="0"><?= lang('Presupuestos.sinImpresion') ?></option>
<option value="1"><?= lang('Presupuestos.unaCara') ?></option> <option value="4"><?= lang('Presupuestos.unaCara') ?></option>
<option value="2"><?= lang('Presupuestos.dosCaras') ?></option> <option value="8"><?= lang('Presupuestos.dosCaras') ?></option>
</select> </select>
</div> </div>

View File

@ -4,12 +4,23 @@
<div class="line mb-4"></div> <div class="line mb-4"></div>
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center"> <div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
<h5 class="mb-1 "> Precio unidad: <span id="resumenPrecioU"></span> </h5> <h5 class="mb-1 "> Precio unidad: <span id="resumenPrecioU"></span> </h5>
<h4 class="mb-1 "> Total base: <span id="resumenTotalBase"></span> </h> <h4 class="mb-1 "> Total base: <span id="resumenTotalBase"></span> </h>
<h4 class="mb-1 "> Iva (<span id="resumenIvaPorcentaje"></span>%): <span id="resumenIva"></span> </h> <h4 class="mb-1 "> Iva (<span id="resumenIvaPorcentaje"></span>%): <span id="resumenIva"></span> </h>
<h3 class="mt-3 mb-1 fw-bold"> Total: <span id="resumenTotal"></span> </h> <h3 class="mt-3 mb-1 fw-bold"> Total: <span id="resumenTotal"></span> </h>
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
<div id="divFormaCubierta" class="col-sm-12 mb-3 d-flex flex-column align-items-center">
<div class="row justify-content-center col-sm-12">
<div id="btnPreviewCubierta" class="btn col-sm-4 btn-primary waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i>Mostrar desarrollo cubierta</span>
</div>
</div>
<div class="row">
<div id="pv_ec_shape" class="col-sm-12 d-none" style="width:850px;height:600px;margin:2.5% auto;"></div>
</div>
</div>
<div class="table-responsive col-10 mb-3"> <div class="table-responsive col-10 mb-3">
<table class="table table-bordered"> <table class="table table-bordered">

View File

@ -161,11 +161,9 @@
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script> <script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script> <script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script> <script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') ?>"></script> <script src="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') ?>"></script>
<script type="module" <script type="module"
src="<?= site_url('assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js') ?>"></script> src="<?= site_url('assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js') ?>"></script>
<?= $this->endSection() ?> <?= $this->endSection() ?>

View File

@ -27,6 +27,7 @@ class DatosGenerales {
this.papelFormatoId = this.domItem.find("#papelFormatoId"); this.papelFormatoId = this.domItem.find("#papelFormatoId");
this.checkFormatoPersonalizado = this.domItem.find("#papelFormatoPersonalizado"); this.checkFormatoPersonalizado = this.domItem.find("#papelFormatoPersonalizado");
this.formatoPersonalizado = this.domItem.find("#formatoPersonalizado"); this.formatoPersonalizado = this.domItem.find("#formatoPersonalizado");
this.formatoEstandar = this.domItem.find("#formatoEstandar");
this.anchoPersonalizado = this.domItem.find("#papelFormatoAncho"); this.anchoPersonalizado = this.domItem.find("#papelFormatoAncho");
this.altoPersonalizado = this.domItem.find("#papelFormatoAlto"); this.altoPersonalizado = this.domItem.find("#papelFormatoAlto");
@ -346,6 +347,14 @@ class DatosGenerales {
this.coleccion.val(datos.coleccion); this.coleccion.val(datos.coleccion);
this.referenciaCliente.val(datos.referenciaCliente); this.referenciaCliente.val(datos.referenciaCliente);
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
this.cliente.setVal(datos.clienteId);
$(this.cliente).trigger('change');
if (datos.excluirRotativa) {
this.excluirRotativa.prop('checked', true);
}
this.tirada1.val(parseInt(datos.tirada)); this.tirada1.val(parseInt(datos.tirada));
if (datos.tirada2) if (datos.tirada2)
this.tirada2.val(parseInt(datos.tirada2)); this.tirada2.val(parseInt(datos.tirada2));
@ -355,8 +364,10 @@ class DatosGenerales {
this.tirada4.val(parseInt(datos.tirada4)); this.tirada4.val(parseInt(datos.tirada4));
if (datos.papelFormatoPersonalizado) { if (datos.papelFormatoPersonalizado) {
this.checkFormatoPersonalizado.prop(':checked', datos.checkFormatoPersonalizado); this.checkFormatoPersonalizado.prop('checked', true);
this.checkFormatoPersonalizado.trigger('change'); this.formatoEstandar.addClass('d-none');
this.formatoPersonalizado.removeClass('d-none');
this.formValidation.revalidateField('papel_formato_id');
this.altoPersonalizado.val(datos.papelFormatoAlto); this.altoPersonalizado.val(datos.papelFormatoAlto);
this.anchoPersonalizado.val(datos.papelFormatoAncho); this.anchoPersonalizado.val(datos.papelFormatoAncho);
} }
@ -365,41 +376,27 @@ class DatosGenerales {
this.formatoLibro.setVal(datos.papelFormatoId); this.formatoLibro.setVal(datos.papelFormatoId);
} }
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
this.cliente.setVal(datos.clienteId);
$(this.cliente).trigger('change');
this.paginas.val(parseInt(datos.paginas)); this.paginas.val(parseInt(datos.paginas));
this.paginasNegro.val(parseInt(datos.paginasNegro)); this.paginasNegro.val(parseInt(datos.paginasNegro));
this.paginasColor.val(parseInt(datos.paginasColor)); this.paginasColor.val(parseInt(datos.paginasColor)).trigger('change');
this.paginasColor.trigger('change');
this.pagColorConsecutivas.prop('checked', datos.paginasColorConsecutivas);
if (datos.paginasColorConsecutivas) {
this.divPapelDiferente.removeClass('d-none');
this.papelDiferente.prop('checked', datos.papelInteriorDiferente).trigger('change');
}
this.posPaginasColor.val(datos.posPaginasColor); this.posPaginasColor.val(datos.posPaginasColor);
/* this.paginasCuadernillo.val(datos.paginasCuadernillo);
this.papelFormatoId = this.domItem.find("#papelFormatoId");
this.checkFormatoPersonalizado = this.domItem.find("#papelFormatoPersonalizado");
this.formatoPersonalizado = this.domItem.find("#formatoPersonalizado");
this.anchoPersonalizado = this.domItem.find("#papelFormatoAncho");
this.altoPersonalizado = this.domItem.find("#papelFormatoAlto");
this.fresado = $(this.domItem.find("#fresado")[0]); if (datos.tipo != "") {
this.cosido = $(this.domItem.find("#cosido")[0]); this.tiposLibro.removeClass('selected');
this.tiposLibro.find('.image-presupuesto').removeClass('selected');
this.domItem.find('#' + datos.tipo).addClass('selected');
}
this.tiposLibro = this.domItem.find(".tipo-libro"); this.prototipo.prop('checked', datos.prototipo);
this.ivaReducido.val(datos.ivaReducido? 1: 0).trigger('change');
this.paginasCuadernillo = this.domItem.find("#paginasCuadernillo");
this.pagColorConsecutivas = this.domItem.find("#pagColorConsecutivas");
this.divPapelDiferente = this.domItem.find("#divPapelDiferente");
this.papelDiferente = this.domItem.find("#papelDiferente");
this.divPosPaginasColor = this.domItem.find("#divPosPaginasColor");
this.posPaginasColor = this.domItem.find("#posPaginasColor");
this.ivaReducido = this.domItem.find("#ivaReducido");
this.excluirRotativa = this.domItem.find("#excluirRotativa");
this.prototipo = this.domItem.find("#prototipo");*/
} }
getDimensionLibro() { getDimensionLibro() {
@ -452,13 +449,13 @@ class DatosGenerales {
#handleFormatoLibro() { #handleFormatoLibro() {
if (this.checkFormatoPersonalizado.is(':checked')) { if (this.checkFormatoPersonalizado.is(':checked')) {
this.formatoLibro.item.hide(); this.formatoEstandar.addClass('d-none');
this.formatoPersonalizado.show(); this.formatoPersonalizado.removeClass('d-none');
this.formValidation.revalidateField('papel_formato_id'); this.formValidation.revalidateField('papel_formato_id');
} }
else { else {
this.formatoLibro.item.show(); this.formatoEstandar.removeClass('d-none');
this.formatoPersonalizado.hide(); this.formatoPersonalizado.addClass('d-none');
this.formValidation.revalidateField('papel_formato_ancho'); this.formValidation.revalidateField('papel_formato_ancho');
this.formValidation.revalidateField('papel_formato_alto'); this.formValidation.revalidateField('papel_formato_alto');
} }

View File

@ -36,7 +36,7 @@ class Direcciones {
init() { init() {
$("#clienteId").on('change', this.#handleChangeCliente.bind(this)); $("#clienteId").on('change', this.handleChangeCliente.bind(this));
this.direccionesCliente.init(); this.direccionesCliente.init();
this.btnAdd.on('click', this.#insertDireccion.bind(this)); this.btnAdd.on('click', this.#insertDireccion.bind(this));
@ -44,7 +44,74 @@ class Direcciones {
} }
cargarDatos(datos, datosGenerales) {
self = this;
try {
let tiradas_envio = [datosGenerales.tirada];
if (datosGenerales.tirada2) {
tiradas_envio.push(datosGenerales.tirada2);
}
if (datosGenerales.tirada3) {
tiradas_envio.push(datosGenerales.tirada3);
}
if (datosGenerales.tirada4) {
tiradas_envio.push(datosGenerales.tirada4);
}
tiradas_envio.sort((a, b) => a - b);
setTimeout(() => {
tiradas_envio.forEach(tirada => {
self.insertTirada(tirada);
});
}, 0);
setTimeout(function () {
$(`#containerTiradasEnvios .tirada-envio input[tirada="${datosGenerales.tirada}"]`).trigger('click');
}, 0);
for (let i = 0; i < datos.length; i++) {
let id = datos[i].id;
let unidades = datos[i].unidades;
let entregaPalets = datos[i].palets;
let divId = "dirEnvio-1";
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
if (direccionesActuales.length > 0) {
// the the lass item
let last = direccionesActuales[direccionesActuales.length - 1];
divId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1);
}
if (id == null || id <= 0 || id == undefined)
return;
if (unidades == null || unidades <= 0 || unidades == undefined)
return;
let peticion = new Ajax('/misdirecciones/get/' + id, {}, {},
(response) => {
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]);
tarjeta.setUnidades(unidades);
tarjeta.setEntregaPalets(entregaPalets);
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self));
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self));
this.divDirecciones.append(tarjeta.card);
this.direcciones.push(tarjeta);
},
() => {
console.error('Error getting address');
});
peticion.get();
}
} catch (e) {
console.error(e);
$('#loader').modal('hide');
}
}
initValidation() { initValidation() {
@ -248,7 +315,7 @@ class Direcciones {
} }
#handleChangeCliente() { handleChangeCliente() {
this.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id }) this.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id })
this.direccionesCliente.empty(); this.direccionesCliente.empty();

View File

@ -25,9 +25,15 @@ class DisenioCubierta {
this.divTamanioSolapas = this.domItem.find("#divTamanioSolapas"); this.divTamanioSolapas = this.domItem.find("#divTamanioSolapas");
this.tamanioSolapasCubierta = $(this.domItem.find("#solapasCubierta")); this.tamanioSolapasCubierta = $(this.domItem.find("#solapasCubierta"));
this.papelGuardas = this.domItem.find("#papelGuardas");
this.guardasImpresas = this.domItem.find("#guardasImpresas");
this.cabezada = this.domItem.find("#cabezada");
this.cartulinaEstucada = this.domItem.find("#cartulinaEstucada"); this.cartulinaEstucada = this.domItem.find("#cartulinaEstucada");
this.estucadoMate = this.domItem.find("#estucadoMate"); this.estucadoMate = this.domItem.find("#estucadoMate");
this.divPapelCubierta = this.domItem.find("#divPapelCubierta");
this.divGramajeCubierta = this.domItem.find("#divGramajeCubierta"); this.divGramajeCubierta = this.domItem.find("#divGramajeCubierta");
this.gramaje = this.domItem.find(".check-gramaje-cubierta"); this.gramaje = this.domItem.find(".check-gramaje-cubierta");
this.gramaje170 = $(this.domItem.find("#divGramaje170Cubierta")); this.gramaje170 = $(this.domItem.find("#divGramaje170Cubierta"));
@ -38,8 +44,16 @@ class DisenioCubierta {
this.checksGramaje = $('.check-gramaje-cubierta'); this.checksGramaje = $('.check-gramaje-cubierta');
this.cubiertaPlastificado = this.domItem.find("#plastificado");
this.cubiertaBarniz = this.domItem.find("#barniz");
this.cubiertaEstampado = this.domItem.find("#estampado");
this.cubiertaRetractilado = this.domItem.find("#retractilado");
this.configuracionSobrecubierta = this.domItem.find(".config-sobrecubierta"); this.configuracionSobrecubierta = this.domItem.find(".config-sobrecubierta");
this.sobrecubierta = this.domItem.find("#addSobrecubierta"); this.sobrecubierta = this.domItem.find("#addSobrecubierta");
this.papelSobrecubierta = this.domItem.find("#papelSobrecubierta");
this.plastificadoSobrecubierta = this.domItem.find("#plastificadoSobrecubierta");
this.configuracionFaja = this.domItem.find(".config-faja"); this.configuracionFaja = this.domItem.find(".config-faja");
this.faja = this.domItem.find("#addFaja"); this.faja = this.domItem.find("#addFaja");
@ -113,6 +127,63 @@ class DisenioCubierta {
}); });
} }
cargarDatos(datosCubierta, datosGuardas, datosSobrecubierta) {
if (datosCubierta.lomoRedondo) {
this.tapaDuraLomoRedondo.trigger('click');
}
else {
if (datosCubierta.tapa == "dura") {
this.tapaDuraLomoRecto.trigger('click');
}
else {
this.tapaBlanda.trigger('click');
}
}
if (datosCubierta.tapa == "dura") {
this.papelGuardas.val(datosGuardas.papel.code + "_" + datosGuardas.gramaje).trigger('change');
this.guardasImpresas.val(datosGuardas.paginas).trigger('change');
this.cabezada.val(datosCubierta.cabezada).trigger('change');
}
else {
this.carasCubierta.val(datosCubierta.caras).trigger('change');
if (datosCubierta.solapas) {
this.conSolapas.trigger('click');
this.tamanioSolapasCubierta.val(datosCubierta.solapas_ancho);
}
else {
this.sinSolapas.trigger('click');
}
}
this.divPapelCubierta.find(`[cod="${datosCubierta.papel.code}"]`).addClass('selected');
setTimeout(function () {
$(`#divGramajeCubierta .gramaje-cubierta input[data-value="${datosCubierta.gramaje}"]`).trigger('click');
}, 0);
this.cubiertaPlastificado.val(datosCubierta.plastificado).trigger('change');
this.cubiertaBarniz.val(datosCubierta.barniz).trigger('change');
this.cubiertaEstampado.val(datosCubierta.estampado).trigger('change');
if (datosCubierta.retractilado) {
setTimeout(() => {
this.cubiertaRetractilado.trigger('click');
}, 0);
}
if (datosSobrecubierta) {
this.sobrecubierta.trigger('click');
this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change');
this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho);
this.plastificadoSobrecubierta.val(datosSobrecubierta.plastificado).trigger('change');
}
}
initValidation() { initValidation() {
const stepper = this.validatorStepper; const stepper = this.validatorStepper;
@ -356,13 +427,13 @@ class DisenioCubierta {
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").text(); let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").text();
guardas.papel = papelGuardas.split(' ')[0] + ' ' + papelGuardas.split(' ')[1]; guardas.papel = papelGuardas.split(' ')[0] + ' ' + papelGuardas.split(' ')[1];
guardas.gramaje = papelGuardas.split(' ')[2]; guardas.gramaje = papelGuardas.split(' ')[2];
guardas.guardasImpresas = this.domItem.find("#guardasImpresas").children("option:selected").text(); guardas.caras = this.domItem.find("#guardasImpresas").children("option:selected").text();
} }
else { else {
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").val(); let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").val();
guardas.papel = papelGuardas.split('_')[0]; guardas.papel = papelGuardas.split('_')[0];
guardas.gramaje = papelGuardas.split('_')[1]; guardas.gramaje = papelGuardas.split('_')[1];
guardas.guardasImpresas = this.domItem.find("#guardasImpresas").children("option:selected").val(); guardas.caras = this.domItem.find("#guardasImpresas").children("option:selected").val();
} }
return guardas; return guardas;
} }

View File

@ -7,6 +7,9 @@ class DisenioInterior {
this.validatorStepper = validatorStepper; this.validatorStepper = validatorStepper;
this.disenioInterior = this.domItem.find(".disenio-interior"); this.disenioInterior = this.domItem.find(".disenio-interior");
this.divPapelInterior = this.domItem.find("#divPapelInterior");
this.divPapelInteriorColor = this.domItem.find("#divPapelInteriorColor");
this.divGramajeInterior = this.domItem.find("#divGramajeInterior");
this.papelInterior = this.domItem.find(".papel-interior"); this.papelInterior = this.domItem.find(".papel-interior");
this.negroEstandar = this.domItem.find("#negroEstandar"); this.negroEstandar = this.domItem.find("#negroEstandar");
@ -108,6 +111,78 @@ class DisenioInterior {
} }
cargarDatos(datos, papelInteriorDiferente) {
if (papelInteriorDiferente) {
if (datos.negro) {
if (datos.negro.tipo.includes("Premium")) {
this.negroPremium.addClass('selected');
}
else {
this.negroEstandar.addClass('selected');
}
this.divPapelInterior.find(`[cod="${datos.negro.papel.code}"]`).addClass('selected');
setTimeout(function () {
$(`#divGramajeInterior .gramaje-interior input[data-value="${datos.negro.gramaje}"]`).trigger('click');
}, 0);
}
if (datos.color) {
if (datos.color.tipo.includes("Premium")) {
this.colorPremium_color.addClass('selected');
}
else {
this.colorEstandar_color.addClass('selected');
}
this.divPapelInteriorColor.find(`[cod="${datos.color.papel.code}"]`).addClass('selected');
setTimeout(function () {
$(`#divGramajeInteriorColor .gramaje-interior-color input[data-value="${datos.color.gramaje}"]`).trigger('click');
}, 0);
}
}
else {
if (datos.color) {
if (datos.color.tipo.includes("Premium")) {
this.colorPremium.addClass('selected');
}
else {
this.colorEstandar.addClass('selected');
}
this.divPapelInterior.find(`[cod="${datos.color.papel.code}"]`).addClass('selected');
setTimeout(function () {
$(`#divGramajeInterior .gramaje-interior input[data-value="${datos.color.gramaje}"]`).trigger('click');
}, 0);
}
else {
if (datos.negro.tipo.includes("Premium")) {
this.negroPremium.addClass('selected');
}
else {
this.negroEstandar.addClass('selected');
}
// mismo papel y gramaje
this.divPapelInterior.find(`[cod="${datos.negro.papel.code}"]`).addClass('selected');
setTimeout(function () {
$(`#divGramajeInterior .gramaje-interior input[data-value="${datos.negro.gramaje}"]`).trigger('click');
}, 0);
}
}
}
initValidation() { initValidation() {
const stepper = this.validatorStepper; const stepper = this.validatorStepper;
@ -311,7 +386,7 @@ class DisenioInterior {
} }
return null; return null;
} catch (e) { } catch (e) {
return null; return null;
} }
@ -324,30 +399,29 @@ class DisenioInterior {
if (this.papelInterior.filter('.selected').length > 0) { if (this.papelInterior.filter('.selected').length > 0) {
if (this.papelInterior_color.filter('.selected').length > 0) { if (this.papelInterior_color.filter('.selected').length > 0) {
if(forResumen) if (forResumen) {
{
return { return {
negro: $(this.papelInterior.filter('.selected').find('.form-label')).text(), negro: $(this.papelInterior.filter('.selected').find('.form-label')).text(),
color: $(this.papelInterior_color.filter('.selected').find('.form-label')).text(), color: $(this.papelInterior_color.filter('.selected').find('.form-label')).text(),
} }
} }
else{ else {
return { return {
negro: this.papelInterior.filter('.selected').attr('cod'), negro: this.papelInterior.filter('.selected').attr('cod'),
color: this.papelInterior_color.filter('.selected').attr('cod') color: this.papelInterior_color.filter('.selected').attr('cod')
} }
} }
} }
if (this.interiorColor.filter('.d-none').length > 0){ if (this.interiorColor.filter('.d-none').length > 0) {
if(forResumen){ if (forResumen) {
return $(this.papelInterior.filter('.selected').find('.form-label')).text(); return $(this.papelInterior.filter('.selected').find('.form-label')).text();
} }
else{ else {
return this.papelInterior.filter('.selected').attr('cod') return this.papelInterior.filter('.selected').attr('cod')
} }
} }
else else
return null; return null;
} }
@ -361,9 +435,9 @@ class DisenioInterior {
getGramaje() { getGramaje() {
try { try {
if (this.interiorColor.filter('.d-none').length == 0){ if (this.interiorColor.filter('.d-none').length == 0) {
let values = { let values = {
negro: this.gramaje.filter(':checked') .attr('data-value'), negro: this.gramaje.filter(':checked').attr('data-value'),
color: this.gramaje_color.filter(':checked').attr('data-value') color: this.gramaje_color.filter(':checked').attr('data-value')
} }
if (values.negro && values.color) { if (values.negro && values.color) {
@ -371,10 +445,10 @@ class DisenioInterior {
} }
else return null; else return null;
} }
else{ else {
return this.gramaje.filter(':checked').attr('data-value'); return this.gramaje.filter(':checked').attr('data-value');
} }
} catch (e) { } catch (e) {
return null; return null;
} }

View File

@ -65,7 +65,7 @@ class PresupuestoCliente {
this.btnSave.on('click', this.#savePresupuesto.bind(this)); this.btnSave.on('click', this.#savePresupuesto.bind(this));
if (window.location.href.includes("edit")) { if (window.location.href.includes("edit")) {
$(".calcular-presupuesto").on('change', ()=>{}); $(".calcular-presupuesto").on('change', () => { });
this.#cargarPresupuesto(); this.#cargarPresupuesto();
const successMessage = sessionStorage.getItem('message'); const successMessage = sessionStorage.getItem('message');
if (successMessage) { if (successMessage) {
@ -73,10 +73,10 @@ class PresupuestoCliente {
sessionStorage.removeItem('message'); sessionStorage.removeItem('message');
} }
} }
else{ else {
$(".calcular-presupuesto").on('change', this.checkForm.bind(this)); $(".calcular-presupuesto").on('change', this.checkForm.bind(this));
} }
} }
@ -103,13 +103,13 @@ class PresupuestoCliente {
if (datos_to_check.direcciones) { if (datos_to_check.direcciones) {
delete datos_to_check.direcciones; delete datos_to_check.direcciones;
} }
if(datos_to_check.posPaginasColor){ if (datos_to_check.posPaginasColor) {
delete datos_to_check.posPaginasColor; delete datos_to_check.posPaginasColor;
} }
if (Object.values(datos_to_check).every(this.#isValidDataForm)) { if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
try { try {
setTimeout(function() { setTimeout(function () {
$('#loader').modal('show'); $('#loader').modal('show');
}, 0); }, 0);
@ -238,13 +238,12 @@ class PresupuestoCliente {
{}, {},
(response) => { (response) => {
$('#loader').modal('hide'); $('#loader').modal('hide');
console.log(response);
if (this.datos["confirmar"] || window.location.href.includes("add")) { if (this.datos["confirmar"] || window.location.href.includes("add")) {
if(response.status){ if (response.status) {
sessionStorage.setItem('message', response.message); sessionStorage.setItem('message', response.message);
window.location.href = response.url + '/' + response.status; window.location.href = response.url + '/' + response.status;
} }
else{ else {
popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial."); popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial.");
} }
} }
@ -272,29 +271,35 @@ class PresupuestoCliente {
, "sk-alert-2", false); , "sk-alert-2", false);
return; return;
} }
else{ else {
popAlert2Hide(); popAlert2Hide();
} }
if (response.tiradas && response.tiradas.length) { if (response.tiradas && response.tiradas.length) {
let tiradas = {...response.tiradas};
tiradas = Object.keys(tiradas).map((key) => tiradas[key]);
tiradas.sort((a, b) => a - b);
this.divTiradasPrecios.empty(); this.divTiradasPrecios.empty();
for (let i = 0; i < response.tiradas.length; i++) { for (let i = 0; i < tiradas.length; i++) {
new tarjetaTiradasPrecio( new tarjetaTiradasPrecio(
this.divTiradasPrecios, this.divTiradasPrecios,
('precio-tiradas-' + response.tiradas[i]), ('precio-tiradas-' + response.tiradas[i]),
response.tiradas[i], tiradas[i],
(parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2), (parseFloat(response.precio_u[i]) * parseInt(tiradas[i])).toFixed(2),
response.precio_u[i] response.precio_u[i]
); );
if (this.actualizarTiradasEnvio) if (this.actualizarTiradasEnvio)
this.direcciones.insertTirada(response.tiradas[i]); this.direcciones.insertTirada(tiradas[i]);
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2));
} }
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2));
setTimeout(() => {
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
}, 0);
} }
// DEBUG // DEBUG
//console.log(response); //console.log(response);
@ -350,6 +355,7 @@ class PresupuestoCliente {
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(), paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'), tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
prototipo: this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
isColor: this.datosGenerales.getIsColor() ? 1 : 0, isColor: this.datosGenerales.getIsColor() ? 1 : 0,
isHq: this.disenioInterior.getIsHq() ? 1 : 0, isHq: this.disenioInterior.getIsHq() ? 1 : 0,
@ -362,6 +368,7 @@ class PresupuestoCliente {
cubierta: { cubierta: {
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'), tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
lomoRedondo: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0,
papelCubierta: this.disenioCubierta.getPapel(), papelCubierta: this.disenioCubierta.getPapel(),
gramajeCubierta: this.disenioCubierta.getGramaje(), gramajeCubierta: this.disenioCubierta.getGramaje(),
cabezada: this.disenioCubierta.getCabezada(), cabezada: this.disenioCubierta.getCabezada(),
@ -429,16 +436,30 @@ class PresupuestoCliente {
{}, {},
{}, {},
(response) => { (response) => {
if (response.status === 1) {
this.datosGenerales.cargarDatos(response.data.datosGenerales); setTimeout(() => {
/*this.disenioInterior.cargarDatos(response); if (response.status === 1) {
this.disenioCubierta.cargarDatos(response);
this.direcciones.cargarDatos(response); this.lc.val(parseFloat(response.data.lc).toFixed(2));
*/ this.lsc.val(parseFloat(response.data.lsc).toFixed(2));
}
console.log(response); this.datosGenerales.cargarDatos(response.data.datosGenerales);
$('#loader').modal('hide'); this.direcciones.handleChangeCliente();
$(".calcular-presupuesto").on('change', this.checkForm.bind(this)); this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
setTimeout(() => {
this.checkForm({ target: { id: 'tirada' } });
this.validationStepper.next();
this.validationStepper.next();
this.validationStepper.next();
this.validationStepper.next();
$('#loader').modal('hide');
}, 0);
}
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
}, 0);
}, },
() => { () => {
$('#loader').modal('hide'); $('#loader').modal('hide');

View File

@ -1,5 +1,7 @@
import previewFormas from "../preview.js";
class Resumen { class Resumen {
constructor(domItem, datosGenerales, disenioInterior, disenioCubierta, direcciones) { constructor(domItem, datosGenerales, disenioInterior, disenioCubierta) {
this.domItem = domItem; this.domItem = domItem;
@ -39,18 +41,39 @@ class Resumen {
this.divSobrecubierta = $(this.domItem.find("#divResumenSobrecubierta")); this.divSobrecubierta = $(this.domItem.find("#divResumenSobrecubierta"));
this.papelSobrecubierta = $(this.domItem.find("#resumenPapelSobrecubierta")); this.papelSobrecubierta = $(this.domItem.find("#resumenPapelSobrecubierta"));
this.gramajeSobrecubierta = $(this.domItem.find("#resumenGramajeSobrecubierta")); this.gramajeSobrecubierta = $(this.domItem.find("#resumenGramajeSobrecubierta"));
this.solapasSobrecubierta = $(this.domItem.find("#resumenSolapasSobrecubierta")); this.solapasSobrecubierta = $(this.domItem.find("#resumenSolapaSobrecubierta"));
this.plastificadoSobrecubierta = $(this.domItem.find("#resumenPlastificadoSobrecubierta")); this.plastificadoSobrecubierta = $(this.domItem.find("#resumenPlastificadoSobreCubierta"));
this.precio_unidad = $(this.domItem.find("#resumenPrecioU")); this.precio_unidad = $(this.domItem.find("#resumenPrecioU"));
this.total_base = $(this.domItem.find("#resumenTotalBase")); this.total_base = $(this.domItem.find("#resumenTotalBase"));
this.iva_porcentaje = $(this.domItem.find("#resumenIvaPorcentaje")); this.iva_porcentaje = $(this.domItem.find("#resumenIvaPorcentaje"));
this.iva = $(this.domItem.find("#resumenIva")); this.iva = $(this.domItem.find("#resumenIva"));
this.total = $(this.domItem.find("#resumenTotal")); this.total = $(this.domItem.find("#resumenTotal"));
this.divPreview = $(this.domItem.find("#pv_ec_shape"));
this.btnPreviewCubierta = $(this.domItem.find("#btnPreviewCubierta"));
this.init();
} }
init() { init() {
this.btnPreviewCubierta.on('click', this.#btnPreview.bind(this));
}
#btnPreview() {
if(this.divPreview.hasClass('d-none')){
this.btnPreviewCubierta.text('Ocultar desarrollo cubierta');
this.divPreview.removeClass('d-none');
this.generate();
}
else{
this.btnPreviewCubierta.text('Mostrar desarrollo cubierta');
this.divPreview.addClass('d-none');
}
} }
generate() { generate() {
@ -58,10 +81,32 @@ class Resumen {
this.titulo.text(this.datosGenerales.titulo.val()); this.titulo.text(this.datosGenerales.titulo.val());
this.tipoLibro.text(this.#capitalizeFirstLetter(this.datosGenerales.tiposLibro.filter('.selected').attr('id'))); this.tipoLibro.text(this.#capitalizeFirstLetter(this.datosGenerales.tiposLibro.filter('.selected').attr('id')));
if (this.datosGenerales.checkFormatoPersonalizado.is(':checked')) let ancho = 0, alto = 0;
this.formato.text(this.datosGenerales.anchoPersonalizado.val() + ' x ' + this.datosGenerales.altoPersonalizado.val()); if (this.datosGenerales.checkFormatoPersonalizado.is(':checked')) {
else ancho = parseFloat(this.datosGenerales.anchoPersonalizado.val());
alto = parseFloat(this.datosGenerales.altoPersonalizado.val());
this.formato.text(ancho + ' x ' + alto);
}
else {
ancho = parseFloat(this.datosGenerales.papelFormatoId.find('option:selected').text().split(" x ")[0]);
alto = parseFloat(this.datosGenerales.papelFormatoId.find('option:selected').text().split(" x ")[1]);
this.formato.text(this.datosGenerales.papelFormatoId.find('option:selected').text()); this.formato.text(this.datosGenerales.papelFormatoId.find('option:selected').text());
}
new previewFormas(
this.divPreview,
this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
"resumen",
{
ancho: ancho,
alto: alto,
lomo: $('#lc').val() === '' ? parseFloat('0.0') : parseFloat($('#lc').val()),
solapas: this.disenioCubierta.getSolapasCubierta(),
lomoRedondo: this.disenioCubierta.tapaDuraLomoRedondo.hasClass('selected'),
}
).previewEsquemaCubierta();
this.paginas.text(this.datosGenerales.paginas.val()); this.paginas.text(this.datosGenerales.paginas.val());
this.paginasColor.text(this.datosGenerales.paginasColor.val()); this.paginasColor.text(this.datosGenerales.paginasColor.val());
@ -105,7 +150,7 @@ class Resumen {
this.itemsCubiertaTapaBlanda.addClass('d-none'); this.itemsCubiertaTapaBlanda.addClass('d-none');
const guardas = this.disenioCubierta.getGuardas(true); const guardas = this.disenioCubierta.getGuardas(true);
this.papelGuardas.text(guardas.papel + ' ' + guardas.gramaje); this.papelGuardas.text(guardas.papel + ' ' + guardas.gramaje);
this.guardasImpresas.text(guardas.guardasImpresas); this.guardasImpresas.text(guardas.caras);
this.cabezada.text(this.disenioCubierta.getCabezada(true)); this.cabezada.text(this.disenioCubierta.getCabezada(true));
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long