trabajando en el backend

This commit is contained in:
2024-10-13 21:10:02 +02:00
parent e64022a7b7
commit 0eaac5af28
32 changed files with 1196 additions and 4746 deletions

View File

@ -407,6 +407,7 @@ $routes->group('clienteusuarios', ['namespace' => 'App\Controllers\Clientes'], f
$routes->group('misdirecciones', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
$routes->get('', 'Clientedirecciones::index', ['as' => 'clientedireccionesIndex']);
$routes->get('get/(:num)', 'Clientedirecciones::get/$1', ['as' => 'get']);
});
@ -575,6 +576,7 @@ $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuest
$routes->post('getNuevaDireccion', 'Presupuestocliente::getNuevaDireccion', ['as' => 'nuevaDireccion']);
$routes->post('guardarPresupuesto', 'Presupuestocliente::guardarPresupuesto', ['as' => 'guardarPresupuesto']);
$routes->post('duplicarPresupuesto', 'Presupuestocliente::duplicarPresupuesto', ['as' => 'duplicarPresupuesto']);
$routes->post('calcular', 'Presupuestocliente::calcular', ['as' => 'calcularPresupuesto']);
});
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);

View File

@ -1,4 +1,6 @@
<?php namespace App\Controllers\Clientes;
<?php
namespace App\Controllers\Clientes;
use App\Models\Collection;
@ -38,7 +40,7 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
// Breadcrumbs (IMN)
$this->viewData['breadcrumb'] = [
['title' => lang("Clientes.direccionesEnvio"), 'route' => "javascript:void(0);", 'active' => false],
];
$this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null);
@ -71,9 +73,10 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
return view(static::$viewPath . 'viewClienteDireccionesList', $viewData);
}
public function add(){
public function add()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$cliente_id = $reqData['cliente_id'] ?? -1;
$att = $reqData['att'] ?? "";
@ -85,7 +88,7 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
$cp = $reqData['cp'] ?? "";
$telefono = $reqData['telefono'] ?? "";
$alias = $reqData['alias'] ?? "";
$data = [
"cliente_id" => $cliente_id,
"att" => $att,
@ -99,7 +102,7 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
"alias" => $alias,
];
$response = $this->model->insert($data);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data_ret = [
@ -107,7 +110,6 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
$csrfTokenName => $newTokenHash
];
return $this->respond($data_ret);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
@ -117,14 +119,14 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
public function menuItems()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$cliente_id = $reqData['cliente_id'] ?? -1;
$clienteDireccionesModel = model('App\Models\Clientes\ClienteDireccionesModel');
$menu = $clienteDireccionesModel->getMenuDirecciones($cliente_id);
//$menu = $this->model->getMenuItems($cliente_id);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
@ -145,7 +147,7 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
$tipo = $reqData['tipo'] ?? null;
if(is_null($tipo)){
if (is_null($tipo)) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
@ -160,22 +162,21 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
$id_C = $reqData['cliente_id'] ?? -1;
$resourceData = $this->model->getResource($search, $id_C)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
return $this->respond(Collection::datatable(
$resourceData,
$this->model->getResource()->countAllResults(),
$this->model->getResource("", $id_C)->countAllResults()
));
}
else{
} else {
$id = $reqData['id'] ?? -1;
$resourceData = $this->model->getDireccion($id);
return $this->respond($resourceData);
}
@ -184,6 +185,25 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
}
}
public function get($id)
{
try {
$resourceData = $this->model->getDireccion($id);
$response = (object)[
'error' => false,
'data' => $resourceData
];
return $this->respond($response);
} catch (\Exception $e) {
$response = (object)[
'error' => true,
'message' => $e->getMessage()
];
return $this->fail($response);
}
}
public function datatable_editor()
{
if ($this->request->isAJAX()) {
@ -194,72 +214,116 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
$response = Editor::inst($db, 'cliente_direcciones')
->fields(
Field::inst('att')
->validator('Validate::notEmpty', array(
'message' => lang('ClienteDirecciones.validation.required'))
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClienteDirecciones.validation.required')
)
)
->validator( Validate::maxLen( 100 ) , array(
'message' => lang('ClienteDirecciones.validation.max_length'))
),
->validator(
Validate::maxLen(100),
array(
'message' => lang('ClienteDirecciones.validation.max_length')
)
),
Field::inst('alias')
->validator('Validate::notEmpty', array(
'message' => lang('ClienteDirecciones.validation.required'))
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClienteDirecciones.validation.required')
)
)
->validator( Validate::maxLen( 100 ) , array(
'message' => lang('ClienteDirecciones.validation.max_length'))
),
->validator(
Validate::maxLen(100),
array(
'message' => lang('ClienteDirecciones.validation.max_length')
)
),
Field::inst('email')
->validator('Validate::notEmpty', array(
'message' => lang('ClienteDirecciones.validation.required'))
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClienteDirecciones.validation.required')
)
)
->validator( Validate::maxLen( 100 ) , array(
'message' => lang('ClienteDirecciones.validation.max_length'))
),
->validator(
Validate::maxLen(100),
array(
'message' => lang('ClienteDirecciones.validation.max_length')
)
),
Field::inst('direccion')
->validator('Validate::notEmpty', array(
'message' => lang('ClienteDirecciones.validation.required'))
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClienteDirecciones.validation.required')
)
)
->validator( Validate::maxLen( 255 ) , array(
'message' => lang('ClienteDirecciones.validation.max_length'))
),
->validator(
Validate::maxLen(255),
array(
'message' => lang('ClienteDirecciones.validation.max_length')
)
),
Field::inst('municipio')
->validator('Validate::notEmpty', array(
'message' => lang('ClienteDirecciones.validation.required'))
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClienteDirecciones.validation.required')
)
)
->validator( Validate::maxLen( 100 ) , array(
'message' => lang('ClienteDirecciones.validation.max_length'))
),
->validator(
Validate::maxLen(100),
array(
'message' => lang('ClienteDirecciones.validation.max_length')
)
),
Field::inst('cp')
->validator('Validate::notEmpty', array(
'message' => lang('ClienteDirecciones.validation.required'))
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClienteDirecciones.validation.required')
)
)
->validator( Validate::maxLen( 20 ) , array(
'message' => lang('ClienteDirecciones.validation.max_length'))
),
->validator(
Validate::maxLen(20),
array(
'message' => lang('ClienteDirecciones.validation.max_length')
)
),
Field::inst('telefono')
->validator('Validate::notEmpty', array(
'message' => lang('ClienteDirecciones.validation.required'))
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClienteDirecciones.validation.required')
)
)
->validator( Validate::maxLen( 40 ) , array(
'message' => lang('ClienteDirecciones.validation.max_length'))
),
->validator(
Validate::maxLen(40),
array(
'message' => lang('ClienteDirecciones.validation.max_length')
)
),
Field::inst('provincia')
->validator( function ( $val, $data, $field, $host ) {
if ($data['pais_id'] == 1) { // Si es españa provincia y CCAA es obligatorio
if (strlen( $val ) > 100)
return lang('ClienteDirecciones.validation.max_length');
else if (strlen( $val ) == 0)
lang('ClienteDirecciones.validation.required');
else
return true;
->validator(
function ($val, $data, $field, $host) {
if ($data['pais_id'] == 1) { // Si es españa provincia y CCAA es obligatorio
if (strlen($val) > 100)
return lang('ClienteDirecciones.validation.max_length');
else if (strlen($val) == 0)
lang('ClienteDirecciones.validation.required');
else
return true;
}
return true;
}
return true;
}
),
),
Field::inst('pais_id')->validator('Validate::notEmpty', array(
'message' => lang('ClienteDirecciones.validation.required'))),
'message' => lang('ClienteDirecciones.validation.required')
)),
Field::inst('cliente_id'),
)
->debug(true)
->process($_POST)
->data();
@ -270,7 +334,6 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
$response[$csrfTokenName] = $newTokenHash;
echo json_encode($response);
} else {
return $this->failUnauthorized('Invalid request', 403);
}

View File

