mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/presu_cliente_v2' into feat/tarifa-code
This commit is contained in:
@ -17,6 +17,7 @@ use App\Models\Presupuestos\PresupuestoManipuladosModel;
|
||||
use App\Models\Presupuestos\PresupuestoModel;
|
||||
use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
|
||||
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
|
||||
use App\Models\Presupuestos\ErrorPresupuesto;
|
||||
use App\Services\PresupuestoClienteService;
|
||||
use App\Services\PresupuestoService;
|
||||
use Exception;
|
||||
@ -100,6 +101,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$model_user = model('App\Models\Usuarios\UserModel');
|
||||
$user = $model_user->find(auth()->user()->id);
|
||||
$clienteId = $user->cliente_id;
|
||||
|
||||
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
||||
|
||||
$this->viewData['breadcrumb'] = [
|
||||
@ -135,52 +137,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||
$model_user = model('App\Models\Usuarios\UserModel');
|
||||
$user = $model_user->find(auth()->user()->id);
|
||||
if(auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')){
|
||||
$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);
|
||||
else{
|
||||
$clienteId = $presupuestoEntity->cliente_id;
|
||||
}
|
||||
|
||||
$this->viewData['formAction'] = 'edit';
|
||||
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
|
||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
|
||||
|
||||
$this->viewData['clienteId'] = $clienteId;
|
||||
$this->viewData['POD'] = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
||||
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
|
||||
@ -294,6 +261,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$modelPapelGenerico = new PapelGenericoModel();
|
||||
|
||||
|
||||
$id = $reqData['id'] ?? 0;
|
||||
|
||||
$cliente_id = $reqData['clienteId'] ?? -1;
|
||||
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
@ -320,6 +289,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$direcciones = $reqData['direcciones'] ?? [];
|
||||
|
||||
$tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']);
|
||||
$lomoRedondo = $cubierta['lomoRedondo'] ?? 0;
|
||||
|
||||
if ($papelInteriorDiferente) {
|
||||
$papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']);
|
||||
@ -348,6 +318,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0),
|
||||
'solapasCubierta' => intval($cubierta['solapas'] ?? 0),
|
||||
'acabadosCubierta' => $cubierta['acabados'] ?? 0,
|
||||
'lomoRedondo' => $lomoRedondo,
|
||||
];
|
||||
|
||||
// Sobrecubierta
|
||||
@ -366,12 +337,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$datos_guardas = [
|
||||
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
|
||||
'gramaje' => intval($guardas['gramaje']),
|
||||
'caras' => intval($guardas['guardasImpresas']),
|
||||
'caras' => intval($guardas['caras']),
|
||||
];
|
||||
} else
|
||||
$datos_guardas = false;
|
||||
|
||||
$datos_presupuesto = array(
|
||||
'id' => $id,
|
||||
'tirada' => $tirada,
|
||||
'tamanio' => $tamanio,
|
||||
'tipo_impresion_id' => $tipo_impresion_id,
|
||||
@ -389,6 +361,18 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
);
|
||||
|
||||
$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)) {
|
||||
return $this->failServerError(
|
||||
$return_data['exception'] . ' - ' .
|
||||
@ -411,7 +395,24 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
if (!property_exists($coste_direccion, 'coste')) {
|
||||
$return_data['errors']->envios = "No se ha podido calcular el coste de envío";
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$data['direccion'] = $direccion;
|
||||
$data['peso'] = $return_data['peso'][$i];
|
||||
$data['palets'] = $direccion['entregaPalets'] == 'true' ? 1 : 0;
|
||||
$errorModel->insertError(
|
||||
$id,
|
||||
auth()->user()->id,
|
||||
'No se ha podido calcular el coste de envío',
|
||||
$data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
|
||||
} else {
|
||||
$coste_envio += $coste_direccion->coste;
|
||||
}
|
||||
@ -426,7 +427,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$coste_direccion = $this->getCosteEnvio(null, $return_data['peso'][$i], $tirada[$i], false)[0];
|
||||
|
||||
if (!property_exists($coste_direccion, 'coste')) {
|
||||
$return_data['errors']->envios = "No se ha podido calcular el coste de envío";
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$data['direccion'] = 'Sin direccion';
|
||||
$data['peso'] = $return_data['peso'][$i];
|
||||
$data['palets'] = 'Sin direccion';
|
||||
$errorModel->insertError(
|
||||
$id,
|
||||
auth()->user()->id,
|
||||
'No se ha podido calcular el coste de envío',
|
||||
$data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
} else {
|
||||
$coste_envio += $coste_direccion->coste;
|
||||
}
|
||||
@ -612,6 +628,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$selected_tirada = $reqData['selectedTirada'] ?? 0;
|
||||
$tamanio = $reqData['tamanio'];
|
||||
$paginas = $reqData['paginas'] ?? 0;
|
||||
$paginas_color = $reqData['paginasColor'] ?? 0;
|
||||
|
||||
$posPaginasColor = $reqData['posPaginasColor'] ?? "";
|
||||
$paginasColorConsecutivas = $reqData['pagColorConsecutivas'] ?? 0;
|
||||
@ -625,6 +642,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$isColor = intval($reqData['isColor']) ?? 0;
|
||||
$isHq = intval($reqData['isHq']) ?? 0;
|
||||
|
||||
$prototipo = intval($reqData['prototipo']) ?? 0;
|
||||
|
||||
$interior = $reqData['interior'] ?? [];
|
||||
$cubierta = $reqData['cubierta'] ?? [];
|
||||
$sobrecubierta = $reqData['sobrecubierta'] ?? [];
|
||||
@ -653,9 +672,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'gramaje' => $gramaje,
|
||||
'excluirRotativa' => $excluirRotativa,
|
||||
'paginas' => $paginas,
|
||||
'paginas_color' => $paginas_color,
|
||||
'pos_paginas_color' => $posPaginasColor,
|
||||
'paginas_color_consecutivas' => $paginasColorConsecutivas,
|
||||
'papel_interior_diferente' => $papelInteriorDiferente
|
||||
'papelInteriorDiferente' => $papelInteriorDiferente
|
||||
];
|
||||
|
||||
|
||||
@ -666,6 +686,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0),
|
||||
'solapasCubierta' => intval($cubierta['solapas'] ?? 0),
|
||||
'acabadosCubierta' => $cubierta['acabados'] ?? 0,
|
||||
'lomoRedondo' => $cubierta['lomoRedondo'] ?? 0,
|
||||
'cabezada' => $cubierta['cabezada'] ?? 'WHI',
|
||||
];
|
||||
|
||||
// Sobrecubierta
|
||||
@ -684,7 +706,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$datos_guardas = [
|
||||
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
|
||||
'gramaje' => intval($guardas['gramaje']),
|
||||
'caras' => intval($guardas['guardasImpresas']),
|
||||
'caras' => intval($guardas['caras']),
|
||||
];
|
||||
} else
|
||||
$datos_guardas = false;
|
||||
@ -817,6 +839,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0;
|
||||
}
|
||||
|
||||
$datos_presupuesto['prototipo'] = $prototipo;
|
||||
|
||||
$id = $model_presupuesto->insertarPresupuestoCliente(
|
||||
$id,
|
||||
$selected_tirada,
|
||||
@ -899,14 +923,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$presupuesto = $this->model->find($id);
|
||||
$data = [];
|
||||
if ($presupuesto) {
|
||||
$data['lc'] = $presupuesto->lomo_cubierta;
|
||||
$data['lsc'] = $presupuesto->lomo_sobrecubierta;
|
||||
$data['datosGenerales']['titulo'] = $presupuesto->titulo;
|
||||
$data['datosGenerales']['autor'] = $presupuesto->autor;
|
||||
$data['datosGenerales']['isbn'] = $presupuesto->isbn;
|
||||
$data['datosGenerales']['coleccion'] = $presupuesto->coleccion;
|
||||
$data['datosGenerales']['referenciaCliente'] = $presupuesto->referencia_cliente;
|
||||
$data['datosGenerales']['paginas'] = $presupuesto->paginas;
|
||||
$data['datosGenerales']['posPaginasColor'] = $presupuesto->paginas_color;
|
||||
$data['datosGenerales']['paginasCuadernillo'] = $presupuesto->paginas_cuadernillo;
|
||||
$data['datosGenerales']['paginasCuadernillo'] = $presupuesto->paginasCuadernillo;
|
||||
$data['datosGenerales']['tirada'] = $presupuesto->tirada;
|
||||
$data['datosGenerales']['ivaReducido'] = $presupuesto->iva_reducido;
|
||||
$data['datosGenerales']['excluirRotativa'] = $presupuesto->excluir_rotativa;
|
||||
@ -920,29 +945,34 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$data['datosGenerales']['papelFormatoAncho'] = $presupuesto->papel_formato_ancho;
|
||||
$data['datosGenerales']['papelFormatoAlto'] = $presupuesto->papel_formato_alto;
|
||||
|
||||
$data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color;
|
||||
$data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente;
|
||||
$data['datosGenerales']['paginasColorConsecutivas'] = $presupuesto->paginas_color_consecutivas;
|
||||
|
||||
$data['tiradasPrecio'] = [
|
||||
(object) [
|
||||
'tirada' => $presupuesto->tirada,
|
||||
'precio' => $presupuesto->total_confirmado,
|
||||
'precio_u' => $presupuesto->total_precio_unidad,
|
||||
]
|
||||
];
|
||||
$data['datosGenerales']['tipo'] = $this->getTipoLibro($presupuesto->tipo_impresion_id ?? null);
|
||||
$data['datosGenerales']['prototipo'] = $presupuesto->prototipo;
|
||||
|
||||
$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;
|
||||
array_push($data['tiradasPrecio'], (object) [
|
||||
'tirada' => intval($tirada->tirada),
|
||||
'precio' => $tirada->total_pedido,
|
||||
'precio_u' => $tirada->precio_unidad,
|
||||
]);
|
||||
}
|
||||
usort($data['tiradasPrecio'], function ($a, $b) {
|
||||
return $a->tirada <=> $b->tirada;
|
||||
});
|
||||
$datos_papel = $this->obtenerDatosPapel($presupuesto->id);
|
||||
$data['interior'] = $datos_papel['interior'] ? $datos_papel['interior'] : [];
|
||||
|
||||
$data['cubierta'] = $datos_papel['cubierta'] ? $datos_papel['cubierta'] : [];
|
||||
$data['cubierta']['tapa'] = $this->obtenerTipoTapa($presupuesto->tipo_impresion_id ?? null);
|
||||
$data['cubierta']['lomoRedondo'] = $presupuesto->lomo_redondo ? 1 : 0;
|
||||
$data['cubierta']['solapas'] = $presupuesto->solapas ? 1 : 0;
|
||||
$data['cubierta']['solapas_ancho'] = $presupuesto->solapas_ancho;
|
||||
$data['cubierta']['cabezada'] = $presupuesto->cabezada;
|
||||
$modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel");
|
||||
$data['cubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_cubierta_id);
|
||||
$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();
|
||||
$lineas = $modelLinea->where('presupuesto_id', $id)->findAll();
|
||||
@ -950,6 +980,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
[$data['datosGenerales']['paginasNegro'], $data['datosGenerales']['paginasColor']] =
|
||||
$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([
|
||||
'status' => 1,
|
||||
@ -1344,6 +1382,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$carasCubierta = $datos_entrada['cubierta']['carasCubierta'];
|
||||
$solapasCubierta = $datos_entrada['cubierta']['solapasCubierta'];
|
||||
$acabadosCubierta = $datos_entrada['cubierta']['acabadosCubierta'] ?? [];
|
||||
$lomoRedondo = $datos_entrada['cubierta']['lomoRedondo'];
|
||||
|
||||
// Sobrecubierta
|
||||
$sobreCubierta = $datos_entrada["sobrecubierta"] ?? null;
|
||||
@ -1354,15 +1393,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
// Servicios
|
||||
$servicios = $datos_entrada['servicios'] ?? [];
|
||||
|
||||
$error = (object) [
|
||||
'interior' => "",
|
||||
'cubierta' => "",
|
||||
'sobrecubierta' => "",
|
||||
'guardas' => "",
|
||||
'servicios' => "",
|
||||
'serviciosDefecto' => "",
|
||||
"envios" => "",
|
||||
];
|
||||
$coste_servicios = 0.0;
|
||||
|
||||
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
||||
@ -1421,6 +1451,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$interior = PresupuestoClienteService::obtenerInterior($input_data);
|
||||
|
||||
if ($interior == -1) {
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'
|
||||
No se puede obtener el interior',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$costeInterior = 0.0;
|
||||
$peso_interior = 0.0;
|
||||
foreach ($interior as $linea) {
|
||||
@ -1441,10 +1488,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
if ($costeInterior <= 0) {
|
||||
$error->interior = lang('Presupuestos.errores.noInterior');
|
||||
}
|
||||
|
||||
// Si es POD hay que volver a calcular para incluir la merma correcta
|
||||
if ($tirada[$t] <= $POD) {
|
||||
$num_formas = [];
|
||||
@ -1459,6 +1502,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$info['merma'] = max($info['merma'], $input_data['datosPedido']->merma);
|
||||
}
|
||||
$interior = PresupuestoClienteService::obtenerInterior($input_data);
|
||||
if ($interior == -1) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener el interior',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$costeInterior = 0.0;
|
||||
$peso_interior = 0.0;
|
||||
@ -1490,11 +1549,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
if ($costeInterior <= 0)
|
||||
$error->interior = lang('Presupuestos.errores.noInterior');
|
||||
else
|
||||
$error->interior = "";
|
||||
if ($costeInterior <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener el interior',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
// Cubierta
|
||||
$input_data['papel_generico'] = $papel_generico_cubierta;
|
||||
@ -1507,6 +1577,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
$input_data['uso'] = 'cubierta';
|
||||
$input_data['lomoRedondo'] = $lomoRedondo;
|
||||
|
||||
$cubierta = PresupuestoClienteService::obtenerCubierta($input_data);
|
||||
$coste_cubierta = 0.0;
|
||||
@ -1527,11 +1598,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($coste_cubierta <= 0)
|
||||
$error->cubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta');
|
||||
else
|
||||
$error->cubierta = "";
|
||||
if ($coste_cubierta <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener la cubierta',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
// Acabados Cubierta
|
||||
$tarifaAcabadoCubierta = $this->obtenerTarifasAcabado($acabadosCubierta);
|
||||
$acabadoCubierta = [];
|
||||
@ -1543,8 +1625,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$acabadoCubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD);
|
||||
|
||||
if (count($acabadoCubierta) > 0) {
|
||||
if ($acabadoCubierta[0]->total <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
if ($acabadoCubierta[0]->total <= 0) {
|
||||
|
||||
$input_data['tarifas_acabado_cubierta'] = $tarifaAcabadoCubierta;
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener acabados de cubierta',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
$coste_servicios += floatval($acabadoCubierta[0]->total);
|
||||
}
|
||||
}
|
||||
@ -1586,11 +1683,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($coste_sobrecubierta <= 0)
|
||||
$error->sobrecubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta');
|
||||
else
|
||||
$error->sobrecubierta = "";
|
||||
if ($coste_sobrecubierta <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener la sobrecubierta',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
$lomo_sobrecubierta = $lomo + floatval($linea_sobrecubierta['mano']);
|
||||
|
||||
$tarifaAcabadoSobrecubierta = $this->obtenerTarifasAcabado(['plastificado' => $sobreCubierta['acabados']]);
|
||||
@ -1604,8 +1712,25 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$acabadoSobrecubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD);
|
||||
|
||||
if (count($acabadoSobrecubierta) > 0) {
|
||||
if ($acabadoSobrecubierta[0]->total <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
|
||||
if ($acabadoSobrecubierta[0]->total <= 0) {
|
||||
|
||||
$input_data['tarifas_acabado_sobrecubierta'] = $tarifaAcabadoSobrecubierta;
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener acabados de sobrecubierta',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($acabadoSobrecubierta[0]->total);
|
||||
}
|
||||
}
|
||||
@ -1656,10 +1781,21 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($coste_guardas <= 0)
|
||||
$error->guardas = lang('Presupuestos.errores.noGuardas');
|
||||
else
|
||||
$error->guardas = "";
|
||||
if ($coste_guardas <= 0) {
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener las guardas',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($extra_info) {
|
||||
@ -1683,8 +1819,24 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
]);
|
||||
$costeServiciosDefecto = 0.0;
|
||||
foreach ($servDefecto as $servicio) {
|
||||
if ($servicio->total <= 0)
|
||||
$error->serviciosDefecto = lang('Presupuestos.errores.errorPresupuesto');
|
||||
if ($servicio->total <= 0) {
|
||||
|
||||
$input_data['servicios'] = $servDefecto;
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener servicios',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
|
||||
$costeServiciosDefecto += floatval($servicio->total);
|
||||
if ($extra_info) {
|
||||
@ -1720,6 +1872,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if ($datos_entrada['servicios']['prototipo'])
|
||||
array_push($servicios, 9);
|
||||
foreach ($servicios as $servicio) {
|
||||
|
||||
if (intval($servicio) == 3) {
|
||||
// Servicios acabado
|
||||
$resultado = PresupuestoCLienteService::getServiciosAcabados([
|
||||
@ -1728,8 +1881,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'POD' => $POD,
|
||||
]);
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
if ($resultado[0]->total <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
|
||||
if ($resultado[0]->total <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener servicio con id 3',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
if ($extra_info) {
|
||||
@ -1742,8 +1910,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'tarifa_id' => $servicio,
|
||||
]);
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
if ($resultado[0]->precio <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
if ($resultado[0]->precio <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener servicio con id 9',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->precio);
|
||||
if ($extra_info) {
|
||||
@ -1755,10 +1938,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios) / $tirada[$t], 4));
|
||||
array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2));
|
||||
foreach ($error as $err) {
|
||||
if ($err != "")
|
||||
break;
|
||||
}
|
||||
|
||||
if ($extra_info) {
|
||||
$totalServicios -= $margenServicios;
|
||||
@ -1785,8 +1964,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
));
|
||||
}
|
||||
|
||||
$info['lomo_cubierta'] = $lomo;
|
||||
$info['lomo_sobrecubierta'] = $lomo_sobrecubierta;
|
||||
$info['lomo_cubierta'] = round(floatval($lomo), 2);
|
||||
$info['lomo_sobrecubierta'] = round(floatval($lomo_sobrecubierta), 2);
|
||||
$return_data['info'] = $info;
|
||||
|
||||
|
||||
@ -1802,7 +1981,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
$return_data += [
|
||||
'errors' => $error,
|
||||
'errors' => (object) ([
|
||||
'status' => 0,
|
||||
]),
|
||||
//'total_lp' => $costeInterior + $coste_cubierta + $coste_sobrecubierta,
|
||||
//'acabadoCubierta' => $acabadoCubierta,
|
||||
//'acabadoSobrecubierta' => $acabadoSobrecubierta,
|
||||
@ -1818,6 +1999,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
return $return_data;
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'exception' => $e->getMessage(),
|
||||
@ -1990,6 +2172,19 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
} else
|
||||
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)
|
||||
{
|
||||
|
||||
@ -2072,18 +2267,18 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
protected function obtenerDireccionesEnvio($presupuestoEntity)
|
||||
protected function obtenerDireccionesEnvio($id, $cliente_id)
|
||||
{
|
||||
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||
$model_pais = model('App\Models\Configuracion\PaisModel');
|
||||
$direcciones = $model->where('presupuesto_id', $presupuestoEntity->id)->findAll();
|
||||
$direcciones = $model->where('presupuesto_id', $id)->findAll();
|
||||
|
||||
$result = [];
|
||||
$temp = [];
|
||||
for ($i = 0; $i < count($direcciones); $i++) {
|
||||
$direccion_id = $model_direcciones->getIdForPresupuestoCliente(
|
||||
$presupuestoEntity->cliente_id,
|
||||
$cliente_id,
|
||||
$direcciones[$i]->att,
|
||||
$direcciones[$i]->email,
|
||||
$direcciones[$i]->direccion,
|
||||
@ -2093,49 +2288,56 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
);
|
||||
if (count($direccion_id) > 0) {
|
||||
$temp = $direcciones[$i]->toArray();
|
||||
$temp['pais'] = $model_pais->where('id', $direcciones[$i]->pais_id)->first()->nombre;
|
||||
$temp['direccion_id'] = $direccion_id[0]->id;
|
||||
array_push($result, $temp);
|
||||
array_push($result, [
|
||||
'id' => $temp['id'],
|
||||
'unidades' => $temp['cantidad'],
|
||||
'palets' => $temp['entregaPieCalle'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
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');
|
||||
$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) {
|
||||
foreach ($data as $linea) {
|
||||
// Se coje el primer papel que se encuentre para el interior
|
||||
// para presupuestos del cliente sólo se escoje un papel para el interior
|
||||
if (strpos($linea->tipo, "bn") !== false || strpos($linea->tipo, "color") !== false) {
|
||||
$presupuestoEntity->papel_interior = $linea->papel_id;
|
||||
$presupuestoEntity->gramaje_interior = $linea->gramaje;
|
||||
}
|
||||
// Si es cubierta
|
||||
else if (strpos($linea->tipo, "cubierta") !== false && strpos($linea->tipo, "sobrecubierta") === false) {
|
||||
$presupuestoEntity->papel_cubierta = $linea->papel_id;
|
||||
$presupuestoEntity->gramaje_cubierta = $linea->gramaje;
|
||||
$presupuestoEntity->paginas_cubierta = $linea->paginas;
|
||||
}
|
||||
// Si es sobrecubierta
|
||||
else if (strpos($linea->tipo, "sobrecubierta") !== false) {
|
||||
$presupuestoEntity->papel_sobrecubierta = $linea->papel_id;
|
||||
$presupuestoEntity->gramaje_sobrecubierta = $linea->gramaje;
|
||||
$presupuestoEntity->paginas_sobrecubierta = $linea->paginas;
|
||||
}
|
||||
// Si es guardas
|
||||
else if (strpos($linea->tipo, "guardas") !== false) {
|
||||
$presupuestoEntity->papel_guardas = $linea->papel_id;
|
||||
$presupuestoEntity->paginas_guardas = $linea->paginas;
|
||||
if ($linea->tipo == 'lp_bn' || $linea->tipo == 'lp_bnhq' || $linea->tipo == 'lp_rot_bn') {
|
||||
$return_data['interior']['negro']['tipo'] = $linea->tipo == 'lp_bn' || $linea->tipo == 'lp_rot_bn' ? 'negroEstandar' : 'negroPremium';
|
||||
$return_data['interior']['negro']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['interior']['negro']['gramaje'] = $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';
|
||||
$return_data['interior']['color']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['interior']['color']['gramaje'] = $linea->gramaje;
|
||||
} else if ($linea->tipo == 'lp_cubierta') {
|
||||
$return_data['cubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['cubierta']['gramaje'] = $linea->gramaje;
|
||||
$return_data['cubierta']['paginas'] = $linea->paginas;
|
||||
} else if ($linea->tipo == 'lp_sobrecubierta') {
|
||||
$return_data['sobrecubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['sobrecubierta']['gramaje'] = $linea->gramaje;
|
||||
$return_data['sobrecubierta']['paginas'] = $linea->paginas;
|
||||
} else if ($linea->tipo == 'lp_guardas') {
|
||||
$return_data['guardas']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['guardas']['gramaje'] = $linea->gramaje;
|
||||
$return_data['guardas']['paginas'] = $linea->paginas;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
protected function generarResumen($presupuestoEntity)
|
||||
@ -2264,7 +2466,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
private function getPaginas($lineas){
|
||||
private function getPaginas($lineas)
|
||||
{
|
||||
|
||||
$paginasNegro = 0;
|
||||
$paginasColor = 0;
|
||||
@ -2290,4 +2493,5 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
return [$paginasNegro, $paginasColor];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -92,6 +92,9 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"is_duplicado" => false,
|
||||
'paginas_color_consecutivas' => null,
|
||||
'papel_interior_diferente' => null,
|
||||
'paginasCuadernillo' => null,
|
||||
'lomo_redondo' => null,
|
||||
'cabezada' => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"cliente_id" => "int",
|
||||
@ -159,5 +162,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"is_duplicado" => "boolean",
|
||||
'paginas_color_consecutivas' => "boolean",
|
||||
'papel_interior_diferente' => "boolean",
|
||||
'paginasCuadernillo' => "int",
|
||||
'lomo_redondo' => "boolean",
|
||||
];
|
||||
}
|
||||
|
||||
@ -76,6 +76,22 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
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.
|
||||
*
|
||||
|
||||
@ -322,4 +322,22 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,6 +129,9 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
"is_duplicado",
|
||||
'paginas_color_consecutivas',
|
||||
'papel_interior_diferente',
|
||||
'paginasCuadernillo',
|
||||
'lomo_redondo',
|
||||
'cabezada',
|
||||
];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
|
||||
|
||||
@ -406,16 +409,21 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'guardas' => in_array(62, $data['servicios']) ? 1 : 0,
|
||||
'faja_color' => in_array(16, $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_personalizado' => !$papel_formato_id ? 1 : 0,
|
||||
'papel_formato_ancho' => !$papel_formato_id ? $data['tamanio']['ancho'] : null,
|
||||
'papel_formato_alto' => !$papel_formato_id ? $data['tamanio']['alto'] : null,
|
||||
'titulo' => $data_cabecera['titulo'],
|
||||
'autor' => $data_cabecera['autor'],
|
||||
'ISBN' => $data_cabecera['isbn'],
|
||||
'coleccion' => $data_cabecera['coleccion'],
|
||||
'referencia_cliente' => $data_cabecera['referenciaCliente'],
|
||||
'paginas' => $data['interior']['paginas'],
|
||||
'tirada' => $tirada,
|
||||
'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_sobrecubierta' => !$data['sobrecubierta'] ? 0 : 1,
|
||||
'solapas_ancho_sobrecubierta' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['solapas'],
|
||||
@ -424,9 +432,9 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'merma_cubierta' => $extra_info['merma'],
|
||||
'paginasCuadernillo' => $data['paginasCuadernillo'],
|
||||
|
||||
'pos_paginas_color' => $data['interior']['pos_paginas_color'],
|
||||
'comp_pos_paginas_color' => $data['interior']['pos_paginas_color'],
|
||||
'paginas_color_consecutivas' => $data['interior']['paginas_color_consecutivas'],
|
||||
'papel_interior_diferente' => $data['interior']['papel_interior_diferente'],
|
||||
'papel_interior_diferente' => $data['interior']['papelInteriorDiferente'],
|
||||
|
||||
'lomo_cubierta' => $extra_info['lomo_cubierta'],
|
||||
'lomo_sobrecubierta' => $extra_info['lomo_sobrecubierta'],
|
||||
@ -495,29 +503,45 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
if (is_array($data)) {
|
||||
// -- INTERIOR --
|
||||
// Si hay negro
|
||||
if ($data['interior']['paginas'] > $data['interior']['paginas_color']) {
|
||||
if (intval($data['interior']['paginas']) > intval($data['interior']['paginas_color'])) {
|
||||
|
||||
if ($data['isHq'])
|
||||
$key = 'bnhq';
|
||||
else
|
||||
$key = 'bn';
|
||||
if (array_key_exists('id', $data['interior']['papel_generico'])) {
|
||||
$papel_id = intval($data['interior']['papel_generico']['id']);
|
||||
$gramaje = intval($data['interior']['gramaje']);
|
||||
} else {
|
||||
$papel_id = intval($data['interior']['papel_generico']['negro']['id']);
|
||||
$gramaje = intval($data['interior']['gramaje']['negro']);
|
||||
}
|
||||
|
||||
|
||||
$values[$key] = array(
|
||||
'paginas' => intval($data['interior']['paginas']) - intval($data['interior']['paginas_color']),
|
||||
'papel_id' => intval($data['interior']['papel_generico']['id']),
|
||||
'gramaje' => intval($data['interior']['gramaje']),
|
||||
'paginas' => intval($data['interior']['paginas']) - intval(intval($data['interior']['paginas_color'])),
|
||||
'papel_id' => $papel_id,
|
||||
'gramaje' => $gramaje,
|
||||
);
|
||||
}
|
||||
// Si hay color
|
||||
if ($data['interior']['paginas_color'] > 0) {
|
||||
if (intval($data['interior']['paginas_color']) > 0) {
|
||||
|
||||
if ($data['isHq'])
|
||||
$key = 'colorhq';
|
||||
else
|
||||
$key = 'color';
|
||||
if (array_key_exists('id', $data['interior']['papel_generico'])) {
|
||||
$papel_id = intval($data['interior']['papel_generico']['id']);
|
||||
$gramaje = intval($data['interior']['gramaje']);
|
||||
} else {
|
||||
$papel_id = intval($data['interior']['papel_generico']['color']['id']);
|
||||
$gramaje = intval($data['interior']['gramaje']['color']);
|
||||
}
|
||||
$values[$key] = array(
|
||||
'paginas' => intval($data['interior']['paginas_color']),
|
||||
'papel_id' => intval($data['interior']['papel_generico']['id']),
|
||||
'gramaje' => intval($data['interior']['gramaje']),
|
||||
'paginas' => intval(intval($data['interior']['paginas_color'])),
|
||||
'papel_id' => $papel_id,
|
||||
'gramaje' => $gramaje,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +116,8 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
|
||||
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
|
||||
->table($this->table . " t1")
|
||||
@ -186,4 +187,23 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
|
||||
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,8 +25,13 @@ class PresupuestoClienteService extends BaseService
|
||||
$total_plana = -1;
|
||||
$hay_plana = false;
|
||||
if ($data['isColor']) {
|
||||
if ($data['datosPedido']->paginas == $data['paginas_color'])
|
||||
if ($data['datosPedido']->paginas == $data['paginas_color']){
|
||||
if(count($plana[1]) > 2)
|
||||
$total_plana += floatval($plana[1]['total_impresion']);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
elseif (count($plana) > 0) {
|
||||
if (count($plana[0]) > 2 && count($plana[1]) > 2) {
|
||||
$total_plana = 0.0;
|
||||
@ -72,6 +77,7 @@ class PresupuestoClienteService extends BaseService
|
||||
$isHq = $data['isHq'];
|
||||
$cliente_id = $data['cliente_id'];
|
||||
$paginas_color = $data['paginas_color'];
|
||||
$lomoRedondo = $data['lomoRedondo'];
|
||||
|
||||
$lineas_cubierta = [];
|
||||
|
||||
@ -86,7 +92,8 @@ class PresupuestoClienteService extends BaseService
|
||||
'isColor' => $isColor,
|
||||
'isHq' => $isHq,
|
||||
'cliente_id' => $cliente_id,
|
||||
'a_favor_fibra' => $i
|
||||
'a_favor_fibra' => $i,
|
||||
'lomoRedondo' => $lomoRedondo
|
||||
]);
|
||||
|
||||
if (count($lineas) > 0) {
|
||||
|
||||
@ -838,9 +838,13 @@ class PresupuestoService extends BaseService
|
||||
* Devuelve el ancho de la cubierta/sobrecubierta, incluido el lomo.
|
||||
* 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;
|
||||
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
|
||||
if($datosPedido->ancho > 210 || $datosPedido->alto > 297){
|
||||
$sangre_cubierta = 15;
|
||||
}
|
||||
|
||||
if ($datosPedido) {
|
||||
// Tapa blanda (cosido y fresado)
|
||||
@ -861,8 +865,13 @@ class PresupuestoService extends BaseService
|
||||
// si es cubierta
|
||||
// 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
|
||||
if ($uso == "cubierta")
|
||||
$ancho_total += (2 * 7 + 2 * self::SANGRE_FORMAS_CUBIERTA + 7);
|
||||
if ($uso == "cubierta"){
|
||||
$ancho_total += (2 * 7 + 2 * $sangre_cubierta + 6);
|
||||
if($lomoRedondo){
|
||||
$ancho_total += 6;
|
||||
}
|
||||
}
|
||||
|
||||
// si es sobrecubierta
|
||||
// Se añaden 5mm de sangre por cada lado + 2 * 7mm de vuelo portada y contraportada -> total 52
|
||||
else
|
||||
@ -893,7 +902,7 @@ class PresupuestoService extends BaseService
|
||||
// Tapa dura
|
||||
else{
|
||||
// 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 {
|
||||
@ -1716,6 +1725,7 @@ class PresupuestoService extends BaseService
|
||||
$cliente_id = $input_data['cliente_id'];
|
||||
$datosTipolog = $input_data['datosTipolog'] ?? null;
|
||||
$a_favor_fibra = $datosPedido->a_favor_fibra ?? false;
|
||||
$lomoRedondo = $input_data['lomoRedondo'] ?? 0;
|
||||
|
||||
$tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro');
|
||||
|
||||
@ -1747,7 +1757,7 @@ class PresupuestoService extends BaseService
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<label for="autor" class="form-label">
|
||||
<?= lang('Presupuestos.autor') ?>
|
||||
</label>
|
||||
<input type="text" id="autor" placeholder="Autor" name="autor" maxLength="150" class="form-control" value="">
|
||||
<input type="text" id="autor" placeholder="Autor" name="autor" maxLength="150" class="form-control text-center" value="">
|
||||
</div>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
@ -101,7 +101,7 @@
|
||||
|
||||
<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">
|
||||
Formato Libro*
|
||||
</label>
|
||||
@ -110,16 +110,16 @@
|
||||
</select>
|
||||
</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">
|
||||
<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"
|
||||
class="form-control formato_libro calcular-presupuesto num-input" min="60" value="60">
|
||||
</div>
|
||||
|
||||
<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"
|
||||
class="form-control formato_libro calcular-presupuesto num-input" min="60" value="60">
|
||||
</div>
|
||||
|
||||
@ -118,8 +118,8 @@
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="guardasImpresas"
|
||||
name="guardas_impresas">
|
||||
<option value="0"><?= lang('Presupuestos.sinImpresion') ?></option>
|
||||
<option value="1"><?= lang('Presupuestos.unaCara') ?></option>
|
||||
<option value="2"><?= lang('Presupuestos.dosCaras') ?></option>
|
||||
<option value="4"><?= lang('Presupuestos.unaCara') ?></option>
|
||||
<option value="8"><?= lang('Presupuestos.dosCaras') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -127,7 +127,7 @@
|
||||
<label for="cabezada" class="form-label">
|
||||
<?= lang('Presupuestos.cabezada') ?>
|
||||
</label>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="cabezada" name="cabezada">
|
||||
<select class="form-select select2bs2" id="cabezada" name="cabezada">
|
||||
<option value="WHI"><?= lang('Presupuestos.blanca') ?></option>
|
||||
<option value="GRE"><?= lang('Presupuestos.verde') ?></option>
|
||||
<option value="BLUE"><?= lang('Presupuestos.azul') ?></option>
|
||||
@ -306,7 +306,7 @@
|
||||
|
||||
<div class="row justify-content-center">
|
||||
|
||||
<div class="row col-sm-3 mb-3 d-flex flex-column align-items-center">
|
||||
<div class="row col-sm-3 mb-3 d-flex flex-column align-items-center sobrecubierta-items">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="calcular-presupuesto form-check-input" type="checkbox" id="addSobrecubierta"
|
||||
name="add_sobrecubierta" value="1">
|
||||
@ -315,7 +315,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 config-sobrecubierta d-none">
|
||||
<div class="col-sm-3 config-sobrecubierta d-none sobrecubierta-items">
|
||||
<label for="papelSobrecubierta" class="form-label">
|
||||
<?= lang('Presupuestos.papelSobrecubierta') ?>
|
||||
</label>
|
||||
@ -326,7 +326,7 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 config-sobrecubierta d-none">
|
||||
<div class="col-sm-3 config-sobrecubierta d-none sobrecubierta-items">
|
||||
<label for="solapasSobrecubierta" class="form-label">
|
||||
<?= lang('Presupuestos.tamanioSolapasSobrecubierta') ?>
|
||||
</label>
|
||||
@ -338,7 +338,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 config-sobrecubierta d-none">
|
||||
<div class="col-sm-3 config-sobrecubierta d-none sobrecubierta-items">
|
||||
<label for="plastificadoSobrecubierta" class="form-label">
|
||||
<?= lang('Presupuestos.plastificadoSobrecubierta') ?>
|
||||
</label>
|
||||
|
||||
@ -10,6 +10,17 @@
|
||||
<h3 class="mt-3 mb-1 fw-bold"> Total: <span id="resumenTotal"></span> €</h>
|
||||
</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">
|
||||
<table class="table table-bordered">
|
||||
|
||||
@ -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/autosize/autosize.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 type="module"
|
||||
src="<?= site_url('assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js') ?>"></script>
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -48,30 +48,30 @@ if (auth()->user()->can('presupuesto.menu')) {
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("presupuestos/grapados") ?>" class="menu-link">
|
||||
<a href="<?= site_url("presupuestos/cosidotapablanda/list/21") ?>" class="menu-link">
|
||||
<?= lang("App.menu_libros_grapados") ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("presupuestos/espiraltapadura") ?>" class="menu-link">
|
||||
<a href="<?= site_url("presupuestos/cosidotapablanda/list/5") ?>" class="menu-link">
|
||||
<?= lang("App.menu_libros_espiral_tapa_dura") ?>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("presupuestos/espiraltapablanda") ?>"
|
||||
<a href="<?= site_url("presupuestos/cosidotapablanda/list/6") ?>"
|
||||
class="menu-link">
|
||||
<?= lang("App.menu_libros_espiral_tapa_blanda") ?>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("presupuestos/wireotapadura") ?>" class="menu-link">
|
||||
<a href="<?= site_url("presupuestos/cosidotapablanda/list/7") ?>" class="menu-link">
|
||||
<?= lang("App.menu_libros_wireo_tapa_dura") ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("presupuestos/wireotapablanda") ?>" class="menu-link">
|
||||
<a href="<?= site_url("presupuestos/cosidotapablanda/list/8") ?>" class="menu-link">
|
||||
<?= lang("App.menu_libros_wireo_tapa_blanda") ?>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@ -9,7 +9,7 @@ class ErrorPresupuestoView {
|
||||
{ data: 'lastUser', searchable: true, sortable: false },
|
||||
{ data: 'visto', searchable: false, sortable: false ,
|
||||
render : (d,t) => {
|
||||
const iconClass = d ? "ti ti-sm ti-check" : "ti ti-sm ti-x"
|
||||
const iconClass = d == "1" ? "ti ti-sm ti-check" : "ti ti-sm ti-x"
|
||||
return `<span class="${iconClass}"</span>`
|
||||
}
|
||||
},
|
||||
|
||||
@ -27,11 +27,14 @@ class DatosGenerales {
|
||||
this.papelFormatoId = this.domItem.find("#papelFormatoId");
|
||||
this.checkFormatoPersonalizado = this.domItem.find("#papelFormatoPersonalizado");
|
||||
this.formatoPersonalizado = this.domItem.find("#formatoPersonalizado");
|
||||
this.formatoEstandar = this.domItem.find("#formatoEstandar");
|
||||
this.anchoPersonalizado = this.domItem.find("#papelFormatoAncho");
|
||||
this.altoPersonalizado = this.domItem.find("#papelFormatoAlto");
|
||||
|
||||
this.fresado = $(this.domItem.find("#fresado")[0]);
|
||||
this.cosido = $(this.domItem.find("#cosido")[0]);
|
||||
this.grapado = $(this.domItem.find("#grapado")[0]);
|
||||
this.espiral = $(this.domItem.find("#espiral")[0]);
|
||||
|
||||
this.tiposLibro = this.domItem.find(".tipo-libro");
|
||||
|
||||
@ -346,6 +349,14 @@ class DatosGenerales {
|
||||
this.coleccion.val(datos.coleccion);
|
||||
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));
|
||||
if (datos.tirada2)
|
||||
this.tirada2.val(parseInt(datos.tirada2));
|
||||
@ -354,52 +365,40 @@ class DatosGenerales {
|
||||
if (datos.tirada4)
|
||||
this.tirada4.val(parseInt(datos.tirada4));
|
||||
|
||||
if (datos.checkFormatoPersonalizado) {
|
||||
this.checkFormatoPersonalizado.prop(':checked', datos.checkFormatoPersonalizado);
|
||||
this.checkFormatoPersonalizado.trigger('change');
|
||||
this.papel_formato_alto.val(datos.papelFormatoAlto);
|
||||
this.papel_formato_ancho.val(datos.papelFormatoAncho);
|
||||
if (datos.papelFormatoPersonalizado) {
|
||||
this.checkFormatoPersonalizado.prop('checked', true);
|
||||
this.formatoEstandar.addClass('d-none');
|
||||
this.formatoPersonalizado.removeClass('d-none');
|
||||
this.formValidation.revalidateField('papel_formato_id');
|
||||
this.altoPersonalizado.val(datos.papelFormatoAlto);
|
||||
this.anchoPersonalizado.val(datos.papelFormatoAncho);
|
||||
}
|
||||
else {
|
||||
this.formatoLibro.setOption(datos.papelFormatoId, datos.papelFormatoNombre);
|
||||
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.paginasNegro.val(parseInt(datos.paginasNegro));
|
||||
this.paginasColor.val(parseInt(datos.paginasColor));
|
||||
this.paginasColor.trigger('change');
|
||||
this.paginasColor.val(parseInt(datos.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.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");
|
||||
if (datos.tipo != "") {
|
||||
this.tiposLibro.removeClass('selected');
|
||||
this.tiposLibro.find('.image-presupuesto').removeClass('selected');
|
||||
this.domItem.find('#' + datos.tipo).addClass('selected');
|
||||
}
|
||||
|
||||
this.fresado = $(this.domItem.find("#fresado")[0]);
|
||||
this.cosido = $(this.domItem.find("#cosido")[0]);
|
||||
|
||||
this.tiposLibro = this.domItem.find(".tipo-libro");
|
||||
|
||||
|
||||
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");*/
|
||||
this.prototipo.prop('checked', datos.prototipo);
|
||||
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
|
||||
}
|
||||
|
||||
getDimensionLibro() {
|
||||
@ -452,13 +451,13 @@ class DatosGenerales {
|
||||
#handleFormatoLibro() {
|
||||
|
||||
if (this.checkFormatoPersonalizado.is(':checked')) {
|
||||
this.formatoLibro.item.hide();
|
||||
this.formatoPersonalizado.show();
|
||||
this.formatoEstandar.addClass('d-none');
|
||||
this.formatoPersonalizado.removeClass('d-none');
|
||||
this.formValidation.revalidateField('papel_formato_id');
|
||||
}
|
||||
else {
|
||||
this.formatoLibro.item.show();
|
||||
this.formatoPersonalizado.hide();
|
||||
this.formatoEstandar.removeClass('d-none');
|
||||
this.formatoPersonalizado.addClass('d-none');
|
||||
this.formValidation.revalidateField('papel_formato_ancho');
|
||||
this.formValidation.revalidateField('papel_formato_alto');
|
||||
}
|
||||
@ -495,6 +494,16 @@ class DatosGenerales {
|
||||
this.divPaginasCuaderillo.addClass('d-none');
|
||||
}
|
||||
|
||||
if (this.grapado.hasClass('selected') || this.espiral.hasClass('selected')) {
|
||||
$('#addSobrecubierta').prop('checked', false).trigger('change');
|
||||
$(".sobrecubierta-items").addClass('d-none');
|
||||
}
|
||||
else{
|
||||
if($('#addSobrecubierta').hasClass('d-none')){
|
||||
$('#addSobrecubierta').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
// Para recalcular el presupuesto
|
||||
element.trigger('change');
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ class Direcciones {
|
||||
|
||||
init() {
|
||||
|
||||
$("#clienteId").on('change', this.#handleChangeCliente.bind(this));
|
||||
$("#clienteId").on('change', this.handleChangeCliente.bind(this));
|
||||
|
||||
this.direccionesCliente.init();
|
||||
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() {
|
||||
|
||||
@ -248,7 +315,7 @@ class Direcciones {
|
||||
}
|
||||
|
||||
|
||||
#handleChangeCliente() {
|
||||
handleChangeCliente() {
|
||||
|
||||
this.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id })
|
||||
this.direccionesCliente.empty();
|
||||
|
||||
@ -25,9 +25,15 @@ class DisenioCubierta {
|
||||
this.divTamanioSolapas = this.domItem.find("#divTamanioSolapas");
|
||||
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.estucadoMate = this.domItem.find("#estucadoMate");
|
||||
|
||||
this.divPapelCubierta = this.domItem.find("#divPapelCubierta");
|
||||
|
||||
this.divGramajeCubierta = this.domItem.find("#divGramajeCubierta");
|
||||
this.gramaje = this.domItem.find(".check-gramaje-cubierta");
|
||||
this.gramaje170 = $(this.domItem.find("#divGramaje170Cubierta"));
|
||||
@ -38,8 +44,16 @@ class DisenioCubierta {
|
||||
|
||||
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.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.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.paginas).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() {
|
||||
|
||||
const stepper = this.validatorStepper;
|
||||
@ -356,13 +427,13 @@ class DisenioCubierta {
|
||||
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").text();
|
||||
guardas.papel = papelGuardas.split(' ')[0] + ' ' + papelGuardas.split(' ')[1];
|
||||
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 {
|
||||
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").val();
|
||||
guardas.papel = papelGuardas.split('_')[0];
|
||||
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;
|
||||
}
|
||||
@ -386,6 +457,7 @@ class DisenioCubierta {
|
||||
sobrecubierta.gramaje = papel.split(' ')[2];
|
||||
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
|
||||
sobrecubierta.plastificado = 'Plastificado ' + this.domItem.find("#plastificadoSobrecubierta").children("option:selected").text();
|
||||
return sobrecubierta;
|
||||
}
|
||||
else {
|
||||
let sobrecubierta = {};
|
||||
|
||||
@ -7,6 +7,9 @@ class DisenioInterior {
|
||||
this.validatorStepper = validatorStepper;
|
||||
|
||||
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.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() {
|
||||
|
||||
const stepper = this.validatorStepper;
|
||||
@ -324,8 +399,7 @@ class DisenioInterior {
|
||||
if (this.papelInterior.filter('.selected').length > 0) {
|
||||
|
||||
if (this.papelInterior_color.filter('.selected').length > 0) {
|
||||
if(forResumen)
|
||||
{
|
||||
if (forResumen) {
|
||||
return {
|
||||
negro: $(this.papelInterior.filter('.selected').find('.form-label')).text(),
|
||||
color: $(this.papelInterior_color.filter('.selected').find('.form-label')).text(),
|
||||
|
||||
@ -42,13 +42,12 @@ class PresupuestoCliente {
|
||||
() => { $('#loader').modal('hide'); });
|
||||
|
||||
this.actualizarTiradasEnvio = false;
|
||||
this.calcularPresupuesto = false;
|
||||
}
|
||||
|
||||
|
||||
init() {
|
||||
|
||||
this.RELLENAR_PRESUPUESTO(false);
|
||||
|
||||
// Fuerza el foco en el campo de búsqueda de select2
|
||||
$(document).on('select2:open', () => {
|
||||
document.querySelector('.select2-search__field').focus();
|
||||
@ -66,10 +65,8 @@ class PresupuestoCliente {
|
||||
this.btnPrev.on('click', this.#prevtStep.bind(this));
|
||||
this.btnSave.on('click', this.#savePresupuesto.bind(this));
|
||||
|
||||
//this.RELLENAR_PRESUPUESTO(true);
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
$(".calcular-presupuesto").on('change', ()=>{});
|
||||
|
||||
this.#cargarPresupuesto();
|
||||
const successMessage = sessionStorage.getItem('message');
|
||||
if (successMessage) {
|
||||
@ -78,14 +75,18 @@ class PresupuestoCliente {
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
this.calcularPresupuesto = true;
|
||||
}
|
||||
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
|
||||
}
|
||||
|
||||
|
||||
checkForm(event) {
|
||||
|
||||
if (this.calcularPresupuesto) {
|
||||
|
||||
if (event.target.id === 'divDirecciones') {
|
||||
if (!this.direcciones.calcularPresupuesto) {
|
||||
this.actualizarTiradasEnvio = false;
|
||||
@ -107,10 +108,15 @@ class PresupuestoCliente {
|
||||
if (datos_to_check.direcciones) {
|
||||
delete datos_to_check.direcciones;
|
||||
}
|
||||
if (datos_to_check.posPaginasColor) {
|
||||
delete datos_to_check.posPaginasColor;
|
||||
}
|
||||
|
||||
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
|
||||
try {
|
||||
setTimeout(function () {
|
||||
$('#loader').modal('show');
|
||||
}, 0);
|
||||
|
||||
// Si se está ejecutando la petición, abortar la petición anterior
|
||||
this.ajax_calcular.abort();
|
||||
@ -126,9 +132,11 @@ class PresupuestoCliente {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RELLENAR_PRESUPUESTO(finalizar) {
|
||||
|
||||
/*RELLENAR_PRESUPUESTO(finalizar) {
|
||||
|
||||
if (finalizar) {
|
||||
|
||||
@ -181,7 +189,7 @@ class PresupuestoCliente {
|
||||
else {
|
||||
$("#titulo").trigger('change');
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
stepperHandler() {
|
||||
@ -237,11 +245,15 @@ class PresupuestoCliente {
|
||||
{},
|
||||
(response) => {
|
||||
$('#loader').modal('hide');
|
||||
console.log(response);
|
||||
if (this.datos["confirmar"] || window.location.href.includes("add")) {
|
||||
if (response.status) {
|
||||
sessionStorage.setItem('message', response.message);
|
||||
window.location.href = response.url + '/' + response.status;
|
||||
}
|
||||
else {
|
||||
popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
popSuccessAlert(response.message);
|
||||
}
|
||||
@ -261,35 +273,49 @@ class PresupuestoCliente {
|
||||
|
||||
$('#loader').modal('hide');
|
||||
|
||||
if (Object.values(response.errors).some((value) => value !== "")) {
|
||||
if(response === null || response === undefined || response === ""){
|
||||
popErrorAlert("No se ha podido calcular el presupuesto para los datos proporcionados. Por favor, póngase en contacto con el departamento comercial."
|
||||
, "sk-alert-2", false);
|
||||
return;
|
||||
}
|
||||
if (Object.values(response.errors).some((value) => value !== "")) {
|
||||
if (response.errors.status == 1) {
|
||||
popErrorAlert("No se ha podido calcular el presupuesto para los datos proporcionados. Por favor, póngase en contacto con el departamento comercial."
|
||||
, "sk-alert-2", false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
popAlert2Hide();
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
for (let i = 0; i < response.tiradas.length; i++) {
|
||||
for (let i = 0; i < tiradas.length; i++) {
|
||||
new tarjetaTiradasPrecio(
|
||||
this.divTiradasPrecios,
|
||||
('precio-tiradas-' + response.tiradas[i]),
|
||||
response.tiradas[i],
|
||||
(parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2),
|
||||
tiradas[i],
|
||||
(parseFloat(response.precio_u[i]) * parseInt(tiradas[i])).toFixed(2),
|
||||
response.precio_u[i]
|
||||
);
|
||||
|
||||
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));
|
||||
setTimeout(() => {
|
||||
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
//console.log(response);
|
||||
}
|
||||
@ -344,6 +370,7 @@ class PresupuestoCliente {
|
||||
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
|
||||
|
||||
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
|
||||
prototipo: this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
|
||||
|
||||
isColor: this.datosGenerales.getIsColor() ? 1 : 0,
|
||||
isHq: this.disenioInterior.getIsHq() ? 1 : 0,
|
||||
@ -356,6 +383,7 @@ class PresupuestoCliente {
|
||||
|
||||
cubierta: {
|
||||
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
||||
lomoRedondo: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0,
|
||||
papelCubierta: this.disenioCubierta.getPapel(),
|
||||
gramajeCubierta: this.disenioCubierta.getGramaje(),
|
||||
cabezada: this.disenioCubierta.getCabezada(),
|
||||
@ -409,6 +437,9 @@ class PresupuestoCliente {
|
||||
this.datos.selectedTirada = this.direcciones.getSelectedTirada();
|
||||
}
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
this.datos["id"] = window.location.href.split("/").pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -420,20 +451,35 @@ class PresupuestoCliente {
|
||||
{},
|
||||
{},
|
||||
(response) => {
|
||||
|
||||
if (response.status === 1) {
|
||||
|
||||
this.lc.val(parseFloat(response.data.lc).toFixed(2));
|
||||
this.lsc.val(parseFloat(response.data.lsc).toFixed(2));
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
|
||||
this.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
/*this.disenioInterior.cargarDatos(response);
|
||||
this.disenioCubierta.cargarDatos(response);
|
||||
this.direcciones.cargarDatos(response);
|
||||
*/
|
||||
}
|
||||
console.log(response);
|
||||
this.direcciones.handleChangeCliente();
|
||||
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');
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
this.calcularPresupuesto = true;
|
||||
this.checkForm({ target: { id: 'tirada' } });
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
$('#loader').modal('hide');
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
this.calcularPresupuesto = true;
|
||||
}
|
||||
).get();
|
||||
}
|
||||
@ -444,7 +490,8 @@ class PresupuestoCliente {
|
||||
return false;
|
||||
}
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
return Object.values(value).every(isValid);
|
||||
const isValidData = Object.values(value).every(isValid);
|
||||
return isValidData;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import previewFormas from "../preview.js";
|
||||
|
||||
class Resumen {
|
||||
constructor(domItem, datosGenerales, disenioInterior, disenioCubierta, direcciones) {
|
||||
constructor(domItem, datosGenerales, disenioInterior, disenioCubierta) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
@ -39,25 +41,73 @@ class Resumen {
|
||||
this.divSobrecubierta = $(this.domItem.find("#divResumenSobrecubierta"));
|
||||
this.papelSobrecubierta = $(this.domItem.find("#resumenPapelSobrecubierta"));
|
||||
this.gramajeSobrecubierta = $(this.domItem.find("#resumenGramajeSobrecubierta"));
|
||||
this.solapasSobrecubierta = $(this.domItem.find("#resumenSolapasSobrecubierta"));
|
||||
this.plastificadoSobrecubierta = $(this.domItem.find("#resumenPlastificadoSobrecubierta"));
|
||||
this.solapasSobrecubierta = $(this.domItem.find("#resumenSolapaSobrecubierta"));
|
||||
this.plastificadoSobrecubierta = $(this.domItem.find("#resumenPlastificadoSobreCubierta"));
|
||||
|
||||
this.precio_unidad = $(this.domItem.find("#resumenPrecioU"));
|
||||
this.total_base = $(this.domItem.find("#resumenTotalBase"));
|
||||
this.iva_porcentaje = $(this.domItem.find("#resumenIvaPorcentaje"));
|
||||
this.iva = $(this.domItem.find("#resumenIva"));
|
||||
this.total = $(this.domItem.find("#resumenTotal"));
|
||||
|
||||
this.divPreview = $(this.domItem.find("#pv_ec_shape"));
|
||||
this.btnPreviewCubierta = $(this.domItem.find("#btnPreviewCubierta"));
|
||||
|
||||
this.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() {
|
||||
|
||||
this.titulo.text(this.datosGenerales.titulo.val());
|
||||
this.tipoLibro.text(this.#capitalizeFirstLetter(this.datosGenerales.tiposLibro.filter('.selected').attr('id')));
|
||||
|
||||
let ancho = 0, alto = 0;
|
||||
if (this.datosGenerales.checkFormatoPersonalizado.is(':checked')) {
|
||||
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());
|
||||
}
|
||||
|
||||
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.paginasColor.text(this.datosGenerales.paginasColor.val());
|
||||
this.paginasNegro.text(this.datosGenerales.paginasNegro.val());
|
||||
@ -100,7 +150,7 @@ class Resumen {
|
||||
this.itemsCubiertaTapaBlanda.addClass('d-none');
|
||||
const guardas = this.disenioCubierta.getGuardas(true);
|
||||
this.papelGuardas.text(guardas.papel + ' ' + guardas.gramaje);
|
||||
this.guardasImpresas.text(guardas.guardasImpresas);
|
||||
this.guardasImpresas.text(guardas.caras);
|
||||
this.cabezada.text(this.disenioCubierta.getCabezada(true));
|
||||
|
||||
}
|
||||
@ -109,7 +159,7 @@ class Resumen {
|
||||
this.cubiertaAcabados.text(this.disenioCubierta.getAcabados(true));
|
||||
|
||||
if (this.disenioCubierta.getSobrecubierta()) {
|
||||
this.divSobrecubierta.rempveClass('d-none');
|
||||
this.divSobrecubierta.removeClass('d-none');
|
||||
const sobrecubierta = this.disenioCubierta.getSobrecubierta(true);
|
||||
this.papelSobrecubierta.text(sobrecubierta.papel);
|
||||
this.gramajeSobrecubierta.text(sobrecubierta.gramaje);
|
||||
|
||||
1040
httpdocs/assets/js/safekat/pages/preview.js
Normal file
1040
httpdocs/assets/js/safekat/pages/preview.js
Normal file
File diff suppressed because it is too large
Load Diff
60181
xdebug.log
60181
xdebug.log
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user