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\PresupuestoModel;
|
||||||
use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
|
use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
|
||||||
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
|
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
|
||||||
|
use App\Models\Presupuestos\ErrorPresupuesto;
|
||||||
use App\Services\PresupuestoClienteService;
|
use App\Services\PresupuestoClienteService;
|
||||||
use App\Services\PresupuestoService;
|
use App\Services\PresupuestoService;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -100,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'] = [
|
||||||
@ -135,52 +137,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||||
$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;
|
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();
|
else{
|
||||||
$datosPresupuesto->paisList = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true);
|
$clienteId = $presupuestoEntity->cliente_id;
|
||||||
$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
|
||||||
@ -294,6 +261,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$modelPapelGenerico = new PapelGenericoModel();
|
$modelPapelGenerico = new PapelGenericoModel();
|
||||||
|
|
||||||
|
|
||||||
|
$id = $reqData['id'] ?? 0;
|
||||||
|
|
||||||
$cliente_id = $reqData['clienteId'] ?? -1;
|
$cliente_id = $reqData['clienteId'] ?? -1;
|
||||||
|
|
||||||
$tirada = $reqData['tirada'] ?? 0;
|
$tirada = $reqData['tirada'] ?? 0;
|
||||||
@ -320,6 +289,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']);
|
||||||
@ -348,6 +318,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
|
||||||
@ -366,12 +337,13 @@ 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;
|
||||||
|
|
||||||
$datos_presupuesto = array(
|
$datos_presupuesto = array(
|
||||||
|
'id' => $id,
|
||||||
'tirada' => $tirada,
|
'tirada' => $tirada,
|
||||||
'tamanio' => $tamanio,
|
'tamanio' => $tamanio,
|
||||||
'tipo_impresion_id' => $tipo_impresion_id,
|
'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
|
$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'] . ' - ' .
|
||||||
@ -411,8 +395,25 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
|
|
||||||
if (!property_exists($coste_direccion, 'coste')) {
|
if (!property_exists($coste_direccion, 'coste')) {
|
||||||
$return_data['errors']->envios = "No se ha podido calcular el coste de envío";
|
|
||||||
}else{
|
$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;
|
$coste_envio += $coste_direccion->coste;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -426,8 +427,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$coste_direccion = $this->getCosteEnvio(null, $return_data['peso'][$i], $tirada[$i], false)[0];
|
$coste_direccion = $this->getCosteEnvio(null, $return_data['peso'][$i], $tirada[$i], false)[0];
|
||||||
|
|
||||||
if (!property_exists($coste_direccion, 'coste')) {
|
if (!property_exists($coste_direccion, 'coste')) {
|
||||||
$return_data['errors']->envios = "No se ha podido calcular el coste de envío";
|
$errorModel = new ErrorPresupuesto();
|
||||||
}else{
|
$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;
|
$coste_envio += $coste_direccion->coste;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,6 +628,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$selected_tirada = $reqData['selectedTirada'] ?? 0;
|
$selected_tirada = $reqData['selectedTirada'] ?? 0;
|
||||||
$tamanio = $reqData['tamanio'];
|
$tamanio = $reqData['tamanio'];
|
||||||
$paginas = $reqData['paginas'] ?? 0;
|
$paginas = $reqData['paginas'] ?? 0;
|
||||||
|
$paginas_color = $reqData['paginasColor'] ?? 0;
|
||||||
|
|
||||||
$posPaginasColor = $reqData['posPaginasColor'] ?? "";
|
$posPaginasColor = $reqData['posPaginasColor'] ?? "";
|
||||||
$paginasColorConsecutivas = $reqData['pagColorConsecutivas'] ?? 0;
|
$paginasColorConsecutivas = $reqData['pagColorConsecutivas'] ?? 0;
|
||||||
@ -625,6 +642,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'] ?? [];
|
||||||
@ -653,9 +672,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
'gramaje' => $gramaje,
|
'gramaje' => $gramaje,
|
||||||
'excluirRotativa' => $excluirRotativa,
|
'excluirRotativa' => $excluirRotativa,
|
||||||
'paginas' => $paginas,
|
'paginas' => $paginas,
|
||||||
|
'paginas_color' => $paginas_color,
|
||||||
'pos_paginas_color' => $posPaginasColor,
|
'pos_paginas_color' => $posPaginasColor,
|
||||||
'paginas_color_consecutivas' => $paginasColorConsecutivas,
|
'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),
|
'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
|
||||||
@ -684,7 +706,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;
|
||||||
@ -817,6 +839,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,
|
||||||
@ -899,20 +923,21 @@ 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;
|
||||||
$data['datosGenerales']['clienteId'] = $presupuesto->cliente_id;
|
$data['datosGenerales']['clienteId'] = $presupuesto->cliente_id;
|
||||||
$data['datosGenerales']['clienteNombre'] = $modelCliente->getNombre($presupuesto->cliente_id);
|
$data['datosGenerales']['clienteNombre'] = $modelCliente->getNombre($presupuesto->cliente_id);
|
||||||
model('App\Models\Clientes\ClienteModel')
|
model('App\Models\Clientes\ClienteModel')
|
||||||
->find($presupuesto->cliente_id)->nombre;
|
->find($presupuesto->cliente_id)->nombre;
|
||||||
$data['datosGenerales']['papelFormatoId'] = $presupuesto->papel_formato_id;
|
$data['datosGenerales']['papelFormatoId'] = $presupuesto->papel_formato_id;
|
||||||
$data['datosGenerales']['papelFormatoNombre'] = $modelPapelFormato->getNombre($presupuesto->papel_formato_id);
|
$data['datosGenerales']['papelFormatoNombre'] = $modelPapelFormato->getNombre($presupuesto->papel_formato_id);
|
||||||
@ -920,29 +945,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();
|
||||||
@ -950,6 +980,14 @@ 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,
|
||||||
@ -1344,6 +1382,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;
|
||||||
@ -1354,15 +1393,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
// Servicios
|
// Servicios
|
||||||
$servicios = $datos_entrada['servicios'] ?? [];
|
$servicios = $datos_entrada['servicios'] ?? [];
|
||||||
|
|
||||||
$error = (object) [
|
|
||||||
'interior' => "",
|
|
||||||
'cubierta' => "",
|
|
||||||
'sobrecubierta' => "",
|
|
||||||
'guardas' => "",
|
|
||||||
'servicios' => "",
|
|
||||||
'serviciosDefecto' => "",
|
|
||||||
"envios" => "",
|
|
||||||
];
|
|
||||||
$coste_servicios = 0.0;
|
$coste_servicios = 0.0;
|
||||||
|
|
||||||
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
||||||
@ -1421,6 +1451,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$interior = PresupuestoClienteService::obtenerInterior($input_data);
|
$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;
|
$costeInterior = 0.0;
|
||||||
$peso_interior = 0.0;
|
$peso_interior = 0.0;
|
||||||
foreach ($interior as $linea) {
|
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
|
// Si es POD hay que volver a calcular para incluir la merma correcta
|
||||||
if ($tirada[$t] <= $POD) {
|
if ($tirada[$t] <= $POD) {
|
||||||
$num_formas = [];
|
$num_formas = [];
|
||||||
@ -1459,6 +1502,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$info['merma'] = max($info['merma'], $input_data['datosPedido']->merma);
|
$info['merma'] = max($info['merma'], $input_data['datosPedido']->merma);
|
||||||
}
|
}
|
||||||
$interior = PresupuestoClienteService::obtenerInterior($input_data);
|
$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;
|
$costeInterior = 0.0;
|
||||||
$peso_interior = 0.0;
|
$peso_interior = 0.0;
|
||||||
@ -1490,11 +1549,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($costeInterior <= 0)
|
if ($costeInterior <= 0) {
|
||||||
$error->interior = lang('Presupuestos.errores.noInterior');
|
|
||||||
else
|
|
||||||
$error->interior = "";
|
|
||||||
|
|
||||||
|
$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
|
// Cubierta
|
||||||
$input_data['papel_generico'] = $papel_generico_cubierta;
|
$input_data['papel_generico'] = $papel_generico_cubierta;
|
||||||
@ -1507,6 +1577,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;
|
||||||
@ -1527,11 +1598,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($coste_cubierta <= 0)
|
if ($coste_cubierta <= 0) {
|
||||||
$error->cubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta');
|
|
||||||
else
|
|
||||||
$error->cubierta = "";
|
|
||||||
|
|
||||||
|
$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
|
// Acabados Cubierta
|
||||||
$tarifaAcabadoCubierta = $this->obtenerTarifasAcabado($acabadosCubierta);
|
$tarifaAcabadoCubierta = $this->obtenerTarifasAcabado($acabadosCubierta);
|
||||||
$acabadoCubierta = [];
|
$acabadoCubierta = [];
|
||||||
@ -1543,8 +1625,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$acabadoCubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD);
|
$acabadoCubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD);
|
||||||
|
|
||||||
if (count($acabadoCubierta) > 0) {
|
if (count($acabadoCubierta) > 0) {
|
||||||
if ($acabadoCubierta[0]->total <= 0)
|
if ($acabadoCubierta[0]->total <= 0) {
|
||||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
|
||||||
|
$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);
|
$coste_servicios += floatval($acabadoCubierta[0]->total);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1586,11 +1683,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($coste_sobrecubierta <= 0)
|
if ($coste_sobrecubierta <= 0) {
|
||||||
$error->sobrecubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta');
|
|
||||||
else
|
|
||||||
$error->sobrecubierta = "";
|
|
||||||
|
|
||||||
|
$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']);
|
$lomo_sobrecubierta = $lomo + floatval($linea_sobrecubierta['mano']);
|
||||||
|
|
||||||
$tarifaAcabadoSobrecubierta = $this->obtenerTarifasAcabado(['plastificado' => $sobreCubierta['acabados']]);
|
$tarifaAcabadoSobrecubierta = $this->obtenerTarifasAcabado(['plastificado' => $sobreCubierta['acabados']]);
|
||||||
@ -1598,14 +1706,31 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
foreach ($tarifaAcabadoSobrecubierta as $tarifa) {
|
foreach ($tarifaAcabadoSobrecubierta as $tarifa) {
|
||||||
|
|
||||||
// NONE
|
// NONE
|
||||||
if($tarifaAcabadoSobrecubierta[0] == 0)
|
if ($tarifaAcabadoSobrecubierta[0] == 0)
|
||||||
continue;
|
continue;
|
||||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||||
$acabadoSobrecubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD);
|
$acabadoSobrecubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD);
|
||||||
|
|
||||||
if (count($acabadoSobrecubierta) > 0) {
|
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);
|
$coste_servicios += floatval($acabadoSobrecubierta[0]->total);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1656,10 +1781,21 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($coste_guardas <= 0)
|
if ($coste_guardas <= 0) {
|
||||||
$error->guardas = lang('Presupuestos.errores.noGuardas');
|
$errorModel = new ErrorPresupuesto();
|
||||||
else
|
$errorModel->insertError(
|
||||||
$error->guardas = "";
|
$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) {
|
if ($extra_info) {
|
||||||
@ -1683,8 +1819,24 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
]);
|
]);
|
||||||
$costeServiciosDefecto = 0.0;
|
$costeServiciosDefecto = 0.0;
|
||||||
foreach ($servDefecto as $servicio) {
|
foreach ($servDefecto as $servicio) {
|
||||||
if ($servicio->total <= 0)
|
if ($servicio->total <= 0) {
|
||||||
$error->serviciosDefecto = lang('Presupuestos.errores.errorPresupuesto');
|
|
||||||
|
$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);
|
$costeServiciosDefecto += floatval($servicio->total);
|
||||||
if ($extra_info) {
|
if ($extra_info) {
|
||||||
@ -1720,6 +1872,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
if ($datos_entrada['servicios']['prototipo'])
|
if ($datos_entrada['servicios']['prototipo'])
|
||||||
array_push($servicios, 9);
|
array_push($servicios, 9);
|
||||||
foreach ($servicios as $servicio) {
|
foreach ($servicios as $servicio) {
|
||||||
|
|
||||||
if (intval($servicio) == 3) {
|
if (intval($servicio) == 3) {
|
||||||
// Servicios acabado
|
// Servicios acabado
|
||||||
$resultado = PresupuestoCLienteService::getServiciosAcabados([
|
$resultado = PresupuestoCLienteService::getServiciosAcabados([
|
||||||
@ -1728,8 +1881,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
'POD' => $POD,
|
'POD' => $POD,
|
||||||
]);
|
]);
|
||||||
array_push($serviciosAutomaticos, $resultado[0]);
|
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);
|
$coste_servicios += floatval($resultado[0]->total);
|
||||||
if ($extra_info) {
|
if ($extra_info) {
|
||||||
@ -1742,8 +1910,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
'tarifa_id' => $servicio,
|
'tarifa_id' => $servicio,
|
||||||
]);
|
]);
|
||||||
array_push($serviciosAutomaticos, $resultado[0]);
|
array_push($serviciosAutomaticos, $resultado[0]);
|
||||||
if ($resultado[0]->precio <= 0)
|
if ($resultado[0]->precio <= 0) {
|
||||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
|
||||||
|
$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);
|
$coste_servicios += floatval($resultado[0]->precio);
|
||||||
if ($extra_info) {
|
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($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));
|
array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2));
|
||||||
foreach ($error as $err) {
|
|
||||||
if ($err != "")
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($extra_info) {
|
if ($extra_info) {
|
||||||
$totalServicios -= $margenServicios;
|
$totalServicios -= $margenServicios;
|
||||||
@ -1785,8 +1964,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$info['lomo_cubierta'] = $lomo;
|
$info['lomo_cubierta'] = round(floatval($lomo), 2);
|
||||||
$info['lomo_sobrecubierta'] = $lomo_sobrecubierta;
|
$info['lomo_sobrecubierta'] = round(floatval($lomo_sobrecubierta), 2);
|
||||||
$return_data['info'] = $info;
|
$return_data['info'] = $info;
|
||||||
|
|
||||||
|
|
||||||
@ -1802,7 +1981,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$return_data += [
|
$return_data += [
|
||||||
'errors' => $error,
|
'errors' => (object) ([
|
||||||
|
'status' => 0,
|
||||||
|
]),
|
||||||
//'total_lp' => $costeInterior + $coste_cubierta + $coste_sobrecubierta,
|
//'total_lp' => $costeInterior + $coste_cubierta + $coste_sobrecubierta,
|
||||||
//'acabadoCubierta' => $acabadoCubierta,
|
//'acabadoCubierta' => $acabadoCubierta,
|
||||||
//'acabadoSobrecubierta' => $acabadoSobrecubierta,
|
//'acabadoSobrecubierta' => $acabadoSobrecubierta,
|
||||||
@ -1818,6 +1999,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $return_data;
|
return $return_data;
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return [
|
return [
|
||||||
'exception' => $e->getMessage(),
|
'exception' => $e->getMessage(),
|
||||||
@ -1990,6 +2172,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)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -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 = 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,
|
||||||
@ -2093,49 +2288,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)
|
||||||
@ -2264,7 +2466,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function getPaginas($lineas){
|
private function getPaginas($lineas)
|
||||||
|
{
|
||||||
|
|
||||||
$paginasNegro = 0;
|
$paginasNegro = 0;
|
||||||
$paginasColor = 0;
|
$paginasColor = 0;
|
||||||
@ -2290,4 +2493,5 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
return [$paginasNegro, $paginasColor];
|
return [$paginasNegro, $paginasColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,6 +92,9 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"is_duplicado" => false,
|
"is_duplicado" => false,
|
||||||
'paginas_color_consecutivas' => null,
|
'paginas_color_consecutivas' => null,
|
||||||
'papel_interior_diferente' => null,
|
'papel_interior_diferente' => null,
|
||||||
|
'paginasCuadernillo' => null,
|
||||||
|
'lomo_redondo' => null,
|
||||||
|
'cabezada' => null,
|
||||||
];
|
];
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
"cliente_id" => "int",
|
"cliente_id" => "int",
|
||||||
@ -159,5 +162,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"is_duplicado" => "boolean",
|
"is_duplicado" => "boolean",
|
||||||
'paginas_color_consecutivas' => "boolean",
|
'paginas_color_consecutivas' => "boolean",
|
||||||
'papel_interior_diferente' => "boolean",
|
'papel_interior_diferente' => "boolean",
|
||||||
|
'paginasCuadernillo' => "int",
|
||||||
|
'lomo_redondo' => "boolean",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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 "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,6 +129,9 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
"is_duplicado",
|
"is_duplicado",
|
||||||
'paginas_color_consecutivas',
|
'paginas_color_consecutivas',
|
||||||
'papel_interior_diferente',
|
'papel_interior_diferente',
|
||||||
|
'paginasCuadernillo',
|
||||||
|
'lomo_redondo',
|
||||||
|
'cabezada',
|
||||||
];
|
];
|
||||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
|
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
|
||||||
|
|
||||||
@ -406,16 +409,21 @@ 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,
|
||||||
'papel_formato_alto' => !$papel_formato_id ? $data['tamanio']['alto'] : null,
|
'papel_formato_alto' => !$papel_formato_id ? $data['tamanio']['alto'] : null,
|
||||||
'titulo' => $data_cabecera['titulo'],
|
'titulo' => $data_cabecera['titulo'],
|
||||||
|
'autor' => $data_cabecera['autor'],
|
||||||
|
'ISBN' => $data_cabecera['isbn'],
|
||||||
|
'coleccion' => $data_cabecera['coleccion'],
|
||||||
'referencia_cliente' => $data_cabecera['referenciaCliente'],
|
'referencia_cliente' => $data_cabecera['referenciaCliente'],
|
||||||
'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'],
|
||||||
@ -424,9 +432,9 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
'merma_cubierta' => $extra_info['merma'],
|
'merma_cubierta' => $extra_info['merma'],
|
||||||
'paginasCuadernillo' => $data['paginasCuadernillo'],
|
'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'],
|
'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_cubierta' => $extra_info['lomo_cubierta'],
|
||||||
'lomo_sobrecubierta' => $extra_info['lomo_sobrecubierta'],
|
'lomo_sobrecubierta' => $extra_info['lomo_sobrecubierta'],
|
||||||
@ -495,29 +503,45 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
// -- INTERIOR --
|
// -- INTERIOR --
|
||||||
// Si hay negro
|
// Si hay negro
|
||||||
if ($data['interior']['paginas'] > $data['interior']['paginas_color']) {
|
if (intval($data['interior']['paginas']) > intval($data['interior']['paginas_color'])) {
|
||||||
|
|
||||||
if ($data['isHq'])
|
if ($data['isHq'])
|
||||||
$key = 'bnhq';
|
$key = 'bnhq';
|
||||||
else
|
else
|
||||||
$key = 'bn';
|
$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(
|
$values[$key] = array(
|
||||||
'paginas' => intval($data['interior']['paginas']) - intval($data['interior']['paginas_color']),
|
'paginas' => intval($data['interior']['paginas']) - intval(intval($data['interior']['paginas_color'])),
|
||||||
'papel_id' => intval($data['interior']['papel_generico']['id']),
|
'papel_id' => $papel_id,
|
||||||
'gramaje' => intval($data['interior']['gramaje']),
|
'gramaje' => $gramaje,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Si hay color
|
// Si hay color
|
||||||
if ($data['interior']['paginas_color'] > 0) {
|
if (intval($data['interior']['paginas_color']) > 0) {
|
||||||
|
|
||||||
if ($data['isHq'])
|
if ($data['isHq'])
|
||||||
$key = 'colorhq';
|
$key = 'colorhq';
|
||||||
else
|
else
|
||||||
$key = 'color';
|
$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(
|
$values[$key] = array(
|
||||||
'paginas' => intval($data['interior']['paginas_color']),
|
'paginas' => intval(intval($data['interior']['paginas_color'])),
|
||||||
'papel_id' => intval($data['interior']['papel_generico']['id']),
|
'papel_id' => $papel_id,
|
||||||
'gramaje' => intval($data['interior']['gramaje']),
|
'gramaje' => $gramaje,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,7 +579,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS numero, t1.tipo_impresion_id as tipo, t1.tirada AS unidades, t1.total_aceptado as total, t1.paginas AS paginas,
|
"t1.id AS numero, t1.tipo_impresion_id as tipo, t1.tirada AS unidades, t1.total_aceptado as total, t1.paginas AS paginas,
|
||||||
t1.titulo AS titulo, t1.autor AS autor, t1.isbn AS isbn,
|
t1.titulo AS titulo, t1.autor AS autor, t1.isbn AS isbn,
|
||||||
t1.papel_formato_id AS papel_formato_id, t1.papel_formato_personalizado AS papel_formato_personalizado,
|
t1.papel_formato_id AS papel_formato_id, t1.papel_formato_personalizado AS papel_formato_personalizado,
|
||||||
t1.papel_formato_ancho AS papel_formato_ancho, t1.papel_formato_alto AS papel_formato_alto,
|
t1.papel_formato_ancho AS papel_formato_ancho, t1.papel_formato_alto AS papel_formato_alto,
|
||||||
@ -563,7 +587,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
t3.codigo AS codigo_encuadernacion,
|
t3.codigo AS codigo_encuadernacion,
|
||||||
t1.solapas AS solapas_cubierta, CAST(t1.solapas_ancho AS INT) AS solapas_ancho_cubierta,
|
t1.solapas AS solapas_cubierta, CAST(t1.solapas_ancho AS INT) AS solapas_ancho_cubierta,
|
||||||
t1.solapas_sobrecubierta AS solapas_sobrecubierta, CAST(t1.solapas_ancho_sobrecubierta AS INT) AS solapas_ancho_sobrecubierta,"
|
t1.solapas_sobrecubierta AS solapas_sobrecubierta, CAST(t1.solapas_ancho_sobrecubierta AS INT) AS solapas_ancho_sobrecubierta,"
|
||||||
);
|
);
|
||||||
$builder->join("lg_papel_formato t2", "t1.papel_formato_id = t2.id", "left");
|
$builder->join("lg_papel_formato t2", "t1.papel_formato_id = t2.id", "left");
|
||||||
$builder->join("tipos_presupuestos t3", "t1.tipo_impresion_id = t3.id", "left");
|
$builder->join("tipos_presupuestos t3", "t1.tipo_impresion_id = t3.id", "left");
|
||||||
$builder->where("t1.is_deleted", 0);
|
$builder->where("t1.is_deleted", 0);
|
||||||
|
|||||||
@ -116,7 +116,8 @@ 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")
|
||||||
@ -135,13 +136,13 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
|
|||||||
$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
|
||||||
@ -186,4 +187,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 "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,8 +25,13 @@ class PresupuestoClienteService extends BaseService
|
|||||||
$total_plana = -1;
|
$total_plana = -1;
|
||||||
$hay_plana = false;
|
$hay_plana = false;
|
||||||
if ($data['isColor']) {
|
if ($data['isColor']) {
|
||||||
if ($data['datosPedido']->paginas == $data['paginas_color'])
|
if ($data['datosPedido']->paginas == $data['paginas_color']){
|
||||||
$total_plana += floatval($plana[1]['total_impresion']);
|
if(count($plana[1]) > 2)
|
||||||
|
$total_plana += floatval($plana[1]['total_impresion']);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
elseif (count($plana) > 0) {
|
elseif (count($plana) > 0) {
|
||||||
if (count($plana[0]) > 2 && count($plana[1]) > 2) {
|
if (count($plana[0]) > 2 && count($plana[1]) > 2) {
|
||||||
$total_plana = 0.0;
|
$total_plana = 0.0;
|
||||||
@ -72,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 = [];
|
||||||
|
|
||||||
@ -86,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) {
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
<label for="autor" class="form-label">
|
<label for="autor" class="form-label">
|
||||||
<?= lang('Presupuestos.autor') ?>
|
<?= lang('Presupuestos.autor') ?>
|
||||||
</label>
|
</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>
|
||||||
|
|
||||||
<div class="row justify-content-center">
|
<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-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>
|
||||||
|
|||||||
@ -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>
|
||||||
|
|
||||||
@ -127,7 +127,7 @@
|
|||||||
<label for="cabezada" class="form-label">
|
<label for="cabezada" class="form-label">
|
||||||
<?= lang('Presupuestos.cabezada') ?>
|
<?= lang('Presupuestos.cabezada') ?>
|
||||||
</label>
|
</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="WHI"><?= lang('Presupuestos.blanca') ?></option>
|
||||||
<option value="GRE"><?= lang('Presupuestos.verde') ?></option>
|
<option value="GRE"><?= lang('Presupuestos.verde') ?></option>
|
||||||
<option value="BLUE"><?= lang('Presupuestos.azul') ?></option>
|
<option value="BLUE"><?= lang('Presupuestos.azul') ?></option>
|
||||||
@ -306,7 +306,7 @@
|
|||||||
|
|
||||||
<div class="row justify-content-center">
|
<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">
|
<div class="form-check form-switch mb-2">
|
||||||
<input class="calcular-presupuesto form-check-input" type="checkbox" id="addSobrecubierta"
|
<input class="calcular-presupuesto form-check-input" type="checkbox" id="addSobrecubierta"
|
||||||
name="add_sobrecubierta" value="1">
|
name="add_sobrecubierta" value="1">
|
||||||
@ -315,7 +315,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</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">
|
<label for="papelSobrecubierta" class="form-label">
|
||||||
<?= lang('Presupuestos.papelSobrecubierta') ?>
|
<?= lang('Presupuestos.papelSobrecubierta') ?>
|
||||||
</label>
|
</label>
|
||||||
@ -326,7 +326,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</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">
|
<label for="solapasSobrecubierta" class="form-label">
|
||||||
<?= lang('Presupuestos.tamanioSolapasSobrecubierta') ?>
|
<?= lang('Presupuestos.tamanioSolapasSobrecubierta') ?>
|
||||||
</label>
|
</label>
|
||||||
@ -338,7 +338,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</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">
|
<label for="plastificadoSobrecubierta" class="form-label">
|
||||||
<?= lang('Presupuestos.plastificadoSobrecubierta') ?>
|
<?= lang('Presupuestos.plastificadoSobrecubierta') ?>
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@ -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">
|
||||||
|
|||||||
@ -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() ?>
|
||||||
@ -48,30 +48,30 @@ if (auth()->user()->can('presupuesto.menu')) {
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<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") ?>
|
<?= lang("App.menu_libros_grapados") ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<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") ?>
|
<?= lang("App.menu_libros_espiral_tapa_dura") ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="<?= site_url("presupuestos/espiraltapablanda") ?>"
|
<a href="<?= site_url("presupuestos/cosidotapablanda/list/6") ?>"
|
||||||
class="menu-link">
|
class="menu-link">
|
||||||
<?= lang("App.menu_libros_espiral_tapa_blanda") ?>
|
<?= lang("App.menu_libros_espiral_tapa_blanda") ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="menu-item">
|
<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") ?>
|
<?= lang("App.menu_libros_wireo_tapa_dura") ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<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") ?>
|
<?= lang("App.menu_libros_wireo_tapa_blanda") ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@ -9,7 +9,7 @@ class ErrorPresupuestoView {
|
|||||||
{ data: 'lastUser', searchable: true, sortable: false },
|
{ data: 'lastUser', searchable: true, sortable: false },
|
||||||
{ data: 'visto', searchable: false, sortable: false ,
|
{ data: 'visto', searchable: false, sortable: false ,
|
||||||
render : (d,t) => {
|
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>`
|
return `<span class="${iconClass}"</span>`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -27,11 +27,14 @@ 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");
|
||||||
|
|
||||||
this.fresado = $(this.domItem.find("#fresado")[0]);
|
this.fresado = $(this.domItem.find("#fresado")[0]);
|
||||||
this.cosido = $(this.domItem.find("#cosido")[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");
|
this.tiposLibro = this.domItem.find(".tipo-libro");
|
||||||
|
|
||||||
@ -346,6 +349,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));
|
||||||
@ -354,52 +365,40 @@ class DatosGenerales {
|
|||||||
if (datos.tirada4)
|
if (datos.tirada4)
|
||||||
this.tirada4.val(parseInt(datos.tirada4));
|
this.tirada4.val(parseInt(datos.tirada4));
|
||||||
|
|
||||||
if (datos.checkFormatoPersonalizado) {
|
if (datos.papelFormatoPersonalizado) {
|
||||||
this.checkFormatoPersonalizado.prop(':checked', datos.checkFormatoPersonalizado);
|
this.checkFormatoPersonalizado.prop('checked', true);
|
||||||
this.checkFormatoPersonalizado.trigger('change');
|
this.formatoEstandar.addClass('d-none');
|
||||||
this.papel_formato_alto.val(datos.papelFormatoAlto);
|
this.formatoPersonalizado.removeClass('d-none');
|
||||||
this.papel_formato_ancho.val(datos.papelFormatoAncho);
|
this.formValidation.revalidateField('papel_formato_id');
|
||||||
|
this.altoPersonalizado.val(datos.papelFormatoAlto);
|
||||||
|
this.anchoPersonalizado.val(datos.papelFormatoAncho);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.formatoLibro.setOption(datos.papelFormatoId, datos.papelFormatoNombre);
|
this.formatoLibro.setOption(datos.papelFormatoId, datos.papelFormatoNombre);
|
||||||
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");
|
if (datos.tipo != "") {
|
||||||
this.checkFormatoPersonalizado = this.domItem.find("#papelFormatoPersonalizado");
|
this.tiposLibro.removeClass('selected');
|
||||||
this.formatoPersonalizado = this.domItem.find("#formatoPersonalizado");
|
this.tiposLibro.find('.image-presupuesto').removeClass('selected');
|
||||||
this.anchoPersonalizado = this.domItem.find("#papelFormatoAncho");
|
this.domItem.find('#' + datos.tipo).addClass('selected');
|
||||||
this.altoPersonalizado = this.domItem.find("#papelFormatoAlto");
|
}
|
||||||
|
|
||||||
this.fresado = $(this.domItem.find("#fresado")[0]);
|
this.prototipo.prop('checked', datos.prototipo);
|
||||||
this.cosido = $(this.domItem.find("#cosido")[0]);
|
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
|
||||||
|
|
||||||
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");*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDimensionLibro() {
|
getDimensionLibro() {
|
||||||
@ -452,13 +451,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');
|
||||||
}
|
}
|
||||||
@ -495,6 +494,16 @@ class DatosGenerales {
|
|||||||
this.divPaginasCuaderillo.addClass('d-none');
|
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
|
// Para recalcular el presupuesto
|
||||||
element.trigger('change');
|
element.trigger('change');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -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.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() {
|
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;
|
||||||
}
|
}
|
||||||
@ -386,6 +457,7 @@ class DisenioCubierta {
|
|||||||
sobrecubierta.gramaje = papel.split(' ')[2];
|
sobrecubierta.gramaje = papel.split(' ')[2];
|
||||||
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
|
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
|
||||||
sobrecubierta.plastificado = 'Plastificado ' + this.domItem.find("#plastificadoSobrecubierta").children("option:selected").text();
|
sobrecubierta.plastificado = 'Plastificado ' + this.domItem.find("#plastificadoSobrecubierta").children("option:selected").text();
|
||||||
|
return sobrecubierta;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let sobrecubierta = {};
|
let sobrecubierta = {};
|
||||||
|
|||||||
@ -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;
|
||||||
@ -324,14 +399,13 @@ 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')
|
||||||
@ -339,11 +413,11 @@ class DisenioInterior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
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')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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,7 +445,7 @@ 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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,13 +42,12 @@ class PresupuestoCliente {
|
|||||||
() => { $('#loader').modal('hide'); });
|
() => { $('#loader').modal('hide'); });
|
||||||
|
|
||||||
this.actualizarTiradasEnvio = false;
|
this.actualizarTiradasEnvio = false;
|
||||||
|
this.calcularPresupuesto = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
|
||||||
this.RELLENAR_PRESUPUESTO(false);
|
|
||||||
|
|
||||||
// Fuerza el foco en el campo de búsqueda de select2
|
// Fuerza el foco en el campo de búsqueda de select2
|
||||||
$(document).on('select2:open', () => {
|
$(document).on('select2:open', () => {
|
||||||
document.querySelector('.select2-search__field').focus();
|
document.querySelector('.select2-search__field').focus();
|
||||||
@ -66,10 +65,8 @@ class PresupuestoCliente {
|
|||||||
this.btnPrev.on('click', this.#prevtStep.bind(this));
|
this.btnPrev.on('click', this.#prevtStep.bind(this));
|
||||||
this.btnSave.on('click', this.#savePresupuesto.bind(this));
|
this.btnSave.on('click', this.#savePresupuesto.bind(this));
|
||||||
|
|
||||||
//this.RELLENAR_PRESUPUESTO(true);
|
|
||||||
|
|
||||||
if (window.location.href.includes("edit")) {
|
if (window.location.href.includes("edit")) {
|
||||||
$(".calcular-presupuesto").on('change', ()=>{});
|
|
||||||
this.#cargarPresupuesto();
|
this.#cargarPresupuesto();
|
||||||
const successMessage = sessionStorage.getItem('message');
|
const successMessage = sessionStorage.getItem('message');
|
||||||
if (successMessage) {
|
if (successMessage) {
|
||||||
@ -77,58 +74,69 @@ class PresupuestoCliente {
|
|||||||
sessionStorage.removeItem('message');
|
sessionStorage.removeItem('message');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
this.calcularPresupuesto = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
checkForm(event) {
|
checkForm(event) {
|
||||||
|
|
||||||
if (event.target.id === 'divDirecciones') {
|
if (this.calcularPresupuesto) {
|
||||||
if (!this.direcciones.calcularPresupuesto) {
|
|
||||||
this.actualizarTiradasEnvio = false;
|
if (event.target.id === 'divDirecciones') {
|
||||||
$('#loader').modal('hide');
|
if (!this.direcciones.calcularPresupuesto) {
|
||||||
return;
|
this.actualizarTiradasEnvio = false;
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.actualizarTiradasEnvio = true;
|
||||||
|
this.direcciones.divTiradas.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
this.#getDatos();
|
||||||
else {
|
|
||||||
this.actualizarTiradasEnvio = true;
|
|
||||||
this.direcciones.divTiradas.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.#getDatos();
|
this.divTiradasPrecios.empty();
|
||||||
|
|
||||||
this.divTiradasPrecios.empty();
|
let datos_to_check = { ...this.datos };
|
||||||
|
if (datos_to_check.direcciones) {
|
||||||
let datos_to_check = { ...this.datos };
|
delete datos_to_check.direcciones;
|
||||||
if (datos_to_check.direcciones) {
|
|
||||||
delete datos_to_check.direcciones;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
|
|
||||||
try {
|
|
||||||
$('#loader').modal('show');
|
|
||||||
|
|
||||||
// Si se está ejecutando la petición, abortar la petición anterior
|
|
||||||
this.ajax_calcular.abort();
|
|
||||||
|
|
||||||
this.ajax_calcular.setData(this.datos);
|
|
||||||
this.ajax_calcular.post();
|
|
||||||
this.direcciones.calcularPresupuesto = false;
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
if (datos_to_check.posPaginasColor) {
|
||||||
console.log(e);
|
delete datos_to_check.posPaginasColor;
|
||||||
$('#loader').modal('hide');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
this.ajax_calcular.setData(this.datos);
|
||||||
|
this.ajax_calcular.post();
|
||||||
|
this.direcciones.calcularPresupuesto = false;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RELLENAR_PRESUPUESTO(finalizar) {
|
|
||||||
|
/*RELLENAR_PRESUPUESTO(finalizar) {
|
||||||
|
|
||||||
if (finalizar) {
|
if (finalizar) {
|
||||||
|
|
||||||
@ -181,7 +189,7 @@ class PresupuestoCliente {
|
|||||||
else {
|
else {
|
||||||
$("#titulo").trigger('change');
|
$("#titulo").trigger('change');
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
stepperHandler() {
|
stepperHandler() {
|
||||||
@ -237,10 +245,14 @@ 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")) {
|
||||||
sessionStorage.setItem('message', response.message);
|
if (response.status) {
|
||||||
window.location.href = response.url + '/' + 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 {
|
else {
|
||||||
popSuccessAlert(response.message);
|
popSuccessAlert(response.message);
|
||||||
@ -261,35 +273,49 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
$('#loader').modal('hide');
|
$('#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."
|
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);
|
, "sk-alert-2", false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else{
|
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();
|
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);
|
||||||
}
|
}
|
||||||
@ -344,6 +370,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,
|
||||||
@ -356,6 +383,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(),
|
||||||
@ -409,6 +437,9 @@ class PresupuestoCliente {
|
|||||||
this.datos.selectedTirada = this.direcciones.getSelectedTirada();
|
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) => {
|
(response) => {
|
||||||
|
|
||||||
if (response.status === 1) {
|
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.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||||
/*this.disenioInterior.cargarDatos(response);
|
this.direcciones.handleChangeCliente();
|
||||||
this.disenioCubierta.cargarDatos(response);
|
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||||
this.direcciones.cargarDatos(response);
|
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');
|
||||||
|
this.calcularPresupuesto = true;
|
||||||
|
this.checkForm({ target: { id: 'tirada' } });
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
console.log(response);
|
|
||||||
$('#loader').modal('hide');
|
|
||||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
$('#loader').modal('hide');
|
$('#loader').modal('hide');
|
||||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
this.calcularPresupuesto = true;
|
||||||
}
|
}
|
||||||
).get();
|
).get();
|
||||||
}
|
}
|
||||||
@ -444,7 +490,8 @@ class PresupuestoCliente {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (typeof value === 'object' && value !== null) {
|
if (typeof value === 'object' && value !== null) {
|
||||||
return Object.values(value).every(isValid);
|
const isValidData = Object.values(value).every(isValid);
|
||||||
|
return isValidData;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,25 +41,73 @@ 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() {
|
||||||
|
|
||||||
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')));
|
||||||
this.formato.text(this.datosGenerales.papelFormatoId.find('option:selected').text());
|
|
||||||
|
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.paginas.text(this.datosGenerales.paginas.val());
|
||||||
this.paginasColor.text(this.datosGenerales.paginasColor.val());
|
this.paginasColor.text(this.datosGenerales.paginasColor.val());
|
||||||
this.paginasNegro.text(this.datosGenerales.paginasNegro.val());
|
this.paginasNegro.text(this.datosGenerales.paginasNegro.val());
|
||||||
@ -93,14 +143,14 @@ class Resumen {
|
|||||||
this.itemsCubiertaTapaBlanda.removeClass('d-none');
|
this.itemsCubiertaTapaBlanda.removeClass('d-none');
|
||||||
this.itemsCubiertaTapaDura.addClass('d-none');
|
this.itemsCubiertaTapaDura.addClass('d-none');
|
||||||
const solapasCubierta = this.disenioCubierta.getSolapasCubierta();
|
const solapasCubierta = this.disenioCubierta.getSolapasCubierta();
|
||||||
this.solapasCubierta.text( solapasCubierta == false ? 'No' : solapasCubierta);
|
this.solapasCubierta.text(solapasCubierta == false ? 'No' : solapasCubierta);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.itemsCubiertaTapaDura.removeClass('d-none');
|
this.itemsCubiertaTapaDura.removeClass('d-none');
|
||||||
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -109,7 +159,7 @@ class Resumen {
|
|||||||
this.cubiertaAcabados.text(this.disenioCubierta.getAcabados(true));
|
this.cubiertaAcabados.text(this.disenioCubierta.getAcabados(true));
|
||||||
|
|
||||||
if (this.disenioCubierta.getSobrecubierta()) {
|
if (this.disenioCubierta.getSobrecubierta()) {
|
||||||
this.divSobrecubierta.rempveClass('d-none');
|
this.divSobrecubierta.removeClass('d-none');
|
||||||
const sobrecubierta = this.disenioCubierta.getSobrecubierta(true);
|
const sobrecubierta = this.disenioCubierta.getSobrecubierta(true);
|
||||||
this.papelSobrecubierta.text(sobrecubierta.papel);
|
this.papelSobrecubierta.text(sobrecubierta.papel);
|
||||||
this.gramajeSobrecubierta.text(sobrecubierta.gramaje);
|
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