@ -93,7 +93,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$model_user = model('App\Models\Usuarios\UserModel');
$user = $model_user->find(auth()->user()->id);
$clienteId = $user->cliente_id;
$presupuestoEntity = isset($sanitizedData) ? new PresupuestoEntity($sanitizedData) : new PresupuestoEntity();
$presupuestoEntity->clienteId = $clienteId;
@ -119,7 +119,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datosPresupuesto->tapa = 'blanda';
$datosPresupuesto->clienteList = $this->getClienteListItems($clienteId ?? null);
$datosPresupuesto->paginasCuadernillo = [32, 28, 24, 20 , 16];
$datosPresupuesto->paginasCuadernillo = [32, 28, 24, 20, 16];
$presupuestoEntity->estado_id = 1;
$presupuestoEntity->paginas_por_cuadernillo = 32;
@ -144,7 +144,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
endif;
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
$presupuestoEntity = $this->model->find($id);
if ($presupuestoEntity == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]);
return $this->redirect2listView('sweet-error', $message);
@ -185,13 +185,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$this->obtenerDireccionesEnvio($presupuestoEntity);
// Si el presupuesto está confirmado, se generan los datos del resumen
if($presupuestoEntity->estado_id == 2){
if ($presupuestoEntity->estado_id == 2) {
$this->generarResumen($presupuestoEntity);
}
$datosPresupuesto->paginasCuadernillo = [32, 28, 24, 20 , 16];
$datosPresupuesto->paginasCuadernillo = [32, 28, 24, 20, 16];
$presupuestoEntity->paginas_por_cuadernillo = $this->obtenerPaginasCuadernillo($presupuestoEntity);
$this->viewData['formAction'] = 'edit';
$this->viewData['paisList'] = $this->getPaisListItems();
@ -255,40 +255,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
public function getGramaje()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
try {
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$tirada = $reqData['tirada'] ?? 0;
$merma = $reqData['merma'] ?? 0;
$papel = $reqData['papel'] ?? "";
$uso = $reqData['uso'] ?? "";
$model = new PapelGenericoModel();
$menu = $model->getGramajeComparador($papel, $uso, intval($tirada + $merma));
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
} catch (Exception $e) {
$data = [
'error' => $e,
$csrfTokenName => $newTokenHash
];
} finally {
return $this->respond($data);
}
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function datatable()
{
@ -334,83 +301,102 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
public function presupuesto()
public function calcular()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
try {
$tirada = $reqData['tirada'] ?? 0;
$tamanio = $reqData['tamanio'];
$tipo_impresion_id = $this->getTipoImpresion($reqData['tipo'], $reqData['tapa']);
$cliente_id = $reqData['clienteId'] ?? -1;
$isColor = intval($reqData['isColor']) ?? 0;
$isHq = intval($reqData['isHq']) ?? 0;
$reqData = $this->request->getPost();
$modelPapelGenerico = new PapelGenericoModel();
// Interior
$papel_generico = [
'id' => $reqData['papelInterior'] ?? 0,
'nombre' => $reqData['papelInteriorNombre'] ?? "",
];
$gramaje = $reqData['gramajeInterior'] ?? 0;
$excluirRotativa = $reqData['excluirRotativa'] ?? 0;
$paginas = intval($reqData['paginas']) ?? 0;
$paginas_color = intval($reqData['paginasColor']) ?? 0;
// Cubierta
$papel_generico_cubierta = [
'id' => $reqData['papelCubierta'] ?? 0,
'nombre' => $reqData['papelCubiertaNombre'] ?? "",
];
$gramajeCubierta = $reqData['gramajeCubierta'] ?? 0;
$carasCubierta = intval($reqData['carasCubierta'] ?? 0);
$solapasCubierta = intval($reqData['solapasCubierta'] ?? 0);
$acabadoCubierta = $reqData['acabadoCubierta'] ?? 0;
$cliente_id = $reqData['clienteId'] ?? -1;
// Sobrecubierta
$sobreCubierta = $reqData["sobrecubierta"] ?? null;
$tirada = $reqData['tirada'] ?? 0;
$tamanio = $reqData['tamanio'];
$paginas = $reqData['paginas'] ?? 0;
$paginas_color = $reqData['paginasColor'] ?? 0;
$tipo = $reqData['tipo'];
// Guardas
$datos_guardas = $reqData['guardas'] ?? [];
$paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null;
$servicios = $reqData['servicios'] ?? [];
$isColor = intval($reqData['isColor']) ?? 0;
$isHq = intval($reqData['isHq']) ?? 0;
$paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null;
$interior = $reqData['interior'] ?? [];
$cubierta = $reqData['cubierta'] ?? [];
$sobrecubierta = $reqData['sobrecubierta'] ?? [];
$guardas = $reqData['guardas'] ?? [];
$faja = $reqData['faja'] ?? [];
$excluirRotativa = $reqData['excluirRotativa'] ?? 0;
$ivaReducido = $reqData['ivaReducido'] ?? 0;
$datos_presupuesto = array(
'tirada' => $tirada,
'tamanio' => $tamanio,
'tipo_impresion_id' => $tipo_impresion_id,
'clienteId' => $cliente_id,
'isColor' => $isColor,
'isHq' => $isHq,
'paginasCuadernillo' => $paginasCuadernillo,
$tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']);
'interior' => array(
'papel_generico' => $papel_generico,
'gramaje' => $gramaje,
'excluirRotativa' => $excluirRotativa,
// Interior
$interior = [
'papel_generico' => $modelPapelGenerico->getIdFromCode($interior['papelInterior']),
'gramaje' => intval($interior['gramajeInterior']),
'excluirRotativa' => $excluirRotativa == "false" ? false: true,
'paginas' => $paginas,
'paginas_color' => $paginas_color,
),
'cubierta' => array(
'papel_generico_cubierta' => $papel_generico_cubierta,
'gramajeCubierta' => $gramajeCubierta,
'carasCubierta' => $carasCubierta,
'solapasCubierta' => $solapasCubierta,
),
'acabadoCubierta' => $acabadoCubierta,
'sobrecubierta' => $sobreCubierta,
'datos_guardas' => $datos_guardas,
'servicios' => $servicios,
);
];
$return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG
array_merge($return_data, [$csrfTokenName => $newTokenHash]);
return $this->respond($return_data);
// Cubierta
$cubierta = [
'papel_generico_cubierta' => $modelPapelGenerico->getIdFromCode($cubierta['papelCubierta']),
'gramajeCubierta' => intval($cubierta['gramajeCubierta']),
'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0),
'solapasCubierta' => intval($cubierta['solapas'] ?? 0),
'acabadosCubierta' => $cubierta['acabados'] ?? 0,
];
// Sobrecubierta
if ($sobrecubierta != "false" && $sobrecubierta != null) {
$sobrecubierta = [
'papel' => $modelPapelGenerico->getIdFromCode($sobrecubierta['papel']),
'gramaje' => intval($sobrecubierta['gramaje']),
'solapas' => intval($sobrecubierta['solapas'] ?? 0),
'acabados' => $sobrecubierta['plastificado'] ?? 0,
];
}
else
$sobrecubierta = false;
// Guardas
if ($guardas != "false" && $guardas != null) {
$datos_guardas = [
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
'gramaje' => intval($guardas['gramaje']),
'caras' => intval($guardas['guardasImpresas']),
];
}
else
$datos_guardas = false;
$datos_presupuesto = array(
'tirada' => $tirada,
'tamanio' => $tamanio,
'tipo_impresion_id' => $tipo_impresion_id,
'clienteId' => $cliente_id,
'isColor' => $isColor,
'isHq' => $isHq,
'paginasCuadernillo' => $paginasCuadernillo,
'interior' => $interior,
'cubierta' => $cubierta,
'sobrecubierta' => $sobrecubierta,
'datos_guardas' => $datos_guardas,
);
$return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG
return $this->respond($return_data);
} catch (Exception $e) {
return $this->failServerError($e->getMessage());
}
} else {
return $this->failUnauthorized('Invalid request', 403);
}
@ -500,7 +486,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
}
public function duplicarPresupuesto(){
public function duplicarPresupuesto()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
@ -510,61 +497,60 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$id = $reqData['id'] ?? 0;
if($id > 0){
try{
if ($id > 0) {
try {
$presupuesto = $this->model->find($id);
$presupuesto->titulo = $presupuesto->titulo .' - ' . lang('Presupuestos.duplicado');
$presupuesto->titulo = $presupuesto->titulo . ' - ' . lang('Presupuestos.duplicado');
$presupuesto->is_duplicado = 1;
$presupuesto->estado_id = 1;
$new_id = $this->model->insert($presupuesto);
$presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
foreach ($presupuestoAcabadosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $acabado) {
$acabado->presupuesto_id = $new_id;
$presupuestoAcabadosModel->insert($acabado);
}
$presupuestoEncuadernacionesModel = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
foreach ($presupuestoEncuadernacionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $encuadernacion) {
$encuadernacion->presupuesto_id = $new_id;
$presupuestoEncuadernacionesModel->insert($encuadernacion);
}
$presupuestoManipuladosModel = model('App\Models\Presupuestos\PresupuestoManipuladosModel');
foreach ($presupuestoManipuladosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $manipulado) {
$manipulado->presupuesto_id = $new_id;
$presupuestoManipuladosModel->insert($manipulado);
}
$presupuestoPreimpresionesModel = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel');
foreach ($presupuestoPreimpresionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $preimpresion) {
$preimpresion->presupuesto_id = $new_id;
$presupuestoPreimpresionesModel->insert($preimpresion);
}
$presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel');
foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) {
$servicioExtra->presupuesto_id = $new_id;
$presupuestoServiciosExtraModel->insert($preimpresion);
}
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) {
$direccion->presupuesto_id = $new_id;
$presupuestoDireccionesModel->insert($direccion);
}
$presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel');
$presupuestoLineaModel->duplicateLineasPresupuesto($presupuesto->id, $new_id);
return $this->respond([
'success' => true,
'id' => $new_id,
$csrfTokenName => $newTokenHash
]);
}catch(\Exception $e){
} catch (\Exception $e) {
return $this->respond([
'success' => false,
'message' => $e->getMessage(),
@ -577,9 +563,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'success' => false,
'message' => "No existe el presupuesto",
$csrfTokenName => $newTokenHash
]);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
@ -697,7 +682,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$proporcion = intval($direccion['unidades']) / $selected_tirada * 100.0;
$unidades_calculo = floor($tirada[$i] * $proporcion / 100.0);
try{
try {
$coste_envio = $this->calcular_coste_envio(
$direccion['id'],
$peso_libro,
@ -712,8 +697,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] += $coste;
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] += $margen;
}
}
catch(Exception $e){
} catch (Exception $e) {
return $this->respond([
'status' => -1,
'message' => "Error al calcular el coste de envío (¿las direcciones están guardadas?)",
@ -793,14 +777,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) {
// Servicios acabado
$this->guardarServicio($id, $servicio, 'acabado');
} else if ($servicio->tarifa_id == 24 ) {
} else if ($servicio->tarifa_id == 24) {
// Servicios preimpresion
$this->guardarServicio($id, $servicio, 'preimpresion');
} else if ($servicio->tarifa_id == 9) {
// Servicios extra
$this->guardarServicio($id, $servicio, 'extra');
}
else if ($servicio->tarifa_id == 62) {
} else if ($servicio->tarifa_id == 62) {
// Servicios manipulado
$this->guardarServicio($id, $servicio, 'manipulado');
}
@ -826,7 +809,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
}
public function get_files(){
public function get_files()
{
// Check if the request is a POST request
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@ -842,14 +826,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$size = filesize($file->file_path);
$splitPath = explode("presupuestos/", $file->file_path);
// se crea un objeto con el nombre del fichero y el tamaño
$obj = (object) array(
'name' => $file->nombre,
'size' => $size,
'hash' => $splitPath[1] ?? $file->file_path);
'hash' => $splitPath[1] ?? $file->file_path
);
// se añade el objeto al array
array_push($result, $obj);
}
@ -858,23 +843,24 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
}
public function upload_files(){
public function upload_files()
{
$model = model('App\Models\Presupuestos\PresupuestoFicheroModel');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$presupuesto_id = $_POST['presupuesto_id'];
$old_files = json_decode($_POST['oldFiles']);
$old_files = json_decode($_POST['oldFiles']);
// Comprobar si se han subido archivos
if (!empty($_FILES['file']) || !empty($old_files)) {
// Borrar los archivos existentes del presupuesto
$model->deleteFiles($presupuesto_id, $old_files);
if (!empty($_FILES['file'])){
if (!empty($_FILES['file'])) {
$files = $_FILES['file'];
// Iterar sobre los archivos
@ -885,23 +871,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$tmp_name = $files['tmp_name'][$i];
$new_name = $model->saveFileInBBDD($presupuesto_id, $name, $extension, auth()->id());
// Se sube el fichero
// Pero primero se comprueba que la carpeta presupuestos exista
if (!is_dir(WRITEPATH . 'uploads/presupuestos')) {
mkdir(WRITEPATH . 'uploads/presupuestos', 0777, true);
}
if(!is_null($new_name)){
if (!is_null($new_name)) {
$path = WRITEPATH . 'uploads/presupuestos/' . $new_name;
move_uploaded_file($tmp_name,$path);
move_uploaded_file($tmp_name, $path);
$ftp = new SafekatFtpClient();
$ftp->uploadFilePresupuesto($presupuesto_id);
}
}
}
}
else{
} else {
// Borrar los archivos existentes del presupuesto
$model->deleteFiles($presupuesto_id);
}
@ -910,7 +895,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
/***********************
@ -1002,7 +987,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if (isset($servicio->paginas_por_cuadernillo)) {
$data['paginas_por_cuadernillo'] = $servicio->paginas_por_cuadernillo;
}
$model->insert($data);
} else if ($tipo == 'extra') {
$model = new PresupuestoServiciosExtraModel();
@ -1077,7 +1062,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$coste = $tarifas_envio[0]->precio;
}
}
if (count($data) > 0 && count($tarifas_envio) > 0){
if (count($data) > 0 && count($tarifas_envio) > 0) {
$data[0]->coste = $coste;
$data[0]->tipo = $entregaPieCalle ? 'palets' : 'cajas';
$data[0]->margen = $margen;
@ -1324,13 +1309,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$linea_sobrecubierta = [];
$acabadoSobrecubierta = [];
$lomo_sobrecubierta = 0.0;
if (!is_null($sobreCubierta)) {
if (!is_null($sobreCubierta) && $sobreCubierta) {
$papel_generico_sobrecubierta = [
'id' => $sobreCubierta['papel'] ?? 0,
'nombre' => $sobreCubierta['papel_nombre'] ?? "",
];
$input_data['papel_generico'] = $papel_generico_sobrecubierta;
$input_data['papel_generico'] = $sobreCubierta['papel'] ?? 0;
$input_data['gramaje'] = $sobreCubierta['gramaje'] ?? 0;
$input_data['datosPedido']->paginas = 4;
$input_data['paginas_color'] = 4;
@ -1365,7 +1346,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$lomo_sobrecubierta = $lomo + floatval($linea_sobrecubierta['mano']);
$tarifaAcabadoSobrecubierta = intval(strlen($sobreCubierta['acabado']) == 0 ? 0 : $sobreCubierta['acabado']);
////////////////////////////////////JJJO
$tarifaAcabadoSobrecubierta = intval(strlen($sobreCubierta['acabados']) == 0 ? 0 : $sobreCubierta['acabados']);
$acabadoSobrecubierta = [];
if ($tarifaAcabadoSobrecubierta > 0) {
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
@ -1382,15 +1364,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$guardas = [];
$peso_guardas = 0.0;
$coste_guardas = 0.0;
if($datos_guardas != 0){
if (count($datos_guardas) != 0) {
if ($datos_guardas != 0) {
if (count($datos_guardas) != 0 && $datos_guardas) {
$guardas = $datos_guardas;
$papel_generico_guardas = [
'id' => $datos_guardas['papel'] ?? 0,
'nombre' => $datos_guardas['nombre'] ?? "",
];
$input_data['papel_generico'] = $papel_generico_guardas;
$input_data['papel_generico'] = $datos_guardas['papel'] ?? 0;
$input_data['gramaje'] = $datos_guardas['gramaje'] ?? 0;
$input_data['datosPedido']->paginas = 8;
$input_data['paginas_color'] = 8;
@ -1470,17 +1448,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Servicios
// se comprueba si $datos guardas es un array
if(is_array($datos_guardas)){
if(count($datos_guardas) > 0){
if (is_array($datos_guardas)) {
if (count($datos_guardas) > 0) {
array_push($servicios, 62); // Plegado de guardas
}
}
else{
} else {
if ($datos_guardas > 0) {
array_push($servicios, 62); // Plegado de guardas
}
}
/*
'retractilado' => 3,
'retractilado5' => 5,
@ -1523,7 +1500,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0;
}
}
if(intval($servicio) == 9) {
if (intval($servicio) == 9) {
// Servicios preimpresion
$resultado = PresupuestoCLienteService::getServiciosExtra([
'tarifa_id' => $servicio,
@ -1541,7 +1518,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Servicios manipulado
$resultado = PresupuestoCLienteService::getServiciosManipulado([
'tarifa_id' => $servicio,
'tirada' => $datosPedido->tirada,
'tirada' => $tirada[$t],
'POD' => $POD,
]);
array_push($serviciosAutomaticos, $resultado[0]);
@ -1591,7 +1568,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$info['lomo_cubierta'] = $lomo;
$info['lomo_sobrecubierta'] = $lomo_sobrecubierta;
$return_data['info'] = $info;
if ($extra_info) { // && $tirada[$t] == $selected_tirada) {
@ -1622,7 +1599,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
return $return_data;
} catch (Exception $e) {
return ['exception' => $e->getMessage()];
return [
'exception' => $e->getMessage(),
"line" => $e->getLine(),
"file" => $e->getFile()
];
}
}
@ -1665,37 +1646,41 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
protected function getTipoImpresion($tipo, $tapa)
{
$tipo_impresion_id = 0;
$tipo_impresion_id = -1;
if ($tipo == 'fresado') {
try {
if ($tipo == 'fresado') {
if ($tapa == 'blanda')
$tipo_impresion_id = 2;
else
$tipo_impresion_id = 1;
} else if ($tipo == 'cosido') {
if (strpos(strtolower($tapa), 'blanda') !== false)
$tipo_impresion_id = 2;
else
$tipo_impresion_id = 1;
} else if ($tipo == 'cosido') {
if ($tapa == 'blanda')
$tipo_impresion_id = 4;
else
$tipo_impresion_id = 3;
} else if ($tipo == 'espiral') {
if (strpos(strtolower($tapa), 'blanda') !== false)
$tipo_impresion_id = 4;
else
$tipo_impresion_id = 3;
} else if ($tipo == 'espiral') {
if ($tapa == 'blanda')
$tipo_impresion_id = 6;
else
$tipo_impresion_id = 5;
} else if ($tipo == 'wireo') {
if (strpos(strtolower($tapa), 'blanda') !== false)
$tipo_impresion_id = 6;
else
$tipo_impresion_id = 5;
} else if ($tipo == 'wireo') {
if ($tapa == 'blanda')
$tipo_impresion_id = 8;
else
$tipo_impresion_id = 7;
} else if ($tipo == 'grapado') {
$tipo_impresion_id = 21;
if (strpos(strtolower($tapa), 'blanda') !== false)
$tipo_impresion_id = 8;
else
$tipo_impresion_id = 7;
} else if ($tipo == 'grapado') {
$tipo_impresion_id = 21;
}
return $tipo_impresion_id;
} catch (Exception $e) {
return -1;
}
return $tipo_impresion_id;
}
@ -1805,11 +1790,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$tipo = "negro";
if($calidad == 'premium' && $color=='negro')
if ($calidad == 'premium' && $color == 'negro')
$tipo = "negroHq";
else if ($calidad == 'estandar' && $color=='color')
else if ($calidad == 'estandar' && $color == 'color')
$tipo = "color";
else if ($calidad == 'premium' && $color=='color')
else if ($calidad == 'premium' && $color == 'color')
$tipo = "colorHq";
return $tipo;
@ -1832,7 +1817,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
protected function obtenerPaginasColor($presupuestoEntity)
{
$comparador_data = json_decode($presupuestoEntity->comparador_json_data);
if(!is_null($comparador_data)){
if (!is_null($comparador_data)) {
if (property_exists($comparador_data, 'color')) {
$presupuestoEntity->paginasColor = $comparador_data->color->paginas;
}
@ -1841,8 +1826,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} else {
$presupuestoEntity->paginasColor = 0;
}
}
else
} else
$presupuestoEntity->paginasColor = 0;
}
@ -1876,23 +1860,24 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$result = [];
$temp = [];
for ($i=0; $i<count($direcciones); $i++) {
for ($i = 0; $i < count($direcciones); $i++) {
$direccion_id = $model_direcciones->getIdForPresupuestoCliente(
$presupuestoEntity->cliente_id,
$presupuestoEntity->cliente_id,
$direcciones[$i]->att,
$direcciones[$i]->email,
$direcciones[$i]->direccion,
$direcciones[$i]->cp,
$direcciones[$i]->pais_id,
$direcciones[$i]->telefono);
if(count($direccion_id) > 0) {
$direcciones[$i]->telefono
);
if (count($direccion_id) > 0) {
$temp = $direcciones[$i]->toArray();
$temp['pais'] = $model_pais->where('id', $direcciones[$i]->pais_id)->first()->nombre;
$temp['direccion_id'] = $direccion_id[0]->id;
array_push($result, $temp);
array_push($result, $temp);
}
}
if(count($result) > 0)
if (count($result) > 0)
$presupuestoEntity->direcciones_envio = $result;
}
@ -1932,8 +1917,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
}
protected function generarResumen($presupuestoEntity){
protected function generarResumen($presupuestoEntity)
{
$presupuestoEntity->resumen = (object)[
'titulo' => $this->generarTitulo($presupuestoEntity),
'tamanio' => $this->obtenerTamanio($presupuestoEntity),
@ -1941,37 +1927,39 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
];
$model_papelGenerico = model('App\Models\Configuracion\PapelGenericoModel');
if(!is_null($presupuestoEntity->papel_interior)){
if (!is_null($presupuestoEntity->papel_interior)) {
$nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_interior)->first()->nombre;
if($nombre != null)
if ($nombre != null)
$presupuestoEntity->papel_interior_nombre = $nombre;
}
if(!is_null($presupuestoEntity->papel_cubierta)){
if (!is_null($presupuestoEntity->papel_cubierta)) {
$nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_interior)->first()->nombre;
if($nombre != null)
if ($nombre != null)
$presupuestoEntity->papel_cubierta_nombre = $nombre;
}
if(!is_null($presupuestoEntity->papel_sobrecubierta)){
if (!is_null($presupuestoEntity->papel_sobrecubierta)) {
$nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_sobrecubierta)->first()->nombre;
if($nombre != null)
if ($nombre != null)
$presupuestoEntity->papel_sobrecubierta_nombre = $nombre;
}
if(!is_null($presupuestoEntity->papel_guardas)){
if (!is_null($presupuestoEntity->papel_guardas)) {
$nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_guardas)->first()->nombre;
if($nombre != null)
if ($nombre != null)
$presupuestoEntity->papel_guardas_nombre = $nombre;
}
}
protected function generarTitulo($presupuestoEntity){
protected function generarTitulo($presupuestoEntity)
{
$model = model('App\Models\Configuracion\TipoPresupuestoModel');
$codigo = $model->where('id', $presupuestoEntity->tipo_impresion_id)->first()->codigo;
$titulo = lang('Presupuestos.titulos.'.$codigo);
$titulo = lang('Presupuestos.titulos.' . $codigo);
return $titulo;
}
protected function obtenerTamanio($presupuestoEntity){
protected function obtenerTamanio($presupuestoEntity)
{
$ancho = 0;
$alto = 0;
@ -1979,15 +1967,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$model = model('App\Models\Presupuestos\PresupuestoModel');
$data = $model->where('id', $presupuestoEntity->id)->first();
if($data != null){
if($data->papel_formato_personalizado == 0){
if ($data != null) {
if ($data->papel_formato_personalizado == 0) {
$model_papel_formato = model('App\Models\Configuracion\PapelFormatoModel');
$data_papel_formato = $model_papel_formato->where('id', $data->papel_formato_id)->first();
$ancho = $data_papel_formato->ancho;
$alto = $data_papel_formato->alto;
}
else{
} else {
$ancho = $data->papel_formato_ancho;
$alto = $data->papel_formato_alto;
}
@ -1996,7 +1983,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
return $ancho . "x" . $alto;
}
protected function obtenerTipoImpresion($presupuestoEntity){
protected function obtenerTipoImpresion($presupuestoEntity)
{
$id = $presupuestoEntity->id;
@ -2019,14 +2007,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
return $tipo;
}
protected function obtenerPaginasCuadernillo($presupuestoEntity){
protected function obtenerPaginasCuadernillo($presupuestoEntity)
{
$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
$lineas = $model->getResource($presupuestoEntity->id)->get()->getResultObject();
foreach ($lineas as $linea){
foreach ($lineas as $linea) {
// check if exist
if($linea->paginas_por_cuadernillo != null)
if ($linea->paginas_por_cuadernillo != null)
return $linea->paginas_por_cuadernillo;
}
return 32; // valor por defecto

View File

@ -39,10 +39,10 @@ class TarifaAcabados extends BaseResourceController
$this->viewData = ['usingServerSideDataTable' => true];
// Breadcrumbs
// Breadcrumbs
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_tarifaacabado"), 'route' => site_url('tarifas/tarifaacabado'), 'active' => true]
['title' => lang("App.menu_tarifaacabado"), 'route' => site_url('tarifas/acabados'), 'active' => true]
];
parent::initController($request, $response, $logger);
@ -133,6 +133,8 @@ class TarifaAcabados extends BaseResourceController
endif; // ($requestMethod === 'post')
$this->viewData['proveedores'] = $this->getProveedores();
$this->viewData['tarifaacabadoEntity'] = isset($sanitizedData) ? new TarifaAcabadoEntity($sanitizedData) : new TarifaAcabadoEntity();
$this->viewData['formAction'] = route_to('tarifaAcabadoAdd');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaacabado.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');

View File

@ -61,6 +61,21 @@ class PapelGenericoModel extends \App\Models\BaseModel
],
];
public function getIdFromCode(string $code=""){
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.nombre AS nombre"
)
->where("t1.code", $code)
->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.
*

View File

@ -15,7 +15,10 @@ class PresupuestoClienteService extends BaseService
{
$rotativa = [];
$plana = PresupuestoClienteService::obtenerPresupuestoClienteInterior($data);
$plana = [];
// no se busca en plana cuando es estándar (no Premium)
if($data['isHq'])
$plana = PresupuestoClienteService::obtenerPresupuestoClienteInterior($data);
if (!$data['excluirRotativa'] && !$data['isHq'])
$rotativa = PresupuestoClienteService::obtenerPresupuestoClienteInteriorRotativa($data);

View File

@ -1,5 +1,9 @@
<div class="col-12 pb-2 d-flex flex-column align-items-center">
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
<h3 class="mb-1 fw-bold"> Datos del libro </h3>
</div>
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
<label for="titulo" class="form-label">
<?= lang('Presupuestos.titulo') ?>*
@ -17,6 +21,14 @@
</div>
<div class="row col-sm-5 mb-3 d-flex flex-column align-items-center">
<div class="form-check form-switch mb-2">
<input class="calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa" name="excluir_rotativa" value="1">
<label class="form-check-label" for="excluirRotativa">Excluir rotativa</label>
</div>
</div>
<div class="row col-sm-10 mb-3 justify-content-center">
<div class="col-sm-2 d-flex flex-column align-items-center mx-1">
<label for="tirada" class="form-label">
@ -81,7 +93,7 @@
</div>
<div class="row col-sm-10 mb-5 justify-content-center">
<div class="row col-sm-9 mb-5 justify-content-center">
<div class="row justify-content-center">
<div class="col-sm-3">
@ -116,10 +128,26 @@
</div>
</div>
<div id='divPaginasCuadernillo' class="row col-sm-9 justify-content-left d-none">
<div class="col-sm-4 mb-5">
<label for="paginas_por_cuadernillo" class="form-label">
<?= lang('Presupuestos.paginasCuadernillo') ?>
</label>
<select id="paginasCuadernillo" name="paginas_por_cuadernillo" class="calcular-presupuesto form-control select2bs2" style="width: 100%;">
<option value="32" selected>32</option>
<option value="28">28</option>
<option value="24">24</option>
<option value="20">20</option>
<option value="16">16</option>
</select>
</div><!--//.mb-3 -->
</div>
<div class="row mt-2 justify-content-center">
<div id="divPaginasColorConsecutivas" class="form-check col-sm-9 form-switch mb-2 d-none">
<input class="calcular-presupuesto form-check-input" type="checkbox" id="pagColorConsecutivas" name="pag_color_consecutivas" value="1">
<input class="form-check-input" type="checkbox" id="pagColorConsecutivas" name="pag_color_consecutivas" value="1">
<label class="form-check-label" for="pagColorConsecutivas"><?= lang('Presupuestos.paginasColorConsecutivas') ?></label>
</div>
@ -136,8 +164,8 @@
</div>
<div class="row mt-2 justify-content-center">
<div id="divPapelDiferente" class="form-check col-sm-9 form-switch mb-2 d-none">
<input class="calcular-presupuesto form-check-input" type="checkbox" id="papelDiferente" name="papel_diferente" value="1">
<div id="divPapelDiferente" class="form-check col-sm-9 form-switch mb-2 d-none">
<input class="form-check-input" type="checkbox" id="papelDiferente" name="papel_diferente" value="1">
<label class="form-check-label" for="papelDiferente"><?= lang('Presupuestos.papelDiferente') ?></label>
</div>
</div>
@ -147,25 +175,25 @@
<div id="divTipoLibro" name="div_tipo_libro" class="row col-sm-10 mb-3 justify-content-center">
<div id="fresado" class="tipo-libro imagen-selector image-container">
<div id="fresado" class="tipo-libro calcular-presupuesto imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/fresado.png") ?>" alt="Fresado">
<div class="form-text text-center">
Fresado (a partir de 32 páginas)
</div>
</div>
<div id="grapado" class="tipo-libro imagen-selector image-container">
<div id="grapado" class="tipo-libro calcular-presupuesto imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/grapado.png") ?>" alt="Grapado">
<div class="form-text text-center">
Grapado (entre 12 y 40 páginas)
</div>
</div>
<div id="espiral" class="tipo-libro imagen-selector image-container">
<div id="espiral" class="tipo-libro calcular-presupuesto imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/espiral.png") ?>" alt="Espiral">
<div class="form-text text-center">
Espiral
</div>
</div>
<div id="cosido" class="tipo-libro imagen-selector image-container">
<div id="cosido" class="tipo-libro calcular-presupuesto imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/cosido.png") ?>" alt="Cosido">
<div class="form-text text-center">
Cosido (a partir de 32 páginas)
@ -173,4 +201,37 @@
</div>
</div>
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
<h3 class="mb-1 fw-bold"> Servicios extra </h3>
</div>
<div class="row col-sm-9 mb-3 d-flex flex-column align-items-center">
<div class="col-sm-3 form-check form-switch mb-2">
<input class="calcular-presupuesto form-check-input" type="checkbox" id="prototipo" name="prototipo" value="1">
<label class="form-check-label" for="prototipo">Prototipo</label>
</div>
</div>
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
<h3 class="mb-1 fw-bold"> Otros </h3>
</div>
<div class="row col-sm-10 mt-5 mb-3">
<div class="col-sm-2 mb-md-0 mb-2">
<label for="ivaReducido" class="form-label">I.V.A. reducido</label>
<select id="ivaReducido" name="ivaReducido" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<option value="1" selected>
<p><?= lang('SI') ?></p>
</option>
<option value="0">
<p><?= lang('NO') ?></p>
</option>
</select>
</div>
<p class="mt-2">Se verificará que el pedido cumpla con los requisitos establecidos en el Artículo 91 de la Ley 37/1992, sobre inserción de publicidad, antes de proceder con su producción, lo que garantiza la aplicación del IVA reducido del 4%.</p>
</div>
</div>

View File

@ -47,7 +47,7 @@
</div>
</div>
<div id="divDirecciones" class="col-sm-12 d-flex flex-column align-items-center">
<div id="divDirecciones" class="calcular-presupuesto col-sm-12 d-flex flex-column align-items-center">
</div>
</div>

View File

@ -16,7 +16,7 @@
<div id="divTipoCubierta" name="div_tipo_cubierta" class="row col-sm-10 mb-5 justify-content-center">
<div id="tapaBlanda"
class="d-flex flex-column align-items-center justify-content-center tipo-cubierta imagen-selector image-container">
class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center tipo-cubierta imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/tapa-blanda.jpg") ?>"
alt="TapaBlanda">
<label class="form-label">
@ -25,7 +25,7 @@
</div>
<div id="tapaDura"
class="d-flex flex-column align-items-center justify-content-center tipo-cubierta imagen-selector image-container">
class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center tipo-cubierta imagen-selector image-container">
<img class="image-presupuesto"
src="<?= site_url("assets/img/presupuestoCliente/tapa-dura-lomo-recto.jpg") ?>" alt="TapaDura">
<label class="form-label">
@ -34,7 +34,7 @@
</div>
<div id="tapaDuraLomoRedondo"
class="d-flex flex-column align-items-center justify-content-center tipo-cubierta imagen-selector image-container">
class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center tipo-cubierta imagen-selector image-container">
<img class="image-presupuesto"
src="<?= site_url("assets/img/presupuestoCliente/tapa-dura-lomo-redondo.png") ?>"
alt="TapaDuraLomoRedondo">
@ -46,10 +46,27 @@
</div>
<div id="divCarasImpresion" name="div_caras_impresion" class="row col-sm-10 mb-5 justify-content-center d-none">
<div class="col-sm-4 mb-md-0 mb-2">
<label for="carasCubierta" class="form-label">Caras impresas cubierta</label>
<select id="carasCubierta" name="carasCubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<option value="2" selected >
<p><?= lang('Presupuestos.unaCara') ?></p>
</option>
<option value="4" >
<p><?= lang('Presupuestos.dosCaras') ?></p>
</option>
</select>
</div>
</div>
<div id="divSolapasCubierta" name="div_solapas_cubierta" class="row col-sm-10 mb-5 justify-content-center d-none">
<div id="solapasCubiertaNo"
class="d-flex flex-column align-items-center justify-content-center solapas-cubierta imagen-selector image-container">
class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center solapas-cubierta imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/sinSolapasCubierta.png") ?>"
alt="Sin solapas">
<label class="form-label">
@ -58,7 +75,7 @@
</div>
<div id="solapasCubiertaSi"
class="d-flex flex-column align-items-center justify-content-center solapas-cubierta imagen-selector image-container">
class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center solapas-cubierta imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/conSolapasCubierta.png") ?>"
alt="Con solapas">
<label class="form-label">
@ -84,12 +101,12 @@
<div class="row justify-content-center">
<div class="col-sm-3">
<label for="paginasColor" class="form-label">
<label for="papelGuardas" class="form-label">
<?= lang('Presupuestos.papelGuardas') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="papelGuardas" name="papel_guardas">
<option value="OFFWH"><?= lang('Presupuestos.offsetBlancoGuardas') ?></option>
<option value="OFFAH"><?= lang('Presupuestos.offsetAhuesadoGuardas') ?></option>
<option value="OFF1_170"><?= lang('Presupuestos.offsetBlancoGuardas') ?></option>
<option value="OFF2_170"><?= lang('Presupuestos.offsetAhuesadoGuardas') ?></option>
</select>
</div>
@ -126,8 +143,8 @@
<div id="divPapelCubierta" name="div_papel_cubierta" class="row col-sm-10 mb-5 justify-content-center">
<div id="cartulinaEstucada"
class="min-width-fit d-flex flex-column align-items-center justify-content-center papel-cubierta imagen-selector image-container">
<div id="cartulinaEstucada" cod="CAR1"
class="calcular-presupuesto min-width-fit d-flex flex-column align-items-center justify-content-center papel-cubierta imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/cartulina-grafica.png") ?>"
alt="Cartulina estucada">
<label class="form-label">
@ -135,8 +152,8 @@
</label>
</div>
<div id="estucadoMate"
class="min-width-fit d-flex flex-column align-items-center justify-content-center papel-cubierta imagen-selector image-container">
<div id="estucadoMate" cod="EST2"
class="calcular-presupuesto min-width-fit d-flex flex-column align-items-center justify-content-center papel-cubierta imagen-selector image-container">
<img class="image-presupuesto"
src="<?= site_url("assets/img/presupuestoCliente/estucado-mate-cubierta.png") ?>" alt="Estucado mate">
<label class="form-label">
@ -156,7 +173,7 @@
<span class="custom-option-title"> 170 gr </span>
</span>
<input id="gramaje170Cubierta" name="gramajeCubiertaRadio" data-value="170"
class="check-gramaje-cubierta form-check-input" type="radio" value="170" />
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="170" />
</label>
</div>
</div>
@ -168,7 +185,7 @@
<span class="custom-option-title"> 250 gr </span>
</span>
<input id="gramaje250Cubierta" name="gramajeCubiertaRadio" data-value="250"
class="check-gramaje-cubierta form-check-input" type="radio" value="250" />
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="250" />
</label>
</div>
</div>
@ -180,7 +197,7 @@
<span class="custom-option-title"> 270 gr </span>
</span>
<input id="gramaje270Cubierta" name="gramajeCubiertaRadio" data-value="270"
class="check-gramaje-cubierta form-check-input" type="radio" value="270" />
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="270" />
</label>
</div>
</div>
@ -192,7 +209,7 @@
<span class="custom-option-title"> 300 gr </span>
</span>
<input id="gramaje300Cubierta" name="gramajeCubiertaRadio" data-value="300"
class="check-gramaje-cubierta form-check-input" type="radio" value="300" />
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="300" />
</label>
</div>
<div class="form-text">
@ -207,7 +224,7 @@
<span class="custom-option-title"> 350 gr </span>
</span>
<input id="gramaje350Cubierta" name="gramajeCubiertaRadio" data-value="350"
class="check-gramaje-cubierta form-check-input" type="radio" value="350" />
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="350" />
</label>
</div>
</div>
@ -224,7 +241,7 @@
<div class="row col-sm-12 mb-5 justify-content-center">
<div class="row justify-content-center">
<div class="col-sm-3">
<label for="plastificado" class="form-label">
<?= lang('Presupuestos.plastificado') ?>
@ -234,7 +251,7 @@
<option value="MATE"><?= lang('Presupuestos.mate') ?></option>
<option value="ANTI"><?= lang('Presupuestos.antirrayado') ?></option>
<option value="SAND"><?= lang('Presupuestos.rugoso') ?></option>
<option value="SINP"><?= lang('Presupuestos.sinPlastificar') ?></option>
<option value="NONE"><?= lang('Presupuestos.sinPlastificar') ?></option>
</select>
</div>
@ -243,7 +260,7 @@
<?= lang('Presupuestos.barniz') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="barniz" name="barniz">
<option value=""> - </option>
<option value="NONE"> - </option>
<option value="R2D"><?= lang('Presupuestos.relieve2D') ?></option>
<option value="R3D"><?= lang('Presupuestos.relieve3D') ?></option>
</select>
@ -257,7 +274,7 @@
<?= lang('Presupuestos.estampado') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="estampado" name="estampado">
<option value=""> - </option>
<option value="NONE"> - </option>
<option value="GOLD"><?= lang('Presupuestos.oro') ?></option>
<option value="SILV"><?= lang('Presupuestos.plata') ?></option>
<option value="COPP"><?= lang('Presupuestos.cobre') ?></option>
@ -265,8 +282,8 @@
</select>
</div>
<div id="solapasCubiertaNo"
class="d-flex flex-column align-items-center justify-content-center solapas-cubierta imagen-selector image-container">
<div id="retractilado"
class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center solapas-cubierta imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/retractilado.png") ?>"
alt="Retractilado">
<label class="form-label">
@ -298,13 +315,13 @@
</div>
<div class="col-sm-3 config-sobrecubierta d-none">
<label for="papelFaja" class="form-label">
<label for="papelSobrecubierta" class="form-label">
<?= lang('Presupuestos.papelSobrecubierta') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="papelFaja"
<select class="form-select select2bs2 calcular-presupuesto" id="papelSobrecubierta"
name="papel_sobrecubierta">
<option value="ESTMAT170"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
<option value="ESTMAT200"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
<option value="EST2_170"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
<option value="EST2_200"><?= lang('Presupuestos.estucadoMate200gr') ?></option>
</select>
</div>
@ -320,12 +337,12 @@
</div>
<div class="col-sm-3 config-sobrecubierta d-none">
<label for="plastificadoFaja" class="form-label">
<?= lang('Presupuestos.plastificadoFaja') ?>
<label for="plastificadoSobrecubierta" class="form-label">
<?= lang('Presupuestos.plastificadoSobrecubierta') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="plastificadoFaja"
name="plastificado_faja">
<option value=""> - </option>
<select class="form-select select2bs2 calcular-presupuesto" id="plastificadoSobrecubierta"
name="plastificado_sobrecubierta">
<option value="NONE"> - </option>
<option value="BRIL"><?= lang('Presupuestos.brillo') ?></option>
<option value="MATE"><?= lang('Presupuestos.mate') ?></option>
<option value="ANTI"><?= lang('Presupuestos.antirrayado') ?></option>
@ -363,10 +380,10 @@
<label for="barniz" class="form-label">
<?= lang('Presupuestos.papelFaja') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="papelSobrecubierta"
<select class="form-select select2bs2 calcular-presupuesto" id="papelFaja"
name="papel_sobrecubierta">
<option value="ESTMAT170"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
<option value="ESTMAT200"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
<option value="EST2_170"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
<option value="EST2_200"><?= lang('Presupuestos.estucadoMate200gr') ?></option>
</select>
</div>
@ -382,12 +399,12 @@
</div>
<div class="col-sm-3 config-faja d-none">
<label for="plastificadoSobrecubierta" class="form-label">
<?= lang('Presupuestos.plastificadoSobrecubierta') ?>
<label for="plastificadoFaja" class="form-label">
<?= lang('Presupuestos.plastificadoFaja') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="plastificadoSobrecubierta"
name="plastificado_sobrecubierta">
<option value=""> - </option>
<select class="form-select select2bs2 calcular-presupuesto" id="plastificadoFaja"
name="plastificado_faja">
<option value="NONE"> - </option>
<option value="BRIL"><?= lang('Presupuestos.brillo') ?></option>
<option value="MATE"><?= lang('Presupuestos.mate') ?></option>
<option value="ANTI"><?= lang('Presupuestos.antirrayado') ?></option>

View File

@ -11,21 +11,21 @@
<div id="divImpresionInterior" name="div_impresion_interior" class="row col-sm-10 mb-3 justify-content-center">
<div id="negroEstandar" class="d-flex flex-column align-items-center justify-content-center disenio-interior imagen-selector image-container">
<div id="negroEstandar" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center disenio-interior imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/blancoYnegro.png") ?>" alt="Negro">
<label for="titulo" class="form-label">
Blanco y Negro
</label>
</div>
<div id="negroPremium" class="d-flex flex-column align-items-center justify-content-center disenio-interior imagen-selector image-container">
<div id="negroPremium" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center disenio-interior imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/negroFoto.png") ?>" alt="NegroPremium">
<label for="titulo" class="form-label">
Blanco y Negro Premium
</label>
</div>
<div id="colorEstandar" class="d-flex flex-column align-items-center justify-content-center disenio-interior imagen-selector image-container">
<div id="colorEstandar" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center disenio-interior imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/color.png") ?>" alt="Color">
<label for="titulo" class="form-label">
Color
@ -49,28 +49,28 @@
<div id="divPapelInterior" name="div_papel_interior" class="row col-sm-10 mb-5 justify-content-center">
<div id="offsetBlanco" class="d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
<div id="offsetBlanco" cod="OFF1" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/offset-blanco.png") ?>" alt="offsetBlanco">
<label for="titulo" class="form-label">
Offset Blanco
</label>
</div>
<div id="offsetAhuesado" class="d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
<div id="offsetAhuesado" cod="OFF2" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/offset-ahuesado.png") ?>" alt="offsetAhuesado">
<label for="titulo" class="form-label">
Offset Ahuesado
</label>
</div>
<div id="offsetAhuesadoVolumen" class="d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
<div id="offsetAhuesadoVolumen" cod="OFF4" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/offset-ahuesado-volumen.png") ?>" alt="offsetAhuesadoVolumen">
<label for="titulo" class="form-label">
Offset Ahuesado Volumen
</label>
</div>
<div id="estucadoMate" class="d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
<div id="estucadoMate" cod="EST2" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/estucado-mate.png") ?>" alt="estucadoMate">
<label for="titulo" class="form-label">
Estucado Mate
@ -82,18 +82,18 @@
<div id="divGramajeInterior" name="div_gramaje_interior" class="row col-sm-10 mb-3 justify-content-center d-none">
<div id="interiorGramaje70" class="checkbox-presupuesto-container col-md mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior">
<label class="form-check-label custom-option-content" for="gramaje70">
<span class="custom-option-body">
<span class="custom-option-title"> 70 gr </span>
</span>
<input id="gramaje70" name="customRadioGramaje" data-value="70" class="check-interior-gramaje form-check-input" type="radio" value="" checked />
<input id="gramaje70" name="customRadioGramaje" data-value="70" class="check-interior-gramaje form-check-input" type="radio" value="" />
</label>
</div>
</div>
<div id="interiorGramaje80" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior">
<label class="form-check-label custom-option-content" for="gramaje80">
<span class="custom-option-body">
<span class="custom-option-title"> 80 gr </span>
@ -104,7 +104,7 @@
</div>
<div id="interiorGramaje90" class="mb-md-0 mb-3 checkbox-presupuesto-container">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior">
<label class="form-check-label custom-option-content" for="gramaje90">
<span class="custom-option-body">
<span class="custom-option-title"> 90 gr </span>
@ -115,7 +115,7 @@
</div>
<div id="interiorGramaje100" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior">
<label class="form-check-label custom-option-content" for="gramaje100">
<span class="custom-option-body">
<span class="custom-option-title"> 100 gr </span>
@ -126,7 +126,7 @@
</div>
<div id="interiorGramaje115" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior">
<label class="form-check-label custom-option-content" for="gramaje115">
<span class="custom-option-body">
<span class="custom-option-title"> 115 gr </span>
@ -137,7 +137,7 @@
</div>
<div id="interiorGramaje120" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior">
<label class="form-check-label custom-option-content" for="gramaje120">
<span class="custom-option-body">
<span class="custom-option-title"> 120 gr </span>
@ -148,7 +148,7 @@
</div>
<div id="interiorGramaje135" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior">
<label class="form-check-label custom-option-content" for="gramaje135">
<span class="custom-option-body">
<span class="custom-option-title"> 135 gr </span>
@ -159,7 +159,7 @@
</div>
<div id="interiorGramaje150" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior">
<label class="form-check-label custom-option-content" for="gramaje150">
<span class="custom-option-body">
<span class="custom-option-title"> 150 gr </span>
@ -170,7 +170,7 @@
</div>
<div id="interiorGramaje170" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior">
<label class="form-check-label custom-option-content" for="gramaje170">
<span class="custom-option-body">
<span class="custom-option-title"> 170 gr </span>
@ -191,14 +191,14 @@
<div id="divImpresionInteriorColor" name="div_impresion_interior_color" class="row col-sm-10 mb-3 justify-content-center interior-color d-none">
<div id="colorEstandarColor" class="d-flex flex-column align-items-center justify-content-center disenio-interior-color imagen-selector image-container">
<div id="colorEstandarColor" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center disenio-interior-color imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/color.png") ?>" alt="Color">
<label for="titulo" class="form-label">
Color
</label>
</div>
<div id="colorPremiumColor" class="d-flex flex-column align-items-center justify-content-center disenio-interior-color imagen-selector image-container">
<div id="colorPremiumColor" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center disenio-interior-color imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/colorFoto.png") ?>" alt="ColorPremium">
<label for="titulo" class="form-label">
Color Premium
@ -215,28 +215,28 @@
<div id="divPapelInteriorColor" name="div_papel_interior_color" class="row col-sm-10 mb-5 interior-color justify-content-center interior-color d-none">
<div id="offsetBlancoColor" class="d-flex flex-column align-items-center justify-content-center papel-interior-color imagen-selector image-container">
<div id="offsetBlancoColor" cod="OFF1" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior-color imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/offset-blanco.png") ?>" alt="offsetBlanco">
<label class="form-label">
Offset Blanco
</label>
</div>
<div id="offsetAhuesadoColor" class="d-flex flex-column align-items-center justify-content-center papel-interior-color imagen-selector image-container">
<div id="offsetAhuesadoColor" cod="OFF2" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior-color imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/offset-ahuesado.png") ?>" alt="offsetAhuesado">
<label for="titulo" class="form-label">
Offset Ahuesado
</label>
</div>
<div id="offsetAhuesadoVolumenColor" class="d-flex flex-column align-items-center justify-content-center papel-interior-color imagen-selector image-container">
<div id="offsetAhuesadoVolumenColor" cod="OFF4" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior-color imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/offset-ahuesado-volumen.png") ?>" alt="offsetAhuesadoVolumen">
<label class="form-label">
Offset Ahuesado Volumen
</label>
</div>
<div id="estucadoMateColor" class="d-flex flex-column align-items-center justify-content-center papel-interior-color imagen-selector image-container">
<div id="estucadoMateColor" cod="EST2" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior-color imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/estucado-mate.png") ?>" alt="estucadoMate">
<label class="form-label">
Estucado Mate
@ -248,18 +248,18 @@
<div id="divGramajeInteriorColor" name="div_gramaje_interior_color" class="row col-sm-10 mb-3 justify-content-center d-none">
<div id="interiorGramaje70Color" class="checkbox-presupuesto-container col-md mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior-color">
<label class="form-check-label custom-option-content" for="gramaje70">
<span class="custom-option-body">
<span class="custom-option-title"> 70 gr </span>
</span>
<input id="gramaje70Color" name="customRadioGramajeColor" data-value="70" class="check-interior-color-gramaje form-check-input" type="radio" value="" checked />
<input id="gramaje70Color" name="customRadioGramajeColor" data-value="70" class="check-interior-color-gramaje form-check-input" type="radio" value="" />
</label>
</div>
</div>
<div id="interiorGramaje80Color" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior-color">
<label class="form-check-label custom-option-content" for="gramaje80">
<span class="custom-option-body">
<span class="custom-option-title"> 80 gr </span>
@ -270,7 +270,7 @@
</div>
<div id="interiorGramaje90Color" class="mb-md-0 mb-3 checkbox-presupuesto-container">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior-color">
<label class="form-check-label custom-option-content" for="gramaje90">
<span class="custom-option-body">
<span class="custom-option-title"> 90 gr </span>
@ -281,7 +281,7 @@
</div>
<div id="interiorGramaje100Color" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior-color">
<label class="form-check-label custom-option-content" for="gramaje100">
<span class="custom-option-body">
<span class="custom-option-title"> 100 gr </span>
@ -292,7 +292,7 @@
</div>
<div id="interiorGramaje115Color" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior-color">
<label class="form-check-label custom-option-content" for="gramaje115">
<span class="custom-option-body">
<span class="custom-option-title"> 115 gr </span>
@ -303,7 +303,7 @@
</div>
<div id="interiorGramaje120Color" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior-color">
<label class="form-check-label custom-option-content" for="gramaje120">
<span class="custom-option-body">
<span class="custom-option-title"> 120 gr </span>
@ -314,7 +314,7 @@
</div>
<div id="interiorGramaje135Color" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior-color">
<label class="form-check-label custom-option-content" for="gramaje135">
<span class="custom-option-body">
<span class="custom-option-title"> 135 gr </span>
@ -325,7 +325,7 @@
</div>
<div id="interiorGramaje150Color" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior-color">
<label class="form-check-label custom-option-content" for="gramaje150">
<span class="custom-option-body">
<span class="custom-option-title"> 150 gr </span>
@ -336,7 +336,7 @@
</div>
<div id="interiorGramaje170Color" class="checkbox-presupuesto-container mb-md-0 mb-3">
<div class="form-check custom-option custom-option-icon gramaje-interior">
<div class="form-check custom-option custom-option-icon calcular-presupuesto gramaje-interior-color">
<label class="form-check-label custom-option-content" for="gramaje170">
<span class="custom-option-body">
<span class="custom-option-title"> 170 gr </span>

View File

@ -1,94 +0,0 @@
<div class="col-12 pb-2">
<input hidden readonly style="background: #E8E8E8;" id="id" name="id" maxLength="12" class="form-control" value="<?= old('id', $presupuestoEntity->id) ?>">
<div class="row g-2">
<div class="col-sm-6 mb-3">
<label for="titulo" class="form-label">
<?=lang('Presupuestos.titulo') ?>*
</label>
<input type="text" id="titulo" name="titulo" maxLength="300" class="form-control" value="<?=old('titulo', $presupuestoEntity->titulo) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-6 mb-3">
<label for="autor" class="form-label">
<?=lang('Presupuestos.autor') ?>
</label>
<input type="text" id="autor" name="autor" maxLength="150" class="form-control" value="<?=old('autor', $presupuestoEntity->autor) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-6 mb-3">
<label for="coleccion" class="form-label">
<?=lang('Presupuestos.coleccion') ?>
</label>
<input type="text" id="coleccion" name="coleccion" maxLength="255" class="form-control" value="<?=old('coleccion', $presupuestoEntity->coleccion) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-6 mb-3">
<label for="numeroEdicion" class="form-label">
<?=lang('Presupuestos.numeroEdicion') ?>
</label>
<input type="text" id="numeroEdicion" name="numero_edicion" maxLength="50" class="form-control" value="<?=old('numero_edicion', $presupuestoEntity->numero_edicion) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-6 mb-3">
<label for="numeroEdicion" class="form-label">
<?=lang('Presupuestos.numeroEdicion') ?>
</label>
<input type="text" id="numeroEdicion" name="numero_edicion" maxLength="50" class="form-control" value="<?=old('numero_edicion', $presupuestoEntity->numero_edicion) ?>">
</div>
<div class="col-sm-6 mb-3">
<label for="isbn" class="form-label">
<?=lang('Presupuestos.isbn') ?>
</label>
<input type="text" id="isbn" name="isbn" maxLength="50" class="form-control" value="<?=old('isbn', $presupuestoEntity->isbn) ?>">
</div>
<div class="col-sm-6 mb-3">
<label for="paisId" class="form-label">
<?=lang('Presupuestos.paisId') ?>*
</label>
<select id="paisId" name="pais_id" class="form-control select2bs" style="width: 100%;" >
<?php foreach ($datosPresupuesto->paisList as $item) : ?>
<option value="<?=$item->id ?>"<?=$item->id==$presupuestoEntity->pais_id ? ' selected':'' ?>>
<?=$item->nombre ?>
</option>
<?php endforeach; ?>
</select>
</div>
<hr> <!-- Separador -->
<div class="col-sm-6 mb-3">
<label for="clienteId" class="form-label">
<?= lang('Presupuestos.clienteId') ?>*
</label>
<select id="clienteId" name="clienteId" class="form-control select2bs2" style="width: 100%;">
<?php if (isset($datosPresupuesto->clienteList) && is_array($datosPresupuesto->clienteList) && !empty($datosPresupuesto->clienteList)) :
foreach ($datosPresupuesto->clienteList as $k => $v) : ?>
<option value="<?= $k ?>" <?= $k == $presupuestoEntity->cliente_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div>
<div class="col-sm-6 mb-3">
<label for="referenciaCliente" class="form-label">
<?=lang('Presupuestos.referenciaCliente') ?>
</label>
<input type="text" id="referenciaCliente" name="referencia_cliente" maxLength="100" class="form-control" value="<?=old('referencia_cliente', $presupuestoEntity->referencia_cliente) ?>">
</div>
</div>
</div><!--//.col -->

View File

@ -1,48 +0,0 @@
<div class="col-12 pb-2">
<div id="containerTiradasEnvios" class="row mb-3">
</div>
<div class="row mb-3">
<div class="col-sm-4 mb-3">
<label for="direcciones" class="form-label">Mis direcciones</label>
<select id="direcciones" name="direcciones" class="form-control select2bs2" style="width: 100%;"></select>
</div>
<div class="col-sm-2 mb-3">
<label for="unidadesEnvio" class="form-label">
Unidades
</label>
<input type="number" class="form-control" id="unidadesEnvio" name="unidadesEnvio" maxLength="8" step="1" class="form-control">
</div><!--//.mb-3 -->
<div class="col-sm-2 mb-3 mt-auto mb-0">
<button id="insertarDireccion" type="button" class="btn btn-secondary waves-effect waves-light">Insertar</button>
</div>
<div id="errorDirecciones" class="fv-plugins-message-container invalid-feedback" style="display: none;">
</div>
</div>
<div class="row mb-3">
<div class="col-sm-4 mb-3">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="entregaPieCalle" name="entregaPieCalle" value="1">
<label class="form-check-label" for="add_entregaPieCalle"><?= lang('PresupuestosDirecciones.entregaPieCalle') ?></label>
</div>
</div>
</div>
<div id="divDirecciones" class="col-12 pb-2">
</div>
</div>
<?= $this->section("additionalInlineJs") ?>
window.direcciones = <?= json_encode($presupuestoEntity->direcciones_envio) ?>;
window.direcciones_sel_tirada = <?= json_encode($presupuestoEntity->selected_tirada) ?>;
window.routes_direcciones = {
direcciones: "<?= route_to('getDirecciones') ?>",
getDatos: "<?= route_to('getDatosDireccion') ?>",
nuevaDireccion: "<?= route_to('nuevaDireccion') ?>",
}
<?= $this->endSection() ?>

View File

@ -1,665 +0,0 @@
<div class="col-12 pb-2">
<input hidden readonly style="background: #E8E8E8;" id="id" name="id" maxLength="12" class="form-control" value="<?= old('id', $presupuestoEntity->id) ?>">
<div class="row g-2">
<h3 id="tituloDisenioLibro">Fresado</h3>
<div class="row">
<div class="col-sm-12 mb-3">
<label for="titulo" class="form-label">
<?= lang('Presupuestos.titulo') ?>*
</label>
<input type="text" id="titulo" name="titulo" maxLength="300" class="form-control" value="<?= old('titulo', $presupuestoEntity->titulo) ?>">
</div><!--//.mb-3 -->
</div>
<div class="row">
<div class="col-sm-6 mb-3" <?= $clienteId != 0 && !(auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) ?' style="display:none;"':''?>>
<label for="clienteId" class="form-label">
<?= lang('Presupuestos.clienteId') ?>*
</label>
<select id="clienteId" name="clienteId" class="form-control select2bs2" style="width: 100%;">
<?php if (isset($datosPresupuesto->clienteList) && is_array($datosPresupuesto->clienteList) && !empty($datosPresupuesto->clienteList)) :
foreach ($datosPresupuesto->clienteList as $k => $v) : ?>
<option value="<?= $k ?>" <?= $k == $clienteId ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div>
<div class="col-sm-6 mb-3">
<label for="referenciaCliente" class="form-label">
<?php if($clienteId == 0): ?>
<?= lang('Presupuestos.referenciaCliente') ?>
<?php else: ?>
<?= lang('Presupuestos.referenciaCliente2') ?>
<?php endif; ?>
</label>
<input type="text" id="referenciaCliente" name="referencia_cliente" maxLength="100" class="form-control" value="<?= old('referencia_cliente', $presupuestoEntity->referencia_cliente) ?>">
</div>
</div>
<div id="tapaDiv" class="row mt-3">
<div class="col-sm-3 mb-md-0 mb-2" id="tapaBlandaDiv">
<div id="tapaBlandaInnerDiv" class="form-check custom-option custom-option-tapa custom-option-basic
<?php echo ($datosPresupuesto->tapa == 'blanda' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="tapaBlanda">
<input name="tapaBlanda" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaBlanda"
<?php echo ($datosPresupuesto->tapa == 'blanda' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Tapa blanda</span>
</span>
</label>
</div>
</div>
<div id="tapaDuraDiv" class="col-sm-3 mb-md-0 mb-2">
<div class="form-check custom-option custom-option-tapa custom-option-basic
<?php echo ($datosPresupuesto->tapa == 'dura' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="tapaDura">
<input name="tapaDura" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaDura"
<?php echo ($datosPresupuesto->tapa == 'dura' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Tapa Dura</span>
</span>
</label>
</div>
</div>
</div> <!--//.row -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h5>Datos presupuesto</h5>
</div>
</div>
<div class="row">
<div id="errorTiradas" class="fv-plugins-message-container invalid-feedback" style="display: none;">
<div>No puede mezclar tiradas mayores de 30 unidades con tiradas menores de 30 unidades</div>
</div>
<div class="row">
<div class="col-sm-3 mb-3">
<label for="tirada" class="form-label">
<?= lang('Presupuestos.tirada') ?> 1
</label>
<input type="number" class="calcular-presupuesto" id="tirada" name="tirada" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-3 mb-3">
<label for="tirada2" class="form-label">
<?= lang('Presupuestos.tirada') ?> 2
</label>
<input type="number" class="calcular-presupuesto" id="tirada2" name="tirada2" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada2) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-3 mb-3">
<label for="tirada3" class="form-label">
<?= lang('Presupuestos.tirada') ?> 3
</label>
<input type="number" class="calcular-presupuesto" id="tirada3" name="tirada3" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada3) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-3 mb-3">
<label for="tirada4" class="form-label">
<?= lang('Presupuestos.tirada') ?> 4
</label>
<input type="number" class="calcular-presupuesto" id="tirada4" name="tirada4" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada4) ?>">
</div><!--//.mb-3 -->
</div> <!--//.row -->
</div> <!--//.row -->
<div class="row">
<div class="col-sm-3 mb-3">
<label for="paginas" class="form-label">
<?= lang('Presupuestos.paginas') ?>
</label>
<input type="number" class="calcular-presupuesto" id="paginas" name="paginas" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->paginas) ?>">
</div><!--//.mb-3 -->
<div id="div_pagCuadernillo" class="col-sm-3 mb-3">
<label for="paginas_por_cuadernillo" class="form-label">
<?= lang('Presupuestos.paginasCuadernillo') ?>
</label>
<select id="paginasCuadernillo" name="paginas_por_cuadernillo" class="calcular-presupuesto form-control select2bs2" style="width: 100%;">
<?php if (isset($datosPresupuesto->paginasCuadernillo) && is_array($datosPresupuesto->paginasCuadernillo) && !empty($datosPresupuesto->paginasCuadernillo)) :
foreach ($datosPresupuesto->paginasCuadernillo as $value) : ?>
<option value="<?= $value ?>" <?= $value == $presupuestoEntity->paginas_por_cuadernillo ? ' selected' : '' ?>>
<?= $value ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
</div> <!--//.row -->
<div class="row">
<div id="tamanioLibroDiv" class="col-sm-3 mb-3" <?= $presupuestoEntity->papel_formato_personalizado == false ? '' : 'style="display: none"'; ?>>
<label id="label_papelFormatoId" for="papelFormatoId" class="form-label">
Tamaño Libro*
</label>
<select id="papelFormatoId" name="papel_formato_id" tabindex="3" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<?php if (isset($datosPresupuesto->papelFormatoList) && is_array($datosPresupuesto->papelFormatoList) && !empty($datosPresupuesto->papelFormatoList)) :
foreach ($datosPresupuesto->papelFormatoList as $formato) : ?>
<option value="<?= $formato->id ?>" <?= $formato->id == $presupuestoEntity->papel_formato_id ? ' selected' : '' ?>>
<?= $formato->tamanio ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div>
<div id="anchoLibroDiv" class="col-sm-3 mb-3" <?= $presupuestoEntity->papel_formato_personalizado == true ? '' : 'style="display: none"'; ?>>
<div class="mb-1">
<label class="form-label" for="papelFormatoAncho">Ancho Libro</label>
<input type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="1" class="form-control formato_libro calcular-presupuesto" value="<?= old('papel_formato_ancho', $presupuestoEntity->papel_formato_ancho) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div id="altoLibroDiv" class="col-sm-3 mb-3" <?= $presupuestoEntity->papel_formato_personalizado == true ? '' : 'style="display: none"'; ?>>
<div class="mb-1">
<label class="form-label" for="papelFormatoAlto">Alto Libro</label>
<input type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="1" class="form-control formato_libro calcular-presupuesto" value="<?= old('papel_formato_alto', $presupuestoEntity->papel_formato_alto) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-sm-3 mb-3 d-flex align-items-end">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="papelFormatoPersonalizado" name="papel_formato_personalizado" value="1" <?= $presupuestoEntity->papel_formato_personalizado == true ? 'checked' : ''; ?>>
<label class="form-check-label" for="papelFormatoPersonalizado"><?= lang('Presupuestos.papelFormatoPersonalizado') ?></label>
</div>
</div>
</div> <!--//.row -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h5>Interior</h5>
</div>
</div>
<div id="errorInterior" class="fv-plugins-message-container invalid-feedback" style="display: none;">
<div>No existe combinación con las opciones seleccionadas. Pruebe con otro papel/gramaje</div>
</div>
<h6> Color del interior </h6>
<div class="row-color">
<!-- Fila 1 -->
<div class="row mb-2">
<!-- Imagen 1 (Color Negro) -->
<div class="col-sm-4 offset-sm-1 d-flex flex-column align-items-center justify-content-center">
<div id="colorNegroDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorNegro">
<span class="custom-option-body">
<img style="height:150px;width:240px" src="<?= site_url('assets/img/bn.png') ?>" alt="">
</span>
</label>
<input name="colorNegro" class="form-check-input calcular-presupuesto" type="radio" value="colorNegro" id="colorNegro"
<?php echo ($datosPresupuesto->color_impresion == 'negro' ? ' checked=""': ''); ?> >
</div>
<!-- Texto alineado debajo de la imagen -->
<div>
<h6 class="mt-2 text-center">Blanco y Negro Estándar</h6>
</div>
</div>
<!-- Imagen 2 (Color Negro HQ) -->
<div class="col-sm-4 d-flex flex-column align-items-center justify-content-center">
<div id="colorNegroHqDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorNegroHq">
<span class="custom-option-body">
<img style="height:150px;width:240px" src="<?= site_url('assets/img/bn_hq.png') ?>" alt="">
</span>
</label>
<input name="colorNegroHq" class="form-check-input calcular-presupuesto" type="radio" value="colorNegroHq" id="colorNegroHq"
<?php echo ($datosPresupuesto->color_impresion == 'negroHq' ? ' checked=""': ''); ?> >
</div>
<!-- Texto alineado debajo de la imagen -->
<div>
<h6 class="mt-2 text-center">Blanco y Negro Premium</h6>
</div>
</div>
</div> <!-- //.row -->
<!-- Fila 2 -->
<div class="row mb-2">
<!-- Imagen 3 (Color) -->
<div class="col-sm-4 offset-sm-1 d-flex flex-column align-items-center justify-content-center">
<div id="colorColorDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorColor">
<span class="custom-option-body">
<img style="height:150px;width:240px" src="<?= site_url('assets/img/color.png') ?>" alt="">
</span>
</label>
<input name="colorColor" class="form-check-input calcular-presupuesto" type="radio" value="colorColor" id="colorColor"
<?php echo ($datosPresupuesto->color_impresion == 'color' ? ' checked=""': ''); ?> >
</div>
<!-- Texto alineado debajo de la imagen -->
<div>
<h6 class="mt-2 text-center">Color Estándar</h6>
</div>
</div>
<!-- Imagen 4 (Color HQ) -->
<div class="col-sm-4 d-flex flex-column align-items-center justify-content-center">
<div id="colorColorHqDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorColorHq">
<span class="custom-option-body">
<img style="height:150px;width:240px" src="<?= site_url('assets/img/color_hq.png') ?>" alt="">
</span>
</label>
<input name="colorColorHq" class="form-check-input calcular-presupuesto" type="radio" value="colorColorHq" id="colorColorHq"
<?php echo ($datosPresupuesto->color_impresion == 'colorHq' ? ' checked=""': ''); ?> >
</div>
<!-- Texto alineado debajo de la imagen -->
<div>
<h6 class="mt-2 text-center">Color Premium</h6>
</div>
</div>
</div> <!-- //.row -->
</div> <!-- //.row-color -->
<div id="pagColorDiv" class="row">
<div class="col-sm-3 mb-3">
<label for="paginasColor" class="form-label">
Páginas a color
</label>
<input type="number" class="calcular-presupuesto" id="paginasColor" name="paginasColor" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->paginasColor) ?>">
</div><!--//.mb-3 -->
</div>
<h6> Papel </h6>
<div class="row">
<div class="col-sm-4 mb-md-0 mb-2">
<label for="papelInterior" class="form-label">Tipo de papel</label>
<select id="papelInterior" name="papelInterior" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;"></select>
</div>
<div class="col-sm-2 mb-md-0 mb-2">
<label for="gramajeInterior" class="form-label">Gramaje (g/m2)</label>
<select id="gramajeInterior" name="gramajeInterior" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
</select>
</div>
</div>
<h6> Opciones extra </h6>
<div class="row" <?= $clienteId != 0 ?' style="display:none;"':' '?>>
<div class="col-sm-3 mb-3 d-flex align-items-end">
<div class="form-check form-switch mb-2">
<input class="form-check-input calcular-presupuesto" type="checkbox" id="excluirRotativa" name="excluir_rotativa" value="0" <?= $presupuestoEntity->excluir_rotativa == true ? 'checked' : ''; ?>>
<label class="form-check-label" for="excluirRotativa">Excluir rotativa</label>
</div>
</div>
</div>
<!--SECCION DE CUBIERTA -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h5>Cubierta</h5>
</div>
</div>
<div id="errorCubierta" class="fv-plugins-message-container invalid-feedback" style="display: none;">
<div>No existe combinación con las opciones seleccionadas. Pruebe con otro papel/gramaje</div>
</div>
<h6> Papel </h6>
<div class="row">
<div class="col-sm-4 mb-md-0 mb-2">
<label for="papelCubierta" class="form-label">Tipo de papel</label>
<select id="papelCubierta" name="papelCubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<?php if (isset($datosPresupuesto->papelCubierta) && is_array($datosPresupuesto->papelCubierta) && !empty($datosPresupuesto->papelCubierta)) :
foreach ($datosPresupuesto->papelCubierta as $k => $v) : ?>
<option value="<?= $v->id ?>">
<?= $v->nombre ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div>
<div class="col-sm-2 mb-md-0 mb-2">
<label for="gramajeCubierta" class="form-label">Gramaje (g/m2)</label>
<select id="gramajeCubierta" name="gramajeCubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
</select>
</div>
</div>
<div class="row">
<div class="col-sm-4 mb-md-0 mb-2">
<label for="carasCubierta" class="form-label">Caras impresas cubierta</label>
<select id="carasCubierta" name="carasCubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<option value="2" <?php echo $presupuestoEntity->paginas_cubierta==2?'selected':''?> >
<p><?= lang('Presupuestos.unaCara') ?></p>
</option>
<option value="4" <?php echo $presupuestoEntity->paginas_cubierta==4?'selected':''?>>
<p><?= lang('Presupuestos.dosCaras') ?></p>
</option>
</select>
</div>
</div>
<h6 class='solapas-cubierta'> Opciones extra </h6>
<div class="row solapas-cubierta">
<div class="col-sm-3 mb-md-0 mb-2 d-flex align-items-end">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="solapasCubierta" name="solapasCubierta" value="0" <?= $presupuestoEntity->solapas == true ? 'checked' : ''; ?>>
<label class="form-check-label" for="solapasCubierta">Solapas cubierta</label>
</div>
</div>
<div id="tamanioSolapasCubierta" class="col-sm-3 mb-md-0 mb-2" <?= $presupuestoEntity->solapas == true ? '' : 'style="display: none;"'; ?>>
<label for="anchoSolapasCubierta" class="form-label">Tamaño</label>
<input type="number" id="anchoSolapasCubierta" name="anchoSolapasCubierta" maxLength="8" step="1" class="form-control calcular-presupuesto" value="<?= old(0, $presupuestoEntity->solapas_ancho) ?>">
</div>
</div>
<div class="row">
<div class="col-sm-4 mb-md-0 mb-2">
<label for="acabadosCubierta" class="form-label">Acabados cubierta</label>
<select id="acabadosCubierta" name="acabadosCubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<?php if (isset($datosPresupuesto->acabadosCubierta) && is_array($datosPresupuesto->acabadosCubierta) && !empty($datosPresupuesto->acabadosCubierta)) :
foreach ($datosPresupuesto->acabadosCubierta as $acabado) : ?>
<option value="<?= $acabado->id ?>" <?= $acabado->id == $presupuestoEntity->acabado_cubierta_id ? ' selected' : '' ?>>
<?= $acabado->label ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div>
</div>
<!--SECCION DE SOBRECUBIERTA -->
<div class="divider divider-dark text-start mb-1 sobrecubierta">
<div class="divider-text">
<h5>Sobrecubierta</h5>
</div>
</div>
<div id="errorSobrecubierta" class="fv-plugins-message-container invalid-feedback" style="display: none;">
<div>No existe combinación con las opciones seleccionadas. Pruebe con otro papel/gramaje</div>
</div>
<div class="row sobrecubierta">
<div class="col-sm-3 mb-md-0 mb-2 d-flex align-items-end">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="enableSobrecubierta" name="enableSobrecubierta" value="0"
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
echo 'checked';
endif; ?>
>
<label class="form-check-label" for="enableSobrecubierta">Añadir sobrecubierta</label>
</div>
</div>
</div>
<h6 class="sobrecubierta enable-sobrecubierta"
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
echo '';
else:
echo 'style="display: none;"';
endif; ?>
> Papel </h6>
<div class="row sobrecubierta enable-sobrecubierta">
<div class="col-sm-4 mb-md-0 mb-2">
<label for="papelSobrecubierta" class="form-label">Tipo de papel</label>
<select id="papelSobrecubierta" name="papelSobrecubierta" class="form-control select2bs2 calcular-presupuesto input-sobrecubierta" style="width: 100%;">
<?php if (isset($datosPresupuesto->papelSobrecubierta) && is_array($datosPresupuesto->papelSobrecubierta) && !empty($datosPresupuesto->papelSobrecubierta)) :
foreach ($datosPresupuesto->papelSobrecubierta as $k => $v) : ?>
<option value="<?= $v->id ?>">
<?= $v->nombre ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div>
<div class="col-sm-2 mb-md-0 mb-2">
<label for="gramajeSobrecubierta" class="form-label">Gramaje (g/m2)</label>
<select id="gramajeSobrecubierta" name="gramajeSobrecubierta" class="form-control select2bs2 calcular-presupuesto input-sobrecubierta" style="width: 100%;">
</select>
</div>
</div>
<h6 class="sobrecubierta enable-sobrecubierta"
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
echo '';
else:
echo 'style="display: none;"';
endif; ?>
> Opciones extra </h6>
<div class="row sobrecubierta enable-sobrecubierta"
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
echo '';
else:
echo 'style="display: none;"';
endif; ?>
>
<div id="tamanioSolapasSobrecubierta" class="col-sm-3 mb-md-0 mb-2"">
<label for="anchoSolapasSobrecubierta" class="form-label">Tamaño solapas</label>
<input type="number" id="anchoSolapasSobrecubierta" name="anchoSolapasSobrecubierta" maxLength="8" step="1" class="form-control input-sobrecubierta calcular-presupuesto" value="<?= old(0, $presupuestoEntity->solapas_ancho_sobrecubierta) ?>">
</div>
</div>
<div class="row sobrecubierta enable-sobrecubierta"
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
echo '';
else:
echo 'style="display: none;"';
endif; ?>
>
<div class="col-sm-4 mb-md-0 mb-2">
<label for="acabadosSobrecubierta" class="form-label">Acabados sobrecubierta</label>
<select id="acabadosSobrecubierta" name="acabadosSobrecubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<?php if (isset($datosPresupuesto->acabadosSobrecubierta) && is_array($datosPresupuesto->acabadosSobrecubierta) && !empty($datosPresupuesto->acabadosSobrecubierta)) :
foreach ($datosPresupuesto->acabadosSobrecubierta as $acabado) : ?>
<option value="<?= $acabado->id ?>" <?= $acabado->id == $presupuestoEntity->acabado_sobrecubierta_id ? ' selected' : '' ?>>
<?= $acabado->label ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div>
</div>
<!--SECCION DE GUARDAS -->
<div class="divider divider-dark text-start mb-1 guardas">
<div class="divider-text">
<h5>Guardas</h5>
</div>
</div>
<div id="errorGuardas" class="fv-plugins-message-container invalid-feedback" style="display: none;">
<div>No existe combinación con las opciones seleccionadas. Pruebe con otro papel/gramaje</div>
</div>
<div id="divGuardas" class="row guardas">
<div class="col-sm-4 mb-md-0 mb-2">
<label for="impresionGuardas" class="form-label">Impresión de guardas</label>
<select id="impresionGuardas" name="impresionGuardas" class="form-control select2bs2 comp_guardas_items calcular-presupuesto" style="width: 100%;">
<option value="0"
<?php echo ((!isset($presupuestoEntity->paginas_guardas) || $presupuestoEntity->paginas_guardas==0) ? 'selected' : ''); ?>
>
<p><?= lang('Presupuestos.sinImpresion') ?></p>
</option>
<option value="4"
<?php echo ($presupuestoEntity->paginas_guardas==4 ? 'selected' : ''); ?>
>
<p><?= lang('Presupuestos.unaCara') ?></p>
</option>
<option value="8"
<?php echo ($presupuestoEntity->paginas_guardas==8 ? 'selected' : ''); ?>
>
<p><?= lang('Presupuestos.dosCaras') ?></p>
</option>
</select>
</div>
</div>
<div class="row guardas">
<div class="col-sm-4 mb-md-0 mb-2">
<label for="papelGuardas" class="form-label">Tipo de papel</label>
<select id="papelGuardas" name="papelGuardas" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<?php if (isset($datosPresupuesto->papelGuardas) && is_array($datosPresupuesto->papelGuardas) && !empty($datosPresupuesto->papelGuardas)) :
foreach ($datosPresupuesto->papelGuardas as $k => $v) : ?>
<option value="<?= $v->id ?>" <?php echo ($v->id==$presupuestoEntity->papel_guardas?'selected':'');?> >
<?= $v->nombre ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div>
</div>
<!--SECCION DE SERVICIOS EXTRA -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h5>Servicios Extra</h5>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="retractilado" class="form-check-label">
<input type="checkbox" id="retractilado" name="retractilado" serv_id="3" value="1" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->retractilado == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.retractilado') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="retractilado5" class="form-check-label">
<input type="checkbox" id="retractilado5" name="retractilado_5" serv_id="5" value="1" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->retractilado5 == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.retractilado5') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="fajaColor" class="form-check-label">
<input type="checkbox" id="fajaColor" name="faja_color" value="1" serv_id="16" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->faja_color == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.fajaColor') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="prototipo" class="form-check-label">
<input type="checkbox" id="prototipo" name="prototipo" value="1" serv_id="9" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->prototipo == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.prototipo') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
<div class="mb-3">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="ferro" class="form-check-label">
<input type="checkbox" id="ferro" name="ferro" value="1" serv_id="24" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->ferro == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.ferro') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!--//.row -->
<!--SECCION DE OTRAS OPCIONES -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h5>Otras opciones</h5>
</div>
</div>
<div class="row">
<div class="col-sm-2 mb-md-0 mb-2">
<label for="ivaReducido" class="form-label">I.V.A. reducido</label>
<select id="ivaReducido" name="ivaReducido" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<option value="1" <?= $presupuestoEntity->iva_reducido == 1? 'selected':''?> >
<p><?= lang('SI') ?></p>
</option>
<option value="0" <?= $presupuestoEntity->iva_reducido == 0? 'selected':''?> >
<p><?= lang('NO') ?></p>
</option>
</select>
</div>
<p class="mt-2">Se verificará que el pedido cumpla con los requisitos establecidos en el Artículo 91 de la Ley 37/1992, sobre inserción de publicidad, antes de proceder con su producción, lo que garantiza la aplicación del IVA reducido del 4%.</p>
</div>
</div><!--//.col -->
</div>
<?= $this->section("additionalInlineJs") ?>
window.datosDisenioLibro = {
papel_interior: <?php echo $presupuestoEntity->papel_interior ? $presupuestoEntity->papel_interior : 'null'; ?>,
gramaje_interior: <?php echo $presupuestoEntity->gramaje_interior ? $presupuestoEntity->gramaje_interior : 'null'; ?>,
papel_cubierta: <?php echo $presupuestoEntity->papel_cubierta ? $presupuestoEntity->papel_cubierta : 'null'; ?>,
gramaje_cubierta: <?php echo $presupuestoEntity->gramaje_cubierta ? $presupuestoEntity->gramaje_cubierta : 'null'; ?>,
papel_sobrecubierta: <?php echo $presupuestoEntity->papel_sobrecubierta ? $presupuestoEntity->papel_sobrecubierta : 'null'; ?>,
gramaje_sobrecubierta: <?php echo $presupuestoEntity->gramaje_sobrecubierta ? $presupuestoEntity->gramaje_sobrecubierta : 'null'; ?>,
}
window.routes_disenio_libro = {
obtenerGramaje: "<?= route_to('obtenerGramaje') ?>",
presupuestoCliente: "<?= route_to('presupuestoCliente') ?>",
}
<?= $this->endSection() ?>

View File

@ -1,316 +0,0 @@
<div class="col-12 pb-2">
<div class="row mb-3">
<?php if($presupuestoEntity->estado_id==2): ?>
<h2>PRESUPUESTO ACEPTADO</h2>
<input type="hidden" id="lomo_cubierta" value=<?php echo $presupuestoEntity->lomo_cubierta ?>>
<br>
<?php endif; ?>
<h3>Resumen</h3>
<div class="col-sm-6">
<h5 class="mb-1">Libro</h5>
<p class="mb-0"><small id="tipoLibro"><?php echo (isset($presupuestoEntity->resumen->titulo)?$presupuestoEntity->resumen->titulo:'') ?></small></p>
<p class="mb-0"><small id="resumenTamanio">Tamaño: <?php echo (isset($presupuestoEntity->resumen->tamanio)?$presupuestoEntity->resumen->tamanio:'') ?></small></p>
<p class="mb-0"><small id="resumenPaginas">Número de páginas: <?php echo $presupuestoEntity->paginas ?></small></p>
<p class="mb-0"><small id="resumenTirada">Tirada: <?php echo $presupuestoEntity->tirada ?></small></p>
<p class="mb-0"><small id="resumenPrototipo">Prototipo: <?php echo ($presupuestoEntity->prototipo?'SI':'NO') ?></small></p>
<p class="mb-3"><small id="resumenFerro">Ferro: <?php echo ($presupuestoEntity->ferro?'SI':'NO') ?></small></p>
<h5 class="mb-1">Interior</h5>
<p class="mb-0"><small id="tipoImpresion">Impresion:
<?php echo (isset($presupuestoEntity->resumen->tipo_impresion)?$presupuestoEntity->resumen->tipo_impresion:'') ?>
</small></p>
<p id="pResumenPaginasColor" class="mb-0" <?php echo ($presupuestoEntity->paginasColor==0?'style="display:none"':'')?>>
<small id="resumenPaginasColor">Páginas a color: <?php echo $presupuestoEntity->paginasColor?></small></p>
<p class="mb-3"><small id="resumenPapelInterior">Papel:
<?php echo (isset($presupuestoEntity->papel_interior_nombre)?$presupuestoEntity->papel_interior_nombre:'') ?>
<?php echo (isset($presupuestoEntity->gramaje_interior)?$presupuestoEntity->gramaje_interior:'') ?>gr/m²</small></p>
<h5 class="mb-1">Cubierta</h5>
<p class="mb-0"><small id="resumenPapelCubierta">Papel:
<?php echo (isset($presupuestoEntity->papel_cubierta_nombre)?$presupuestoEntity->papel_cubierta_nombre:''); ?>
<?php echo (isset($presupuestoEntity->gramaje_cubierta)?$presupuestoEntity->gramaje_cubierta:''); ?>gr/m²</small></p>
<p class="mb-0"><small id="resumenCarasCubierta">Impresión: <?php echo ($presupuestoEntity->paginas_cubierta==2?"1 cara":"2 caras");?></small></p>
<?php if($presupuestoEntity->solapas_ancho>0 || $presupuestoEntity->estado_id==1): ?>
<p class="mb-0"><small id="resumenSolapasCubierta">Solapas: <?php echo $presupuestoEntity->solapas_ancho;?>mm</small></p>
<?php endif; ?>
<?php if($presupuestoEntity->acabado_cubierta_id>0 || $presupuestoEntity->estado_id==1): ?>
<p class="mb-3"><small id="resumenAcabadoCubierta">Acabado:
<?php if (isset($datosPresupuesto->acabadosCubierta) && is_array($datosPresupuesto->acabadosCubierta) && !empty($datosPresupuesto->acabadosCubierta)) :
foreach ($datosPresupuesto->acabadosCubierta as $acabado) :
if ($acabado->id == $presupuestoEntity->acabado_cubierta_id):
echo $acabado->label;
endif;
endforeach;
endif; ?>
</small></p>
<?php endif; ?>
<?php if($presupuestoEntity->papel_sobrecubierta || $presupuestoEntity->estado_id==1): ?>
<h5 class="mb-1 resumen-sobrecubierta">Sobrecubierta</h5>
<p class="mb-0 resumen-sobrecubierta"><small id="resumenPapelSobrecubierta">Papel:
<?php echo (isset($presupuestoEntity->papel_sobrecubierta_nombre)?$presupuestoEntity->papel_sobrecubierta_nombre:'') ?>
<?php echo (isset($presupuestoEntity->gramaje_sobrecubierta)?$presupuestoEntity->gramaje_sobrecubierta:'') ?>gr/m²</small></p>
<?php if($presupuestoEntity->solapas_ancho_sobrecubierta>0 || $presupuestoEntity->estado_id==1): ?>
<p class="mb-0 resumen-sobrecubierta"><small id="resumenSolapasCubierta">Ancho solapas: <?php echo $presupuestoEntity->solapas_ancho_sobrecubierta;?>mm</small></p>
<?php endif; ?>
<p class="mb-3 resumen-sobrecubierta"><small id="resumenAcabadoSobrecubierta">Acabado:
<?php if (isset($datosPresupuesto->acabadosSobrecubierta) && is_array($datosPresupuesto->acabadosSobrecubierta) && !empty($datosPresupuesto->acabadosSobrecubierta)) :
foreach ($datosPresupuesto->acabadosSobrecubierta as $acabado) :
if ($acabado->id == $presupuestoEntity->acabado_sobrecubierta_id):
echo $acabado->label;
endif;
endforeach;
endif; ?>
</small></p>
<?php endif; ?>
<?php if($presupuestoEntity->papel_guardas || $presupuestoEntity->estado_id==1): ?>
<h5 class="mb-1 resumen-guardas">Guardas</h5>
<p class="mb-0 resumen-guardas"><small id="resumenGuardasPapel">Papel:
<?php echo (isset($presupuestoEntity->papel_guardas_nombre)?$presupuestoEntity->papel_guardas_nombre:''); ?>
170gr/m²</small></p>
<p class="mb-3 resumen-guardas"><small id="resumenGuardasCaras">Impresión:
<?php if(!isset($presupuestoEntity->paginas_guardas) || $presupuestoEntity->paginas_guardas==0):
echo "Sin impresion";
elseif($presupuestoEntity->paginas_guardas==4):
echo "1 cara";
else:
echo "2 caras";
endif; ?></small></p>
<?php endif; ?>
<?php if($presupuestoEntity->retractiladol || $presupuestoEntity->retractilado5 || $presupuestoEntity->faja_color || $presupuestoEntity->estado_id==1): ?>
<h5 class="mb-1 resumen-extras">Extras</h5>
<?php endif; ?>
<?php if($presupuestoEntity->retractiladol): ?>
<p class="mb-0 resumen-extras" id="resumenRetractilado1"><small>Retractilado individual</small></p>
<?php elseif ($presupuestoEntity->retractilado5): ?>
<p class="mb-0 resumen-extras" id="resumenRetractilado5"><small>Retractilado de 5</small></p>
<?php elseif ($presupuestoEntity->faja_color): ?>
<p class="mb-0 resumen-extras" id="resumenFajaColor"><small>Imprimir faja a color</small></p>
<?php endif; ?>
</div>
<div class="col-sm-6">
<?php if($presupuestoEntity->estado_id==2):
$total = $presupuestoEntity->total_aceptado;
$iva = $presupuestoEntity->iva_reducido?1.04:1.21;
$total *= $iva;
$total_unidad = $presupuestoEntity->total_precio_unidad * $iva;;
echo '<h4 id="resumenTotalIVA" class="mb-1">Total: ' . round($total, 2) . '€</h4>';
echo '<h6 id="resumenPrecioU" class="mb-0">' . round($total_unidad, 4) . '€/ud</h6>'
?>
<?php else: ?>
<h4 id="resumenTotalIVA" class="mb-1">Total: 100€</h4>
<h6 id="resumenPrecioU" class="mb-0">10.4€/ud</h6>
<?php endif; ?>
<div id="shape-container">
<div id="thumbnail_ec_shape" style="width:350px;height:300px;margin:2.5% auto;"></div>
<div class="d-flex justify-content-center">
<button type="button" id="pv_details" class="btn btn-primary align-content-center"
data-bs-toggle="modal" data-bs-target="#pv_ec_modal">
Previsualizar detalles de cubierta
</button>
</div>
</div>
</div>
</div>
<?php if($presupuestoEntity->estado_id==2):
echo '<div class="row mb-3">';
echo '<h3>Direcciones de envío</h3>';
echo '<div class="col-sm-6">';
if(isset($presupuestoEntity->direcciones_envio)):
foreach ($presupuestoEntity->direcciones_envio as $direccion):
echo '<div class="row mb-3">';
echo '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
echo '<label class="form-check-label custom-option-content">';
echo '<span class="custom-option-header mb-2">';
echo '<h6 class="fw-semibold mb-0">' . $direccion['att'] . '</h6>';
echo '<span class="badge bg-label-primary">' . $direccion['cantidad'] . ' unidades</span>';
echo '</span>';
echo '<span class="custom-option-body">';
echo '<small>' . $direccion['direccion'] . '</small><br>';
echo '<small>' . $direccion['cp'] . '</small><br>';
echo '<small>' . $direccion['municipio'] .', ' . $direccion['pais'] . '</small><br>';
echo '<small>' . $direccion['telefono'] . '</small><br>';
echo '<small>' . $direccion['email'] . '</small><br>';
if($direccion['entregaPieCalle'] == 1){
echo '<small><i>Envío en palets</i></small><br>';
}
echo '<hr class="my-2">';
echo '</span>';
echo '</label>';
echo '</div>';
echo '</div>';
endforeach;
endif;
echo '</div>';
echo '</div>';
endif; ?>
<?php if($presupuestoEntity->estado_id==2): ?>
<div class="row mb-3">
<h3>Ficheros</h3>
<div class="col-12">
<div class="dropzone needsclick" id="dropzone-multi" >
<div class="dz-message needsclick">
Arrastre aquí los ficheros o haga click
</div>
<div class="fallback">
<input name="file" type="file" />
</div>
</div>
</div>
<button id="submit-all" class="btn mt-3 btn-primary btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Actualizar ficheros</span>
<i class="ti ti-upload ti-xs"></i>
</button>
</div>
<?php endif; ?>
</div>
<!-- Modal -->
<div class="modal fade" id="pv_ec_modal" tabindex="-1">
<div class="modal-dialog modal-xl modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Esquema de cubierta</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
</button>
</div>
<div class="modal-body" >
<div id="pv_ec_shape" style="width:850px;height:600px;margin:2.5% auto;"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
<?= $this->section("additionalInlineJs") ?>
window.estado = <?= $presupuestoEntity->estado_id ?? 1?>;
window.tirada = <?= $presupuestoEntity->selected_tirada ?? 0?>;
window.total = <?= $presupuestoEntity->total_aceptado ?? 0?>;
window.total_unidad = <?= $presupuestoEntity->total_precio_unidad ?? 0 ?>;
window.routes_resumen = {
guardarPresupuesto: "<?= route_to('guardarPresupuesto') ?>",
duplicarPresupuesto: "<?= route_to('duplicarPresupuesto') ?>",
}
<?php if ($presupuestoEntity->estado_id===2): ?>
previewEsquemaCubierta(true);
const previewTemplate = `<div class="dz-preview dz-file-preview">
<div class="dz-details">
<div class="dz-thumbnail">
<!---<img data-dz-thumbnail>
<span class="dz-nopreview">No preview</span> --->
<div class="dz-success-mark"></div>
<div class="dz-error-mark"></div>
<div class="dz-error-message"><span data-dz-errormessage></span></div>
<div class="progress">
<div class="progress-bar progress-bar-primary" role="progressbar" aria-valuemin="0" aria-valuemax="100" data-dz-uploadprogress></div>
</div>
</div>
<div class="dz-filename" data-dz-name></div>
<div class="dz-size" data-dz-size></div>
</div>
</div>`;
Dropzone.autoDiscover = false;
var dropzoneMulti = new Dropzone('#dropzone-multi', {
url: "<?= site_url('presupuestos/presupuestocliente/upload_files') ?>",
addRemoveLinks: true,
previewTemplate: previewTemplate,
paramName: "file",
uploadMultiple: true,
parallelUploads: 4, // Ajusta este número al máximo número de archivos que esperas subir a la vez
maxFiles: 5, // Ajusta este número al máximo número de archivos que esperas subir a la vez
autoProcessQueue: true,
dictRemoveFile: "Eliminar",
acceptedFiles: 'image/*, application/pdf',
maxFilesize: 5e+7, // Bytes
init: function() {
thisDropzone = this;
$('#loader').show();
$.ajax({
url: "<?= site_url('presupuestos/presupuestocliente/get_files') ?>",
type: 'POST',
data: { presupuesto_id: <?= $presupuestoEntity->id ?> },
}).done(function(response) {
if(response == null || response == ""){
return;
}
values = JSON.parse(response);
for(var i = 0; i < values.length; i++){
var mockFile = { name: values[i].name, size: values[i].size, hash: values[i].hash};
thisDropzone.files.push(mockFile); // add to files array
thisDropzone.emit("addedfile", mockFile);
thisDropzone.emit("thumbnail", mockFile, window.location.host + "/sistema/intranet/presupuestos/"+values[i].hash);
thisDropzone.emit("complete", mockFile);
thisDropzone.options.success.call(thisDropzone, mockFile);
};
}).always(function() {
$('#loader').hide();
});
this.on("addedfile", function (file) {
if(file.hash){
var viewButton = Dropzone.createElement("<span class='dz-remove'>Ver</span>");
file.previewElement.appendChild(viewButton);
// Listen to the view button click event
viewButton.addEventListener("click", function (e) {
window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/presupuestos/"+file.hash, '_blank');
});
}
});
}
});
$('#presupuesto-cliente-form').submit(function(e){
e.preventDefault();
var files = dropzoneMulti.files;
$('#loader').show();
var formData = new FormData();
var oldFiles = [];
var counter = 0;
for (var i = 0; i < files.length; i++) {
if(files[i].upload){
var file = files[i];
formData.append('file[' + counter + ']', file);
counter += 1;
}
else{
oldFiles.push(files[i].name);
}
}
formData.append('oldFiles', JSON.stringify(oldFiles));
formData.append('presupuesto_id', <?= $presupuestoEntity->id ?>);
$.ajax({
url: "<?= site_url('presupuestos/presupuestocliente/upload_files') ?>",
type: 'POST',
data: formData,
processData: false, // Indicar a jQuery que no procese los datos
contentType: false // Indicar a jQuery que no establezca el tipo de contenido
}).done(function(response) {
// Aquí puedes manejar la respuesta del servidor
}).always(function() {
$('#loader').hide();
})
return false;
});
<?php endif; ?>
<?= $this->endSection() ?>

View File

@ -1,122 +0,0 @@
<div class="col-12 pb-2">
<div class="tipo_libro">
<input type="hidden" id="lomo_cubierta" value=<?php echo $presupuestoEntity->lomo_cubierta ?>>
<div class="row row-cols-3 mb-6 d-flex justify-content-center d-flex justify-content-center">
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="cosidoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php
if($datosPresupuesto->tipo_libro == 'cosido' || $datosPresupuesto->tipo_libro == ''){
echo ' checked"';
}
else
{
echo '"';
}
?>
>
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoCosido">
<span class="custom-option-body">
<img style="max-width:200px;max-height:200px;"
src="<?= site_url("assets/img/libro_cosido.png") ?>" alt="radioImg">
</span>
</label>
<input name="cosido" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoCosido"
id="tipoCosido"
<?php
if($datosPresupuesto->tipo_libro == 'cosido' || $datosPresupuesto->tipo_libro == ''){
echo 'checked=""';
}
?>
>
</div>
<h4 class="text-center">Rústica cosido</h4>
</div>
</div>
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="fresadoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'fresado' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoFresado">
<span class="custom-option-body">
<img style="max-width:200px;max-height:200px;"
src="<?= site_url("assets/img/libro_fresado.png") ?>" alt="radioImg2">
</span>
</label>
<input name="fresado" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoFresado"
id="tipoFresado" <?php echo (($datosPresupuesto->tipo_libro)=='fresado'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Rústica fresado</h4>
</div>
</div>
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="grapadoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'grapado' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoGrapado">
<span class="custom-option-body">
<img style="max-width:200px;max-height:200px;"
src="<?= site_url("assets/img/libro_grapado.png") ?>" alt="radioImg3">
</span>
</label>
<input name="grapado" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoGrapado"
id="tipoGrapado" <?php echo (($datosPresupuesto->tipo_libro)=='grapado'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Cosido con grapas</h4>
</div>
</div>
</div>
<div class="row row-cols-3 d-flex justify-content-center d-flex justify-content-center">
<div class="col-md-4 mb-6 d-flex justify-content-center">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="espiralDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'espiral' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoEspiral">
<span class="custom-option-body">
<img style="max-width:200px;max-height:200px;"
src="<?= site_url("assets/img/libro_espiral.png") ?>" alt="radioImg4">
</span>
</label>
<input name="espiral" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoEspiral"
id="tipoEspiral" <?php echo (($datosPresupuesto->tipo_libro)=='espiral'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Espiral</h4>
</div>
</div>
<div class="col-md-4 mb-6 d-flex justify-content-center" >
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="wireoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'wireo' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoWireO">
<span class="custom-option-body">
<img style="max-width:200px;max-height:200px;"
src="<?= site_url("assets/img/libro_wire-o.png") ?>" alt="radioImg5">
</span>
</label>
<input name="wireo" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoWireO"
id="tipoWireO" <?php echo (($datosPresupuesto->tipo_libro)=='wireo'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Wire-o</h4>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,387 +0,0 @@
function initDirecciones() {
data = {
id: $('#clienteId').val()
},
data = Object.assign(data, window.token_ajax);
$('#errorDirecciones').hide();
$.ajax({
url: window.routes_direcciones.direcciones,
type: 'POST',
data: data,
success: function(response) {
$("#direcciones").empty();
$.each(response.menu, function(index, value) {
$("#direcciones").append('<option value="' + value.id + '">' + value.text + '</option>');
});
$("#direcciones").val('');
},
error: function() {
$("#direcciones").empty();
},
});
}
function initTiradasDirecciones() {
const _this = this
let sel_index = 1;
$('#containerTiradasEnvios').empty();
for (i = 1; i <= 4; i++) {
let id = "tiradaPrecio" + i;
if ($('#' + id).length > 0) {
let tirada_id = "ud_tiradaPrecio" + i;
let total_id = "tot_tiradaPrecio" + i;
let precio_u_id = "pu_tiradaPrecio" + i;
let peso = $('#' + id).attr('peso');
let html = '';
html += '<div class="col-sm-3">';
html += '<div id=div-env_' + id + ' class="form-check custom-option custom-option-basic custom-option-tiradasDirecciones">';
html += '<label class="form-check-label custom-option-content" for="tiradaEnvios' + i + '">';
html += '<input name=env_"' + id + '" peso="' + peso + '" class="form-check-input" type="radio" value="" id="env_' + id + '"></input>';
html += '<span class="custom-option-header">';
html += '<span id="tiradaDireccionesValue' + i + '" class="h6 mb-0">' + $('#' + tirada_id).text().split(' ')[0] + '</span>';
html += '<span class="text-muted">' + $('#' + total_id).text() + '</span>';
html += '</span>';
html += '<span class="custom-option-body">';
html += '<small>' + $('#' + precio_u_id).text() + '</small>';
html += '</span>';
html += '</label>';
html += '</div>';
html += '</div>';
$('#containerTiradasEnvios').append(html);
if(parseInt($('#' + tirada_id).text().split(' ')[0]) == window.direcciones_sel_tirada){
sel_index = i;
}
$('#' + id).hide();
}
}
$(('#env_tiradaPrecio' + sel_index)).trigger('click');
cargarDirecciones();
const tiradasDireccionesList = [].slice.call(document.querySelectorAll('.custom-option-tiradasDirecciones .form-check-input'))
tiradasDireccionesList.map(function (customOptionEL) {
// Update custom options check on page load
_this.updateTiradasDireccionesCheck(customOptionEL)
// Update custom options check on click
customOptionEL.addEventListener('click', e => {
_this.updateTiradasDireccionesCheck(customOptionEL)
})
})
}
function cargarDirecciones(){
$('#loader').show();
$('#divDirecciones').empty();
if(window.direcciones == null){
$('#loader').hide();
return;
}
for(let i=0; i<window.direcciones.length; i++){
const tipo = window.direcciones[i].entregaPieCalle == 1?'palets':'cajas';
let html = '';
html += '<div id="envioId' + window.direcciones[i].direccion_id + '" t="' + tipo + '" p= ' +window.direcciones[i].precio + ' class="row mb-3">';
html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">';
html += '<span class="custom-option-header mb-2">';
html += '<h6 class="fw-semibold mb-0">' + window.direcciones[i].att + '</h6>';
html += '<span class="badge bg-label-primary">' + window.direcciones[i].cantidad + ' unidades</span>';
html += '</span>';
html += '<span class="custom-option-body">';
html += '<small>' + window.direcciones[i].direccion + '</small><br>';
html += '<small>' + window.direcciones[i].cp + '</small><br>';
html += '<small>' + window.direcciones[i].municipio +', ' + window.direcciones[i].pais + '</small><br>';
html += '<small>' + window.direcciones[i].telefono + '</small><br>';
html += '<small>' + window.direcciones[i].email + '</small><br>';
if(tipo == 'palets'){
html += '<small><i>Envío en palets</i></small><br>';
}
html += '<hr class="my-2">';
html += '<span class="d-flex">';
html += '<a class="eliminar-direccion" href="javascript:void(0)">Eliminar</a>';
html += '</span>';
html += '</span>';
html += '</label>';
html += '</div>';
html += '</div>';
$('#divDirecciones').append(html);
$('#errorDirecciones').hide();
$('#loader').hide();
}
}
function updateTiradasDireccionesCheck(el) {
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-tiradasDirecciones'))
customRadioOptionList.map(function (customRadioOptionEL) {
customRadioOptionEL.closest('.custom-option-tiradasDirecciones').classList.remove('checked')
let id_temp = customRadioOptionEL.id.split('-')[1];
$('#' + id_temp).prop('checked', false);
})
}
const element = el.closest('.custom-option-tiradasDirecciones');
element.classList.add('checked');
let id = element.id.split('-')[1];
$('#' + id).prop('checked', true);
} else {
el.closest('.custom-option-tiradasDirecciones').classList.remove('checked')
}
}
function obtenerUnidadesEnvio(){
const elements = $('#divDirecciones').find('.row.mb-3');
let total = 0;
if(elements.length > 0) {
for (let index=0; index<elements.length; index++){
let unidades_direcciones = parseInt($(elements[index]).find('div label span span').text().split(' ')[0]);
total += unidades_direcciones;
};
}
return total;
}
$('#insertarDireccion').on('click', function() {
if( $('#direcciones').val() > 0 ) {
let unidades = $('#unidadesEnvio').val();
if(unidades == '' || isNaN(unidades) || parseInt(unidades) <= 0){
return false;
}
unidades = parseInt(unidades);
const seleccion = $('.custom-option-tiradasDirecciones.checked');
if(seleccion.length == 0) {
return false;
}
const element_tirada =($(seleccion[0]).find('label input')[0]);
const number = element_tirada.id.match(/\d+$/);
if (number.length == 0) {
return false;
}
let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
let total = obtenerUnidadesEnvio();
if($('#prototipo').is(':checked')) {
tirada += 1;
}
if(total + unidades <= tirada) {
data = {
id: $('#direcciones').val(),
peso: $('#env_tiradaPrecio' + number[0]).attr('peso'),
unidades: unidades,
entregaPieCalle: $('#entregaPieCalle').is(':checked')?1:0,
},
data = Object.assign(data, window.token_ajax)
$('#loader').show();
$.ajax({
url: window.routes_direcciones.getDatos,
type: 'POST',
data: data,
success: function(response) {
if(response.data.length > 0) {
let html = '';
html += '<div id="envioId' + response.data[0].id + '" t="' +response.data[0].tipo + '" p= ' +response.data[0].coste + ' class="row mb-3">';
html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">';
html += '<span class="custom-option-header mb-2">';
html += '<h6 class="fw-semibold mb-0">' + response.data[0].att + '</h6>';
html += '<span class="badge bg-label-primary">' + unidades + ' unidades</span>';
html += '</span>';
html += '<span class="custom-option-body">';
html += '<small>' + response.data[0].direccion + '</small><br>';
html += '<small>' + response.data[0].cp + '</small><br>';
html += '<small>' + response.data[0].municipio +', ' + response.data[0].pais + '</small><br>';
html += '<small>' + response.data[0].telefono + '</small><br>';
html += '<small>' + response.data[0].email + '</small><br>';
if(response.data[0].tipo == 'palets'){
html += '<small><i>Envío en palets</i></small><br>';
}
html += '<hr class="my-2">';
html += '<span class="d-flex">';
html += '<a class="eliminar-direccion" href="javascript:void(0)">Eliminar</a>';
html += '</span>';
html += '</span>';
html += '</label>';
html += '</div>';
html += '</div>';
$('#divDirecciones').append(html);
$('#errorDirecciones').hide();
$('#loader').hide();
}
},
error: function() {
$("#direcciones").empty();
$('#loader').hide();
},
});
}
else{
$('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
$('#errorDirecciones').show();
}
}
return false;
})
$(document).on('click', '.eliminar-direccion', function(e) {
$(this).closest('.row.mb-3').remove();
const seleccion = $('.custom-option-tiradasDirecciones.checked');
if(seleccion.length == 0) {
return false;
}
const element_tirada =($(seleccion[0]).find('label input')[0]);
const number = element_tirada.id.match(/\d+$/);
if (number.length == 0) {
return false;
}
let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
const elements = $('#divDirecciones').find('.row.mb-3');
let total = 0;
if(elements.length > 0) {
for (let index=0; index<elements.length; index++){
let unidades_direcciones = parseInt($(elements[index]).find('div label span span').text().split(' ')[0]);
total += unidades_direcciones;
};
}
if(total <= tirada) {
$('#errorDirecciones').hide();
}
return false;
});
$('#direcciones').on('change', function() {
if( $('#direcciones').val() == 0 ) {
$("#addressForm").attr('action','create')
var $newAddDialog = $("#addressForm")
$newAddDialog.modal('show')
$newAddDialog.on('hidden.bs.modal', function (e) {
$('#direcciones').val('');
});
}
})
function saveAdd_callback(){
if($('#addressForm').attr('action')=='create'){
let data = {
cliente_id: $('#clienteId').val(),
alias: $('#add_alias').val(),
att: $('#add_att').val(),
email: $('#add_email').val(),
direccion: $('#add_direccion').val(),
pais_id: $("#add_pais_id option:selected").val(),
municipio: $('#add_municipio').val(),
provincia: $('#add_provincia').val(),
cp: $('#add_cp').val(),
telefono: $('#add_telefono').val(),
}
data = Object.assign(data, window.token_ajax)
$.ajax({
url: window.routes_direcciones.nuevaDireccion,
type: 'POST',
data: data,
success: function(response) {
$("#direcciones").empty();
$.each(response.data, function(index, value) {
$("#direcciones").append('<option value="' + value.id + '">' + value.text + '</option>');
});
$("#direcciones").val('');
$('#addressForm').modal('hide');
},
error: function() {
$('#addressForm').modal('hide');
},
});
}
}
function validarEnvio(){
const seleccion = $('.custom-option-tiradasDirecciones.checked');
if(seleccion.length == 0) {
return false;
}
const element_tirada =($(seleccion[0]).find('label input')[0]);
const number = element_tirada.id.match(/\d+$/);
if (number.length == 0) {
return false;
}
let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
let total = obtenerUnidadesEnvio();
if($('#prototipo').is(':checked')) {
tirada += 1;
}
if(total != tirada){
return false;
}
return true;
}
function getDireccionesEnvio(){
const elements = $('#divDirecciones').find('.row.mb-3');
let direcciones = [];
if(elements.length > 0) {
for (let index=0; index<elements.length; index++){
const unidades = parseInt($(elements[index]).find('div label span span').text().split(' ')[0]);
const id = $(elements[index]).attr('id').replace('envioId', '');
const tipo = $(elements[index]).attr('t');
direcciones.push({
unidades: unidades,
id: id,
tipo: tipo,
})
};
}
return direcciones;
}

View File

@ -1,789 +0,0 @@
$('#papelFormatoPersonalizado').on('change', function () {
if ($(this).is(":checked")) {
$('#tamanioLibroDiv').hide();
$('#anchoLibroDiv').show();
$('#altoLibroDiv').show();
$('#papelFormatoId').val('').trigger('change');
} else {
$('#tamanioLibroDiv').show();
$('#anchoLibroDiv').hide();
$('#altoLibroDiv').hide();
}
});
// Init custom option check
function initTapaCheck() {
const _this = this
const tapaOptionList = [].slice.call(document.querySelectorAll('.custom-option-tapa .form-check-input'))
tapaOptionList.map(function (customOptionEL) {
// Update custom options check on page load
_this.updateTapaCheck(customOptionEL)
// Update custom options check on click
customOptionEL.addEventListener('click', e => {
_this.updateTapaCheck(customOptionEL)
})
})
}
function updateTapaCheck(el) {
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-tapa'))
customRadioOptionList.map(function (customRadioOptionEL) {
customRadioOptionEL.closest('.custom-option-tapa').classList.remove('checked')
})
}
el.closest('.custom-option-tapa').classList.add('checked')
if (el.closest('.custom-option-tapa').id == 'tapaBlandaInnerDiv') {
$('#tapaBlanda').prop('checked', true);
$('#tapaDura').prop('checked', false);
}
else {
$('#tapaBlanda').prop('checked', false);
$('#tapaDura').prop('checked', true);
}
} else {
el.closest('.custom-option-tapa').classList.remove('checked')
}
}
function initColorCheck() {
const _this = this
const custopOptionList = [].slice.call(document.querySelectorAll('.custom-option-color .form-check-input'))
custopOptionList.map(function (customOptionEL) {
// Update custom options check on page load
_this.updateColorCheck(customOptionEL)
// Update custom options check on click
customOptionEL.addEventListener('click', e => {
_this.updateColorCheck(customOptionEL)
})
})
}
function updateColorCheck(el) {
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
const customRadioOptionList = [].slice.call(el.closest('.row-color').querySelectorAll('.custom-option-color'))
customRadioOptionList.map(function (customRadioOptionEL) {
customRadioOptionEL.closest('.custom-option-color').classList.remove('checked')
})
}
el.closest('.custom-option-color').classList.add('checked')
if (el.closest('.custom-option-color').id == 'colorNegroDiv') {
$('#colorNegro').prop('checked', true);
$('#colorNegroHq').prop('checked', false);
$('#colorColor').prop('checked', false);
$('#colorColorHq').prop('checked', false);
}
else if (el.closest('.custom-option-color').id == 'colorNegroHqDiv') {
$('#colorNegro').prop('checked', false);
$('#colorNegroHq').prop('checked', true);
$('#colorColor').prop('checked', false);
$('#colorColorHq').prop('checked', false);
}
else if (el.closest('.custom-option-color').id == 'colorColorDiv') {
$('#colorNegro').prop('checked', false);
$('#colorNegroHq').prop('checked', false);
$('#colorColor').prop('checked', true);
$('#colorColorHq').prop('checked', false);
}
else {
$('#colorNegro').prop('checked', false);
$('#colorNegroHq').prop('checked', false);
$('#colorColor').prop('checked', false);
$('#colorColorHq').prop('checked', true);
}
} else {
el.closest('.custom-option-color').classList.remove('checked')
}
}
$('#enableSobrecubierta').on('change', function () {
if ($(this).is(":checked")) {
$('.enable-sobrecubierta').show();
} else {
$('#gramajeSobrecubierta').val('').trigger('change');
$('#paperSobrecubierta').val('').trigger('change');
$('#acabadosSobrecubierta').val('').trigger('change');
$('#tamanioSolapasSobrecubierta').val();
$('.enable-sobrecubierta').hide();
}
});
function initDisenioLibro() {
initTapaCheck();
initColorCheck();
$('.elementos-libro').trigger('change');
$('.change-tipo-impresion').trigger('change');
$('#papelInterior').trigger('change');
$('#papelInterior').val(window.datosDisenioLibro.papel_interior);
$('#gramajeInterior').append($('<option>', {
value: window.datosDisenioLibro.gramaje_interior,
text: window.datosDisenioLibro.gramaje_interior
}));
$('#gramajeInterior').val(window.datosDisenioLibro.gramaje_interior);
$('#papelCubierta').val('').trigger('change');
$('#papelCubierta').val(window.datosDisenioLibro.papel_cubierta);
$('#gramajeCubierta').append($('<option>', {
value: window.datosDisenioLibro.gramaje_cubierta,
text: window.datosDisenioLibro.gramaje_cubierta
}));
$('#gramajeCubierta').val(window.datosDisenioLibro.gramaje_cubierta);
$('#papelSobrecubierta').val('').trigger('change');
$('#papelSobrecubierta').val(window.datosDisenioLibro.papel_sobrecubierta);
$('#gramajeSobrecubierta').append($('<option>', {
value: window.datosDisenioLibro.gramaje_sobrecubierta,
text: window.datosDisenioLibro.gramaje_sobrecubierta
}));
$('#gramajeSobrecubierta').val(window.datosDisenioLibro.gramaje_sobrecubierta);
$('#enableSobrecubierta').trigger('change');
}
$('.change-tipo-impresion').on('change', function () {
let isColor = false;
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isColor = true;
let isHq = false;
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isHq = true;
//si es color hay que mostrar el numero de paginas a color
if (isColor) {
$('#pagColorDiv').show();
if($('#paginasColor').val() == '')
$('#paginasColor').val('0');
}
else {
$('#pagColorDiv').hide();
$('#paginasColor').val('0');
}
var data = [];
if (!isColor && !isHq) {
data = window.datosPresupuesto.papelInteriorNegro;
}
else if (!isColor && isHq) {
data = window.datosPresupuesto.papelInteriorNegroHq;
}
else if (isColor && !isHq) {
data = window.datosPresupuesto.papelInteriorColor;
}
else if (isColor && isHq) {
data = window.datosPresupuesto.papelInteriorColorHq;
}
var dropdown = $("#papelInterior");
dropdown.empty();
$.each(data, function () {
dropdown.append($("<option />").val(this.id).text(this.nombre));
});
//Se quita la seleccion del dropdown
dropdown.val('').trigger('change');
$('#gramajeInterior').val('').trigger('change');
});
$('#tirada').on('change', function () {
const valInterior = $('#gramajeInterior option:selected').val();
const valCubierta = $('#gramajeCubierta option:selected').val();
const valSobrecubierta = $('#gramajeSobrecubierta option:selected').val();
$('#papelInterior').trigger('change');
$('#papelCubierta').trigger('change');
$('#papelSobrecubierta').trigger('change');
});
$('#papelInterior').on('change', function () {
let isColor = false;
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isColor = true;
let isHq = false;
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isHq = true;
if ($('#papelInterior option:selected').val() != undefined) {
var uso = 'bn';
if (!isColor && !isHq) {
uso = 'bn';
}
else if (!isColor && isHq) {
uso = 'bnhq';
}
else if (isColor && !isHq) {
uso = 'color';
}
else if (isColor && isHq) {
uso = 'colorhq';
}
datos = {
tirada: $('#tirada').val(),
merma: 0,
uso: uso,
papel: $('#papelInterior option:selected').text()
};
datos = Object.assign(datos, window.token_ajax)
const valInterior = $('#gramajeInterior option:selected').val();
$.ajax({
url: window.routes_disenio_libro.obtenerGramaje,
type: 'POST',
data: datos,
success: function (response) {
if(response.menu){
$('#gramajeInterior').empty();
$(response.menu).each(function (index, element) {
$('#gramajeInterior').append($("<option />").val(element.id).text(element.text));
});
}
if (valInterior != undefined && valInterior != '')
$('#gramajeInterior option[value=' + valInterior + ']').prop('selected', true).trigger('change');
else
$('#gramajeInterior').val('').trigger('change');
}
});
}
});
$('#papelCubierta').on('change', function () {
let isColor = true;
let isHq = true;
if ($('#papelCubierta option:selected').val() != undefined) {
var uso = 'cubierta';
datos = {
tirada: $('#tirada').val(),
merma: 0,
uso: uso,
papel: $('#papelCubierta option:selected').text().trim()
};
datos = Object.assign(datos, window.token_ajax)
const valCubierta = $('#gramajeCubierta option:selected').val();
$.ajax({
url: window.routes_disenio_libro.obtenerGramaje,
type: 'POST',
data: datos,
success: function (response) {
$('#gramajeCubierta').empty();
$(response.menu).each(function (index, element) {
$('#gramajeCubierta').append($("<option />").val(element.id).text(element.text));
});
if (valCubierta != undefined && valCubierta != '')
$('#gramajeCubierta option[value=' + valCubierta + ']').prop('selected', true).trigger('change');
else
$('#gramajeCubierta').val('').trigger('change');
}
});
}
});
$('#papelSobrecubierta').on('change', function () {
let isColor = true;
let isHq = true;
if ($('#papelSobrecubierta option:selected').val() != undefined) {
var uso = 'sobrecubierta';
datos = {
tirada: $('#tirada').val(),
merma: 0,
uso: uso,
papel: $('#papelSobrecubierta option:selected').text().trim()
};
datos = Object.assign(datos, window.token_ajax)
const valSobrecubierta = $('#gramajeSobrecubierta option:selected').val();
$.ajax({
url: window.routes_disenio_libro.obtenerGramaje,
type: 'POST',
data: datos,
success: function (response) {
$('#gramajeSobrecubierta').empty();
$(response.menu).each(function (index, element) {
$('#gramajeSobrecubierta').append($("<option />").val(element.id).text(element.text));
});
if (valSobrecubierta != undefined)
$('#gramajeSobrecubierta option[value=' + valSobrecubierta + ']').prop('selected', true).trigger('change');
else
$('#gramajeSobrecubierta').val('').trigger('change');
}
});
}
});
$('#solapasCubierta').on('change', function () {
if ($(this).is(":checked")) {
$('#tamanioSolapasCubierta').show();
} else {
$('#tamanioSolapasCubierta').hide();
}
});
// Funcion que comprueba que están rellenos todos los datos necesarios para calcular el presupuesto
function checkValues() {
const tirada = $('#tirada').val();
const paginas = $('#paginas').val();
const papelInterior = $('#papelInterior option:selected').val();
const gramajeInterior = $('#gramajeInterior option:selected').text();
const papelCubierta = $('#papelCubierta option:selected').val();
const gramajeCubierta = $('#gramajeCubierta option:selected').text();
const papelFormatoAlto = $('#papelFormatoAlto').val();
const papelFormatoAncho = $('#papelFormatoAncho').val();
const clienteId = $('#clienteId').val();
if (paginas == '' || isNaN(paginas) || parseInt(paginas) <= 0) {
return false;
}
if(parseInt(paginas)%2!=0){
$('#paginas').val(parseInt(paginas)+1).trigger('change');
return false;
}
if(clienteId == '' || isNaN(clienteId) || parseInt(clienteId) <= 0){
return false;
}
if (tirada == '' || isNaN(tirada) || parseInt(tirada) <= 0) {
return false;
}
if (papelInterior == '' || gramajeInterior == '') {
return false;
}
if (papelCubierta == '' || gramajeCubierta == '') {
return false;
}
if ($('#papelFormatoId').val() == null && !$('#papelFormatoPersonalizado').is(':checked')){
return false;
}
if($('#papelFormatoPersonalizado').is(':checked')){
if(papelFormatoAncho == '' || parseInt(papelFormatoAncho) <= 0 ||
papelFormatoAlto == '' || parseInt(papelFormatoAlto) <= 0){
return false;
}
}
return true;
}
function getTiradas() {
let tiradas = [];
tiradas.push(parseInt($('#tirada').val()));
if ($('#tirada2').val().length > 0 && parseInt($('#tirada2').val()) > 0)
tiradas.push(parseInt($('#tirada2').val()));
if ($('#tirada3').val().length > 0 && parseInt($('#tirada3').val()) > 0)
tiradas.push(parseInt($('#tirada3').val()));
if ($('#tirada4').val().length > 0 && parseInt($('#tirada4').val()) > 0)
tiradas.push(parseInt($('#tirada4').val()));
return tiradas;
}
function getDimensionLibro() {
var ancho = 0;
var alto = 0;
if ($('#papelFormatoId option:selected').length > 0) {
var selectedText = $('#papelFormatoId option:selected').text();
if (selectedText.length > 0) {
ancho = parseFloat(selectedText.trim().split(" x ")[0]);
alto = parseFloat(selectedText.trim().split(" x ")[1]);
}
else if (document.getElementById('papelFormatoPersonalizado').checked) {
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
}
}
else if (document.getElementById('papelFormatoPersonalizado').checked) {
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
}
return {
ancho: ancho,
alto: alto
}
}
$('#retractilado').on('change', function () {
if ($(this).is(':checked')) {
if ($('#retractilado5').is(':checked'))
$('#retractilado5').prop('checked', false);
}
});
$('#retractilado5').on('change', function () {
if ($(this).is(':checked')) {
if ($('#retractilado').is(':checked'))
$('#retractilado').prop('checked', false);
}
});
$('.elementos-libro').on('change', function () {
// Libro cosido
if ($('#cosidoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Rústica cosido");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// Cosido tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').show();
$('#enableSobrecubierta').trigger('change');
}
else {
// Cosido tapa dura
$('.guardas').show();
numCarasGuardas(2);
$('.solapas-cubierta').hide();
$('.sobrecubierta').show();
$('#enableSobrecubierta').trigger('change');
}
}
// Libro fresado
else if ($('#fresadoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Rústica fresado");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// fresado tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').show();
$('#enableSobrecubierta').trigger('change');
}
else {
// fresado tapa dura
$('.guardas').show();
numCarasGuardas(2);
$('.solapas-cubierta').hide();
$('.sobrecubierta').show();
$('#enableSobrecubierta').trigger('change');
}
}
// Libro grapado
else if ($('#grapadoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Cosido con grapas");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// grapado tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
}
// Libro wire-o
else if ($('#wireoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Wire-O");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// wire-o tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
else {
// wire-o tapa dura
$('.guardas').show();
numCarasGuardas(1);
$('.solapas-cubierta').hide();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
}
// Libro espiral
else if ($('#espiralDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Espiral");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// espiral tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
else {
// espiral tapa dura
$('.espiral').show();
numCarasGuardas(1);
$('.solapas-cubierta').hide();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
}
});
function numCarasGuardas(numCaras) {
if (numCaras == 1) {
$("#impresionGuardas option[value='8']").remove();
}
else {
if ($("#impresionGuardas option[value='8']").length == 0)
$("#impresionGuardas").append('<option value="8">' + window.Presupuestos.dosCaras + '</option>');
}
}
$('.calcular-presupuesto').on('change', function () {
// se obtiene el id del elemento que ha disparado el evento
if($(this).hasClass('input-sobrecubierta')){
if($('#papelSobrecubierta option:selected').val() == '' || $('#gramajeSobrecubierta option:selected').val() == ''){
return;
}
}
calcularPresupuesto();
});
function comprobarTiradasPOD(){
const tiradas = getTiradas();
//Comprobar que todos los elementos del array tiradas estan por encima de 30 o por debajo
const tiradasPOD = tiradas.every(tirada => tirada <= 30);
const tiradasNoPOD = tiradas.every(tirada => tirada > 30);
if (tiradasPOD == !tiradasNoPOD) {
return true;
}
return false;
}
$('#clienteId').on('select2:change', function () {
calcularPresupuesto();
});
async function calcularPresupuesto() {
let isColor = false;
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isColor = true;
let isHq = false;
if($('#colorNegroHqDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isHq = true;
if(!comprobarTiradasPOD()){
$('#errorTiradas').show();
return;
}
$('#errorTiradas').hide();
// se obtiene la propiedad serv_id de los checkboxes seleccionados de la clase .servicio-extra
if (!checkValues()) {
return;
}
let servicios = [];
$('.servicio-extra:checked').each(function () {
servicios.push($(this).attr('serv_id'));
})
let datos = {
tamanio: getDimensionLibro(),
tirada: getTiradas(),
paginas: $('#paginas').val(),
paginasColor: $('#paginasColor').val(),
tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
isColor: isColor ? 1 : 0,
isHq: isHq ? 1 : 0,
papelInterior: $('#papelInterior option:selected').val(),
papelInteriorNombre: $('#papelInterior option:selected').text().trim(),
gramajeInterior: $('#gramajeInterior option:selected').text(),
excluirRotativa: $('#excluirRotativa').is(':checked')? 1 : 0,
papelCubierta: $('#papelCubierta option:selected').val(),
papelCubiertaNombre: $('#papelCubierta option:selected').text().trim(),
gramajeCubierta: $('#gramajeCubierta option:selected').text(),
carasCubierta: $('#carasCubierta').val(),
acabadoCubierta: $('#acabadosCubierta').val(),
clienteId: $('#clienteId').val(),
servicios: servicios,
}
// Si es cosido, se añade el número de páginas del cuadernillo
if ($('#cosidoDiv').hasClass('checked')) {
datos.paginasCuadernillo = $('#paginasCuadernillo').val();
}
// Si hay solapas de cubierta
if ($('#solapasCubierta').is(':checked')) {
datos.solapasCubierta = $('#anchoSolapasCubierta').val()
}
// Si hay sobrecubierta
if ($('#enableSobrecubierta').is(':checked')) {
if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
datos.sobrecubierta = {
papel: $('#papelSobrecubierta option:selected').val(),
papel_nombre: $('#papelSobrecubierta option:selected').text().trim(),
gramaje: $('#gramajeSobrecubierta option:selected').text(),
acabado: $('#acabadosSobrecubierta').val()
}
datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
}
}
if ($('#divGuardas').is(':visible')) {
datos.guardas = {
papel: $('#papelGuardas option:selected').val(),
papel_nombre: $('#papelGuardas option:selected').text().trim(),
gramaje: 170,
caras: $('#impresionGuardas option:selected').val()
}
}
datos = Object.assign(datos, window.token_ajax)
$('#divTiradasPrecio').empty();
$('#loader').show();
$.ajax({
url: window.routes_disenio_libro.presupuestoCliente,
type: 'POST',
data: datos,
success: function (response) {
error = false;
$('#errorGeneral').hide();
try{
if(response.errors.interior.length > 0){
$('#errorInterior').show();
error = true;
}
else
$('#errorInterior').hide();
if(response.errors.cubierta.length > 0){
$('#errorCubierta').show();
error = true;
}
else
$('#errorCubierta').hide();
if(response.errors.sobrecubierta.length > 0){
$('#errorSobrecubierta').show();
error = true;
}
else
$('#errorSobrecubierta').hide();
if(response.errors.guardas.length > 0){
$('#errorGuardas').show();
error = true;
}
else
$('#errorGuardas').hide();
if(response.errors.servicios.length > 0 || response.errors.serviciosDefecto.length > 0){
error = true;
$('#errorGeneral').show();
}
else{
$('#errorGeneral').hide();
}
}
catch(error){
}
//For debug only
//console.log(response);
$('#loader').hide();
$('#divTiradasPrecio').empty();
if(!error){
$('#lomo_cubierta').val(response.info.lomo_cubierta);
$('#precios').show();
if(response.tiradas){
for (i = 0; i < response.tiradas.length; i++) {
const total = (parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2) ;
const label = "tiradaPrecio" + parseInt(i+1);
let html = '';
html += '<div id="' + label + '" peso="' +response.peso[i]+ '" class="list-group" >';
html += '<a href="javascript:void(0);" class="list-group-item list-group-item-action">';
html += '<div class="li-wrapper d-flex justify-content-start align-items-center" >';
html += '<div class="list-content">';
html += '<h7 id="ud_' + label + '" class="mb-1">' + (response.tiradas[i] + ' ud.') + '</h7>';
html += '<h6 id="tot_' + label + '" class="mb-1">' + ('Total: ' + total + '€') + '</h6>';
html += '<h7 id="pu_' + label + '" class="mb-1">' + (response.precio_u[i] + '€/ud') + '</h7>';
html += '</div>';
html += '</div>'
html += '</a>';
html += '</div>';
$('#divTiradasPrecio').append(html);
}
}
if($('#resumen-libro').hasClass('active')) {
initDirecciones();
initTiradasDirecciones();
generarResumen();
previewEsquemaCubierta(true);
}
}
},
error: function (error) {
$('#loader').hide();
$('#divTiradasPrecio').empty();
}
});
}

View File

@ -1,356 +0,0 @@
/**
* Cliente presupuesto Wizard
*/
'use strict';
(function () {
// Init custom option check
//window.Helpers.initCustomOptionCheck();
// Vertical Wizard
// --------------------------------------------------------------------
const clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente');
if (typeof clientePresupuestoWizard !== undefined && clientePresupuestoWizard !== null ) {
// Wizard form
const clientePresupuestoWizardForm = clientePresupuestoWizard.querySelector('#presupuesto-cliente-form');
// Wizard steps
const clientePresupuestoWizardFormStep2 = clientePresupuestoWizardForm.querySelector('#tipo-libro');
const clientePresupuestoWizardFormStep3 = clientePresupuestoWizardForm.querySelector('#disenio-libro');
const clientePresupuestoWizardFormStep4 = clientePresupuestoWizardForm.querySelector('#direcciones-libro');
const clientePresupuestoWizardFormStep5 = clientePresupuestoWizardForm.querySelector('#resumen-libro');
// Wizard next prev button
const clientePresupuestoWizardNext = [].slice.call(clientePresupuestoWizardForm.querySelectorAll('.btn-next'));
const clientePresupuestoWizardPrev = [].slice.call(clientePresupuestoWizardForm.querySelectorAll('.btn-prev'));
let FormValidation2;
let FormValidation3;
let FormValidation4;
let FormValidation5;
let validationStepper = new Stepper(clientePresupuestoWizard, {
linear: true
});
if(clientePresupuestoWizardFormStep2 != null) {
// select2 (clienteId)
const clienteId = $('#clienteId');
clienteId.on('change.select2', function () {
// Revalidate the clienteId field when an option is chosen
FormValidation2.revalidateField('clienteId');
});
// Deal Details
FormValidation2 = FormValidation.formValidation(clientePresupuestoWizardFormStep2, {
fields: {
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
// eleInvalidClass: '',
eleValidClass: '',
rowSelector: '.col-sm-3'
}),
autoFocus: new FormValidation.plugins.AutoFocus(),
submitButton: new FormValidation.plugins.SubmitButton()
}
}).on('core.form.valid', function () {
// Jump to the next step when all fields in the current step are valid
validationStepper.next();
});
// Deal Usage
FormValidation3 = FormValidation.formValidation(clientePresupuestoWizardFormStep3, {
fields: {
titulo: {
validators: {
notEmpty: {
message: window.Presupuestos.validation.requerido_short
},
}
},
clienteId: {
validators: {
callback: {
message: window.Presupuestos.validation.cliente,
callback: function (input) {
// Get the selected options
const options = $("#clienteId").select2('data');
const hasValidOption = options.some(option => parseInt(option.id) > 0);
return options !== null && options.length > 0 && hasValidOption;
},
}
}
},
tirada: {
validators: {
callback: {
message: window.Presupuestos.validation.integer_greatherThan_0,
callback: function (input) {
const value = $("#tirada").val();
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
},
}
}
},
paginas: {
validators: {
callback: {
message: window.Presupuestos.validation.integer_greatherThan_0,
callback: function (input) {
const value = $("#paginas").val();
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
},
}
}
},
paginasColor: {
validators: {
callback: {
message: window.Presupuestos.validation.integer_greatherThan_0,
callback: function (input) {
if ($('#pagColorDiv').is(':hidden'))
return true;
else {
const value = $("#paginasColor").val();
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
}
},
}
}
},
gramajeInterior: {
validators: {
callback: {
callback: function (input) {
const value = $("#tirada").val();
if ($('#gramajeInterior option:selected').text().length == 0) {
if(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0){
return {
valid: false,
message: window.Presupuestos.validation.sin_gramaje,
}
}
return {
valid: value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0,
message: window.Presupuestos.validation.tirada_no_valida,
}
}
return true;
},
},
}
},
gramajeCubierta: {
validators: {
callback: {
message: window.Presupuestos.validation.tirada_no_valida,
callback: function (input) {
const value = $("#tirada").val();
if ($('#gramajeCubierta option:selected').text().length == 0) {
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
}
return true;
},
},
callback: {
message: window.Presupuestos.validation.sin_gramaje,
callback: function (input) {
if ($('#gramajeCubierta option:selected').text().length == 0) {
return false;
}
return true;
},
}
}
},
gramajeSobrecubierta: {
validators: {
callback: {
message: window.Presupuestos.validation.tirada_no_valida,
callback: function (input) {
const value = $("#tirada").val();
if ($('#gramajeSobrecubierta option:selected').text().length == 0) {
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
}
return true;
},
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
// eleInvalidClass: '',
eleValidClass: '',
rowSelector: function (field, ele) {
// field is the field name
// ele is the field element
switch (field) {
case 'gramajeInterior':
case 'gramajeCubierta':
case 'gramajeSobrecubierta':
return '.col-sm-2';
case 'titulo':
return '.col-sm-12';
case 'clienteId':
return '.col-sm-6';
default:
return '.col-sm-3';
}
}
}),
autoFocus: new FormValidation.plugins.AutoFocus(),
submitButton: new FormValidation.plugins.SubmitButton()
}
}).on('core.form.valid', function () {
if($('#tiradaPrecio1').length > 0) {
validationStepper.next();
initDirecciones();
initTiradasDirecciones();
}
});
const tirada = $('#tirada');
tirada.on('change', function () {
// Revalidate the clienteId field when an option is chosen
FormValidation2.revalidateField('gramajeInterior');
FormValidation2.revalidateField('gramajeCubierta');
FormValidation2.revalidateField('gramajeSobrecubierta');
});
// Direcciones
FormValidation4 = FormValidation.formValidation(clientePresupuestoWizardFormStep4, {
fields: {
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
// eleInvalidClass: '',
eleValidClass: '',
rowSelector: '.col-md-12'
}),
autoFocus: new FormValidation.plugins.AutoFocus(),
submitButton: new FormValidation.plugins.SubmitButton()
}
}).on('core.form.valid', function () {
if(validarEnvio()){
generarResumen();
validationStepper.next();
}
else{
let text = "El número de unidades enviadas no coincie con la tirada seleccionada.";
if($('#prototipo').is(':checked')) {
text += "<br>(Tenga en cuenta que se ha seleccionado la opción de prototipo)";
}
$('#errorDirecciones').text(text);
$('#errorDirecciones').show();
}
});
}
// Deal Usage
FormValidation5 = FormValidation.formValidation(clientePresupuestoWizardFormStep5, {
fields: {
// * Validate the fields here based on your requirements
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
// eleInvalidClass: '',
eleValidClass: '',
rowSelector: '.col-md-12'
}),
autoFocus: new FormValidation.plugins.AutoFocus(),
submitButton: new FormValidation.plugins.SubmitButton()
}
}).on('core.form.valid', function () {
// You can submit the form
// clientePresupuestoWizardForm.submit()
// or send the form data to server via an Ajax request
// To make the demo simple, I just placed an alert
//alert('Submitted..!!');
});
clientePresupuestoWizardNext.forEach(item => {
item.addEventListener('click', event => {
// When click the Next button, we will validate the current step
switch (validationStepper._currentIndex) {
case 0:
FormValidation2.validate();
break;
case 1:
FormValidation3.validate();
break;
case 2:
FormValidation4.validate();
break;
case 3:
FormValidation5.validate();
break;
default:
validationStepper.next();
break;
}
});
});
clientePresupuestoWizardPrev.forEach(item => {
item.addEventListener('click', event => {
switch (validationStepper._currentIndex) {
case 4:
validationStepper.previous();
break;
case 3:
validationStepper.previous();
break;
case 2:
for (let i = 0; i < 4; i++) {
let id = "tiradaPrecio" + i;
if ($('#' + id).length > 0) {
$('#' + id).show();
}
}
validationStepper.previous();
break;
case 1:
validationStepper.previous();
break;
case 0:
window.location.href = document.location.origin + '/presupuestocliente/list';
default:
break;
}
});
});
var url = $(location).attr('href'); // Obtener URL actual
if (url.includes('/edit/')) { // Comprobar si la URL contiene 'edit'
validationStepper.to(4);
}
}
})();

View File

@ -1,819 +0,0 @@
// Global parameters
var pvObj;
$('#toReview').on("click", function () {
previewEsquemaCubierta(true);
});
$(document).on('shown.bs.modal', function (e) {
previewEsquemaCubierta(false);
})
function previewEsquemaCubierta(isThumbnail = false) {
if($('#cosidoDiv').length){
if ($('#cosidoDiv').hasClass('checked') || $("#fresadoDiv").hasClass('checked')) {
//console.log("Cosido/Fresado");
if ($("#tapaBlanda").is(":checked")) {
portadaTapaBlanda(isThumbnail);
} else if ($("#tapaDura").is(":checked")) {
portadaTapaDura(isThumbnail);
}
} else if ($('#espiralDiv').hasClass('checked') || $('#wireoDiv').hasClass('checked')) {
//console.log("Espiral/Wireo");
if ($("#tapaBlanda").is(":checked")) {
portadaEspiral(isThumbnail, false);
} else if ($("#tapaDura").is(":checked")) {
portadaEspiral(isThumbnail, true);
}
} else if ($('#grapadoDiv').hasClass('checked')) {
portadaGrapado(isThumbnail);
}
}
else{
let titulo = $('#tipoLibro').text().toLowerCase();
if(titulo.includes("cosido") || titulo.includes("fresado")){
if(titulo.includes("dura"))
portadaTapaDura(isThumbnail);
else{
portadaTapaBlanda(isThumbnail);
}
}
else if (titulo.includes("espiral") || titulo.includes("wire-o")){
if(titulo.includes("dura"))
portadaEspiral(isThumbnail, true);
else
portadaEspiral(isThumbnail, false);
}
else if (titulo.includes("grapado")){
portadaGrapado(isThumbnail);
}
}
}
function portadaTapaDura(isThumbnail = false) {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoCubierta, altoSangrado, anchoSangrado;
let styleCotas = {size: 12, family: 'Public Sans'};
let sangradoTexto = "Sangrado 20 mm";
let sangradoValor = parseFloat(20); // mm
let anchoPliegue = parseFloat(7); // mm
let altoPliegue = parseFloat(7); // mm
let anchoCarton = parseFloat(7); // mm
let divIdName = (isThumbnail) ? 'thumbnail_ec_shape' : 'pv_ec_shape';
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 800; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.88;
anchoLibro = anchoSangrado * 0.39;
lomoLibro = anchoSangrado * 0.133;
anchoCubierta = (2 * anchoLibro) + lomoLibro;
// Clear the canvas element
$(`#${divIdName}`).empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById(divIdName);
var previewEC = new Two({fitted: true}).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
var libro = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
((2 * anchoLibro) + lomoLibro),
altoLibro);
libro.stroke = 'black';
libro.linewidth = 1;
var lomo = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
lomoLibro,
altoLibro);
lomo.stroke = 'black';
lomo.fill = '#F4F8F2';
lomo.linewidth = 1;
// Cotas y textos
if (!isThumbnail) {
// Cotas:
var cotaAnchoCubierta = previewEC.makeDobleArrow(
origenEC.x - (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
origenEC.x + (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
10);
cotaAnchoCubierta.linewidth = 2;
var cotaAltoCubierta = previewEC.makeDobleArrow(
origenEC.x + (anchoCubierta / 2) + 40,
origenEC.y + (altoSangrado / 2),
origenEC.x + (anchoCubierta / 2) + 40,
origenEC.y - (altoSangrado / 2),
10);
cotaAltoCubierta.linewidth = 2;
var cotaAltoLibro = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y + (altoLibro / 2),
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y - (altoLibro / 2),
10);
cotaAltoLibro.linewidth = 2;
var cotaLomo = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
origenEC.x + (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
10);
cotaLomo.linewidth = 2;
var cotaContraportada = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
origenEC.x - (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
origenEC.x + (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
10);
cotaPortada.linewidth = 2;
// Textos:
// Titulos generales
let stylesEC = {size: 22, weight: 'bold', family: 'Public Sans'};
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
previewEC.makeText("Lomo", origenEC.x, origenEC.y, stylesEC).rotation = -Math.PI / 2;
// Sangrados
let styleSangrado = {size: 10, family: 'Public Sans', style: 'italic', fill: 'red'};
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + 13), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + 13), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.lomoLibro + anchoCarton + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + anchoPliegue + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + anchoPliegue + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + altoPliegue + " mm", origenEC.x + (lomoLibro / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + altoPliegue + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro) + 55, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + pvObj.lomoLibro + (2 * sangradoValor) + +(2 * anchoPliegue) + anchoCarton + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
}
previewEC.update();
}
function portadaTapaBlanda(isThumbnail = false) {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
let styleCotas = {size: 12, family: 'Public Sans'};
let sangradoTexto = "Sangrado 5 mm";
let sangradoValor = parseFloat(5); // mm
let offsetSolapaValor = parseFloat(0); // mm
let divIdName = (isThumbnail) ? 'thumbnail_ec_shape' : 'pv_ec_shape';
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if (pvObj.anchoSolapa == 0) {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 800; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.97;
anchoLibro = anchoSangrado * 0.419;
anchoSolapa = 0;
lomoLibro = anchoSangrado * 0.133;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
} else {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 750; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.95;
anchoLibro = anchoSangrado * 0.28;
anchoSolapa = anchoSangrado * 0.163;
lomoLibro = anchoSangrado * 0.09;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
offsetSolapaValor = parseFloat('3.0'); // mm
}
// Clear the canvas element
$(`#${divIdName}`).empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById(divIdName);
var previewEC = new Two({fitted: true}).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if (pvObj.anchoSolapa != 0) {
var solapas = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoCubierta,
altoLibro);
solapas.stroke = 'black';
solapas.linewidth = 1;
// Cotas Solapas
if (!isThumbnail) {
var cotaSolapa2 = previewEC.makeDobleArrow(
origenEC.x - anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x - anchoLibro - lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa2.linewidth = 2;
var cotaSolapa1 = previewEC.makeDobleArrow(
origenEC.x + anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x + anchoLibro + lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa1.linewidth = 2;
// Textos Solapas
let stylesSolapa = {size: 18, family: 'Public Sans'};
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
}
var libro = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
((2 * anchoLibro) + lomoLibro),
altoLibro);
libro.stroke = 'black';
libro.linewidth = 1;
var lomo = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
lomoLibro,
altoLibro);
lomo.stroke = 'black';
lomo.fill = '#F4F8F2';
lomo.linewidth = 1;
// Cotas y textos
if (!isThumbnail) {
// Cotas:
var cotaAnchoCubierta = previewEC.makeDobleArrow(
origenEC.x - (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
origenEC.x + (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
10);
cotaAnchoCubierta.linewidth = 2;
var cotaAltoCubierta = previewEC.makeDobleArrow(
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y + (altoSangrado / 2),
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y - (altoSangrado / 2),
10);
cotaAltoCubierta.linewidth = 2;
var cotaAltoLibro = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y + (altoLibro / 2),
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y - (altoLibro / 2),
10);
cotaAltoLibro.linewidth = 2;
var cotaLomo = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
origenEC.x + (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
10);
cotaLomo.linewidth = 2;
var cotaContraportada = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
origenEC.x - (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
origenEC.x + (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
10);
cotaPortada.linewidth = 2;
// Textos:
// Titulos generales
let stylesEC = {size: 22, weight: 'bold', family: 'Public Sans'};
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
let a = previewEC.makeText("Lomo", origenEC.x, origenEC.y, stylesEC).rotation = -Math.PI / 2;
// Sangrados
let styleSangrado = {size: 10, family: 'Public Sans', style: 'italic', fill: 'red'};
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.lomoLibro + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + pvObj.offsetSolapa)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
}
previewEC.update();
}
function portadaEspiral(isThumbnail = false, isTapaDura = false) {
// Variables locales
let altoLibro, anchoLibro, anchoCalle, anchoCubierta, altoSangrado, anchoSangrado, anchoSolapa, offsetCubierta;
let styleCotas = {size: 12, family: 'Public Sans'};
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
let divIdName = (isThumbnail) ? 'thumbnail_ec_shape' : 'pv_ec_shape';
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if ((pvObj.anchoSolapa !== 0) && (!isTapaDura)) {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 750; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.95;
anchoLibro = anchoSangrado * 0.28;
anchoCalle = anchoSangrado * 0.02;
anchoSolapa = anchoSangrado * 0.163;
sangrado = anchoSangrado * 0.03;
anchoCubierta = 2 * (anchoLibro + anchoSolapa + sangrado) + anchoCalle;
offsetCubierta = anchoLibro / 2 + anchoCalle / 2 + anchoSolapa / 2 + sangrado;
} else {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 750; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = (isTapaDura) ? altoSangrado * 0.88 : altoSangrado * 0.97;
anchoLibro = (isTapaDura) ? anchoSangrado * 0.39 : anchoSangrado * 0.419;
anchoCalle = anchoSangrado * 0.02;
anchoSolapa = 0;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + anchoCalle;
offsetCubierta = anchoLibro / 2 + anchoCalle / 2 + anchoSolapa + sangradoValor;
}
// Clear the canvas element
$(`#${divIdName}`).empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById(divIdName);
var previewEC = new Two({fitted: true}).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if ((pvObj.anchoSolapa != 0) && (!isTapaDura)) {
var solapa1 = previewEC.makeRectangle(
origenEC.x + (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor),
origenEC.y,
anchoSolapa,
altoLibro);
solapa1.stroke = 'black';
solapa1.linewidth = 1;
var solapa2 = previewEC.makeRectangle(
origenEC.x - (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor),
origenEC.y,
anchoSolapa,
altoLibro);
solapa2.stroke = 'black';
solapa2.linewidth = 1;
// Cotas y textos
if (!isThumbnail) {
// Cotas
var cotaSolapa2 = previewEC.makeDobleArrow(
origenEC.x - (anchoCalle / 2 + sangradoValor + anchoLibro + anchoSolapa),
origenEC.y - (altoLibro / 3),
origenEC.x - (anchoLibro + sangradoValor + anchoCalle / 2),
origenEC.y - (altoLibro / 3),
10);
cotaSolapa2.linewidth = 2;
var cotaSolapa1 = previewEC.makeDobleArrow(
origenEC.x + (anchoCalle / 2 + sangradoValor + anchoLibro + anchoSolapa),
origenEC.y - (altoLibro / 3),
origenEC.x + (anchoLibro + sangradoValor + anchoCalle / 2),
origenEC.y - (altoLibro / 3),
10);
cotaSolapa1.linewidth = 2;
// Textos Solapas
let stylesSolapa = {size: 18, family: 'Public Sans'};
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
}
var portada = previewEC.makeRectangle(
origenEC.x + (anchoLibro / 2 + anchoCalle / 2 + sangradoValor),
origenEC.y,
anchoLibro,
altoLibro);
portada.stroke = 'black';
portada.linewidth = 1;
var contraportada = previewEC.makeRectangle(
origenEC.x - (anchoLibro / 2 + anchoCalle / 2 + sangradoValor),
origenEC.y,
anchoLibro,
altoLibro);
contraportada.stroke = 'black';
contraportada.linewidth = 1;
var calle = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoCalle,
altoSangrado);
calle.stroke = 'black';
calle.dashes = [2, 5];
calle.fill = '#F4F8F2';
calle.linewidth = 1;
// Cotas y textos
if (!isThumbnail) {
// Cotas:
var cotaAnchoCubierta = previewEC.makeDobleArrow(
origenEC.x - (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
origenEC.x + (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
10);
cotaAnchoCubierta.linewidth = 2;
var cotaAltoCubierta = previewEC.makeDobleArrow(
origenEC.x + (anchoSangrado / 2) + 15,
origenEC.y + (altoSangrado / 2),
origenEC.x + (anchoSangrado / 2) + 15,
origenEC.y - (altoSangrado / 2),
10);
cotaAltoCubierta.linewidth = 2;
var cotaAltoLibro = previewEC.makeDobleArrow(
origenEC.x + (anchoCalle / 2) + 35,
origenEC.y + (altoLibro / 2),
origenEC.x + (anchoCalle / 2) + 35,
origenEC.y - (altoLibro / 2),
10);
cotaAltoLibro.linewidth = 2;
var cotaContraportada = previewEC.makeDobleArrow(
origenEC.x - (anchoCalle / 2 + anchoLibro + sangradoValor),
origenEC.y - (altoLibro / 3),
origenEC.x - ((anchoCalle / 2) + sangradoValor),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + ((anchoCalle / 2) + sangradoValor),
origenEC.y - (altoLibro / 3),
origenEC.x + (anchoCalle / 2 + anchoLibro + sangradoValor),
origenEC.y - (altoLibro / 3),
10);
cotaPortada.linewidth = 2;
// Textos:
// Titulos generales
let stylesEC = {size: 22, weight: 'bold', family: 'Public Sans'};
previewEC.makeText("Portada",
origenEC.x + anchoLibro / 2 + anchoCalle / 2 + sangradoValor + 15,
origenEC.y,
stylesEC
);
previewEC.makeText("Contraportada",
origenEC.x - (anchoLibro / 2 + anchoCalle / 2 + sangradoValor),
origenEC.y,
stylesEC
);
// Sangrados
let styleSangrado = {size: 10, family: 'Public Sans', style: 'italic', fill: 'red'};
previewEC.makeText(sangradoTexto, origenEC.x + offsetCubierta, origenEC.y + (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + offsetCubierta, origenEC.y - (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x - offsetCubierta, origenEC.y + (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x - offsetCubierta, origenEC.y - (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (anchoSangrado / 2) - 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (anchoSangrado / 2) + 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x - (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x + (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (anchoCalle / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm",
origenEC.x + (anchoSangrado / 2) + 30,
origenEC.y,
styleCotas
).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
}
previewEC.update();
}
function portadaGrapado(isThumbnail = false) {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
let styleCotas = {size: 12, family: 'Public Sans'};
let sangradoTexto = "Sangrado 5 mm";
let sangradoValor = parseFloat('5.0'); // mm
let offsetSolapaValor = parseFloat('0.0'); // mm
let divIdName = (isThumbnail) ? 'thumbnail_ec_shape' : 'pv_ec_shape';
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if (pvObj.anchoSolapa == 0) {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 750; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.97;
anchoLibro = anchoSangrado * 0.48;
anchoSolapa = 0;
lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
} else {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 750; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.95;
anchoLibro = anchoSangrado * 0.3;
anchoSolapa = anchoSangrado * 0.18;
lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
offsetSolapaValor = parseFloat('3.0'); // mm
}
// Clear the canvas element
$(`#${divIdName}`).empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById(divIdName);
var previewEC = new Two({fitted: true}).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if (pvObj.anchoSolapa != 0) {
var solapas = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoCubierta,
altoLibro);
solapas.stroke = 'black';
solapas.linewidth = 1;
// Cotas y textos
if (!isThumbnail) {
// Cotas
var cotaSolapa2 = previewEC.makeDobleArrow(
origenEC.x - anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x - anchoLibro - lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa2.linewidth = 2;
var cotaSolapa1 = previewEC.makeDobleArrow(
origenEC.x + anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x + anchoLibro + lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa1.linewidth = 2;
// Textos Solapas
let stylesSolapa = {size: 18, family: 'Public Sans'};
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
}
var libro = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
((2 * anchoLibro) + lomoLibro),
altoLibro);
libro.stroke = 'black';
libro.linewidth = 1;
var lomo = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
lomoLibro,
altoLibro);
lomo.stroke = 'black';
lomo.fill = '#F4F8F2';
lomo.linewidth = 1;
// Cotas y textos
if (!isThumbnail) {
// Cotas:
var cotaAnchoCubierta = previewEC.makeDobleArrow(
origenEC.x - (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
origenEC.x + (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
10);
cotaAnchoCubierta.linewidth = 2;
var cotaAltoCubierta = previewEC.makeDobleArrow(
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y + (altoSangrado / 2),
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y - (altoSangrado / 2),
10);
cotaAltoCubierta.linewidth = 2;
var cotaAltoLibro = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y + (altoLibro / 2),
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y - (altoLibro / 2),
10);
cotaAltoLibro.linewidth = 2;
var cotaContraportada = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
origenEC.x - (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
origenEC.x + (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
10);
cotaPortada.linewidth = 2;
// Textos:
// Titulos generales
let stylesEC = {size: 22, weight: 'bold', family: 'Public Sans'};
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
// Sangrados
let styleSangrado = {size: 10, family: 'Public Sans', style: 'italic', fill: 'red'};
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + pvObj.offsetSolapa)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
}
previewEC.update();
}
function getObjetoToPreview() {
if($('#cosidoDiv').length){
pvObj = {
lomoLibro: $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat(parseFloat($('#lomo_cubierta').val()).toFixed(2)),
anchoSolapa: $('#solapasCubierta').is(':checked') ? parseFloat($('#anchoSolapasCubierta').val()) : parseFloat('0.0'),
altoLibro: getDimensionLibro().alto,
anchoLibro: getDimensionLibro().ancho,
offsetSolapa: $('#solapasCubierta').is(':checked') ? parseFloat('3.0') : parseFloat('0.0')
};
} else {
let tamanio = $('#resumenTamanio').text().split(' ')[1].split('x');
let solapas = parseInt($('#resumenSolapasCubierta').length ? $('#resumenSolapasCubierta').text().split(' ')[1].replace("mm", '') : 0);
pvObj = {
lomoLibro: $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat(parseFloat($('#lomo_cubierta').val()).toFixed(2)),
anchoSolapa: solapas,
altoLibro: parseInt(tamanio[1]),
anchoLibro: parseInt(tamanio[0]),
offsetSolapa: (solapas != 0) ? parseFloat('3.0') : parseFloat('0.0')
};
}
//console.log($('#lomo_cubierta').val());
}

View File

@ -1,311 +0,0 @@
function generarResumen(){
$('#tipoLibro').text($('#tituloDisenioLibro').text() + ' tapa ' + (($('#tapaBlandaInnerDiv').hasClass('checked'))?'blanda':'dura'));
$('#resumenTamanio').text('Dimensiones: ' + getDimensionLibro().ancho + 'x' + getDimensionLibro().alto + 'mm');
$('#resumenPaginas').text('Páginas: '+ $('#paginas').val() + ' páginas');
const seleccion = $('.custom-option-tiradasDirecciones.checked');
let tirada = 0;
if(seleccion.length != 0) {
const element_tirada =($(seleccion[0]).find('label input')[0]);
const number = element_tirada.id.match(/\d+$/);
if (number.length != 0) {
tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
}
}
$('#resumenTirada').text('Tirada: '+ tirada + ' unidades');
$('#resumenPrototipo').text('Prototipo: ' + (($('#prototipo').is(':checked'))?'Sí':'No'));
$('#resumenFerro').text('Ferro: ' + (($('#ferro').is(':checked'))?'Sí':'No'));
$('#tipoImpresion').text('Impresión: ' +
($('#colorNegroDiv').hasClass('checked')?'Negro estándar':
$('#colorNegroHqDiv').hasClass('checked')?'Negro premium':
$('#colorColorDiv').hasClass('checked')?'Color estándar':'Color premium'));
if($('#colorNegroDiv').hasClass('checked') || $('#colorNegroHqDiv').hasClass('checked')){
$('#pResumenPaginasColor').hide();
}
else{
$('#pResumenPaginasColor').show();
$('#resumenPaginasColor').text($('#paginasColor').val());
}
$('#resumenPapelInterior').text($('#papelInterior option:selected').text().trim() + ' ' +
$('#gramajeInterior option:selected').text() + 'gr/m²');
let papelCubierta = $('#papelCubierta option:selected').text().trim() + ' ' +
$('#gramajeCubierta option:selected').text();
papelCubierta += 'gr/m²';
$('#resumenPapelCubierta').text(papelCubierta);
$('#resumenCarasCubierta').text('Impresión: ' + $('#carasCubierta option:selected').text())
$('#resumenAcabadoCubierta').text('Acabado: ' + $('#acabadosCubierta option:selected').text())
if ($('#solapasCubierta').is(':checked')) {
$('#resumenSolapasCubierta').text('Solapas: ' + $('#anchoSolapasCubierta').val())
}
else{
$('#resumenSolapasCubierta').text('Solapas: No')
}
if ($('#enableSobrecubierta').is(':checked')) {
$(".resumen-sobrecubierta").show();
$('#resumenPapelCubierta').text($('#papelSobrecubierta option:selected').text().trim() + ' ' +
$('#gramajeSobrecubierta option:selected').text() + 'gr/m²');
$('#resumenAcabadoSobrecubierta').text('Acabado: ' + $('#acabadosSobrecubierta option:selected').text())
$('#resumenSolapasSobrecubierta').text('Solapas: ' + $('#anchoSolapasSobrecubierta').val())
}
else{
$(".resumen-sobrecubierta").hide();
}
if ($('#divGuardas').css('display') != 'none') {
$(".resumen-guardas").show();
$('#resumenGuardasPapel').text($('#papelGuardas option:selected').text().trim() + ' ' + '170gr/m²');
$('#resumenGuardasCaras').text('Impresión: ' + $('#impresionGuardas option:selected').text())
}
else{
$(".resumen-guardas").hide();
}
if($('#retractilado').is(':checked') || $('#retractilado5').is(':checked') || $('#fajaColor').is(':checked')){
$('.resumen-extras').show();
$('#retractilado').is(':checked')?$('#resumenRetractilado1').show():$('#resumenRetractilado1').hide();
$('#retractilado5').is(':checked')?$('#resumenRetractilado5').show():$('#resumenRetractilado5').hide();
$('#fajaColor').is(':checked')?$('#resumenFajaColor').show():$('#resumenFajaColor').hide();
}
else{
$('.resumen-extras').hide();
}
for (i = 1; i <= 4; i++) {
let id = "tiradaPrecio" + i;
if ($('#' + id).length > 0) {
const envio = getTotalEnvio();
let tirada_id = "ud_tiradaPrecio" + i;
if(parseInt($('#' + tirada_id).text().replace(' ud.', '')) != tirada){
continue;
}
let total_id = "tot_tiradaPrecio" + i;
let total = parseFloat($('#' + total_id).text().replace('€', '').replace('Total: ', '')) + envio;
let total_iva = 0.0;
if($('#ivaReducido').val() == '1'){
total_iva = total * 1.04;
}
else{
total_iva = total * 1.21;
}
const precio_u = total_iva/tirada;
$('#resumenTotalIVA').text('Total (I.V.A. ' + (($('#ivaReducido').val() == '1')?'4':'21') + '%): ' + total_iva.toFixed(2) + '€');
$('#resumenPrecioU').text(precio_u.toFixed(4) + '€/ud');
}
}
}
function getTotalEnvio(){
const elements = $('#divDirecciones').find('.row.mb-3');
let total = 0.0;
if(elements.length > 0) {
for (let index=0; index<elements.length; index++){
let precio_envio = parseFloat($(elements[index]).attr('p'));
total += precio_envio;
};
}
return total;
}
$('#btnSave').on('click', function() {
finalizarPresupuesto(false);
});
$('#btnConfirm').on('click', function() {
finalizarPresupuesto(true);
});
$('#btnDuplicar').on('click', function() {
const paths = window.location.pathname.split("/").filter(path => path !== "");
let id=0;
if(paths.length > 0 && paths[paths.length - 2] == 'edit'){
id=paths[paths.length - 1];
}
datos = {
id: id,
}
datos = Object.assign(datos, window.token_ajax)
$('#loader').show();
$.ajax({
url: window.routes_resumen.duplicarPresupuesto,
type: 'POST',
data: datos,
success: function(response) {
if(Object.keys(response).length > 0) {
if(response.success){
$('#loader').hide();
window.location.href = document.location.origin + '/presupuestos/presupuestocliente/edit/' + response.id;
}
}
$('#loader').hide();
},
error: function() {
$('#loader').hide();
},
});
});
$('#btnBack').on('click', function() {
window.location.href = document.location.origin + '/presupuestocliente/list';
});
function finalizarPresupuesto(confirmar){
let isColor = false;
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isColor = true;
let isHq = false;
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isHq = true;
const paths = window.location.pathname.split("/").filter(path => path !== "");
let id=0;
if(paths.length > 0 && paths[paths.length - 2] == 'edit'){
id=paths[paths.length - 1];
}
let servicios = [];
$('.servicio-extra:checked').each(function () {
servicios.push($(this).attr('serv_id'));
})
let datos_libro = {
tamanio: getDimensionLibro(),
tirada: getTiradas(),
paginas: $('#paginas').val(),
paginasColor: $('#paginasColor').val(),
tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
isColor: isColor,
isHq: isHq,
papelInterior: $('#papelInterior option:selected').val(),
papelInteriorNombre: $('#papelInterior option:selected').text().trim(),
gramajeInterior: $('#gramajeInterior option:selected').text(),
excluirRotativa: $('#excluirRotativa').is(':checked')? 1 : 0,
papelCubierta: $('#papelCubierta option:selected').val(),
papelCubiertaNombre: $('#papelCubierta option:selected').text().trim(),
gramajeCubierta: $('#gramajeCubierta option:selected').text(),
carasCubierta: $('#carasCubierta').val(),
acabadoCubierta: $('#acabadosCubierta').val(),
clienteId: $('#clienteId').val(),
servicios: servicios,
};
// Si es cosido, se añade el número de páginas del cuadernillo
if ($('#cosidoDiv').hasClass('checked')) {
datos_libro.paginasCuadernillo = $('#paginasCuadernillo').val();
}
// Si hay solapas de cubierta
if ($('#solapasCubierta').is(':checked')) {
datos_libro.solapasCubierta = $('#anchoSolapasCubierta').val()
}
// Si hay sobrecubierta
if ($('#enableSobrecubierta').is(':checked')) {
if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
datos_libro.sobrecubierta = {
papel: $('#papelSobrecubierta option:selected').val(),
papel_nombre: $('#papelSobrecubierta option:selected').text().trim(),
gramaje: $('#gramajeSobrecubierta option:selected').text(),
acabado: $('#acabadosSobrecubierta').val()
}
datos_libro.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
}
}
if ($('#divGuardas').css('display') != 'none') {
datos_libro.guardas = {
papel: $('#papelGuardas option:selected').val(),
papel_nombre: $('#papelGuardas option:selected').text().trim(),
gramaje: 170,
caras: $('#impresionGuardas option:selected').val()
}
}
let datos_cabecera = {
titulo: $('#titulo').val(),
referenciaCliente: $('#referenciaCliente').val(),
}
const seleccion = $('.custom-option-tiradasDirecciones.checked');
let tirada = 0;
let peso_libro = 0;
if(seleccion.length != 0) {
const element_tirada =($(seleccion[0]).find('label input')[0]);
const number = element_tirada.id.match(/\d+$/);
if (number.length != 0) {
tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
peso_libro = ($(seleccion[0])).find('label input').attr('peso');
}
}
let direcciones = getDireccionesEnvio();
datos = {
id: id,
datos_libro : datos_libro,
datos_cabecera: datos_cabecera,
direcciones: direcciones,
tirada: tirada,
peso: peso_libro,
iva_reducido: $('#ivaReducido').val()==1?1:0,
confirmar: confirmar?1:0,
},
datos = Object.assign(datos, window.token_ajax)
$('#loader').show();
$.ajax({
url: window.routes_resumen.guardarPresupuesto,
type: 'POST',
data: datos,
success: function(response) {
if(Object.keys(response).length > 0) {
if(response.status > 0){
if(confirmar || window.location.href.includes("add"))
window.location.href = response.url + '/' + response.status;
}
}
$('#loader').hide();
},
error: function() {
$('#loader').hide();
},
});
}

View File

@ -1,58 +0,0 @@
// Init custom option check
function initTipoLibroCheck()
{
const _this = this
const custopOptionList = [].slice.call(document.querySelectorAll('.custom-option-tipo .form-check-input'))
custopOptionList.map(function (customOptionEL) {
// Update custom options check on page load
_this.updateTipoLibroCheck(customOptionEL)
// Update custom options check on click
customOptionEL.addEventListener('click', e => {
_this.updateTipoLibroCheck(customOptionEL)
})
})
}
function updateTipoLibroCheck(el)
{
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
const customRadioOptionList = [].slice.call(el.closest('.tipo_libro').querySelectorAll('.custom-option-tipo'))
customRadioOptionList.map(function (customRadioOptionEL) {
customRadioOptionEL.closest('.custom-option-tipo').classList.remove('checked')
})
}
el.closest('.custom-option-tipo').classList.add('checked')
if(el.closest('.custom-option-tipo').id == 'grapadoDiv') {
$('#tapaDuraDiv').hide();
$('#tapaBlanda').prop('checked', true);
}
else {
$('#tapaDuraDiv').show();
}
if(el.closest('.custom-option-tipo').id == 'cosidoDiv') {
$('#div_pagCuadernillo').show();
}
else {
$('#div_pagCuadernillo').hide();
}
} else {
el.closest('.custom-option-tipo').classList.remove('checked')
}
}
initTipoLibroCheck();
function getUpdatePapelInterior() {
var impresionInterior = $('input[name="impresionInterior"]:checked').val();
if(impresionInterior == 'color') {
$('#colorInteriorDiv').show();
}
else {
$('#colorInteriorDiv').hide();
}
}

View File

@ -1,332 +0,0 @@
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<?= view("themes/vuexy/form/clientes/cliente/_clienteDireccionesForm") ?>
<div class="container-xxl flex-grow-1 container-p-y">
<div class="col-12">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= view("themes/vuexy/form/presupuestos/cliente/loader") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<!-- Create Deal Wizard -->
<div id="wizard-presupuesto-cliente" class="bs-stepper vertical mt-2 linear">
<?php if ($presupuestoEntity->estado_id == 1) : ?>
<div class="bs-stepper-header">
<div class="step active" data-target="#datos-generales">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
<span class="bs-stepper-circle"><i class="ti ti-book ti-sm"></i></span>
<span class="bs-stepper-label">
<span class="bs-stepper-title">Datos generales</span>
</span>
</button>
</div>
<div class="line"></div>
<div class="step" data-target="#disenio-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
<span class="bs-stepper-circle"><i class="ti ti-book ti-sm"></i></span>
<span class="bs-stepper-label">
<span class="bs-stepper-title">Diseño del libro</span>
<span class="bs-stepper-subtitle">Detalles técnicos del libro</span>
</span>
</button>
</div>
<div class="line"></div>
<div class="step" data-target="#direcciones-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
<span class="bs-stepper-circle"><i class="ti ti-map-pins ti-sm"></i></span>
<span class="bs-stepper-label">
<span class="bs-stepper-title">Direcciones</span>
<span class="bs-stepper-subtitle">Dirección envío, facturación</span>
</span>
</button>
</div>
<div class="line"></div>
<div class="step" data-target="#resumen-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
<span class="bs-stepper-circle"><i class="ti ti-checkbox ti-sm"></i></span>
<span class="bs-stepper-label">
<span class="bs-stepper-title">Resumen del presupuesto</span>
</span>
</button>
</div>
<div id="errorGeneral" class="fv-plugins-message-container invalid-feedback" style="display: none;">
<p>Se ha producido un error <br>
al calcular el presupuesto. <br>
Póngase en contacto con el <br>
administrador.</p>
</div>
<div id='divTiradasPrecio'>
</div>
</div>
<div class="bs-stepper-content">
<form id="presupuesto-cliente-form" onsubmit="return false">
<!-- Tipo Libro -->
<div id="datos-generales" class="content active" dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/_tipoLibroItems") ?>
</div>
</div>
<!-- Diseño Libro
<div id="disenio-libro" class="content dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/_disenioLibroItems") ?>
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-primary btn-prev waves-effect waves-light">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Anterior</span>
</button>
<button class="btn btn-primary btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Siguiente</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
</div>
</div>
</div>
<!-- Direcciones -->
<div id="direcciones-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/_direccionesItems") ?>
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-primary btn-prev waves-effect waves-light">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Anterior</span>
</button>
<button id="toReview" class="btn btn-primary btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Siguiente</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
</div>
</div>
</div>
<!-- Review & Complete -->
<div id="resumen-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/_resumenItems") ?>
</div>
<div class="col-12 d-flex justify-content-between mt-4">
<div class="col-6 d-flex flex-row">
<?php if ($presupuestoEntity->estado_id == 1) : ?>
<button class="btn btn-primary btn-prev waves-effect waves-light">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Anterior</span>
</button>
<?php endif; ?>
</div>
<div class="col-6 d-flex flex-row-reverse">
<?php if ($presupuestoEntity->estado_id == 1) : ?>
<button id="btnSave" class="btn btn-primary btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
<button id="btnConfirm" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
</button>
<?php else: ?>
<button id="btnBack" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Volver</span><i class="ti ti-check ti-xs"></i>
</button>
<?php endif; ?>
<button id="btnDuplicar" class="btn btn-primary btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Duplicar</span>
<i class="ti ti-copy ti-xs"></i>
</button>
<?php
// Mostrar boton de impresion solo en presupuestos guardados (no add!)
if ($formAction == "edit") {
echo anchor(
route_to("presupuestoToPdf", $presupuestoEntity->id),
lang("Basic.global.Print"),
[
"class" => "btn btn-dark float-start me-sm-3 ml-2",
"target" => "_blank"
]
);
}
?>
</div>
</div>
</div>
</form>
</div>
<?php else: ?>
<div class="row">
<div class="card">
<div class="card-body">
<form id="presupuesto-cliente-form" onsubmit="return false">
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/_resumenItems") ?>
<div class="col-12 d-flex justify-content-between mt-4">
<div class="col-6 d-flex flex-row">
<?php if ($presupuestoEntity->estado_id == 1) : ?>
<button class="btn btn-primary btn-prev waves-effect waves-light">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Anterior</span>
</button>
<?php endif; ?>
</div>
<div class="col-6 d-flex flex-row-reverse">
<?php if ($presupuestoEntity->estado_id == 1) : ?>
<button id="btnSave" class="btn btn-primary btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
<button id="btnConfirm" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
</button>
<?php else: ?>
<button id="btnBack" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Volver</span><i class="ti ti-check ti-xs"></i>
</button>
<?php endif; ?>
<button id="btnDuplicar" class="btn btn-primary btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Duplicar</span>
<i class="ti ti-copy ti-xs"></i>
</button>
<?php
// Si esta confirmado siempre es un presupuesto guardado
echo anchor(
route_to("presupuestoToPdf", $presupuestoEntity->id),
lang("Basic.global.Print"),
[
"class" => "btn btn-dark float-start me-sm-3 ml-2",
"target" => "_blank"
]
);
?>
</div>
</div>
</form>
</div>
</div>
</div>
<?php endif; ?>
</div><!--//.col -->
<?= view("themes/vuexy/components/chat_presupuesto",data:["modelId" => $presupuestoEntity->id]) ?>
</div><!--//.row -->
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>
<?= $this->endSection() ?>
<?= $this->section("additionalInlineJs") ?>
window.datosPresupuesto = <?= json_encode($datosPresupuesto) ?>;
window.token_ajax= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
<?php if ($presupuestoEntity->estado_id == 1) : ?>
$('#clienteId').select2({
allowClear: false,
ajax: {
url: '<?= route_to("menuItemsOfClientes") ?>',
type: 'post',
dataType: 'json',
data: function(params) {
return {
id: 'id',
text: 'nombre',
searchTerm: params.term,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function(response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
});
initDisenioLibro();
<?php endif; ?>
<?= $this->endSection() ?>
<?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/bs-stepper/bs-stepper.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/formvalidation/dist/css/formValidation.min.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/dropzone/dropzone.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("themes/vuexy/vendor/libs/dropzone/dropzone.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/bs-stepper/bs-stepper.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.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/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/select/dataTables.select.min.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteResumen_js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') ?>"></script>
<?php if ($presupuestoEntity->estado_id == 1) : ?>
<script src="<?= site_url('js_loader/presupuestoCliente_js') ?>"></script>
<?php endif; ?>
<script src="<?= site_url('js_loader/presupuestoClienteTipoLibro_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteDisenioLibro_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteDirecciones_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClientePreview_js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -53,15 +53,18 @@
<div class="step" data-target="#direcciones-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
<span class="bs-stepper-circle"><i class="ti ti-books ti-sm"></i></span>
<span class="bs-stepper-circle"><i class="ti ti-map-pins ti-sm"></i></span>
<span class="bs-stepper-label">
<span class="bs-stepper-title">Direcciones</span>
</span>
</button>
</div>
<div class="line"></div>
<div id='divTiradasPrecio'></div>
</div> <!--//.bs-stepper-header -->
<div class="bs-stepper-content">
@ -77,23 +80,23 @@
</div>
<div id="interior-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioInterior") ?>
</div>
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioInterior") ?>
</div>
</div>
<div id="cubierta-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta") ?>
</div>
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta") ?>
</div>
</div>
<div id="direcciones-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_direcciones") ?>
</div>
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_direcciones") ?>
</div>
</div>
<?= view("themes/vuexy/form/presupuestos/cliente/items/_buttons") ?>
@ -108,7 +111,8 @@
<div id="form_buttons" class="row col-sm-12 justify-content-center" style="display: none;">
</div>
<?php //<?= view("themes/vuexy/components/chat_presupuesto", data: ["modelId" => $presupuestoEntity->id]) ?> */?>
<?php //<?= view("themes/vuexy/components/chat_presupuesto", data: ["modelId" => $presupuestoEntity->id])
?> */?>
</div><!--//.row -->
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>

View File

@ -6,6 +6,7 @@ class Ajax{
this.success = success;
this.error = error;
this.type = type;
this.jqXHR = null;
}
post(){
(this.type == 'default') ? this.ajax('POST'): this.ajaxForm('POST');
@ -19,8 +20,21 @@ class Ajax{
delete(){
(this.type == 'default') ? this.ajax('DELETE'): this.ajaxForm('DELETE');
}
abort() {
if (this.jqXHR) {
this.jqXHR.abort();
this.jqXHR = null; // Limpiamos la referencia a la petición
}
}
setData(data){
this.data = data;
}
ajax(method){
$.ajax({
if (this.jqXHR) {
this.jqXHR.abort();
}
this.jqXHR = $.ajax({
url : this.url,
type : method,
data: this.data,
@ -30,7 +44,11 @@ class Ajax{
})
}
ajaxForm(method){
$.ajax({
if (this.jqXHR) {
this.jqXHR.abort();
}
this.jqXHR = $.ajax({
url : this.url,
type : method,
data: this.data,

View File

@ -44,11 +44,6 @@ class ClassSelect2 {
}
});
}
setParams(params) {
this.params = params;
}
// Método para obtener el valor seleccionado
getValue() {
return this.domItem.val();
@ -59,6 +54,10 @@ class ClassSelect2 {
this.domItem.val(value).trigger('change');
}
setParams(params) {
this.params = params;
}
clear() {
this.domItem.val(null).trigger('change');
}

View File

@ -20,19 +20,18 @@ class tarjetaDireccion {
var $label = $('<label>', { class: 'form-check-label custom-option-content' });
var $header = $('<span>', { class: 'custom-option-header mb-2' });
var $name = $('<h6>', { class: 'fw-semibold mb-0', text: direccion.nombre });
var $name = $('<h6>', { class: 'fw-semibold mb-0', text: direccion.att });
var $unidades = $('<span>', { class: 'badge bg-label-primary unidades', text: direccion.unidades + ' unidades' });
var $body = $('<span>', { class: 'custom-option-body' });
var $direccion = $('<small>', { class: 'address-direccion', text: direccion.direccion });
var $cp = $('<small>', { class: 'address-cp', text: direccion.cp });
var $municipioPais = $('<small>', { class: 'address-municipio-pais', text: direccion.municipioPais });
var $municipioPais = $('<small>', { class: 'address-municipio-pais', text: direccion.municipio + ', '+ direccion.pais });
var $telefono = $('<small>', { class: 'address-telefono', text: direccion.telefono });
var $email = $('<small>', { class: 'address-email', text: direccion.email });
var $palets = $('<small>', {class: 'address-palets', html: '<i>Envío en palets</i>'});
if (!direccion.palets) $palets.addClass('d-none');
var $hr = $('<hr>', { class: 'my-2' });
var $eliminar = $('<a>', { class: 'ms-auto direccion-eliminar', href: 'javascript:void(0)', text: 'Eliminar' });
var $editar = $('<a>', { class: 'me-auto direccion-editar', href: 'javascript:void(0)', text: 'Editar' });
@ -64,6 +63,18 @@ class tarjetaDireccion {
}
setEntregaPalets(palets) {
this.card.find('.address-palets').toggleClass('d-none', !palets);
}
getEntregaPalets() {
return !this.card.find('.address-palets').hasClass('d-none');
}
setUnidades(unidades) {
this.card.find('.unidades').text(unidades + ' unidades');
}
getUnidades() {
return this.card.find('.unidades').text().split(' ')[0];
}

View File

@ -14,6 +14,12 @@ class DatosGenerales {
this.titulo = this.domItem.find("#titulo");
this.tirada1 = this.domItem.find("#tirada");
this.tirada2 = this.domItem.find("#tirada2");
this.tirada3 = this.domItem.find("#tirada3");
this.tirada4 = this.domItem.find("#tirada4");
this.papelFormatoId = this.domItem.find("#papelFormatoId");
this.checkFormatoPersonalizado = this.domItem.find("#papelFormatoPersonalizado");
this.formatoPersonalizado = this.domItem.find("#formatoPersonalizado");
this.anchoPersonalizado = this.domItem.find("#papelFormatoAncho");
@ -27,6 +33,8 @@ class DatosGenerales {
this.paginas = this.domItem.find("#paginas");
this.paginasNegro = this.domItem.find("#paginasNegro");
this.paginasColor = this.domItem.find("#paginasColor");
this.divPaginasCuaderillo = this.domItem.find("#divPaginasCuadernillo");
this.paginasCuadernillo = this.domItem.find("#paginasCuadernillo");
this.divPaginasColorConsecutivas = this.domItem.find("#divPaginasColorConsecutivas");
this.pagColorConsecutivas = this.domItem.find("#pagColorConsecutivas");
this.divPapelDiferente = this.domItem.find("#divPapelDiferente");
@ -34,6 +42,10 @@ class DatosGenerales {
this.divPosPaginasColor = this.domItem.find("#divPosPaginasColor");
this.posPaginasColor = this.domItem.find("#posPaginasColor");
this.ivaReducido = this.domItem.find("#ivaReducido");
this.excluirRotativa = this.domItem.find("#excluirRotativa");
this.prototipo = this.domItem.find("#prototipo");
this.initValidation();
}
@ -44,6 +56,9 @@ class DatosGenerales {
this.formatoLibro.init();
this.cliente.init();
// Inicializa el tipo de impresion
this.#handlePaginas();
// Eventos
this.checkFormatoPersonalizado.bind('change', this.#handleFormatoLibro.bind(this));
this.tiposLibro.on('click', this.#handleTipolibro.bind(this));
@ -318,6 +333,52 @@ class DatosGenerales {
});
}
getDimensionLibro() {
let ancho = 0;
let alto = 0;
if (this.checkFormatoPersonalizado.is(':checked')) {
ancho = parseFloat(this.anchoPersonalizado.val());
alto = parseFloat(this.altoPersonalizado.val());
}
else {
if (this.papelFormatoId.val() != null) {
const selectedText = this.papelFormatoId.find('option:selected').text();
if (selectedText.length > 0) {
ancho = parseFloat(selectedText.trim().split(" x ")[0]);
alto = parseFloat(selectedText.trim().split(" x ")[1]);
}
}
else
return null;
}
return {
ancho: ancho,
alto: alto
}
}
getTiradas() {
let tiradas = [];
tiradas.push(parseInt(this.tirada1.val()));
if (this.tirada2.val().length > 0 && parseInt(this.tirada2.val()) > 0)
tiradas.push(parseInt(this.tirada2.val()));
if (this.tirada3.val().length > 0 && parseInt(this.tirada3.val()) > 0)
tiradas.push(parseInt(this.tirada3.val()));
if (this.tirada4.val().length > 0 && parseInt(this.tirada4.val()) > 0)
tiradas.push(parseInt(this.tirada4.val()));
return tiradas;
}
getIsColor() {
if(this.paginasColor.val() > 0) {
return true;
}
return false;
}
#handleFormatoLibro() {
@ -351,11 +412,22 @@ class DatosGenerales {
if (this.fresado.hasClass('selected') || this.cosido.hasClass('selected')) {
$('#tapaDuraLomoRedondo').removeClass('d-none');
if(this.cosido.hasClass('selected')){
$('#tapaDuraLomoRedondo').addClass('selected');
this.divPaginasCuaderillo.removeClass('d-none');
}
else{
this.divPaginasCuaderillo.addClass('d-none');
}
}
else {
$('#tapaDuraLomoRedondo').addClass('d-none');
$('#tapaDuraLomoRedondo').removeClass('selected');
this.divPaginasCuaderillo.addClass('d-none');
}
// Para recalcular el presupuesto
element.trigger('change');
}
#handlePaginas() {
@ -431,8 +503,10 @@ class DatosGenerales {
#handlePapelDiferente() {
if (this.papelDiferente.is(':checked')) {
$(".papel-interior").removeClass('selected');
$(".interior-color").removeClass('d-none');
this.#handleInteriorLayout('mixto');
}
else {
$(".interior-color").addClass('d-none');

View File

@ -1,4 +1,5 @@
import ClassSelect from '../../components/select2.js';
import Ajax from '../../components/ajax.js';
import tarjetaDireccion from '../../components/tarjetaDireccionPresupuesto.js';
class Direcciones {
@ -9,6 +10,10 @@ class Direcciones {
this.wizardStep = wizardForm.querySelector('#direcciones-libro');
this.validatorStepper = validatorStepper;
this.unidadesAdd = this.domItem.find('#unidadesEnvio');
this.btnAdd = this.domItem.find('#insertarDireccion');
this.entregaPieCallero = this.domItem.find('#entregaPieCalle');
this.direccionesCliente = new ClassSelect($("#direcciones"), '/clientedirecciones/menuitems');
this.divDirecciones = $(this.domItem.find('#divDirecciones'));
@ -24,16 +29,8 @@ class Direcciones {
$("#clienteId").on('change', this.#handleChangeCliente.bind(this));
let direccion = {
nombre: 'Casa',
unidades: '100',
direccion: 'Calle de la Prueba, 12',
cp: '28000',
municipioPais: 'Madrid, España',
telefono: '912345678',
email: 'aaa@aa.com',
palets: false,
}
this.direccionesCliente.init();
this.btnAdd.on('click', this.#insertDireccion.bind(this));
}
@ -70,24 +67,60 @@ class Direcciones {
});
}
#insertDireccion(direccion_id) {
let tarjeta = new tarjetaDireccion();
tarjeta.setDireccion(direccion);
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(this));
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(this));
this.divDirecciones.append(tarjeta.card);
this.direcciones.push(direccion);
#insertDireccion() {
self = this;
try {
let id = this.direccionesCliente.getValue();
let unidades = this.unidadesAdd.val();
let entregaPalets = this.entregaPieCallero.is(':checked');
let dirId = "dirEnvio-1";
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
if (direccionesActuales.length > 0) {
// the the lass item
let last = direccionesActuales[direccionesActuales.length - 1];
dirId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1);
}
if (id == null || id <= 0 || id == undefined)
return;
if (unidades == null || unidades <= 0 || unidades == undefined)
return;
$('#loader').show();
let peticion = new Ajax('/misdirecciones/get/' + id, {}, {},
(response) => {
let tarjeta = new tarjetaDireccion(this.divDirecciones, dirId, 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({ "id": dirId, "unidades": unidades, "enPallets": entregaPalets, "direccion": response.data[0] });
self.divDirecciones.trigger('change');
$('#loader').hide();
},
() => {
console.error('Error getting address');
$('#loader').hide();
});
peticion.get();
} catch (e) {
console.error(e);
$('#loader').hide();
}
}
#handleChangeCliente() {
this.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id })
this.direccionesCliente.clear();
this.domItem.find('.direccion-cliente').remove();
this.direcciones = [];
}
@ -103,12 +136,13 @@ class Direcciones {
modal.modal('show');
modal.find('.btn-primary').off('click');
modal.find('.btn-primary').on('click', function () {
modal.find('.btn-primary').on('click', () => {
try {
let nuevo_valor = parseInt(modal.find('.modal-body input').val());
if (nuevo_valor > 0) {
tarjeta.find('.unidades').text(nuevo_valor + ' unidades');
this.divDirecciones.trigger('change');
}
} catch (error) {
console.error('Units must be a number');
@ -123,7 +157,8 @@ class Direcciones {
let id = tarjeta.id;
tarjeta.remove();
this.divDirecciones.trigger('change');
this.direcciones = this.direcciones.filter(direccion => direccion.id != id);
}
}

View File

@ -11,8 +11,11 @@ class DisenioCubierta {
this.papelCubierta = this.domItem.find(".papel-cubierta");
this.divSolapas = this.domItem.find("#divSolapasCubierta");
this.divCarasImpresion = this.domItem.find("#divCarasImpresion");
this.divConfigTapaDura = this.domItem.find("#divConfigTapaDura");
this.carasCubierta = this.domItem.find("#carasCubierta");
this.tapaBlanda = this.domItem.find("#tapaBlanda");
this.tapaDuraLomoRecto = this.domItem.find("#tapaDura");
this.tapaDuraLomoRedondo = this.domItem.find("#tapaDuraLomoRedondo");
@ -26,6 +29,7 @@ class DisenioCubierta {
this.estucadoMate = this.domItem.find("#estucadoMate");
this.divGramajeCubierta = this.domItem.find("#divGramajeCubierta");
this.gramaje = this.domItem.find(".check-gramaje-cubierta");
this.gramaje170 = $(this.domItem.find("#divGramaje170Cubierta"));
this.gramaje250 = $(this.domItem.find("#divGramaje250Cubierta"));
this.gramaje270 = $(this.domItem.find("#divGramaje270Cubierta"));
@ -37,7 +41,7 @@ class DisenioCubierta {
this.configuracionSobrecubierta = this.domItem.find(".config-sobrecubierta");
this.sobrecubierta = this.domItem.find("#addSobrecubierta");
this.configuracionFaja = this.domItem.find(".config-faja");
this.faja = this.domItem.find("#addFaja");
this.faja = this.domItem.find("#addFaja");
this.solapasSobrecubierta = this.domItem.find("#solapasSobrecubierta");
this.solapasFaja = this.domItem.find("#solapasFaja");
@ -79,11 +83,15 @@ class DisenioCubierta {
this.solapasSobrecubierta.on('blur', this.#handleInputs);
this.solapasFaja.on('blur', this.#handleInputs);
this.sobrecubierta.on('change', () => {
this.sobrecubierta.is(":checked") ? this.configuracionSobrecubierta.removeClass("d-none") : this.configuracionSobrecubierta.addClass("d-none") }
this.carasCubierta.on('change', this.#handleCarasCubierta.bind(this));
this.sobrecubierta.on('change', () => {
this.sobrecubierta.is(":checked") ? this.configuracionSobrecubierta.removeClass("d-none") : this.configuracionSobrecubierta.addClass("d-none")
}
);
this.faja.on('change', () => {
this.faja.is(":checked") ? this.configuracionFaja.removeClass("d-none") : this.configuracionFaja.addClass("d-none") }
this.faja.is(":checked") ? this.configuracionFaja.removeClass("d-none") : this.configuracionFaja.addClass("d-none")
}
);
@ -97,7 +105,7 @@ class DisenioCubierta {
this.observer.observe(this.sinSolapas[0], { attributes: true });
this.checksGramaje.each(function () {
const customOptionEL = $(this);
customOptionEL.on('click', function () {
self.#handleClickGramaje(customOptionEL);
@ -139,7 +147,7 @@ class DisenioCubierta {
validators: {
callback: {
callback: function (input) {
const div = $('#divSolapasCubierta');
const div = $('#divSolapasCubierta');
if (div.hasClass("d-none")) return true;
div.find('.fv-plugins-message-container').remove();
@ -164,7 +172,7 @@ class DisenioCubierta {
validators: {
callback: {
callback: function (input) {
const div = $('#divPapelCubierta');
const div = $('#divPapelCubierta');
if (div.hasClass("d-none")) return true;
div.find('.fv-plugins-message-container').remove();
@ -190,7 +198,7 @@ class DisenioCubierta {
callback: {
callback: function (input) {
const div = $('#divGramajeCubierta'); // Selecciona el div
div.find('.fv-plugins-message-container').remove();
if ($('.check-gramaje-cubierta:checked').length > 0) {
return true;
@ -239,6 +247,159 @@ class DisenioCubierta {
}
getSolapasCubierta() {
try {
if (this.solapasCubierta.hasClass("selected").length == 0)
return null;
else {
if (this.solapasCubierta.hasClass("selected").attr("id") == "solapasCubiertaNo")
return false;
else
parseInt(this.tamanioSolapasCubierta.val());
}
}
catch (error) {
return null;
}
}
getPapel() {
try {
if (this.papelCubierta.filter('.selected').length > 0) {
return this.papelCubierta.filter('.selected').attr('cod');
}
return null;
}
catch (e) {
return null;
}
}
getGramaje() {
try {
if(this.divGramajeCubierta.hasClass("d-none"))
return null;
if (this.gramaje.filter(':checked').length > 0)
return this.gramaje.filter(':checked').attr('data-value');
else
return null;
} catch (e) {
return null;
}
}
getAcabados() {
try {
let acabados = {};
acabados.plastificado = this.domItem.find("#plastificado ").children("option:selected").val();
acabados.barniz = this.domItem.find("#barniz").children("option:selected").val();
acabados.estampado = this.domItem.find("#estampado").children("option:selected").val();
acabados.retractilado = this.domItem.find("#retractilado").hasClass('selected') ? true : false;
return acabados;
} catch (e) {
return null;
}
}
getCabezada() {
try {
if (this.tapaBlanda.hasClass("selected"))
return false;
else
return this.domItem.find("#cabezada").children("option:selected").val();
} catch (e) {
return null;
}
}
getGuardas() {
try {
if (this.tapaBlanda.hasClass("selected")) {
return false;
}
else {
let guardas = {};
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").val();
guardas.papel = papelGuardas.split('_')[0];
guardas.gramaje = papelGuardas.split('_')[1];
guardas.guardasImpresas = this.domItem.find("#guardasImpresas").children("option:selected").val();
return guardas;
}
} catch (e) {
return null;
}
}
getSobrecubierta() {
try {
if (!this.sobrecubierta.is(":checked")) {
return false;
}
else {
let sobrecubierta = {};
let papel = this.domItem.find("#papelSobrecubierta").children("option:selected").val();
sobrecubierta.papel = papel.split('_')[0];
sobrecubierta.gramaje = papel.split('_')[1];
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
sobrecubierta.plastificado = this.domItem.find("#plastificadoSobrecubierta").children("option:selected").val();
return sobrecubierta;
}
} catch (e) {
return null;
}
}
getFaja() {
try {
if (!this.faja.is(":checked")) {
return false;
}
else {
let faja = {};
faja.alto = this.domItem.find("#altoFaja").val();
let papel = this.domItem.find("#papelFaja").children("option:selected").val();
faja.papel = papel.split('_')[0];
faja.gramaje = papel.split('_')[1];
faja.solapas = this.domItem.find("#solapasFaja").val();
faja.plastificado = this.domItem.find("#plastificadoFaja").children("option:selected").val();
return faja;
}
} catch (e) {
return null;
}
}
#handleCarasCubierta(){
// Si es a dos caras
if(this.carasCubierta.val() == 4){
this.cartulinaEstucada.addClass("d-none");
}
else{
this.cartulinaEstucada.removeClass("d-none");
}
}
#handleDisenioCubierta(event) {
// Accede al ID del elemento que disparó el evento
const element = $(event.target);
@ -259,7 +420,9 @@ class DisenioCubierta {
$(".papel-cubierta").removeClass("selected");
if (this.tapaBlanda.hasClass("selected")) {
this.cartulinaEstucada.removeClass("d-none");
if(this.carasCubierta.val() == 2){
this.cartulinaEstucada.removeClass("d-none");
}
this.divGramajeCubierta.addClass("d-none");
}
else {
@ -273,6 +436,8 @@ class DisenioCubierta {
this.gramaje300.addClass("d-none");
this.gramaje350.addClass("d-none");
}
element.trigger('change');
}
@ -292,6 +457,8 @@ class DisenioCubierta {
element.closest(class2Find).toggleClass('selected');
element.closest('.image-presupuesto').toggleClass('selected');
element.trigger('change');
}
@ -311,23 +478,28 @@ class DisenioCubierta {
element.closest(class2Find).toggleClass('selected');
element.closest('.image-presupuesto').toggleClass('selected');
element.trigger('change');
}
#handleMenuTipoCubierta() {
if (this.tapaBlanda.hasClass("selected")) {
this.divSolapas.removeClass("d-none");
this.divCarasImpresion.removeClass("d-none");
this.divConfigTapaDura.addClass("d-none");
}
else if (this.tapaDuraLomoRecto.hasClass("selected") || this.tapaDuraLomoRedondo.hasClass("selected")) {
this.solapasCubierta.removeClass("selected");
this.divSolapas.addClass("d-none");
this.divCarasImpresion.addClass("d-none");
this.divConfigTapaDura.removeClass("d-none");
this.#handleMenuPapel();
}
else {
this.divSolapas.addClass("d-none");
this.divCarasImpresion.addClass("d-none");
this.divConfigTapaDura.addClass("d-none");
this.#handleMenuPapel();
}
@ -348,7 +520,7 @@ class DisenioCubierta {
$(".check-gramaje-cubierta").prop("checked", false);
if(!this.tapaBlanda.hasClass("selected") && !this.tapaDuraLomoRecto.hasClass("selected") && !this.tapaDuraLomoRedondo.hasClass("selected")) {
if (!this.tapaBlanda.hasClass("selected") && !this.tapaDuraLomoRecto.hasClass("selected") && !this.tapaDuraLomoRedondo.hasClass("selected")) {
this.divGramajeCubierta.addClass("d-none");
this.estucadoMate.removeClass("selected");
this.cartulinaEstucada.removeClass("selected");
@ -363,8 +535,8 @@ class DisenioCubierta {
this.gramaje300.removeClass("d-none");
this.gramaje350.removeClass("d-none");
}
else if(this.estucadoMate.hasClass("selected")) {
if(this.tapaBlanda.hasClass("selected")) {
else if (this.estucadoMate.hasClass("selected")) {
if (this.tapaBlanda.hasClass("selected")) {
this.divGramajeCubierta.removeClass("d-none");
this.gramaje170.addClass("d-none");
this.gramaje250.removeClass("d-none");
@ -372,7 +544,7 @@ class DisenioCubierta {
this.gramaje300.removeClass("d-none");
this.gramaje350.removeClass("d-none");
}
else{
else {
this.divGramajeCubierta.removeClass("d-none");
this.gramaje170.removeClass("d-none");
this.gramaje250.addClass("d-none");

View File

@ -19,6 +19,7 @@ class DisenioInterior {
this.offsetAhuesadoVolumen = this.domItem.find("#offsetAhuesadoVolumen");
this.estucadoMate = this.domItem.find("#estucadoMate");
this.gramaje = this.domItem.find(".check-interior-gramaje");
this.gramaje70 = this.domItem.find("#interiorGramaje70");
this.gramaje80 = this.domItem.find("#interiorGramaje80");
this.gramaje90 = this.domItem.find("#interiorGramaje90");
@ -29,6 +30,7 @@ class DisenioInterior {
this.gramaje150 = this.domItem.find("#interiorGramaje150");
this.gramaje170 = this.domItem.find("#interiorGramaje170");
this.interiorColor = this.domItem.find(".interior-color");
this.disenioInterior_color = this.domItem.find(".disenio-interior-color");
this.papelInterior_color = this.domItem.find(".papel-interior-color");
@ -40,6 +42,7 @@ class DisenioInterior {
this.offsetAhuesadoVolumen_color = this.domItem.find("#offsetAhuesadoVolumenColor");
this.estucadoMate_color = this.domItem.find("#estucadoMateColor");
this.gramaje_color = this.domItem.find(".check-interior-color-gramaje");
this.gramaje70_color = this.domItem.find("#interiorGramaje70Color");
this.gramaje80_color = this.domItem.find("#interiorGramaje80Color");
this.gramaje90_color = this.domItem.find("#interiorGramaje90Color");
@ -96,7 +99,7 @@ class DisenioInterior {
this.observer.observe(this.estucadoMate_color[0], { attributes: true });
this.checksGramaje.each(function () {
const customOptionEL = $(this);
customOptionEL.on('click', function () {
self.#handleClickGramaje(customOptionEL);
@ -291,6 +294,76 @@ class DisenioInterior {
}
getIsHq() {
try {
if (this.interiorColor.filter('.d-none').length > 0) {
return this.disenioInterior.filter('.selected').attr('id').includes('Premium');
}
else if (this.disenioInterior_color.filter('.selected').length > 0) {
return {
negro: this.disenioInterior.filter('.selected').attr('id').includes('Premium'),
color: this.disenioInterior_color.filter('.selected').attr('id').includes('Premium')
}
}
return null;
} catch (e) {
return null;
}
}
getPapel() {
try {
if (this.papelInterior.filter('.selected').length > 0) {
if (this.papelInterior_color.filter('.selected').length > 0) {
return {
negro: this.papelInterior.filter('.selected').attr('cod'),
color: this.papelInterior_color.filter('.selected').attr('cod')
}
}
if (this.interiorColor.filter('.d-none').length > 0)
return this.papelInterior.filter('.selected').attr('cod')
else
return null;
}
return null;
}
catch (e) {
return null;
}
}
getGramaje() {
try {
if (this.interiorColor.filter('.d-none').length == 0){
let values = {
negro: this.gramaje.filter(':checked') .attr('data-value'),
color: this.gramaje_color.filter(':checked').attr('data-value')
}
if (values.negro && values.color) {
return values;
}
else return null;
}
else{
return this.gramaje.filter(':checked').attr('data-value');
}
} catch (e) {
return null;
}
}
#handleClickGramaje(customOption) {
const el = customOption[0];
@ -328,6 +401,9 @@ class DisenioInterior {
element.closest(class2Find).toggleClass('selected');
element.closest('.image-presupuesto').toggleClass('selected');
// Para recalcular el presupuesto
element.trigger('change');
}
@ -358,6 +434,9 @@ class DisenioInterior {
$('#tapaDuraLomoRedondo').removeClass('d-none');
}
}
// Para recalcular el presupuesto
element.trigger('change');
}
#handleUpdateGramaje() {
@ -366,7 +445,7 @@ class DisenioInterior {
$(".check-interior-gramaje ").prop("checked", false);
$(".check-interior-color-gramaje ").prop("checked", false);
if (this.negroEstandar.hasClass("selected") || this.colorEstandar.hasClass("selected")) {
if (this.offsetBlanco.hasClass("selected")) {

View File

@ -4,6 +4,9 @@ import DisenioCubierta from './disenioCubierta.js';
import Direcciones from './direcciones.js';
import Ajax from '../../components/ajax.js';
import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js';
class PresupuestoCliente {
constructor() {
@ -23,6 +26,12 @@ class PresupuestoCliente {
this.disenioInterior = new DisenioInterior($("#interior-libro"), this.clientePresupuestoWizard, this.validationStepper);
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper);
this.direcciones = new Direcciones($("#direcciones-libro"), this.clientePresupuestoWizard, this.validationStepper);
this.datos = {};
this.ajax_calcular = new Ajax('/presupuestocliente/calcular',
{}, this.datos,
this.#procesarPresupuesto,
() => { $('#loader').hide(); console.log("Error") });
}
@ -31,6 +40,8 @@ class PresupuestoCliente {
this.btnNext.on('click', this.#nextStep.bind(this));
this.btnPrev.on('click', this.#prevtStep.bind(this));
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
// Fuerza el foco en el campo de búsqueda de select2
$(document).on('select2:open', () => {
document.querySelector('.select2-search__field').focus();
@ -48,6 +59,29 @@ class PresupuestoCliente {
}
checkForm() {
this.#getDatos();
if (Object.values(this.datos).every(this.#isValidDataForm)) {
try {
$('#loader').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();
}
catch (e) {
console.log(e);
$('#loader').hide();
}
}
}
RELLENAR_PRESUPUESTO() {
$("#titulo").val("Titulo del libro");
@ -58,7 +92,7 @@ class PresupuestoCliente {
clienteId.append(newOption).trigger('change');
const papelFormatoId = $("#papelFormatoId");
const newOption2 = new Option("Formato 1", "1", true, true);
const newOption2 = new Option("148 x 210", "1", true, true);
papelFormatoId.append(newOption2).trigger('change');
$("#paginasColor").val("6");
@ -66,18 +100,33 @@ class PresupuestoCliente {
$("#fresado").trigger("click");
$("#colorEstandar").trigger("click");
$("#offsetBlanco").trigger("click");
setTimeout(function() {
$("#offsetBlanco").trigger("click");
setTimeout(function () {
$("#gramaje80").trigger("click");
}, 0);
setTimeout(function() {
setTimeout(function () {
$("#tapaDura").trigger("click");
}, 0);
}, 0);
/*
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#unidadesEnvio").val("100");
}, 0);*/
}
@ -102,6 +151,14 @@ class PresupuestoCliente {
}
#procesarPresupuesto(response) {
$('#loader').hide();
console.log("Success");
console.log(response);
}
#nextStep() {
switch (this.validationStepper._currentIndex) {
@ -112,27 +169,113 @@ class PresupuestoCliente {
case 1:
this.disenioInterior.formValidation.validate();
break;
case 2:
this.disenioCubierta.formValidation.validate();
break;
/*
case 3:
FormValidation5.validate();
this.direcciones.formValidation.validate();
break;
*/
default:
break;
}
}
#prevtStep() {
if(this.validationStepper._currentIndex >= 1 && this.validationStepper._currentIndex <= 4)
if (this.validationStepper._currentIndex >= 1 && this.validationStepper._currentIndex <= 4)
this.validationStepper.previous();
}
#getDatos() {
this.datos = {
clienteId: this.datosGenerales.cliente.getValue(),
tamanio: this.datosGenerales.getDimensionLibro(),
tirada: this.datosGenerales.getTiradas(),
paginas: this.datosGenerales.paginas.val(),
paginasColor: this.datosGenerales.paginasColor.val(),
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
isColor: this.datosGenerales.getIsColor(),
isHq: this.disenioInterior.getIsHq(),
interior: {
papelInterior: this.disenioInterior.getPapel(),
gramajeInterior: this.disenioInterior.getGramaje(),
},
cubierta: {
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
papelCubierta: this.disenioCubierta.getPapel(),
gramajeCubierta: this.disenioCubierta.getGramaje(),
cabezada: this.disenioCubierta.getCabezada(),
acabados: this.disenioCubierta.getAcabados(),
carasImpresion: this.disenioCubierta.carasCubierta.val(),
},
guardas: this.disenioCubierta.getGuardas(),
sobrecubierta: this.disenioCubierta.getSobrecubierta(),
faja: this.disenioCubierta.getFaja(),
excluirRotativa: this.datosGenerales.excluirRotativa.is(':checked'),
ivaReducido: this.datosGenerales.ivaReducido.find('option:selected').val(),
servicios: {
'prototipo' : this.datosGenerales.servicios.prototipo.is(':checked'),
},
};
if(this.datos.tipo == "cosido"){
this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val();
}
let solapasCubierta = this.disenioCubierta.getSolapasCubierta();
if (solapasCubierta !== null && solapasCubierta !== undefined) {
if (solapasCubierta === false)
this.datos.cubierta.solapas = false;
else {
this.datos.cubierta.solapas = true;
this.datos.cubierta.tamanioSolapas = solapasCubierta;
}
}
else{
this.datos.cubierta.solapas = false;
}
}
#isValidDataForm(value) {
if (value === null || value === undefined || value === '') {
return false;
}
if (typeof value === 'object' && value !== null) {
return Object.values(value).every(isValid);
}
return true;
}
}
function isValid(value) {
if (value === null || value === undefined || value === '') {
return false;
}
if (typeof value === 'object' && value !== null) {
return Object.values(value).every(isValid);
}
return true;
}
function initialize(translations) {
window.translations = JSON.parse(translations);

View File

@ -0,0 +1,60 @@
class tarjetaTiradasPrecio {
constructor(domItem, id, tirada, precio, precio_unidad) {
this.domItem = domItem;
this.id = id;
this.tirada = tirada;
this.precio = precio;
this.precio_unidad = precio_unidad;
this.card = this.#generateHTML(id, tirada, precio, precio_unidad);
this.domItem.append(this.card);
}
#generateHTML(id, tirada, precio, precio_unidad) {
let $html = $('<div>', {
id: id,
class: 'list-group'
});
let $link = $('<a>', {
href: 'javascript:void(0);',
class: 'list-group-item list-group-item-action'
});
let $liWrapper = $('<div>', {
class: 'li-wrapper d-flex justify-content-start align-items-center'
});
let $listContent = $('<div>', {
class: 'list-content'
});
$listContent.append($('<h7>', {
id: 'ud_' + id,
class: 'mb-1',
text: tirada + ' ud.'
}));
$listContent.append($('<h6>', {
id: 'tot_' + id,
class: 'mb-1',
text: 'Total: ' + precio + '€'
}));
$listContent.append($('<h7>', {
id: 'pu_' + id,
class: 'mb-1',
text: precio_unidad + '€/ud'
}));
$liWrapper.append($listContent);
$link.append($liWrapper);
$html.append($link);
return $html;
}
}
export default tarjetaTiradasPrecio;