26 Commits

Author SHA1 Message Date
2e80fddfb6 añadidos más formatos a tarifas encuadernacion lineas (dimensiones) 2024-11-07 14:15:14 +01:00
1e2d550301 archivos resumen 2024-11-06 22:10:09 +01:00
0a3618cd00 Merge branch 'fix/message-notification' into 'dev/presu_cliente_v2'
Fix/message notification

See merge request jjimenez/safekat!359
2024-11-06 21:09:05 +00:00
33fbfc1a5d Merge branch 'dev/presu_cliente_v2' into fix/message-notification 2024-11-06 22:06:02 +01:00
a8612f64a4 fix : notification clientes add where chat_department_id is not NULL 2024-11-06 19:56:20 +01:00
0b614d4d58 bug para presupuesto cliente (en direcciones) 2024-11-06 17:15:41 +01:00
55b225ab49 errata de 109 en encuadernaciones model 2024-11-05 17:47:30 +01:00
315d2a3acd arreglado carga de cliente 2024-11-04 23:58:18 +01:00
83c8628645 presupuesto cliente para perfil cliente 2024-10-31 08:42:41 +01:00
d0ee0b27bc precio minimo en tarifa encuadernacion a nivel de lineas 2024-10-30 18:36:35 +01:00
8556887567 vuelta a importe minimo en tiradas 2024-10-30 17:46:35 +01:00
f50987dc2b arreglado bug con tamaño personalizado en presupuesto admin 2024-10-28 18:52:06 +01:00
4180cea16a Merge branch 'fix/message-notification' into 'dev/presu_cliente_v2'
refactor : in message notification send client to presupuestocliente and admin...

See merge request jjimenez/safekat!357
2024-10-26 11:15:09 +00:00
0b3bf0ed85 refactor : in message notification send client to presupuestocliente and admin or beta to presupuesto admin 2024-10-26 08:56:18 +02:00
14fe3b1461 refactor : in message notification send client to presupuestocliente and admin or beta to presupuesto admin 2024-10-26 08:56:06 +02:00
58ab81d8e8 arreglado el poder guardar sin direcciones 2024-10-25 13:59:23 +02:00
cdb9afc290 arreglando el lomo de cubierta cuando cambias de fresado a cosido 2024-10-25 13:56:37 +02:00
adcf2fbec3 arreglado grapado 2024-10-25 13:42:09 +02:00
eb806621c6 preview
terminada
2024-10-25 12:30:38 +02:00
0963fae240 preview 2024-10-25 12:12:16 +02:00
daa10420c7 Merge branch 'fix/datatable-error-presupuesto' into 'dev/presu_cliente_v2'
default sort error presupuestos datatable,set pagination to 50 and add page selector

See merge request jjimenez/safekat!356
2024-10-25 09:29:30 +00:00
716019bf81 default sort error presupuestos datatable,set pagination to 50 and add page selector 2024-10-25 11:27:27 +02:00
2ac99d14c0 click para moverse del menu 2024-10-24 21:05:59 +02:00
0f00649f99 corregidos errores 2024-10-24 08:50:13 +02:00
3dd9f8f7e3 fix notification chat error cuando cliente no tiene facturas asociadas 2024-10-23 05:48:06 +00:00
c79bc4343f Merge branch 'feat/add-chat-presupuesto-cliente' into 'dev/presu_cliente_v2'
Feat/add chat presupuesto cliente

See merge request jjimenez/safekat!354
2024-10-23 05:19:36 +00:00
38 changed files with 1335 additions and 1189 deletions

View File

@ -58,9 +58,9 @@ class ConfigErrores extends BaseResourceController
public function get_error_presupuesto(int $error_presupuesto_id) public function get_error_presupuesto(int $error_presupuesto_id)
{ {
$data = $this->errorPresupuestoModel->getErrorPresupuestoForm($error_presupuesto_id); $data = $this->errorPresupuestoModel->getErrorPresupuestoForm($error_presupuesto_id);
if(isset($data[0])){ if (isset($data[0])) {
return $this->response->setJSON(["data" => $data[0]]); return $this->response->setJSON(["data" => $data[0]]);
}else{ } else {
return $this->response->setJSON(["data" => []]); return $this->response->setJSON(["data" => []]);
} }
} }
@ -73,9 +73,9 @@ class ConfigErrores extends BaseResourceController
public function datatable() public function datatable()
{ {
$query = $this->errorPresupuestoModel->getQueryDatatable(); $query = $this->errorPresupuestoModel->getQueryDatatable()->orderBy("created_at", "DESC");
return DataTable::of($query) return DataTable::of($query)
->add("action", fn($q) => $q->id) ->add("action", fn($q) => $q->id)
->toJson(true); ->toJson(true);
} }
} }

View File

@ -1,4 +1,5 @@
<?php namespace App\Controllers\Configuracion; <?php
namespace App\Controllers\Configuracion;
use App\Controllers\BaseResourceController; use App\Controllers\BaseResourceController;
@ -12,8 +13,8 @@ use App\Models\Configuracion\MaquinasTarifasImpresionModel;
use App\Models\Configuracion\MaquinaModel; use App\Models\Configuracion\MaquinaModel;
use use
DataTables\Editor, DataTables\Editor,
DataTables\Editor\Field; DataTables\Editor\Field;
class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
{ {
@ -69,9 +70,9 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
{ {
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1'); $nullIfEmpty = true; // !(phpversion() >= '8.1');
@ -81,10 +82,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()):
try { try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData); $successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -98,14 +99,14 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
endif; endif;
if ($noException && $successfulResult) : if ($noException && $successfulResult):
$id = $this->model->db->insertID(); $id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) : if ($thenRedirect):
if (!empty($this->indexRoute)) : if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else: else:
return $this->redirect2listView('sweet-success', $message); return $this->redirect2listView('sweet-success', $message);
@ -129,25 +130,25 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
return $this->displayForm(__METHOD__); return $this->displayForm(__METHOD__);
} // end function add() } // end function add()
public function edit($requestedId = null) public function edit($requestedId = null)
{ {
if ($requestedId == null) : if ($requestedId == null):
return $this->redirect2listView(); return $this->redirect2listView();
endif; endif;
$id = filter_var($requestedId, FILTER_SANITIZE_URL); $id = filter_var($requestedId, FILTER_SANITIZE_URL);
$maquinasTarifasImpresion = $this->model->find($id); $maquinasTarifasImpresion = $this->model->find($id);
if ($maquinasTarifasImpresion == false) : if ($maquinasTarifasImpresion == false):
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')), $id]); $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')), $id]);
return $this->redirect2listView('sweet-error', $message); return $this->redirect2listView('sweet-error', $message);
endif; endif;
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1'); $nullIfEmpty = true; // !(phpversion() >= '8.1');
@ -160,10 +161,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()):
try { try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -180,12 +181,12 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$thenRedirect = false; $thenRedirect = false;
endif; endif;
if ($noException && $successfulResult) : if ($noException && $successfulResult):
$id = $maquinasTarifasImpresion->id ?? $id; $id = $maquinasTarifasImpresion->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) : if ($thenRedirect):
if (!empty($this->indexRoute)) : if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else: else:
return $this->redirect2listView('sweet-success', $message); return $this->redirect2listView('sweet-success', $message);
@ -220,30 +221,48 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
$response = Editor::inst($db, 'lg_maquinas_tarifas_impresion') $response = Editor::inst($db, 'lg_maquinas_tarifas_impresion')
->fields( ->fields(
Field::inst('uso') Field::inst('uso')
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('MaquinasTarifasImpresions.validation.uso.required')) 'Validate::notEmpty',
array(
'message' => lang('MaquinasTarifasImpresions.validation.uso.required')
)
), ),
Field::inst('tipo') Field::inst('tipo')
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')) 'Validate::notEmpty',
array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
)
), ),
Field::inst('precio') Field::inst('precio')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')) 'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')) 'Validate::notEmpty',
array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
)
), ),
Field::inst('margen') Field::inst('margen')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')) 'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')) 'Validate::notEmpty',
array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
)
), ),
Field::inst('maquina_id'), Field::inst('maquina_id'),
Field::inst('user_created_id'), Field::inst('user_created_id'),
@ -269,16 +288,21 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
'maquina_id' => $values['maquina_id'], 'maquina_id' => $values['maquina_id'],
'tipo' => $values['tipo'], 'tipo' => $values['tipo'],
'uso' => $values['uso'], 'uso' => $values['uso'],
'is_deleted' => 0)); 'is_deleted' => 0
));
$id = $builder->get()->getFirstRow()->id; $id = $builder->get()->getFirstRow();
if ($id) {
$id = $id->id;
// No se pueden duplicar valores al crear o al editar
if ($builder->countAllResults() >= 1) {
if (
($action === Editor::ACTION_EDIT && $id != $pkey)
|| $action === Editor::ACTION_CREATE
) {
// No se pueden duplicar valores al crear o al editar return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
if ($builder->countAllResults() >= 1) { }
if (($action === Editor::ACTION_EDIT && $id != $pkey)
|| $action === Editor::ACTION_CREATE) {
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
} }
} }
} }
@ -413,11 +437,11 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
protected function getMaquinaListItems($selId = null) protected function getMaquinaListItems($selId = null)
{ {
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
if (!empty($selId)) : if (!empty($selId)):
$maquinaModel = model('App\Models\Configuracion\MaquinaModel'); $maquinaModel = model('App\Models\Configuracion\MaquinaModel');
$selOption = $maquinaModel->where('id', $selId)->findColumn('nombre'); $selOption = $maquinaModel->where('id', $selId)->findColumn('nombre');
if (!empty($selOption)) : if (!empty($selOption)):
$data[$selId] = $selOption[0]; $data[$selId] = $selOption[0];
endif; endif;
endif; endif;

View File

@ -1278,8 +1278,8 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController
$input_data['is_duplicado'] = $presupuestoEntity->is_duplicado; $input_data['is_duplicado'] = $presupuestoEntity->is_duplicado;
if($presupuestoEntity->papel_formato_personalizado){ if($presupuestoEntity->papel_formato_personalizado){
$input_data['ancho'] = $presupuestoEntity->ancho; $input_data['ancho'] = $presupuestoEntity->papel_formato_ancho ;
$input_data['alto'] = $presupuestoEntity->alto; $input_data['alto'] = $presupuestoEntity->papel_formato_alto ;
} }
else{ else{
$model = model("App\Models\Configuracion\PapelFormatoModel"); $model = model("App\Models\Configuracion\PapelFormatoModel");

View File

@ -99,9 +99,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Se obtiene el cliente ID a partir del usuario de la sesion // Se obtiene el cliente ID a partir del usuario de la sesion
$model_user = model('App\Models\Usuarios\UserModel'); $model_user = model('App\Models\Usuarios\UserModel');
$user = $model_user->find(auth()->user()->id); $user = $model_user->find(auth()->user()->id);
$clienteId = $user->cliente_id; $clienteId = $user->cliente_id;
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
if ($clienteId === false || $clienteId === null) {
return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.');
}
}
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); $POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$this->viewData['breadcrumb'] = [ $this->viewData['breadcrumb'] = [
@ -137,13 +144,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Se obtiene el cliente ID a partir del usuario de la sesion // Se obtiene el cliente ID a partir del usuario de la sesion
$model_user = model('App\Models\Usuarios\UserModel'); $model_user = model('App\Models\Usuarios\UserModel');
$user = $model_user->find(auth()->user()->id); $user = $model_user->find(auth()->user()->id);
if(auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')){ if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
$clienteId = $user->cliente_id; $clienteId = $user->cliente_id;
} if ($clienteId === false || $clienteId === null) {
else{ return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.');
}
} else {
$clienteId = $presupuestoEntity->cliente_id; $clienteId = $presupuestoEntity->cliente_id;
} }
$this->viewData['formAction'] = 'edit'; $this->viewData['formAction'] = 'edit';
$this->viewData['paisList'] = $this->getPaisListItems(); $this->viewData['paisList'] = $this->getPaisListItems();
@ -155,8 +164,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if ($presupuestoEntity->is_duplicado) { if ($presupuestoEntity->is_duplicado) {
$this->model->removeIsDuplicado($presupuestoEntity->id); $this->model->removeIsDuplicado($presupuestoEntity->id);
} }
$this->viewData['presupuestoId'] = $presupuestoEntity->id; $this->viewData['presupuestoId'] = $presupuestoEntity->id;
$this->viewData['state'] = intval($presupuestoEntity->estado_id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.edit3'); $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id); return $this->displayForm(__METHOD__, $id);
@ -361,8 +371,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
); );
$return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG $return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG
if(array_key_exists('errors', $return_data)){ if (array_key_exists('errors', $return_data)) {
if($return_data['errors']->status == 1){ if ($return_data['errors']->status == 1) {
$return_data = [ $return_data = [
'errors' => (object) ([ 'errors' => (object) ([
'status' => 1 'status' => 1
@ -370,9 +380,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
]; ];
return $return_data; return $return_data;
} }
} }
if (array_key_exists('exception', $return_data)) { if (array_key_exists('exception', $return_data)) {
return $this->failServerError( return $this->failServerError(
$return_data['exception'] . ' - ' . $return_data['exception'] . ' - ' .
@ -412,7 +421,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
]), ]),
]; ];
return $return_data; return $return_data;
} else { } else {
$coste_envio += $coste_direccion->coste; $coste_envio += $coste_direccion->coste;
} }
@ -449,8 +457,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio / $tirada[$i], 4); $return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio / $tirada[$i], 4);
} }
} }
return $this->respond($return_data); return $this->respond($return_data);
@ -621,6 +627,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datosCabecera = $reqData['datosCabecera'] ?? []; $datosCabecera = $reqData['datosCabecera'] ?? [];
$confirmar = $reqData['confirmar'] ?? 0; $confirmar = $reqData['confirmar'] ?? 0;
$confirmar = intval($confirmar);
$cliente_id = $reqData['clienteId'] ?? -1; $cliente_id = $reqData['clienteId'] ?? -1;
@ -719,7 +726,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'isColor' => $isColor, 'isColor' => $isColor,
'isHq' => $isHq, 'isHq' => $isHq,
'paginasCuadernillo' => $paginasCuadernillo, 'paginasCuadernillo' => $paginasCuadernillo,
'interior' => $interior, 'interior' => $interior,
'cubierta' => $cubierta, 'cubierta' => $cubierta,
'sobrecubierta' => $sobrecubierta, 'sobrecubierta' => $sobrecubierta,
@ -728,6 +735,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'servicios' => $reqData['servicios'] ?? [], 'servicios' => $reqData['servicios'] ?? [],
); );
$datos_presupuesto['id'] = $id;
$resultado_presupuesto = $this->calcular_presupuesto($datos_presupuesto, $selected_tirada, true); $resultado_presupuesto = $this->calcular_presupuesto($datos_presupuesto, $selected_tirada, true);
if (isset($resultado_presupuesto['errors'])) { if (isset($resultado_presupuesto['errors'])) {
@ -785,8 +794,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] = $coste_envio - $margen_envio; $resultado_presupuesto['info']['totales'][$i]['coste_envio'] = $coste_envio - $margen_envio;
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] = $margen_envio; $resultado_presupuesto['info']['totales'][$i]['margen_envio'] = $margen_envio;
} }
} }
$model_presupuesto = new PresupuestoModel(); $model_presupuesto = new PresupuestoModel();
@ -832,9 +839,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
$acabado_id = $this->obtenerTarifasAcabado($datos_presupuesto['cubierta']['acabadosCubierta']); $acabado_id = $this->obtenerTarifasAcabado($datos_presupuesto['cubierta']['acabadosCubierta']);
if (count($acabado_id) > 0) { if (count($acabado_id) > 0) {
$datos_presupuesto['cubierta']['acabadosCubierta']['plastificado'] = $acabado_id[0]; if (array_key_exists('plastificado', $acabado_id)) {
$datos_presupuesto['cubierta']['acabadosCubierta']['barniz'] = $acabado_id[1]; $datos_presupuesto['cubierta']['acabadosCubierta']['plastificado'] = $acabado_id['plastificado'];
$datos_presupuesto['cubierta']['acabadosCubierta']['estampado'] = $acabado_id[2]; }
if (array_key_exists('barniz', $acabado_id)) {
$datos_presupuesto['cubierta']['acabadosCubierta']['barniz'] = $acabado_id['barniz'];
}
if (array_key_exists('estampado', $acabado_id)) {
$datos_presupuesto['cubierta']['acabadosCubierta']['estampado'] = $acabado_id['estampado'];
}
} else { } else {
$datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0; $datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0;
} }
@ -890,8 +903,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
} }
foreach ($reqData['direcciones'] as $direccion) { if (array_key_exists('direcciones', $reqData)) {
$this->guardarLineaEnvio($id, $direccion, $peso_libro);
foreach ($reqData['direcciones'] as $direccion) {
$this->guardarLineaEnvio($id, $direccion, $peso_libro);
}
} }
if ($confirmar) { if ($confirmar) {
@ -914,17 +930,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
{ {
if ($this->request->isAJAX()) { if ($this->request->isAJAX()) {
$modelPapelGenerico = new PapelGenericoModel();
$modelPapelFormato = new PapelFormatoModel(); $modelPapelFormato = new PapelFormatoModel();
$modelCliente = new ClienteModel(); $modelCliente = new ClienteModel();
$reqData = $this->request->getPost();
$presupuesto = $this->model->find($id); $presupuesto = $this->model->find($id);
$data = []; $data = [];
if ($presupuesto) { if ($presupuesto) {
$data['lc'] = $presupuesto->lomo_cubierta; $data['lc'] = $presupuesto->lomo_cubierta;
$data['lsc'] = $presupuesto->lomo_sobrecubierta; $data['lsc'] = $presupuesto->lomo_sobrecubierta;
$data['state'] = intval($presupuesto->estado_id);
$data['datosGenerales']['titulo'] = $presupuesto->titulo; $data['datosGenerales']['titulo'] = $presupuesto->titulo;
$data['datosGenerales']['autor'] = $presupuesto->autor; $data['datosGenerales']['autor'] = $presupuesto->autor;
$data['datosGenerales']['isbn'] = $presupuesto->isbn; $data['datosGenerales']['isbn'] = $presupuesto->isbn;
@ -963,8 +978,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$data['cubierta']['cabezada'] = $presupuesto->cabezada; $data['cubierta']['cabezada'] = $presupuesto->cabezada;
$modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel"); $modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel");
$data['cubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_cubierta_id); $data['cubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_cubierta_id);
if ($data['cubierta']['plastificado'] == '') {
$data['cubierta']['plastificado'] = 'NONE';
}
$data['cubierta']['barniz'] = $modelAcabado->getCodeFromId($presupuesto->barniz_cubierta_id); $data['cubierta']['barniz'] = $modelAcabado->getCodeFromId($presupuesto->barniz_cubierta_id);
if ($data['cubierta']['barniz'] == '') {
$data['cubierta']['barniz'] = 'NONE';
}
$data['cubierta']['estampado'] = $modelAcabado->getCodeFromId($presupuesto->estampado_cubierta_id); $data['cubierta']['estampado'] = $modelAcabado->getCodeFromId($presupuesto->estampado_cubierta_id);
if ($data['cubierta']['estampado'] == '') {
$data['cubierta']['estampado'] = 'NONE';
}
$data['cubierta']['retractilado'] = $presupuesto->retractilado ? 1 : 0; $data['cubierta']['retractilado'] = $presupuesto->retractilado ? 1 : 0;
$data['sobrecubierta'] = array_key_exists('sobrecubierta', $datos_papel) ? $datos_papel['sobrecubierta'] : []; $data['sobrecubierta'] = array_key_exists('sobrecubierta', $datos_papel) ? $datos_papel['sobrecubierta'] : [];
@ -982,20 +1006,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id); $data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
if(intval($presupuesto->estado_id) == 2){
$data['resumen']['base'] = $presupuesto->total_aceptado;
$data['resumen']['precio_unidad'] = $presupuesto->total_precio_unidad;
}
$tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data); $tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data);
for ($i = 0; $i < count($tiradas_alternativas); $i++) { for ($i = 0; $i < count($tiradas_alternativas); $i++) {
$tirada = $tiradas_alternativas[$i]; $tirada = $tiradas_alternativas[$i];
$data['datosGenerales']['tirada' . ($i + 2)] = $tirada->tirada; $data['datosGenerales']['tirada' . ($i + 2)] = $tirada->tirada;
} }
return $this->respond([ return $this->respond([
'status' => 1, 'status' => 1,
'data' => $data 'data' => $data
]); ]);
} }
} else { } else {
return $this->failUnauthorized('Invalid request', 403); return $this->failUnauthorized('Invalid request', 403);
} }
@ -1387,7 +1413,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if ($interior == -1) { if ($interior == -1) {
$errorModel = new ErrorPresupuesto(); $errorModel = new ErrorPresupuesto();
$errorModel->insertError( $errorModel->insertError(
$datos_entrada['id'], $datos_entrada['id'] == 0 ? null : $datos_entrada['id'],
auth()->user()->id, auth()->user()->id,
' '
No se puede obtener el interior', No se puede obtener el interior',
@ -1932,7 +1958,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
return $return_data; return $return_data;
} catch (Exception $e) { } catch (Exception $e) {
return [ return [
'exception' => $e->getMessage(), 'exception' => $e->getMessage(),
@ -2389,7 +2414,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if ($value != 'NONE') { if ($value != 'NONE') {
$data = $model->where('code', $value)->first(); $data = $model->where('code', $value)->first();
$data = $data->id; $data = $data->id;
array_push($tarifas, $data); array_push($tarifas, [$acabado => $data]);
} else { } else {
array_push($tarifas, 0); array_push($tarifas, 0);
} }
@ -2426,5 +2451,4 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
return [$paginasNegro, $paginasColor]; return [$paginasNegro, $paginasColor];
} }
} }

View File

@ -1,4 +1,5 @@
<?php namespace App\Controllers\Tarifas; <?php
namespace App\Controllers\Tarifas;
use App\Controllers\BaseResourceController; use App\Controllers\BaseResourceController;
@ -10,15 +11,15 @@ use App\Entities\Tarifas\TarifaEncuadernacionLinea;
use App\Models\Tarifas\TarifaEncuadernacionLineaModel; use App\Models\Tarifas\TarifaEncuadernacionLineaModel;
use use
DataTables\Editor, DataTables\Editor,
DataTables\Database, DataTables\Database,
DataTables\Editor\Field, DataTables\Editor\Field,
DataTables\Editor\Format, DataTables\Editor\Format,
DataTables\Editor\Mjoin, DataTables\Editor\Mjoin,
DataTables\Editor\Options, DataTables\Editor\Options,
DataTables\Editor\Upload, DataTables\Editor\Upload,
DataTables\Editor\Validate, DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions; DataTables\Editor\ValidateOptions;
class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
@ -73,9 +74,9 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
{ {
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1'); $nullIfEmpty = true; // !(phpversion() >= '8.1');
@ -84,10 +85,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
$sanitizedData = $this->sanitized($postData, $nullIfEmpty); $sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()):
try { try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData); $successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -101,14 +102,14 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
endif; endif;
if ($noException && $successfulResult) : if ($noException && $successfulResult):
$id = $this->model->db->insertID(); $id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) : if ($thenRedirect):
if (!empty($this->indexRoute)) : if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else: else:
return $this->redirect2listView('sweet-success', $message); return $this->redirect2listView('sweet-success', $message);
@ -134,20 +135,20 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
public function edit($requestedId = null) public function edit($requestedId = null)
{ {
if ($requestedId == null) : if ($requestedId == null):
return $this->redirect2listView(); return $this->redirect2listView();
endif; endif;
$id = filter_var($requestedId, FILTER_SANITIZE_URL); $id = filter_var($requestedId, FILTER_SANITIZE_URL);
$tarifaEncuadernacionLinea = $this->model->find($id); $tarifaEncuadernacionLinea = $this->model->find($id);
if ($tarifaEncuadernacionLinea == false) : if ($tarifaEncuadernacionLinea == false):
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]); $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
return $this->redirect2listView('sweet-error', $message); return $this->redirect2listView('sweet-error', $message);
endif; endif;
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1'); $nullIfEmpty = true; // !(phpversion() >= '8.1');
@ -156,10 +157,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
$sanitizedData = $this->sanitized($postData, $nullIfEmpty); $sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()):
try { try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -176,12 +177,12 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
$thenRedirect = false; $thenRedirect = false;
endif; endif;
if ($noException && $successfulResult) : if ($noException && $successfulResult):
$id = $tarifaEncuadernacionLinea->id ?? $id; $id = $tarifaEncuadernacionLinea->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) : if ($thenRedirect):
if (!empty($this->indexRoute)) : if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else: else:
return $this->redirect2listView('sweet-success', $message); return $this->redirect2listView('sweet-success', $message);
@ -214,45 +215,90 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas') $response = Editor::inst($db, 'tarifa_encuadernacion_lineas')
->fields( ->fields(
Field::inst('paginas_libro_min') Field::inst('paginas_libro_min')
->validator('Validate::numeric', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')) 'Validate::numeric',
array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')) 'Validate::notEmpty',
array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')
)
), ),
Field::inst('paginas_libro_max') Field::inst('paginas_libro_max')
->validator('Validate::numeric', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')) 'Validate::numeric',
array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')) 'Validate::notEmpty',
array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')
)
), ),
Field::inst('precio_min') Field::inst('precio_min')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) 'Validate::notEmpty',
array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')
)
), ),
Field::inst('precio_max') Field::inst('precio_max')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')) 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')) 'Validate::notEmpty',
array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')
)
),
Field::inst('total_min')
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator(
'Validate::numeric',
array(
"decimal" => ',',
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')
)
)
->validator(
'Validate::notEmpty',
array(
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')
)
), ),
Field::inst('margen') Field::inst('margen')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.margen.required')) 'Validate::notEmpty',
array(
'message' => lang('TarifaAcabadoLineas.validation.margen.required')
)
), ),
Field::inst('tirada_encuadernacion_id'), Field::inst('tirada_encuadernacion_id'),
Field::inst('user_created_id'), Field::inst('user_created_id'),
@ -322,10 +368,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
if ($this->request->isAJAX()) { if ($this->request->isAJAX()) {
$reqData = $this->request->getPost(); $reqData = $this->request->getPost();
$cleandatatable = $reqData['cleandatatable'] ?? 0; $cleandatatable = $reqData['cleandatatable'] ?? 0;
if($cleandatatable){ if ($cleandatatable) {
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1; $tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
@ -338,11 +384,9 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
$csrfTokenName => $newTokenHash $csrfTokenName => $newTokenHash
]; ];
return $this->respond($data); return $this->respond($data);
}
else{ } else {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) { if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.'; $errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); $response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);

View File

@ -1,4 +1,5 @@
<?php namespace App\Controllers\Tarifas; <?php
namespace App\Controllers\Tarifas;
use App\Controllers\BaseResourceController; use App\Controllers\BaseResourceController;
@ -10,15 +11,15 @@ use App\Entities\Tarifas\TarifaEncuadernacionLinea;
use App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel; use App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel;
use use
DataTables\Editor, DataTables\Editor,
DataTables\Database, DataTables\Database,
DataTables\Editor\Field, DataTables\Editor\Field,
DataTables\Editor\Format, DataTables\Editor\Format,
DataTables\Editor\Mjoin, DataTables\Editor\Mjoin,
DataTables\Editor\Options, DataTables\Editor\Options,
DataTables\Editor\Upload, DataTables\Editor\Upload,
DataTables\Editor\Validate, DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions; DataTables\Editor\ValidateOptions;
class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceController class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceController
@ -71,9 +72,9 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
public function add() public function add()
{ {
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1'); $nullIfEmpty = true; // !(phpversion() >= '8.1');
@ -82,10 +83,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
$sanitizedData = $this->sanitized($postData, $nullIfEmpty); $sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()):
try { try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData); $successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -99,14 +100,14 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
endif; endif;
if ($noException && $successfulResult) : if ($noException && $successfulResult):
$id = $this->model->db->insertID(); $id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) : if ($thenRedirect):
if (!empty($this->indexRoute)) : if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else: else:
return $this->redirect2listView('sweet-success', $message); return $this->redirect2listView('sweet-success', $message);
@ -134,20 +135,20 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
public function edit($requestedId = null) public function edit($requestedId = null)
{ {
if ($requestedId == null) : if ($requestedId == null):
return $this->redirect2listView(); return $this->redirect2listView();
endif; endif;
$id = filter_var($requestedId, FILTER_SANITIZE_URL); $id = filter_var($requestedId, FILTER_SANITIZE_URL);
$tarifaEncuadernacionLinea = $this->model->find($id); $tarifaEncuadernacionLinea = $this->model->find($id);
if ($tarifaEncuadernacionLinea == false) : if ($tarifaEncuadernacionLinea == false):
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]); $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
return $this->redirect2listView('sweet-error', $message); return $this->redirect2listView('sweet-error', $message);
endif; endif;
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1'); $nullIfEmpty = true; // !(phpversion() >= '8.1');
@ -156,10 +157,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
$sanitizedData = $this->sanitized($postData, $nullIfEmpty); $sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()):
try { try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -176,12 +177,12 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
$thenRedirect = false; $thenRedirect = false;
endif; endif;
if ($noException && $successfulResult) : if ($noException && $successfulResult):
$id = $tarifaEncuadernacionLinea->id ?? $id; $id = $tarifaEncuadernacionLinea->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) : if ($thenRedirect):
if (!empty($this->indexRoute)) : if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else: else:
return $this->redirect2listView('sweet-success', $message); return $this->redirect2listView('sweet-success', $message);
@ -214,40 +215,79 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas_horas') $response = Editor::inst($db, 'tarifa_encuadernacion_lineas_horas')
->fields( ->fields(
Field::inst('tiempo_min') Field::inst('tiempo_min')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')) 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')) 'Validate::notEmpty',
array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')
)
), ),
Field::inst('tiempo_max') Field::inst('tiempo_max')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')) 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')) 'Validate::notEmpty',
array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')
)
), ),
Field::inst('precio_hora') Field::inst('precio_hora')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) 'Validate::notEmpty',
array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')
)
),
Field::inst('total_min')
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator(
'Validate::numeric',
array(
"decimal" => ',',
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')
)
)
->validator(
'Validate::notEmpty',
array(
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')
)
), ),
Field::inst('margen') Field::inst('margen')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator('Validate::numeric', array( ->validator(
'Validate::numeric',
array(
"decimal" => ',', "decimal" => ',',
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')
)
) )
->validator('Validate::notEmpty', array( ->validator(
'message' => lang('TarifaAcabadoLineas.validation.margen.required')) 'Validate::notEmpty',
array(
'message' => lang('TarifaAcabadoLineas.validation.margen.required')
)
), ),
Field::inst('tirada_encuadernacion_id'), Field::inst('tirada_encuadernacion_id'),
Field::inst('user_created_id'), Field::inst('user_created_id'),
@ -314,10 +354,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
{ {
if ($this->request->isAJAX()) { if ($this->request->isAJAX()) {
$reqData = $this->request->getPost(); $reqData = $this->request->getPost();
$cleandatatable = $reqData['cleandatatable'] ?? 0; $cleandatatable = $reqData['cleandatatable'] ?? 0;
if($cleandatatable){ if ($cleandatatable) {
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1; $tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
@ -330,9 +370,8 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
$csrfTokenName => $newTokenHash $csrfTokenName => $newTokenHash
]; ];
return $this->respond($data); return $this->respond($data);
} } else {
else{
if (!isset($reqData['draw']) || !isset($reqData['columns'])) { if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.'; $errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); $response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);

View File

@ -126,15 +126,6 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\BaseResourceControlle
->validator('Validate::notEmpty', array( ->validator('Validate::notEmpty', array(
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')) 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required'))
), ),
Field::inst('precio_min')
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
->validator('Validate::numeric', array(
"decimal" => ',',
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal'))
)
->validator('Validate::notEmpty', array(
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required'))
),
Field::inst('proveedor_id') Field::inst('proveedor_id')
->validator('Validate::notEmpty', array( ->validator('Validate::notEmpty', array(
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required')) 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required'))

View File

@ -1,4 +1,6 @@
<?php namespace App\Controllers\Tarifas; <?php
namespace App\Controllers\Tarifas;
use App\Controllers\BaseResourceController; use App\Controllers\BaseResourceController;
@ -100,7 +102,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
if ($this->request->getPost('servicio_encuadernacion') == null) { if ($this->request->getPost('servicio_encuadernacion') == null) {
$sanitizedData['servicio_encuadernacion'] = false; $sanitizedData['servicio_encuadernacion'] = false;
} }
if ($this->request->getPost('por_horas') == null) { if ($this->request->getPost('por_horas') == null) {
$sanitizedData['por_horas'] = false; $sanitizedData['por_horas'] = false;
} }
@ -146,7 +148,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
$this->viewData['tarifaEncuadernacionEntity'] = isset($sanitizedData) ? new TarifaEncuadernacionEntity($sanitizedData) : new TarifaEncuadernacionEntity(); $this->viewData['tarifaEncuadernacionEntity'] = isset($sanitizedData) ? new TarifaEncuadernacionEntity($sanitizedData) : new TarifaEncuadernacionEntity();
$this->viewData['formAction'] = site_url('tarifas/tarifasencuadernacion/add');//route_to('createTarifaEncuadernacion'); $this->viewData['formAction'] = site_url('tarifas/tarifasencuadernacion/add'); //route_to('createTarifaEncuadernacion');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
@ -171,7 +173,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
return $this->redirect2listView('sweet-error', $message); return $this->redirect2listView('sweet-error', $message);
endif; endif;
if ($this->request->getPost()) : if ($this->request->getPost()) :
@ -188,7 +190,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
if ($this->request->getPost('mostrar_en_presupuesto') == null) { if ($this->request->getPost('mostrar_en_presupuesto') == null) {
$sanitizedData['mostrar_en_presupuesto'] = false; $sanitizedData['mostrar_en_presupuesto'] = false;
} }
if ($this->request->getPost('tipo_encuadernacion') == null) { if ($this->request->getPost('tipo_encuadernacion') == null) {
$sanitizedData['tipo_encuadernacion'] = false; $sanitizedData['tipo_encuadernacion'] = false;
} }
@ -335,7 +337,8 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
} }
} }
private function getProveedores(){ private function getProveedores()
{
$provTipoModel = new ProveedorTipoModel(); $provTipoModel = new ProveedorTipoModel();
$provModel = new ProveedorModel(); $provModel = new ProveedorModel();
@ -343,12 +346,13 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
return $provModel->getProvList($tipoId); return $provModel->getProvList($tipoId);
} }
private function getDimensiones(){ private function getDimensiones()
{
$dimensionModel = new TarifaEncuadernacionDimensionesModel(); $dimensionModel = new TarifaEncuadernacionDimensionesModel();
$dimensiones = $dimensionModel->getDimensiones(); $dimensiones = $dimensionModel->getDimensiones();
foreach($dimensiones as $dim){ foreach ($dimensiones as $dim) {
$dim->label= lang("TarifaEncuadernacionLineas." . $dim->label); $dim->label = lang("TarifaEncuadernacionLineas." . $dim->label);
} }
return $dimensiones; return $dimensiones;
} }

View File

@ -15,6 +15,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity
"precio_max" => 0, "precio_max" => 0,
"tirada_min" => 0, "tirada_min" => 0,
"tirada_max" => 0, "tirada_max" => 0,
"total_min" => 0,
"margen" => 0, "margen" => 0,
"user_created_id" => 0, "user_created_id" => 0,
"user_updated_id" => 0, "user_updated_id" => 0,
@ -31,6 +32,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity
"precio_max" => "float", "precio_max" => "float",
"tirada_min" => "float", "tirada_min" => "float",
"tirada_max" => "float", "tirada_max" => "float",
"total_min" => "float",
"margen" => "float", "margen" => "float",
"user_created_id" => "int", "user_created_id" => "int",
"user_updated_id" => "int", "user_updated_id" => "int",

View File

@ -11,6 +11,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity
"tiempo_min" => 0, "tiempo_min" => 0,
"tiempo_max" => 0, "tiempo_max" => 0,
"precio_hora" => 0, "precio_hora" => 0,
"total_min" => 0,
"margen" => 0, "margen" => 0,
"user_created_id" => 0, "user_created_id" => 0,
"user_updated_id" => 0, "user_updated_id" => 0,
@ -22,6 +23,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity
"tirada_encuadernacion_id" => "int", "tirada_encuadernacion_id" => "int",
"tiempo_min" => "float", "tiempo_min" => "float",
"tiempo_max" => "float", "tiempo_max" => "float",
"total_min" => "float",
"precio_hora" => "float", "precio_hora" => "float",
"margen" => "float", "margen" => "float",
"user_created_id" => "int", "user_created_id" => "int",

View File

@ -11,7 +11,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity
"tirada_min" => 0, "tirada_min" => 0,
"tirada_max" => 0, "tirada_max" => 0,
"proveedor_id" => 0, "proveedor_id" => 0,
"precio_min" => 0,
"importe_fijo" => 0, "importe_fijo" => 0,
"user_created_id" => 0, "user_created_id" => 0,
"user_updated_id" => 0, "user_updated_id" => 0,
@ -24,7 +23,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity
"tirada_min" => "float", "tirada_min" => "float",
"tirada_max" => "float", "tirada_max" => "float",
"proveedor_id" => "int", "proveedor_id" => "int",
"precio_min" => "float",
"importe_fijo" => "float", "importe_fijo" => "float",
"user_created_id" => "int", "user_created_id" => "int",
"user_updated_id" => "int", "user_updated_id" => "int",

View File

@ -20,6 +20,10 @@ return [
'menor_a5' =>'Hasta A5', 'menor_a5' =>'Hasta A5',
'entre_a5_a4' =>'Entre A5 y A4', 'entre_a5_a4' =>'Entre A5 y A4',
'mayor_a4' =>'Desde A4', 'mayor_a4' =>'Desde A4',
'menor_a5_apaisado' =>'Hasta A5 apaisado',
'entre_a5_a4_apaisado' =>'Entre A5 y A4 apaisado',
'mayor_a4_apaisado' =>'Desde A4 apaisado',
'210x210' =>'210x210',
'por_defecto' =>'Genérico', 'por_defecto' =>'Genérico',
'moduleExplanation' => 'El número de páginas reflejado en este apartado se refiere por ejemplar, no al total del pedido', 'moduleExplanation' => 'El número de páginas reflejado en este apartado se refiere por ejemplar, no al total del pedido',
'margen' => 'Margen', 'margen' => 'Margen',

View File

@ -199,7 +199,7 @@ class ChatModel extends Model
} }
public function getClienteChatPedidos(array $pedidos) : array public function getClienteChatPedidos(array $pedidos) : array
{ {
$results = $this->db->table("chats") $q = $this->db->table("chats")
->select([ ->select([
"chats.id as chatId", "chats.id as chatId",
"chats.pedido_id as pedidoId", "chats.pedido_id as pedidoId",
@ -209,9 +209,13 @@ class ChatModel extends Model
]) ])
->join("chat_departments","chat_departments.id = chats.chat_department_id","left") ->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
->join("pedidos","pedidos.id = chats.pedido_id","left") ->join("pedidos","pedidos.id = chats.pedido_id","left")
->whereIn("pedidos.id",$pedidos) ->where('chats.chat_department_id is NOT NULL', NULL, FALSE);
->where("chats.chat_department_id is NOT NULL",NULL,FALSE) if(count($pedidos)>0){
->get()->getResultObject(); $q->whereIn("pedidos.id",$pedidos);
}else{
return [];
}
$results = $q->get()->getResultObject();
$chatMessageModel = model(ChatMessageModel::class); $chatMessageModel = model(ChatMessageModel::class);
$count = 0; $count = 0;
foreach ($results as $row) { foreach ($results as $row) {
@ -221,13 +225,14 @@ class ChatModel extends Model
$count++; $count++;
} }
} }
$row->uri = "/pedidos/edit/".$row->pedidoId;
$row->unreadMessages=$count; $row->unreadMessages=$count;
} }
return $results; return $results;
} }
public function getClienteChatFacturas(array $facturas) : array public function getClienteChatFacturas(array $facturas) : array
{ {
$results = $this->db->table("chats") $q = $this->db->table("chats")
->select([ ->select([
"chats.id as chatId", "chats.id as chatId",
"chats.factura_id as facturaId", "chats.factura_id as facturaId",
@ -237,9 +242,14 @@ class ChatModel extends Model
]) ])
->join("chat_departments","chat_departments.id = chats.chat_department_id","left") ->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
->join("facturas","facturas.id = chats.factura_id","left") ->join("facturas","facturas.id = chats.factura_id","left")
->whereIn("facturas.id",$facturas) ->where('chats.chat_department_id is NOT NULL', NULL, FALSE);
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
->get()->getResultObject(); if(count($facturas)>0){
$q->whereIn("facturas.id",$facturas);
}else{
return [];
}
$results = $q->get()->getResultObject();
$chatMessageModel = model(ChatMessageModel::class); $chatMessageModel = model(ChatMessageModel::class);
$count = 0; $count = 0;
foreach ($results as $row) { foreach ($results as $row) {
@ -249,13 +259,14 @@ class ChatModel extends Model
$count++; $count++;
} }
} }
$row->uri = "/facturas/edit/".$row->facturaId;
$row->unreadMessages=$count; $row->unreadMessages=$count;
} }
return $results; return $results;
} }
public function getClienteChatPresupuestos(array $presupuestos) : array public function getClienteChatPresupuestos(array $presupuestos) : array
{ {
$results = $this->db->table("chats") $q = $this->db->table("chats")
->select([ ->select([
"chats.id as chatId", "chats.id as chatId",
"chats.presupuesto_id as presupuestoId", "chats.presupuesto_id as presupuestoId",
@ -265,9 +276,14 @@ class ChatModel extends Model
]) ])
->join("chat_departments","chat_departments.id = chats.chat_department_id","left") ->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
->join("presupuestos","presupuestos.id = chats.presupuesto_id","left") ->join("presupuestos","presupuestos.id = chats.presupuesto_id","left")
->whereIn("presupuestos.id",$presupuestos) ->where('chats.chat_department_id is NOT NULL', NULL, FALSE);
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
->get()->getResultObject(); if(count($presupuestos)>0){
$q->whereIn("presupuestos.id",$presupuestos);
}else{
return [];
}
$results = $q->get()->getResultObject();
$chatMessageModel = model(ChatMessageModel::class); $chatMessageModel = model(ChatMessageModel::class);
$count = 0; $count = 0;
foreach ($results as $row) { foreach ($results as $row) {
@ -277,6 +293,7 @@ class ChatModel extends Model
$count++; $count++;
} }
} }
$row->uri = "/presupuestos/presupuestocliente/edit/".$row->presupuestoId;
$row->unreadMessages=$count; $row->unreadMessages=$count;
} }

View File

@ -33,8 +33,8 @@ class ErrorPresupuesto extends Model
protected array $castHandlers = []; protected array $castHandlers = [];
// Dates // Dates
protected $useTimestamps = false; protected $useTimestamps = true;
protected $dateFormat = 'datetime'; //protected $dateFormat = 'datetime';
protected $createdField = 'created_at'; protected $createdField = 'created_at';
protected $updatedField = 'updated_at'; protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at'; protected $deletedField = 'deleted_at';

View File

@ -267,7 +267,15 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
$precio_total = floatval(1.0* $tarifa_proveedor->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0); $precio_total = floatval(1.0* $tarifa_proveedor->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0);
if (!$POD){ if (!$POD){
$precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo); $precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo);
} }
$tarifa_precio_min = floatval($tarifa_proveedor->tarifa_precio_min);
if($tarifa_precio_min > $precio_total){
$total = $total-($total * $margen/100.0);
$margen = round(100.0 * (floatval($$tarifa_precio_min) - $total) / floatval($$tarifa_precio_min), 0);
$total = floatval($$tarifa_precio_min);
}
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad $result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
$result_data[1] = $precio_total; $result_data[1] = $precio_total;
@ -323,11 +331,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
$total = $precio_unidad * $ejemplares; $total = $precio_unidad * $ejemplares;
$margen = floatval($tarifa->margen); $margen = floatval($tarifa->margen);
$tarifa_precio_min = floatval($tarifa->tarifa_precio_min);
if($tarifa->tarifa_precio_min > $total){ if($tarifa_precio_min > $total){
$total = $total-($total * $margen/100.0); $total = $total-($total * $margen/100.0);
$margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $total) / floatval($tarifa->tarifa_precio_min), 0); $margen = round(100.0 * (floatval($tarifa_precio_min) - $total) / floatval($tarifa_precio_min), 0);
$total = floatval($tarifa->tarifa_precio_min); $total = floatval($tarifa_precio_min);
$precio_unidad = round(floatval($total / $ejemplares), 2); $precio_unidad = round(floatval($total / $ejemplares), 2);
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Models\Tarifas; namespace App\Models\Tarifas;
class TarifaEncuadernacionDimensionesModel extends \App\Models\BaseModel class TarifaEncuadernacionDimensionesModel extends \App\Models\BaseModel
@ -12,20 +13,14 @@ class TarifaEncuadernacionDimensionesModel extends \App\Models\BaseModel
*/ */
protected $useAutoIncrement = true; protected $useAutoIncrement = true;
protected $allowedFields = [ protected $allowedFields = [];
];
protected $returnType = "App\Entities\Tarifas\TarifaEncuadernacionDimensionesEntity"; protected $returnType = "App\Entities\Tarifas\TarifaEncuadernacionDimensionesEntity";
public static $labelField = "descripcion"; public static $labelField = "descripcion";
protected $validationRules = [ protected $validationRules = [];
];
protected $validationMessages = [ protected $validationMessages = [];
];
/** /**
* Get resource data. * Get resource data.
@ -34,13 +29,32 @@ class TarifaEncuadernacionDimensionesModel extends \App\Models\BaseModel
* *
* @return \CodeIgniter\Database\BaseBuilder * @return \CodeIgniter\Database\BaseBuilder
*/ */
public function getDimensiones(){ public function getDimensiones()
{
$builder = $this->db $builder = $this->db
->table($this->table . " t1") ->table($this->table . " t1")
->select("t1.id AS value, t1.keyword AS label") ->select("t1.id AS value, t1.keyword AS label")
->orderBy('t1.id', 'asc'); ->orderBy('t1.id', 'asc');
return $builder->get()->getResultObject(); $result = $builder->get()->getResultObject();
// Convertir el resultado en un array
$resultArray = json_decode(json_encode($result), true);
// Buscar y mover el objeto con value == 3 al principio
foreach ($resultArray as $key => $item) {
if ($item['value'] == 4) {
$generico = $item;
unset($resultArray[$key]);
array_unshift($resultArray, $generico);
break;
}
}
// Convertir de nuevo a objetos
$result = json_decode(json_encode($resultArray));
return $result;
} }
} }

View File

@ -17,7 +17,8 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
1 => "t1.tiempo_min", 1 => "t1.tiempo_min",
2 => "t1.tiempo_max", 2 => "t1.tiempo_max",
3 => "t1.precio_hora", 3 => "t1.precio_hora",
4 => "t1.margen", 4 => "t1.total_min",
5 => "t1.margen",
]; ];
protected $allowedFields = [ protected $allowedFields = [
@ -25,6 +26,7 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
"tiempo_min", "tiempo_min",
"tiempo_max", "tiempo_max",
"precio_hora", "precio_hora",
"total_min",
"margen", "margen",
"user_created_id", "user_created_id",
"is_deleted", "is_deleted",
@ -54,6 +56,10 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
"label" => "TarifaEncuadernacionLineas.precioHora", "label" => "TarifaEncuadernacionLineas.precioHora",
"rules" => "required|decimal", "rules" => "required|decimal",
], ],
"total_min" => [
"label" => "TarifaEncuadernacionLineas.precioHora",
"rules" => "required|decimal",
],
"margen" => [ "margen" => [
"label" => "TarifaEncuadernacionLineas.margen", "label" => "TarifaEncuadernacionLineas.margen",
"rules" => "required|decimal", "rules" => "required|decimal",
@ -73,6 +79,10 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
"decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal", "decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal",
"required" => "TarifaEncuadernacionLineas.validation.tirada_max.required", "required" => "TarifaEncuadernacionLineas.validation.tirada_max.required",
], ],
"total_min" => [
"decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal",
"required" => "TarifaEncuadernacionLineas.validation.tirada_max.required",
],
"margen" => [ "margen" => [
"decimal" => "TarifaEncuadernacionLineas.validation.margen.decimal", "decimal" => "TarifaEncuadernacionLineas.validation.margen.decimal",
"required" => "TarifaEncuadernacionLineas.validation.margen.required", "required" => "TarifaEncuadernacionLineas.validation.margen.required",
@ -92,7 +102,7 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
->table($this->table . " t1") ->table($this->table . " t1")
->select( ->select(
"t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.tiempo_min AS tiempo_min, "t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.tiempo_min AS tiempo_min,
t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.margen AS margen, t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.total_min AS total_min, t1.margen AS margen,
t2.id AS tarifa_encuadernacion" t2.id AS tarifa_encuadernacion"
); );
//JJO //JJO

View File

@ -19,6 +19,8 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
3 => "t1.paginas_libro_max", 3 => "t1.paginas_libro_max",
4 => "t1.precio_min", 4 => "t1.precio_min",
5 => "t1.precio_max", 5 => "t1.precio_max",
6 => "t1.total_min",
7 => "t1.margen",
]; ];
protected $allowedFields = [ protected $allowedFields = [
@ -30,6 +32,8 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
"precio_max", "precio_max",
"tirada_min", "tirada_min",
"tirada_max", "tirada_max",
"margen",
"total_min",
"user_created_id", "user_created_id",
"is_deleted", "is_deleted",
@ -62,6 +66,10 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
"label" => "TarifaEncuadernacionLineas.tiradaMin", "label" => "TarifaEncuadernacionLineas.tiradaMin",
"rules" => "required|decimal", "rules" => "required|decimal",
], ],
"total_min" => [
"label" => "TarifaEncuadernacionLineas.precioMin",
"rules" => "required|decimal",
],
"paginas_libro_max" => [ "paginas_libro_max" => [
"label" => "TarifaEncuadernacionLineas.paginasMax", "label" => "TarifaEncuadernacionLineas.paginasMax",
"rules" => "required|decimal", "rules" => "required|decimal",
@ -93,6 +101,10 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
"decimal" => "TarifaEncuadernacionLineas.validation.tirada_min.decimal", "decimal" => "TarifaEncuadernacionLineas.validation.tirada_min.decimal",
"required" => "TarifaEncuadernacionLineas.validation.tirada_min.required", "required" => "TarifaEncuadernacionLineas.validation.tirada_min.required",
], ],
"total_min" => [
"decimal" => "TarifaEncuadernacionLineas.validation.precio_min.decimal",
"required" => "TarifaEncuadernacionLineas.validation.precio_min.required",
],
"paginas_libro_max" => [ "paginas_libro_max" => [
"decimal" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.decimal", "decimal" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.decimal",
"required" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.required", "required" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.required",
@ -120,7 +132,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
->table($this->table . " t1") ->table($this->table . " t1")
->select( ->select(
"t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.paginas_libro_min AS paginas_libro_min, t1.paginas_libro_max AS paginas_libro_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.tirada_min AS tirada_min, "t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.paginas_libro_min AS paginas_libro_min, t1.paginas_libro_max AS paginas_libro_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.tirada_min AS tirada_min,
t1.tirada_max AS tirada_max, t1.margen AS margen, t2.id AS tarifa_encuadernacion, t3.id AS dimensiones_id, t3.ancho_min, t3.ancho_max, , t3.alto_min, t3.alto_max, t3.descripcion as descripcion" t1.tirada_max AS tirada_max, t1.total_min as total_min, t1.margen AS margen, t2.id AS tarifa_encuadernacion, t3.id AS dimensiones_id, t3.ancho_min, t3.ancho_max, , t3.alto_min, t3.alto_max, t3.descripcion as descripcion"
); );
//JJO //JJO
$builder->where('tirada_encuadernacion_id', $tirada_encuadernacion_id); $builder->where('tirada_encuadernacion_id', $tirada_encuadernacion_id);
@ -190,6 +202,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
return $builder; return $builder;
} }
public function removeAllEncuadernacionLineasForTarifa($tarifaId = -1, $datetime = null, $delete_flag=1){ public function removeAllEncuadernacionLineasForTarifa($tarifaId = -1, $datetime = null, $delete_flag=1){

View File

@ -125,7 +125,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel
$builder = $this->db $builder = $this->db
->table($this->table . " t1") ->table($this->table . " t1")
->select( ->select(
"t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t2.precio_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t3.total_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo,
t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max, t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max,
t3.id AS tarifa_linea_id, t3.paginas_libro_min AS paginas_min, t3.paginas_libro_max AS paginas_max, t3.precio_min AS precio_min, t3.precio_max AS precio_max, t3.margen AS margen, t3.id AS tarifa_linea_id, t3.paginas_libro_min AS paginas_min, t3.paginas_libro_max AS paginas_max, t3.precio_min AS precio_min, t3.precio_max AS precio_max, t3.margen AS margen,
t4.ancho_min AS ancho_min, t4.ancho_max AS ancho_max, t4.alto_min AS alto_min, t4.alto_max AS alto_max" t4.ancho_min AS ancho_min, t4.ancho_max AS ancho_max, t4.alto_min AS alto_min, t4.alto_max AS alto_max"
@ -161,7 +161,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel
$builder = $this->db $builder = $this->db
->table($this->table . " t1") ->table($this->table . " t1")
->select( ->select(
"t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t2.precio_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t3.total_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo,
t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max, t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max,
t3.id AS tarifa_linea_id, t3.tiempo_min AS tiempo_min, t3.tiempo_max AS tiempo_max, t3.precio_hora AS precio_hora, t3.margen AS margen" t3.id AS tarifa_linea_id, t3.tiempo_min AS tiempo_min, t3.tiempo_max AS tiempo_max, t3.precio_hora AS precio_hora, t3.margen AS margen"
) )

View File

@ -16,7 +16,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
0 => "t3.nombre", 0 => "t3.nombre",
1 => "t1.tirada_min", 1 => "t1.tirada_min",
2 => "t1.tirada_max", 2 => "t1.tirada_max",
3 => "t1.precio_min",
4 => "t1.importe_fijo", 4 => "t1.importe_fijo",
]; ];
@ -25,7 +24,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
"tirada_min", "tirada_min",
"tirada_max", "tirada_max",
"proveedor_id", "proveedor_id",
"precio_min",
"importe_fijo", "importe_fijo",
"user_created_id", "user_created_id",
"user_updated_id", "user_updated_id",
@ -53,10 +51,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
"label" => "TarifaEncuadernacionTiradas.tiradaMin", "label" => "TarifaEncuadernacionTiradas.tiradaMin",
"rules" => "required|integer", "rules" => "required|integer",
], ],
"precio_min" => [
"label" => "Tarifaencuadernacion.precioMin",
"rules" => "required|decimal",
],
"importe_fijo" => [ "importe_fijo" => [
"label" => "Tarifaencuadernacion.importeFijo", "label" => "Tarifaencuadernacion.importeFijo",
"rules" => "required|decimal", "rules" => "required|decimal",
@ -72,10 +66,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
"integer" => "TarifaEncuadernacionTiradas.validation.tirada_min.integer", "integer" => "TarifaEncuadernacionTiradas.validation.tirada_min.integer",
"required" => "TarifaEncuadernacionTiradas.validation.tirada_min.required", "required" => "TarifaEncuadernacionTiradas.validation.tirada_min.required",
], ],
"precio_min" => [
"required" => "Tarifaencuadernacion.validation.precio_min.required",
"decimal" => "Tarifaencuadernacion.validation.precio_min.decimal",
],
"importe_fijo" => [ "importe_fijo" => [
"required" => "Tarifaencuadernacion.validation.importe_fijo.required", "required" => "Tarifaencuadernacion.validation.importe_fijo.required",
"decimal" => "Tarifaencuadernacion.validation.importe_fijo.decimal", "decimal" => "Tarifaencuadernacion.validation.importe_fijo.decimal",
@ -95,7 +85,7 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
->table($this->table . " t1") ->table($this->table . " t1")
->select( ->select(
"t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id, "t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id,
t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo, t1.importe_fijo AS importe_fijo,
t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max,
t3.nombre AS proveedor, t3.id AS proveedor_id, t2.id AS tarifa_encuadernacion" t3.nombre AS proveedor, t3.id AS proveedor_id, t2.id AS tarifa_encuadernacion"
); );

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,36 @@
<div class="col-12" style="min-height: 50px;"> <div class="col-12" style="min-height: 50px;">
<div id="btnsDiv" class="d-flex w-100 position-relative" style="margin-top: 40px;"> <div id="btnsDiv" class="d-flex w-100 position-relative" style="margin-top: 40px;">
<div class="me-auto"> <div class="me-auto">
<div id="btnPrint" class="btn mt-3 btn-secondary waves-effect waves-light ml-2 d-none"> <div id="btnPrint" class="btn mt-3 btn-secondary waves-effect waves-light ml-2 d-none">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_print2') ?></span> <span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_print2') ?></span>
</div>
</div> </div>
<div class="position-absolute start-50 translate-middle-x">
<?php if ($state != 2): ?>
<div id="btnPrev" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_prev') ?></span>
</div>
<div id="btnNext" class="btn mt-3 btn-primary waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_next') ?></span>
</div>
<?php endif; ?>
</div>
<div class="ms-auto">
<?php if ($state != 2): ?>
<div id="btnConfirm" class="btn mt-3 btn-success waves-effect waves-light ml-2 d-none">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_confirm') ?></span>
</div>
<div id="btnSave" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_save') ?></span>
</div>
<?php endif; ?>
</div>
</div> </div>
<div class="position-absolute start-50 translate-middle-x">
<div id="btnPrev" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_prev') ?></span>
</div>
<div id="btnNext" class="btn mt-3 btn-primary waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_next') ?></span>
</div>
</div>
<div class="ms-auto">
<div id="btnConfirm" class="btn mt-3 btn-success waves-effect waves-light ml-2 d-none">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_confirm') ?></span>
</div>
<div id="btnSave" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_save') ?></span>
</div>
</div>
</div>
</div> </div>

View File

@ -16,14 +16,15 @@
<label for="autor" class="form-label"> <label for="autor" class="form-label">
<?= lang('Presupuestos.autor') ?> <?= lang('Presupuestos.autor') ?>
</label> </label>
<input type="text" id="autor" placeholder="Autor" name="autor" maxLength="150" class="form-control text-center" value=""> <input type="text" id="autor" placeholder="Autor" name="autor" maxLength="150" class="form-control text-center"
value="">
</div> </div>
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-sm-4 mb-3"> <div class="col-sm-4 mb-3">
<label for="isbn" class="form-label"> <label for="isbn" class="form-label">
<?=lang('Presupuestos.isbn') ?> <?= lang('Presupuestos.isbn') ?>
</label> </label>
<input type="text" id="isbn" name="isbn" placeholder="ISBN" maxLength="50" class="form-control" value=""> <input type="text" id="isbn" name="isbn" placeholder="ISBN" maxLength="50" class="form-control" value="">
</div> </div>
@ -32,35 +33,44 @@
<label for="coleccion" class="form-label"> <label for="coleccion" class="form-label">
<?= lang('Presupuestos.coleccion') ?> <?= lang('Presupuestos.coleccion') ?>
</label> </label>
<input type="text" id="coleccion" name="coleccion" placeholder="Coleccion" maxLength="255" class="form-control" value=""> <input type="text" id="coleccion" name="coleccion" placeholder="Coleccion" maxLength="255"
class="form-control" value="">
</div> </div>
<div class="col-sm-4 mb-3"> <div class="col-sm-4 mb-3">
<label for="referenciaCliente" class="form-label"> <label for="referenciaCliente" class="form-label">
<?=lang('Presupuestos.referenciaCliente') ?> <?= lang('Presupuestos.referenciaCliente') ?>
</label> </label>
<input type="text" id="referenciaCliente" name="referencia_cliente" placeholder="Referencia cliente" maxLength="100" class="form-control" value=""> <input type="text" id="referenciaCliente" name="referencia_cliente" placeholder="Referencia cliente"
</div> maxLength="100" class="form-control" value="">
</div>
</div> </div>
<div class="col-sm-5 mb-3 d-flex flex-column align-items-center"> <div class="col-sm-5 mb-3 d-flex flex-column align-items-center">
<label id="label_clienteId" for="clienteId" class="form-label"> <label <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
id="label_clienteId" for="clienteId" class="form-label">
Cliente* Cliente*
</label> </label>
<select id="clienteId" name="cliente_id" class="form-control select2bs2 calcular-presupuesto" <select <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
id="clienteId" name="cliente_id" class="form-control select2bs2 calcular-presupuesto"
style="width: 100%;"> style="width: 100%;">
<?php if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')): ?>
<option value="<?= $clienteId ?>" selected>cliente</option>
<?php endif; ?>
</select> </select>
</div> </div>
<div class="row col-sm-5 mb-3 d-flex flex-column align-items-center"> <div class="row col-sm-5 mb-3 d-flex flex-column align-items-center">
<div class="form-check form-switch mb-2"> <div class="form-check form-switch mb-2">
<input class="calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa" <input <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
class="calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa"
name="excluir_rotativa" value="1"> name="excluir_rotativa" value="1">
<label class="form-check-label" for="excluirRotativa">Excluir rotativa</label> <label <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
class="form-check-label" for="excluirRotativa">Excluir rotativa</label>
</div> </div>
</div> </div>

View File

@ -182,4 +182,25 @@
</table> </table>
</div> </div>
<?php if ($state == 2): ?>
<div class="col-12 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-files" 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> </div>

View File

@ -12,7 +12,7 @@
<?= view("themes/vuexy/components/modals/modalDireccion") ?> <?= view("themes/vuexy/components/modals/modalDireccion") ?>
<div class="container-xxl flex-grow-1 container-p-y"> <div class="container-xxl flex-grow-1 container-p-y">
<div class="col-12"> <div class="col-12">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3> <h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
<?= csrf_field() ?> <?= csrf_field() ?>
@ -29,7 +29,7 @@
<div class="bs-stepper-header"> <div class="bs-stepper-header">
<div class="step active" data-target="#datos-generales"> <div <?= ($state == 2)? 'hidden': '' ?> class="step active titulos-menu" data-target="#datos-generales">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled"> <button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
<span class="bs-stepper-circle"><i class="ti ti-info-circle ti-sm"></i></span> <span class="bs-stepper-circle"><i class="ti ti-info-circle ti-sm"></i></span>
<span class="bs-stepper-label"> <span class="bs-stepper-label">
@ -38,7 +38,7 @@
</button> </button>
</div> </div>
<div class="step" data-target="#interior-libro"> <div <?= ($state == 2)? 'hidden': '' ?> class="step titulos-menu" data-target="#interior-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled"> <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-circle"><i class="ti ti-book ti-sm"></i></span>
<span class="bs-stepper-label"> <span class="bs-stepper-label">
@ -47,7 +47,7 @@
</button> </button>
</div> </div>
<div class="step" data-target="#cubierta-libro"> <div <?= ($state == 2)? 'hidden': '' ?> class="step titulos-menu" data-target="#cubierta-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled"> <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-books ti-sm"></i></span>
<span class="bs-stepper-label"> <span class="bs-stepper-label">
@ -56,7 +56,7 @@
</button> </button>
</div> </div>
<div class="step" data-target="#direcciones-libro"> <div <?= ($state == 2)? 'hidden': '' ?> class="step titulos-menu" data-target="#direcciones-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled"> <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-circle"><i class="ti ti-map-pins ti-sm"></i></span>
<span class="bs-stepper-label"> <span class="bs-stepper-label">
@ -65,7 +65,7 @@
</button> </button>
</div> </div>
<div class="step" data-target="#resumen-libro"> <div id="menu_resumen_button" class="step titulos-menu" data-target="#resumen-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled"> <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-circle"><i class="ti ti-checkbox ti-sm"></i></span>
<span class="bs-stepper-label"> <span class="bs-stepper-label">
@ -87,26 +87,30 @@
<form id="presupuesto-cliente-form" onsubmit="return false"> <form id="presupuesto-cliente-form" onsubmit="return false">
<div id="datos-generales" class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework"> <div <?= ($state == 2) ? 'hidden' : '' ?> id="datos-generales"
class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3"> <div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_datosGenerales") ?> <?= view("themes/vuexy/form/presupuestos/cliente/items/_datosGenerales") ?>
</div> </div>
</div> </div>
<div id="interior-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework"> <div <?= ($state == 2) ? 'hidden' : '' ?> id="interior-libro"
class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3"> <div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioInterior") ?> <?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioInterior") ?>
</div> </div>
</div> </div>
<div id="cubierta-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework"> <div <?= ($state == 2) ? 'hidden' : '' ?> id="cubierta-libro"
class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3"> <div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta") ?> <?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta") ?>
</div> </div>
</div> </div>
<div id="direcciones-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework"> <div <?= ($state == 2) ? 'hidden' : '' ?> id="direcciones-libro"
class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3"> <div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/items/_direcciones") ?> <?= view("themes/vuexy/form/presupuestos/cliente/items/_direcciones") ?>
</div> </div>
@ -132,7 +136,9 @@
<div id="form_buttons" class="row col-sm-12 justify-content-center" style="display: none;"> <div id="form_buttons" class="row col-sm-12 justify-content-center" style="display: none;">
</div> </div>
<?= view("themes/vuexy/components/chat_internal_presupuesto",data:["modelId" => $presupuestoId,"type" => "presupuesto"]) ?> <?php if ($formAction == 'edit'): ?>
<?= view("themes/vuexy/components/chat_internal_presupuesto", data: ["modelId" => $presupuestoId, "type" => "presupuesto"]) ?>
<?php endif; ?>
</div><!--//.row --> </div><!--//.row -->
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?> <?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?> <?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>
@ -164,5 +170,5 @@
<script type="module" <script type="module"
src="<?= site_url('assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js') ?>"></script> src="<?= site_url('assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js') ?>"></script>
<?= $this->endSection() ?> <?= $this->endSection() ?>

View File

@ -121,11 +121,11 @@ function calcular_mermas(){
$('#papelFormatoPersonalizado').on("click",function(){ $('#papelFormatoPersonalizado').on("click",function(){
var checkbox = document.getElementById('papelFormatoPersonalizado');
if(checkbox.checked == true){ if($('#papelFormatoPersonalizado').is(':checked')){
document.getElementById("papelFormatoAncho").style.display = "block"; document.getElementById("papelFormatoAncho").style.display = "block";
document.getElementById("papelFormatoAlto").style.display = "block"; document.getElementById("papelFormatoAlto").style.display = "block";
$('#papelFormatoId').next(".select2-container").hide(); $('#papelFormatoId').hide();
$('#papelFormatoId').val(0).change(); $('#papelFormatoId').val(0).change();
document.getElementById("label_papelFormatoId").innerHTML = document.getElementById("label_papelFormatoId").innerHTML =
window.Presupuestos.papelFormatoId + " (" + window.Presupuestos.papelFormatoId + " (" +
@ -136,7 +136,7 @@ $('#papelFormatoPersonalizado').on("click",function(){
document.getElementById("papelFormatoAlto").value= ""; document.getElementById("papelFormatoAlto").value= "";
document.getElementById("papelFormatoAncho").style.display = "none"; document.getElementById("papelFormatoAncho").style.display = "none";
document.getElementById("papelFormatoAlto").style.display = "none"; document.getElementById("papelFormatoAlto").style.display = "none";
$('#papelFormatoId').next(".select2-container").show(); $('#papelFormatoId').show();
document.getElementById("label_papelFormatoId").innerHTML = document.getElementById("label_papelFormatoId").innerHTML =
window.Presupuestos.papelFormatoId + '*'; window.Presupuestos.papelFormatoId + '*';
} }

View File

@ -42,7 +42,7 @@
<?= lang('Presupuestos.papelFormatoId') ?>* <?= lang('Presupuestos.papelFormatoId') ?>*
</label> </label>
<select id="papelFormatoId" name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;"> <select id="papelFormatoId" <?= $presupuestoEntity->papel_formato_personalizado == false ? '' : 'style="display: none"'; ?> name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
<?php if (isset($papelFormatoList) && is_array($papelFormatoList) && !empty($papelFormatoList)) : <?php if (isset($papelFormatoList) && is_array($papelFormatoList) && !empty($papelFormatoList)) :
foreach ($papelFormatoList as $formato) : ?> foreach ($papelFormatoList as $formato) : ?>

View File

@ -49,7 +49,6 @@
<th><?= lang('TarifaEncuadernacionTiradas.proveedor') ?></th> <th><?= lang('TarifaEncuadernacionTiradas.proveedor') ?></th>
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMin') ?></th> <th><?= lang('TarifaEncuadernacionTiradas.tiradaMin') ?></th>
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMax') ?></th> <th><?= lang('TarifaEncuadernacionTiradas.tiradaMax') ?></th>
<th><?= lang('Tarifaencuadernacion.importeMin') ?></th>
<th><?= lang('Tarifaencuadernacion.importeFijo') ?></th> <th><?= lang('Tarifaencuadernacion.importeFijo') ?></th>
<th></th> <th></th>
</tr> </tr>
@ -83,6 +82,7 @@
<th><?= lang('TarifaEncuadernacionLineas.precioMin') ?></th> <th><?= lang('TarifaEncuadernacionLineas.precioMin') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.paginasMax') ?></th> <th><?= lang('TarifaEncuadernacionLineas.paginasMax') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.precioMax') ?></th> <th><?= lang('TarifaEncuadernacionLineas.precioMax') ?></th>
<th><?= lang('Tarifaencuadernacion.importeMin') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th> <th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
<th style="min-width:100px"></th> <th style="min-width:100px"></th>
</tr> </tr>
@ -112,6 +112,7 @@
<th><?= lang('TarifaEncuadernacionLineas.tiempoMin') ?></th> <th><?= lang('TarifaEncuadernacionLineas.tiempoMin') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.tiempoMax') ?></th> <th><?= lang('TarifaEncuadernacionLineas.tiempoMax') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.precioHora') ?></th> <th><?= lang('TarifaEncuadernacionLineas.precioHora') ?></th>
<th><?= lang('Tarifaencuadernacion.importeMin') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th> <th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
<th style="min-width:100px"></th> <th style="min-width:100px"></th>
</tr> </tr>
@ -298,6 +299,8 @@
name: "tiempo_max" name: "tiempo_max"
}, { }, {
name: "precio_hora" name: "precio_hora"
}, {
name: "total_min"
}, { }, {
name: "margen" name: "margen"
}, { }, {
@ -366,6 +369,7 @@
{ 'data': 'tiempo_min' }, { 'data': 'tiempo_min' },
{ 'data': 'tiempo_max' }, { 'data': 'tiempo_max' },
{ 'data': 'precio_hora' }, { 'data': 'precio_hora' },
{ 'data': 'total_min' },
{ 'data': 'margen' }, { 'data': 'margen' },
{ {
data: actionBtns, data: actionBtns,
@ -477,6 +481,8 @@
name: "paginas_libro_max" name: "paginas_libro_max"
}, { }, {
name: "precio_max" name: "precio_max"
}, {
name: "total_min"
}, { }, {
name: "margen" name: "margen"
}, { }, {
@ -556,6 +562,7 @@
{ 'data': 'precio_max' }, { 'data': 'precio_max' },
{ 'data': 'paginas_libro_max' }, { 'data': 'paginas_libro_max' },
{ 'data': 'precio_min' }, { 'data': 'precio_min' },
{ 'data': 'total_min' },
{ 'data': 'margen' }, { 'data': 'margen' },
{ {
data: actionBtns, data: actionBtns,
@ -661,8 +668,6 @@
name: "tirada_min" name: "tirada_min"
}, { }, {
name: "tirada_max" name: "tirada_max"
}, {
name: "precio_min"
}, { }, {
name: "importe_fijo" name: "importe_fijo"
}, { }, {
@ -746,7 +751,6 @@
}, },
{ 'data': 'tirada_min' }, { 'data': 'tirada_min' },
{ 'data': 'tirada_max' }, { 'data': 'tirada_max' },
{ 'data': 'precio_min' },
{ 'data': 'importe_fijo' }, { 'data': 'importe_fijo' },
{ {
data: actionBtns, data: actionBtns,

View File

@ -98,7 +98,7 @@
}); });
theTable.on( 'draw.dt', function () { theTable.on( 'draw.dt', function () {
const boolCols = [1,2,3]; const boolCols = [1,2,3, 4];
for (let coln of boolCols) { for (let coln of boolCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : ''; cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';

View File

@ -482,6 +482,9 @@ export const showNotificationMessages = (dom) => {
if(data.totalMessages > 0){ if(data.totalMessages > 0){
$("#chat-notification-number").removeClass("d-none") $("#chat-notification-number").removeClass("d-none")
$("#chat-notification-number").text(data.totalMessages ?? 0) $("#chat-notification-number").text(data.totalMessages ?? 0)
}else{
$("#chat-notification-number").addClass("d-none")
$("#chat-notification-number").text(0)
} }
data?.internals?.map((e) => { data?.internals?.map((e) => {
let numberOfMessages = e.unreadMessages let numberOfMessages = e.unreadMessages
@ -509,7 +512,7 @@ export const showNotificationMessages = (dom) => {
dom.append( dom.append(
` `
<li class=""> <li class="">
<a href="/presupuestos/cosidotapablanda/edit/${e.presupuestoId}" class="d-flex align-items-center flex-grow"> <a href="${e.uri}" class="d-flex align-items-center flex-grow">
<div class="avatar d-block flex-shrink-0"> <div class="avatar d-block flex-shrink-0">
<span class="avatar-initial rounded-circle bg-label-primary">${e.presupuestoId}</span> <span class="avatar-initial rounded-circle bg-label-primary">${e.presupuestoId}</span>
</div> </div>
@ -529,7 +532,7 @@ export const showNotificationMessages = (dom) => {
dom.append( dom.append(
` `
<li class=""> <li class="">
<a href="/facturas/edit/${e.facturaId}" class="d-flex align-items-center flex-grow"> <a href="${e.uri}" class="d-flex align-items-center flex-grow">
<div class="avatar d-block flex-shrink-0"> <div class="avatar d-block flex-shrink-0">
<span class="avatar-initial rounded-circle bg-label-primary">${e.facturaId}</span> <span class="avatar-initial rounded-circle bg-label-primary">${e.facturaId}</span>
</div> </div>
@ -549,7 +552,7 @@ export const showNotificationMessages = (dom) => {
dom.append( dom.append(
` `
<li class=""> <li class="">
<a href="/pedidos/edit/${e.pedidoId}" class="d-flex align-items-center flex-grow"> <a href="${e.uri}" class="d-flex align-items-center flex-grow">
<div class="avatar d-block flex-shrink-0"> <div class="avatar d-block flex-shrink-0">
<span class="avatar-initial rounded-circle bg-label-primary">${e.pedidoId}</span> <span class="avatar-initial rounded-circle bg-label-primary">${e.pedidoId}</span>
</div> </div>

View File

@ -29,9 +29,14 @@ class ErrorPresupuestoView {
init() { init() {
this.datatable = this.datatableItem.DataTable({ this.datatable = this.datatableItem.DataTable({
processing: true, processing: true,
dom: 'Brtip', layout :{
topStart: 'pageLength',
topEnd: 'search',
bottomStart: 'info',
bottomEnd: 'paging'
},
serverSide: true, serverSide: true,
pageLength : 50,
language: { language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
}, },

View File

@ -5,7 +5,9 @@ import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js';
class DatosGenerales { class DatosGenerales {
constructor(domItem, wizardForm, validatorStepper) { constructor(domItem, wizardForm, validatorStepper) {
this.domItem = domItem; this.domItem = domItem;
this.allowNext = true;
this.wizardStep = wizardForm.querySelector('#datos-generales'); this.wizardStep = wizardForm.querySelector('#datos-generales');
this.validatorStepper = validatorStepper; this.validatorStepper = validatorStepper;
@ -64,6 +66,7 @@ class DatosGenerales {
this.formatoLibro.init(); this.formatoLibro.init();
this.cliente.init(); this.cliente.init();
// Inicializa el tipo de impresion // Inicializa el tipo de impresion
this.#handlePaginas(); this.#handlePaginas();
@ -98,6 +101,8 @@ class DatosGenerales {
message: window.translations["validation"].cliente, message: window.translations["validation"].cliente,
callback: function (input) { callback: function (input) {
// Get the selected options // Get the selected options
if (!$(this.excluirRotativa).prop('hidden'))
return true;
const options = $("#clienteId").select2('data'); const options = $("#clienteId").select2('data');
const hasValidOption = options.some(option => parseInt(option.id) > 0); const hasValidOption = options.some(option => parseInt(option.id) > 0);
return options !== null && options.length > 0 && hasValidOption; return options !== null && options.length > 0 && hasValidOption;
@ -116,25 +121,25 @@ class DatosGenerales {
const value4 = $("#tirada4").val(); const value4 = $("#tirada4").val();
let tiradas = [value]; let tiradas = [value];
if(!(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0)){ if (!(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0)) {
return { return {
valid: false, valid: false,
message: window.translations["validation"].integer_greatherThan_0, message: window.translations["validation"].integer_greatherThan_0,
}; };
} }
if(value2.length > 0 && Number.isInteger(parseInt(value2)) && parseInt(value2) > 0){ if (value2.length > 0 && Number.isInteger(parseInt(value2)) && parseInt(value2) > 0) {
tiradas.push(value2); tiradas.push(value2);
} }
if(value3.length > 0 && Number.isInteger(parseInt(value3)) && parseInt(value3) > 0){ if (value3.length > 0 && Number.isInteger(parseInt(value3)) && parseInt(value3) > 0) {
tiradas.push(value3); tiradas.push(value3);
} }
if(value4.length > 0 && Number.isInteger(parseInt(value4)) && parseInt(value4) > 0){ if (value4.length > 0 && Number.isInteger(parseInt(value4)) && parseInt(value4) > 0) {
tiradas.push(value4); tiradas.push(value4);
} }
// comprobar si hay valores > 30 // comprobar si hay valores > 30
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30)); const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30)); const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
if(noPOD && siPOD){ if (noPOD && siPOD) {
return { return {
valid: false, valid: false,
message: "No se pueden mezclar tiradas <30 con >30", message: "No se pueden mezclar tiradas <30 con >30",
@ -367,7 +372,8 @@ class DatosGenerales {
submitButton: new FormValidation.plugins.SubmitButton() submitButton: new FormValidation.plugins.SubmitButton()
} }
}).on('core.form.valid', () => { }).on('core.form.valid', () => {
stepper.next(); if (this.allowNext)
stepper.next();
}); });
} }
@ -431,6 +437,12 @@ class DatosGenerales {
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change'); this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
} }
getCliente() {
if ($(this.excluirRotativa).prop('hidden'))
return $('#clienteId').val();
return this.cliente.getVal();
}
getDimensionLibro() { getDimensionLibro() {
let ancho = 0; let ancho = 0;
@ -511,7 +523,7 @@ class DatosGenerales {
if (this.fresado.hasClass('selected') || this.cosido.hasClass('selected')) { if (this.fresado.hasClass('selected') || this.cosido.hasClass('selected')) {
$('#tapaDuraLomoRedondo').removeClass('d-none'); $('#tapaDuraLomoRedondo').removeClass('d-none');
if (this.cosido.hasClass('selected')) { if (this.cosido.hasClass('selected')) {
$('#tapaDuraLomoRedondo').addClass('selected'); //$('#tapaDuraLomoRedondo').addClass('selected');
this.divPaginasCuaderillo.removeClass('d-none'); this.divPaginasCuaderillo.removeClass('d-none');
} }
else { else {
@ -528,8 +540,8 @@ class DatosGenerales {
$('#addSobrecubierta').prop('checked', false).trigger('change'); $('#addSobrecubierta').prop('checked', false).trigger('change');
$(".sobrecubierta-items").addClass('d-none'); $(".sobrecubierta-items").addClass('d-none');
} }
else{ else {
if($('#addSobrecubierta').hasClass('d-none')){ if ($('#addSobrecubierta').hasClass('d-none')) {
$('#addSobrecubierta').removeClass('d-none'); $('#addSobrecubierta').removeClass('d-none');
} }
} }

View File

@ -12,6 +12,7 @@ class Direcciones {
this.domItem = domItem; this.domItem = domItem;
this.wizardStep = wizardForm.querySelector('#direcciones-libro'); this.wizardStep = wizardForm.querySelector('#direcciones-libro');
this.validatorStepper = validatorStepper; this.validatorStepper = validatorStepper;
this.allowNext = true;
this.unidadesAdd = this.domItem.find('#unidadesEnvio'); this.unidadesAdd = this.domItem.find('#unidadesEnvio');
this.btnAdd = this.domItem.find('#insertarDireccion'); this.btnAdd = this.domItem.find('#insertarDireccion');
@ -19,7 +20,7 @@ class Direcciones {
this.entregaPieCallero = this.domItem.find('#entregaPieCalle'); this.entregaPieCallero = this.domItem.find('#entregaPieCalle');
this.direccionesCliente = new ClassSelect($("#direcciones"), '/misdirecciones/getSelect2'); this.direccionesCliente = new ClassSelect($("#direcciones"), '/misdirecciones/getSelect2');
this.divDirecciones = $(this.domItem.find('#divDirecciones')); this.divDirecciones = $(this.domItem.find('#divDirecciones'));
this.divTiradas = this.domItem.find('#containerTiradasEnvios'); this.divTiradas = this.domItem.find('#containerTiradasEnvios');
@ -36,7 +37,7 @@ class Direcciones {
init() { init() {
$("#clienteId").on('change', this.handleChangeCliente.bind(this)); $("#clienteId").on('change', this.handleChangeCliente.bind(this));
this.direccionesCliente.init(); this.direccionesCliente.init();
this.btnAdd.on('click', this.#insertDireccion.bind(this)); this.btnAdd.on('click', this.#insertDireccion.bind(this));
@ -94,13 +95,13 @@ class Direcciones {
let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {}, let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {},
(response) => { (response) => {
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]); let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]);
tarjeta.setUnidades(unidades); tarjeta.setUnidades(unidades);
tarjeta.setEntregaPalets(entregaPalets); tarjeta.setEntregaPalets(entregaPalets);
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self)); tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self));
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self)); tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self));
this.divDirecciones.append(tarjeta.card); this.divDirecciones.append(tarjeta.card);
this.direcciones.push(tarjeta); this.direcciones.push(tarjeta);
}, },
() => { () => {
console.error('Error getting address'); console.error('Error getting address');
@ -124,7 +125,7 @@ class Direcciones {
validators: { validators: {
callback: { callback: {
callback: () => { callback: () => {
const div = $('#divErrorEnvios'); // Selecciona el div /* const div = $('#divErrorEnvios'); // Selecciona el div
div.find('.fv-plugins-message-container').remove(); div.find('.fv-plugins-message-container').remove();
@ -148,6 +149,8 @@ class Direcciones {
</div> </div>
`); `);
return false; return false;
*/
return true;
}, },
} }
@ -175,7 +178,8 @@ class Direcciones {
submitButton: new FormValidation.plugins.SubmitButton() submitButton: new FormValidation.plugins.SubmitButton()
} }
}).on('core.form.valid', () => { }).on('core.form.valid', () => {
stepper.next(); if (this.allowNext)
stepper.next();
}); });
} }

View File

@ -1,7 +1,9 @@
class DisenioCubierta { class DisenioCubierta {
constructor(domItem, wizardForm, validatorStepper) { constructor(domItem, wizardForm, validatorStepper) {
this.domItem = domItem; this.domItem = domItem;
this.allowNext = true;
this.wizardStep = wizardForm.querySelector('#cubierta-libro'); this.wizardStep = wizardForm.querySelector('#cubierta-libro');
this.validatorStepper = validatorStepper; this.validatorStepper = validatorStepper;
@ -28,7 +30,7 @@ class DisenioCubierta {
this.papelGuardas = this.domItem.find("#papelGuardas"); this.papelGuardas = this.domItem.find("#papelGuardas");
this.guardasImpresas = this.domItem.find("#guardasImpresas"); this.guardasImpresas = this.domItem.find("#guardasImpresas");
this.cabezada = this.domItem.find("#cabezada"); this.cabezada = this.domItem.find("#cabezada");
this.cartulinaEstucada = this.domItem.find("#cartulinaEstucada"); this.cartulinaEstucada = this.domItem.find("#cartulinaEstucada");
this.estucadoMate = this.domItem.find("#estucadoMate"); this.estucadoMate = this.domItem.find("#estucadoMate");
@ -174,7 +176,7 @@ class DisenioCubierta {
}, 0); }, 0);
} }
if(datosSobrecubierta && datosSobrecubierta.papel) { if (datosSobrecubierta && datosSobrecubierta.papel) {
this.sobrecubierta.trigger('click'); this.sobrecubierta.trigger('click');
this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change'); this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change');
this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho); this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho);
@ -313,7 +315,8 @@ class DisenioCubierta {
submitButton: new FormValidation.plugins.SubmitButton() submitButton: new FormValidation.plugins.SubmitButton()
} }
}).on('core.form.valid', () => { }).on('core.form.valid', () => {
stepper.next(); if (this.allowNext)
stepper.next();
}); });
} }

View File

@ -5,6 +5,7 @@ class DisenioInterior {
this.wizardStep = wizardForm.querySelector('#interior-libro'); this.wizardStep = wizardForm.querySelector('#interior-libro');
this.validatorStepper = validatorStepper; this.validatorStepper = validatorStepper;
this.allowNext = true;
this.disenioInterior = this.domItem.find(".disenio-interior"); this.disenioInterior = this.domItem.find(".disenio-interior");
this.divPapelInterior = this.domItem.find("#divPapelInterior"); this.divPapelInterior = this.domItem.find("#divPapelInterior");
@ -364,7 +365,8 @@ class DisenioInterior {
submitButton: new FormValidation.plugins.SubmitButton() submitButton: new FormValidation.plugins.SubmitButton()
} }
}).on('core.form.valid', () => { }).on('core.form.valid', () => {
stepper.next(); if (this.allowNext)
stepper.next();
}); });
} }

View File

@ -35,6 +35,8 @@ class PresupuestoCliente {
this.divTiradasPrecios = $("#divTiradasPrecio"); this.divTiradasPrecios = $("#divTiradasPrecio");
this.titulosMenu = $(".titulos-menu");
this.datos = {}; this.datos = {};
this.ajax_calcular = new Ajax('/presupuestocliente/calcular', this.ajax_calcular = new Ajax('/presupuestocliente/calcular',
{}, this.datos, {}, this.datos,
@ -59,11 +61,26 @@ class PresupuestoCliente {
this.disenioInterior.init(); this.disenioInterior.init();
this.disenioCubierta.init(); this.disenioCubierta.init();
this.direcciones.init(); this.direcciones.init();
if (window.location.href.includes("edit")) {
this.resumen.init(window.location.href.split("/").pop());
}
else {
this.resumen.init();
}
if (this.datosGenerales.excluirRotativa.length == 0) {
this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() })
}
this.btnNext.on('click', this.#nextStep.bind(this)); this.btnNext.on('click', this.#nextStep.bind(this));
this.btnPrev.on('click', this.#prevtStep.bind(this)); this.btnPrev.on('click', this.#prevtStep.bind(this));
this.btnSave.on('click', this.#savePresupuesto.bind(this)); this.btnSave.on('click', this.#savePresupuesto.bind(this));
this.btnConfirm.on('click', this.#confirmPresupuesto.bind(this));
this.titulosMenu.on('click', this.#handleTitulosMenu.bind(this));
if (window.location.href.includes("edit")) { if (window.location.href.includes("edit")) {
@ -110,7 +127,7 @@ class PresupuestoCliente {
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30)); const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30)); const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
this.datosGenerales.formValidation.validateField('tirada'); this.datosGenerales.formValidation.validateField('tirada');
return !(noPOD && siPOD); return !(noPOD && siPOD);
} }
@ -145,9 +162,21 @@ class PresupuestoCliente {
if (datos_to_check.direcciones) { if (datos_to_check.direcciones) {
delete datos_to_check.direcciones; delete datos_to_check.direcciones;
} }
if (datos_to_check.posPaginasColor) { if (datos_to_check.posPaginasColor == "" || datos_to_check.posPaginasColor == null) {
delete datos_to_check.posPaginasColor; delete datos_to_check.posPaginasColor;
} }
if (datos_to_check.cubierta.acabados.barniz == undefined) {
delete datos_to_check.cubierta.acabados.barniz;
}
if (datos_to_check.cubierta.acabados.plastificado == undefined) {
delete datos_to_check.cubierta.acabados.plastificado;
}
if (datos_to_check.cubierta.acabados.estampado == undefined) {
delete datos_to_check.cubierta.acabados.estampado;
}
if (datos_to_check.sobrecubierta.plastificado == undefined) {
delete datos_to_check.sobrecubierta.plastificado;
}
if (Object.values(datos_to_check).every(this.#isValidDataForm)) { if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
try { try {
@ -172,61 +201,134 @@ class PresupuestoCliente {
} }
#handleTitulosMenu(event) {
/*RELLENAR_PRESUPUESTO(finalizar) { $('.titulos-menu').removeClass('crossed');
if (finalizar) { const nextElement = $(event.target).attr('data-target')
const currentElement = $('.dstepper-block.active').attr('id');
$("#titulo").val("Titulo del libro"); if (currentElement === nextElement) {
$("#titulo").trigger('change'); return;
}
const clienteId = $("#clienteId");
const newOption = new Option("Cliente Potencial", "1817", true, true);
clienteId.append(newOption).trigger('change');
const papelFormatoId = $("#papelFormatoId");
const newOption2 = new Option("148 x 210", "1", true, true);
papelFormatoId.append(newOption2).trigger('change');
$("#paginasColor").val("6");
$("#paginasColor").trigger('change');
$("#fresado").trigger("click");
$("#colorPremium").trigger("click");
$("#offsetBlanco").trigger("click");
setTimeout(function () {
$("#gramaje90").trigger("click");
}, 0);
setTimeout(function () {
$("#tapaDura").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#unidadesEnvio").val("50");
}, 0);
if (currentElement !== 'resumen-libro') {
this.#validateCurrentForm(currentElement, nextElement);
} }
else { else {
$("#titulo").trigger('change'); this.#goToForm(nextElement);
} }
}*/ }
#goToForm(form) {
switch (form) {
case '#datos-generales':
this.validationStepper.to(1);
break;
case '#interior-libro':
this.validationStepper.to(2);
break;
case '#cubierta-libro':
this.validationStepper.to(3);
break;
case '#direcciones-libro':
this.validationStepper.to(4);
break;
case '#resumen-libro':
this.validationStepper.to(5);
break;
default:
break;
}
}
#validateCurrentForm(form, nextForm) {
switch (form) {
case 'datos-generales':
this.datosGenerales.allowNext = false;
validateForm(this.datosGenerales.formValidation).then((status) => {
if (status !== 'Valid') {
this.datosGenerales.allowNext = true;
return false;
}
this.#goToForm(nextForm);
this.datosGenerales.allowNext = true;
return true;
}).catch(error => {
this.datosGenerales.allowNext = true;
console.error('Error al validar:', error);
return false;
});
break;
case 'interior-libro':
this.disenioInterior.allowNext = false;
validateForm(this.disenioInterior.formValidation).then((status) => {
if (status !== 'Valid') {
this.disenioInterior.allowNext = true;
return false;
}
this.#goToForm(nextForm);
this.disenioInterior.allowNext = true;
return true;
}
).catch(error => {
this.disenioInterior.allowNext = true;
console.error('Error al validar:', error);
return false;
});
break;
case 'cubierta-libro':
this.disenioCubierta.allowNext = false;
validateForm(this.disenioCubierta.formValidation).then((status) => {
if (status !== 'Valid') {
this.disenioCubierta.allowNext = true;
return false;
}
this.#goToForm(nextForm);
this.disenioCubierta.allowNext = true;
return true;
}
).catch(error => {
this.disenioCubierta.allowNext = true;
console.error('Error al validar:', error);
return false;
});
break;
case 'direcciones-libro':
this.direcciones.allowNext = false;
validateForm(this.direcciones.formValidation).then((status) => {
if (status !== 'Valid') {
this.direcciones.allowNext = true;
return false;
}
this.#goToForm(nextForm);
this.direcciones.allowNext = true;
return true;
}
).catch(error => {
this.direcciones.allowNext = true;
console.error('Error al validar:', error);
return false;
});
break;
default:
return false;
}
}
stepperHandler() { stepperHandler() {
@ -267,10 +369,27 @@ class PresupuestoCliente {
} }
#confirmPresupuesto() {
this.#solicitudGuardarPresupuesto(true);
}
#savePresupuesto() { #savePresupuesto() {
this.#solicitudGuardarPresupuesto(false);
}
#solicitudGuardarPresupuesto(confirmar = false) {
this.#getDatos(true); this.#getDatos(true);
if (confirmar) {
this.datos["confirmar"] = 1;
}
try { try {
$('#loader').modal('show'); $('#loader').modal('show');
@ -292,7 +411,11 @@ class PresupuestoCliente {
} }
} }
else { else {
popSuccessAlert(response.message); if (response.error) {
popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial.");
}
else
popSuccessAlert(response.message);
} }
}, },
() => { $('#loader').modal('hide'); } () => { $('#loader').modal('hide'); }
@ -352,7 +475,7 @@ class PresupuestoCliente {
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click'); $(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
}, 0); }, 0);
} }
$('#loader').modal('hide');
// DEBUG // DEBUG
//console.log(response); //console.log(response);
} }
@ -395,7 +518,7 @@ class PresupuestoCliente {
this.datos = { this.datos = {
clienteId: this.datosGenerales.cliente.getVal(), clienteId: this.datosGenerales.getCliente(),
tamanio: this.datosGenerales.getDimensionLibro(), tamanio: this.datosGenerales.getDimensionLibro(),
tirada: this.datosGenerales.getTiradas(), tirada: this.datosGenerales.getTiradas(),
@ -420,7 +543,6 @@ class PresupuestoCliente {
cubierta: { cubierta: {
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'), tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
lomoRedondo: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0,
papelCubierta: this.disenioCubierta.getPapel(), papelCubierta: this.disenioCubierta.getPapel(),
gramajeCubierta: this.disenioCubierta.getGramaje(), gramajeCubierta: this.disenioCubierta.getGramaje(),
cabezada: this.disenioCubierta.getCabezada(), cabezada: this.disenioCubierta.getCabezada(),
@ -438,6 +560,10 @@ class PresupuestoCliente {
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0, 'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
}, },
}; };
let lomoRedondo = 0;
if (this.disenioCubierta.disenioCubierta.filter('.selected').length > 0)
lomoRedondo = this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0;
this.datos.cubierta.lomoRedondo = lomoRedondo;
if (this.datos.tipo == "cosido") { if (this.datos.tipo == "cosido") {
this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val(); this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val();
@ -498,14 +624,27 @@ class PresupuestoCliente {
this.datosGenerales.cargarDatos(response.data.datosGenerales); this.datosGenerales.cargarDatos(response.data.datosGenerales);
this.direcciones.handleChangeCliente(); this.direcciones.handleChangeCliente();
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente); this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta); this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales); this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
setTimeout(() => { setTimeout(() => {
$('#loader').modal('hide'); $('#loader').modal('hide');
this.calcularPresupuesto = true;
this.checkForm({ target: { id: 'tirada' } }); if (response.data.state != 2) {
this.calcularPresupuesto = true;
this.checkForm({ target: { id: 'tirada' } });
}
else {
$('#menu_resumen_button').trigger('click');
setTimeout(() => {
this.resumen.init_dropzone();
this.resumen.generate_total(response.data.resumen.base, response.data.resumen.precio_unidad);
}, 0);
}
}, 0); }, 0);
} }
}, },
@ -530,6 +669,16 @@ class PresupuestoCliente {
} }
async function validateForm(formValidation) {
try {
const validationResult = await formValidation.validate();
return validationResult;
} catch (error) {
console.error('Error durante la validación:', error);
throw error;
}
}
function isValid(value) { function isValid(value) {
if (value === null || value === undefined || value === '') { if (value === null || value === undefined || value === '') {

View File

@ -53,13 +53,134 @@ class Resumen {
this.divPreview = $(this.domItem.find("#pv_ec_shape")); this.divPreview = $(this.domItem.find("#pv_ec_shape"));
this.btnPreviewCubierta = $(this.domItem.find("#btnPreviewCubierta")); this.btnPreviewCubierta = $(this.domItem.find("#btnPreviewCubierta"));
this.init(); this.submitFiles = $(this.domItem.find("#submit-all-files"));
this.dropzone = null;
this.presupuesto_id = -1;
} }
init() { init(presupuesto_id = -1) {
this.btnPreviewCubierta.on('click', this.#btnPreview.bind(this)); this.btnPreviewCubierta.on('click', this.#btnPreview.bind(this));
this.submitFiles.on('click', this.#btnUploadFiles.bind(this));
if (presupuesto_id != -1) {
this.presupuesto_id = presupuesto_id;
}
}
init_dropzone() {
let id = this.presupuesto_id;
Dropzone.autoDiscover = false;
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>`;
this.dropzone = new Dropzone('#dropzone-multi', {
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 () {
let thisDropzone = this;
$('#loader').show();
$.ajax({
url: "/presupuestos/presupuestocliente/get_files",
type: 'POST',
data: { presupuesto_id: id }
}).done(function (response) {
if (response == null || response == "") {
return;
}
let 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');
});
}
});
},
});
}
#btnUploadFiles() {
var files = this.dropzone.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', this.presupuesto_id);
$.ajax({
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) {
popSuccessAlert("Archivos actualizados correctamente");
}).always(function () {
$('#loader').hide();
});
} }
@ -178,15 +299,15 @@ class Resumen {
const tarjetaPrecio = $('.tarjeta-tiradas-precios').filter(function () { const tarjetaPrecio = $('.tarjeta-tiradas-precios').filter(function () {
return parseInt($(this).find('.tarjeta-tiradas-precios-tirada').attr('data')) == unidades; return parseInt($(this).find('.tarjeta-tiradas-precios-tirada').attr('data')) == unidades;
}); });
let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text();
let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text();
precio_u_text = precio_u_text.replace('€/u', ''); precio_u_text = precio_u_text.replace('€/u', '');
precio_u_text = this.#changeDecimalFormat(precio_u_text); precio_u_text = this.#changeDecimalFormat(precio_u_text);
const base = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio').attr('data'); const base = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio').attr('data');
let base_text = this.#changeDecimalFormat(base); let base_text = this.#changeDecimalFormat(base);
const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04; const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04;
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2); const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
let iva_text = this.#changeDecimalFormat(iva); let iva_text = this.#changeDecimalFormat(iva);
@ -202,6 +323,28 @@ class Resumen {
} }
generate_total(base, precio_u) {
let precio_u_text = String(precio_u);
precio_u_text = precio_u_text.replace('€/u', '');
precio_u_text = this.#changeDecimalFormat(precio_u_text);
let base_text = this.#changeDecimalFormat(String(base));
const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04;
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
let iva_text = this.#changeDecimalFormat(iva);
const total = (parseFloat(base) + parseFloat(iva)).toFixed(2);
let total_text = this.#changeDecimalFormat(total);
this.precio_unidad.text(precio_u_text);
this.total_base.text(base_text);
this.iva_porcentaje.text(this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? '21' : '4');
this.iva.text(iva_text);
this.total.text(total_text);
}
#capitalizeFirstLetter(string) { #capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1); return string.charAt(0).toUpperCase() + string.slice(1);
@ -209,7 +352,7 @@ class Resumen {
#changeDecimalFormat(number) { #changeDecimalFormat(number) {
let cleanedNumber = String(number).replace(/[^\d.]/g, ''); let cleanedNumber = String(number).replace(/[^\d.]/g, '');
let partes = cleanedNumber.split('.'); let partes = cleanedNumber.split('.');
partes[0] = partes[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.'); partes[0] = partes[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');

View File

@ -1,7 +1,7 @@
class previewFormas { class previewFormas {
constructor(container, tipoLibro, tipoTapa, size, datos) { constructor(container, tipoLibro, tipoTapa, size, datos) {
this.container = container; this.container = container;
this.tipoLibro = tipoLibro; this.tipoLibro = tipoLibro;
this.tipoTapa = tipoTapa; this.tipoTapa = tipoTapa;
@ -10,7 +10,15 @@ class previewFormas {
this.ancho = datos.ancho; this.ancho = datos.ancho;
this.alto = datos.alto; this.alto = datos.alto;
this.lomo = datos.lomo; this.lomo = datos.lomo;
this.solapa = datos.solapa;
if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) {
this.solapa = 0;
this.offsetSolapa = 0.0;
}
else {
this.solapa = datos.solapas;
this.offsetSolapa = 3.0;
}
this.lomoRedondo = datos.lomoRedondo; this.lomoRedondo = datos.lomoRedondo;
} }
@ -25,7 +33,7 @@ class previewFormas {
} }
} }
else if (this.tipoLibro.includes("espiral") || this.tipoLibro.includes("wire-o")) { else if (this.tipoLibro.includes("espiral") || this.tipoLibro.includes("wire-o")) {
if (this.tipoTapa.includes("dura")) if (this.tipoTapa.toLowerCase().includes("dura"))
this.#portadaEspiral(true); this.#portadaEspiral(true);
else else
this.#portadaEspiral(false); this.#portadaEspiral(false);
@ -45,7 +53,7 @@ class previewFormas {
let sangradoTexto = "Sangrado 5 mm"; let sangradoTexto = "Sangrado 5 mm";
let sangradoValor = parseFloat(5); // mm let sangradoValor = parseFloat(5); // mm
let offsetSolapaValor = parseFloat(0); // mm let offsetSolapaValor = parseFloat(0); // mm
// Definicion de los parametros del Esquema de Cubierta (EC) // Definicion de los parametros del Esquema de Cubierta (EC)
if (this.solapa == 0) { if (this.solapa == 0) {
if (this.size == "thumbnail") { if (this.size == "thumbnail") {
@ -55,13 +63,13 @@ class previewFormas {
anchoSangrado = 800; // px anchoSangrado = 800; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
} }
altoLibro = altoSangrado * 0.97; altoLibro = altoSangrado * 0.97;
anchoLibro = anchoSangrado * 0.419; anchoLibro = anchoSangrado * 0.419;
anchoSolapa = 0; anchoSolapa = 0;
lomoLibro = anchoSangrado * 0.133; lomoLibro = anchoSangrado * 0.133;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro; anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
} else { } else {
if (this.size == "thumbnail") { if (this.size == "thumbnail") {
anchoSangrado = 350; // px anchoSangrado = 350; // px
@ -76,14 +84,14 @@ class previewFormas {
lomoLibro = anchoSangrado * 0.09; lomoLibro = anchoSangrado * 0.09;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro; anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
} }
// Clear the canvas element // Clear the canvas element
this.container.empty(); this.container.empty();
// Get the element for placing the graphical elements // Get the element for placing the graphical elements
var previewEC = new Two({ fitted: true }).appendTo(this.container[0]); var previewEC = new Two({ fitted: true }).appendTo(this.container[0]);
// Calculate the center of the canvas element // Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2); var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle( var sangrado = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -94,7 +102,7 @@ class previewFormas {
sangrado.dashes = [5, 5]; sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1'; sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1; sangrado.linewidth = 1;
if (this.solapa != 0) { if (this.solapa != 0) {
var solapas = previewEC.makeRectangle( var solapas = previewEC.makeRectangle(
origenEC.x, origenEC.x,
@ -103,7 +111,7 @@ class previewFormas {
altoLibro); altoLibro);
solapas.stroke = 'black'; solapas.stroke = 'black';
solapas.linewidth = 1; solapas.linewidth = 1;
// Cotas Solapas // Cotas Solapas
if (this.size != "thumbnail") { if (this.size != "thumbnail") {
var cotaSolapa2 = previewEC.makeDobleArrow( var cotaSolapa2 = previewEC.makeDobleArrow(
@ -120,7 +128,7 @@ class previewFormas {
origenEC.y - (altoLibro / 3), origenEC.y - (altoLibro / 3),
10); 10);
cotaSolapa1.linewidth = 2; cotaSolapa1.linewidth = 2;
// Textos Solapas // Textos Solapas
let stylesSolapa = { size: 18, family: 'Public Sans' }; let stylesSolapa = { size: 18, family: 'Public Sans' };
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa); previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
@ -129,9 +137,9 @@ class previewFormas {
previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
} }
} }
var libro = previewEC.makeRectangle( var libro = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -139,7 +147,7 @@ class previewFormas {
altoLibro); altoLibro);
libro.stroke = 'black'; libro.stroke = 'black';
libro.linewidth = 1; libro.linewidth = 1;
var lomo = previewEC.makeRectangle( var lomo = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -148,7 +156,7 @@ class previewFormas {
lomo.stroke = 'black'; lomo.stroke = 'black';
lomo.fill = '#F4F8F2'; lomo.fill = '#F4F8F2';
lomo.linewidth = 1; lomo.linewidth = 1;
// Cotas y textos // Cotas y textos
if (this.size != "thumbnail") { if (this.size != "thumbnail") {
// Cotas: // Cotas:
@ -194,8 +202,8 @@ class previewFormas {
origenEC.y - (altoLibro / 3), origenEC.y - (altoLibro / 3),
10); 10);
cotaPortada.linewidth = 2; cotaPortada.linewidth = 2;
// Textos: // Textos:
// Titulos generales // Titulos generales
let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' }; let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' };
@ -218,11 +226,11 @@ class previewFormas {
origenEC.x, origenEC.x,
origenEC.y + (altoLibro / 2) + 50, origenEC.y + (altoLibro / 2) + 50,
styleCotas); styleCotas);
} }
previewEC.update(); previewEC.update();
} }
@ -233,14 +241,14 @@ class previewFormas {
let styleCotas = { size: 12, family: 'Public Sans' }; let styleCotas = { size: 12, family: 'Public Sans' };
let sangradoTexto = "Sangrado 20 mm"; let sangradoTexto = "Sangrado 20 mm";
let sangradoValor = parseFloat(20); // mm let sangradoValor = parseFloat(20); // mm
if(this.ancho > 210 || this.alto > 297){ if (this.ancho >= 210 || this.alto >= 297) {
sangradoValor = parseFloat(15); // mm sangradoValor = parseFloat(15); // mm
sangradoTexto = "Sangrado 15 mm"; sangradoTexto = "Sangrado 15 mm";
} }
let anchoPliegue = parseFloat(7); // mm cajo let anchoPliegue = parseFloat(7); // mm cajo
let altoPliegue = parseFloat(7); // mm let altoPliegue = parseFloat(7); // mm
let anchoCarton = parseFloat(6); // mm let anchoCarton = parseFloat(6); // mm
if(this.lomoRedondo) if (this.lomoRedondo)
anchoCarton += parseFloat(6); // mm anchoCarton += parseFloat(6); // mm
// Definicion de los parametros del Esquema de Cubierta (EC) // Definicion de los parametros del Esquema de Cubierta (EC)
if (this.size == "thumbnail") { if (this.size == "thumbnail") {
@ -254,15 +262,15 @@ class previewFormas {
anchoLibro = anchoSangrado * 0.39; anchoLibro = anchoSangrado * 0.39;
lomoLibro = anchoSangrado * 0.133; lomoLibro = anchoSangrado * 0.133;
anchoCubierta = (2 * anchoLibro) + lomoLibro; anchoCubierta = (2 * anchoLibro) + lomoLibro;
// Clear the canvas element // Clear the canvas element
this.container.empty(); this.container.empty();
// Get the element for placing the graphical elements // Get the element for placing the graphical elements
var previewEC = new Two({ fitted: true }).appendTo($(this.container)[0]); var previewEC = new Two({ fitted: true }).appendTo($(this.container)[0]);
// Calculate the center of the canvas element // Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2); var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle( var sangrado = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -273,7 +281,7 @@ class previewFormas {
sangrado.dashes = [5, 5]; sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1'; sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1; sangrado.linewidth = 1;
var libro = previewEC.makeRectangle( var libro = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -281,7 +289,7 @@ class previewFormas {
altoLibro); altoLibro);
libro.stroke = 'black'; libro.stroke = 'black';
libro.linewidth = 1; libro.linewidth = 1;
var lomo = previewEC.makeRectangle( var lomo = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -290,7 +298,7 @@ class previewFormas {
lomo.stroke = 'black'; lomo.stroke = 'black';
lomo.fill = '#F4F8F2'; lomo.fill = '#F4F8F2';
lomo.linewidth = 1; lomo.linewidth = 1;
// Cotas y textos // Cotas y textos
if (this.size != "thumbnail") { if (this.size != "thumbnail") {
// Cotas: // Cotas:
@ -336,8 +344,8 @@ class previewFormas {
origenEC.y - (altoLibro / 3), origenEC.y - (altoLibro / 3),
10); 10);
cotaPortada.linewidth = 2; cotaPortada.linewidth = 2;
// Textos: // Textos:
// Titulos generales // Titulos generales
let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' }; let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' };
@ -354,29 +362,29 @@ class previewFormas {
previewEC.makeText((this.lomo + anchoCarton).toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas); previewEC.makeText((this.lomo + anchoCarton).toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((this.alto + altoPliegue).toFixed(1)+ " mm", origenEC.x + (lomoLibro / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2; previewEC.makeText((this.alto + altoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((this.alto + (2 * sangradoValor) + altoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro) + 55, origenEC.y, styleCotas).rotation = -Math.PI / 2; previewEC.makeText((this.alto + (2 * sangradoValor) + altoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro) + 55, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * this.ancho) + this.lomo + (2 * sangradoValor) + +(2 * anchoPliegue) + anchoCarton + " mm", previewEC.makeText((2 * this.ancho) + this.lomo + (2 * sangradoValor) + +(2 * anchoPliegue) + anchoCarton + " mm",
origenEC.x, origenEC.x,
origenEC.y + (altoLibro / 2) + 50, origenEC.y + (altoLibro / 2) + 50,
styleCotas); styleCotas);
} }
previewEC.update(); previewEC.update();
} }
#portadaEspiral(isTapaDura = false) { #portadaEspiral(isTapaDura = false) {
// Variables locales // Variables locales
let altoLibro, anchoLibro, anchoCalle, altoSangrado, anchoSangrado, anchoSolapa, offsetCubierta, anchoCubierta; let altoLibro, anchoLibro, anchoSolapa, anchoCalle, altoSangrado, anchoSangrado, offsetCubierta, anchoCubierta;
let styleCotas = { size: 12, family: 'Public Sans' }; let styleCotas = { size: 12, family: 'Public Sans' };
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm"; let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
// Definicion de los parametros del Esquema de Cubierta (EC) // Definicion de los parametros del Esquema de Cubierta (EC)
if ((anchoSolapa !== 0) && (!isTapaDura)) { if ((this.solapa !== 0) && (!isTapaDura)) {
if (this.size == "thumbnail") { if (this.size == "thumbnail") {
anchoSangrado = 350; // px anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
@ -399,18 +407,18 @@ class previewFormas {
anchoSangrado = 750; // px anchoSangrado = 750; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
} }
altoLibro = (isTapaDura) ? altoSangrado * 0.88 : altoSangrado * 0.97; altoLibro = (isTapaDura) ? altoSangrado * 0.88 : altoSangrado * 0.9;
anchoLibro = (isTapaDura) ? anchoSangrado * 0.39 : anchoSangrado * 0.419; anchoLibro = (isTapaDura) ? anchoSangrado * 0.39 : anchoSangrado * 0.44;
anchoCalle = anchoSangrado * 0.02; anchoCalle = anchoSangrado * 0.02;
anchoSolapa = 0; anchoSolapa = 0;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + anchoCalle; anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + anchoCalle;
offsetCubierta = anchoLibro / 2 + anchoCalle / 2 + anchoSolapa + sangradoValor; offsetCubierta = anchoLibro / 2 + anchoCalle / 2 + anchoSolapa + sangradoValor;
} }
var previewEC = new Two({ fitted: true }).appendTo(this.container[0]); var previewEC = new Two({ fitted: true }).appendTo(this.container[0]);
// Calculate the center of the canvas element // Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2); var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle( var sangrado = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -421,8 +429,8 @@ class previewFormas {
sangrado.dashes = [5, 5]; sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1'; sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1; sangrado.linewidth = 1;
if ((anchoSolapa != 0) && (!isTapaDura)) { if ((this.solapa != 0) && (!isTapaDura)) {
var solapa1 = previewEC.makeRectangle( var solapa1 = previewEC.makeRectangle(
origenEC.x + (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor), origenEC.x + (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor),
origenEC.y, origenEC.y,
@ -430,7 +438,7 @@ class previewFormas {
altoLibro); altoLibro);
solapa1.stroke = 'black'; solapa1.stroke = 'black';
solapa1.linewidth = 1; solapa1.linewidth = 1;
var solapa2 = previewEC.makeRectangle( var solapa2 = previewEC.makeRectangle(
origenEC.x - (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor), origenEC.x - (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor),
origenEC.y, origenEC.y,
@ -438,7 +446,7 @@ class previewFormas {
altoLibro); altoLibro);
solapa2.stroke = 'black'; solapa2.stroke = 'black';
solapa2.linewidth = 1; solapa2.linewidth = 1;
// Cotas y textos // Cotas y textos
if (this.size != "thumbnail") { if (this.size != "thumbnail") {
// Cotas // Cotas
@ -456,18 +464,18 @@ class previewFormas {
origenEC.y - (altoLibro / 3), origenEC.y - (altoLibro / 3),
10); 10);
cotaSolapa1.linewidth = 2; cotaSolapa1.linewidth = 2;
// Textos Solapas // Textos Solapas
let stylesSolapa = { size: 18, family: 'Public Sans' }; let stylesSolapa = { size: 18, family: 'Public Sans' };
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa); 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); previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas // Textos Cotas Solapas
previewEC.makeText((anchoSolapa).toFixed(1) + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText((this.solapa).toFixed(1) + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(this.solapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
} }
} }
var portada = previewEC.makeRectangle( var portada = previewEC.makeRectangle(
origenEC.x + (anchoLibro / 2 + anchoCalle / 2 + sangradoValor), origenEC.x + (anchoLibro / 2 + anchoCalle / 2 + sangradoValor),
origenEC.y, origenEC.y,
@ -475,7 +483,7 @@ class previewFormas {
altoLibro); altoLibro);
portada.stroke = 'black'; portada.stroke = 'black';
portada.linewidth = 1; portada.linewidth = 1;
var contraportada = previewEC.makeRectangle( var contraportada = previewEC.makeRectangle(
origenEC.x - (anchoLibro / 2 + anchoCalle / 2 + sangradoValor), origenEC.x - (anchoLibro / 2 + anchoCalle / 2 + sangradoValor),
origenEC.y, origenEC.y,
@ -483,7 +491,7 @@ class previewFormas {
altoLibro); altoLibro);
contraportada.stroke = 'black'; contraportada.stroke = 'black';
contraportada.linewidth = 1; contraportada.linewidth = 1;
var calle = previewEC.makeRectangle( var calle = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -493,7 +501,7 @@ class previewFormas {
calle.dashes = [2, 5]; calle.dashes = [2, 5];
calle.fill = '#F4F8F2'; calle.fill = '#F4F8F2';
calle.linewidth = 1; calle.linewidth = 1;
// Cotas y textos // Cotas y textos
if (this.size != "thumbnail") { if (this.size != "thumbnail") {
// Cotas: // Cotas:
@ -532,8 +540,8 @@ class previewFormas {
origenEC.y - (altoLibro / 3), origenEC.y - (altoLibro / 3),
10); 10);
cotaPortada.linewidth = 2; cotaPortada.linewidth = 2;
// Textos: // Textos:
// Titulos generales // Titulos generales
let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' }; let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' };
@ -556,22 +564,22 @@ class previewFormas {
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;
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 // Cotas
previewEC.makeText(anchoLibro.toFixed(1) + " mm", origenEC.x - (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(this.ancho.toFixed(1) + " mm", origenEC.x - (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoLibro.toFixed(1) + " mm", origenEC.x + (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(this.ancho.toFixed(1) + " mm", origenEC.x + (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(altoLibro.toFixed(1) + " mm", origenEC.x + (anchoCalle / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2; previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (anchoCalle / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((altoLibro + (2 * sangradoValor)).toFixed(1) + " mm", previewEC.makeText((this.alto + (2 * sangradoValor)).toFixed(1) + " mm",
origenEC.x + (anchoSangrado / 2) + 30, origenEC.x + (anchoSangrado / 2) + 30,
origenEC.y, origenEC.y,
styleCotas styleCotas
).rotation = -Math.PI / 2; ).rotation = -Math.PI / 2;
previewEC.makeText(((2 * anchoLibro) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm", previewEC.makeText(((2 * this.ancho) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm",
origenEC.x, origenEC.x,
origenEC.y + (altoLibro / 2) + 50, origenEC.y + (altoLibro / 2) + 50,
styleCotas); styleCotas);
} }
previewEC.update(); previewEC.update();
} }
@ -582,10 +590,9 @@ class previewFormas {
let styleCotas = { size: 12, family: 'Public Sans' }; let styleCotas = { size: 12, family: 'Public Sans' };
let sangradoTexto = "Sangrado 5 mm"; let sangradoTexto = "Sangrado 5 mm";
let sangradoValor = parseFloat(5); // mm let sangradoValor = parseFloat(5); // mm
let offsetSolapaValor = parseFloat(0); // mm
// Definicion de los parametros del Esquema de Cubierta (EC) // Definicion de los parametros del Esquema de Cubierta (EC)
if (anchoSolapa == 0) { if (this.solapa == 0) {
if (this.size == "thumbnail") { if (this.size == "thumbnail") {
anchoSangrado = 350; // px anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
@ -598,7 +605,7 @@ class previewFormas {
anchoSolapa = 0; anchoSolapa = 0;
lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro; anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
} else { } else {
if (this.size == "thumbnail") { if (this.size == "thumbnail") {
anchoSangrado = 350; // px anchoSangrado = 350; // px
@ -613,11 +620,11 @@ class previewFormas {
lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro; anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
} }
var previewEC = new Two({ fitted: true }).appendTo(this.container[0]); var previewEC = new Two({ fitted: true }).appendTo(this.container[0]);
// Calculate the center of the canvas element // Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2); var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle( var sangrado = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -628,8 +635,8 @@ class previewFormas {
sangrado.dashes = [5, 5]; sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1'; sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1; sangrado.linewidth = 1;
if (anchoSolapa != 0) { if (this.solapa != 0) {
var solapas = previewEC.makeRectangle( var solapas = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -637,7 +644,7 @@ class previewFormas {
altoLibro); altoLibro);
solapas.stroke = 'black'; solapas.stroke = 'black';
solapas.linewidth = 1; solapas.linewidth = 1;
// Cotas y textos // Cotas y textos
if (this.size != "thumbnail") { if (this.size != "thumbnail") {
// Cotas // Cotas
@ -655,18 +662,18 @@ class previewFormas {
origenEC.y - (altoLibro / 3), origenEC.y - (altoLibro / 3),
10); 10);
cotaSolapa1.linewidth = 2; cotaSolapa1.linewidth = 2;
// Textos Solapas // Textos Solapas
let stylesSolapa = { size: 18, family: 'Public Sans' }; let stylesSolapa = { size: 18, family: 'Public Sans' };
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa); 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); previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas // Textos Cotas Solapas
previewEC.makeText(anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(this.solapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(this.solapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
} }
} }
var libro = previewEC.makeRectangle( var libro = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -674,7 +681,7 @@ class previewFormas {
altoLibro); altoLibro);
libro.stroke = 'black'; libro.stroke = 'black';
libro.linewidth = 1; libro.linewidth = 1;
var lomo = previewEC.makeRectangle( var lomo = previewEC.makeRectangle(
origenEC.x, origenEC.x,
origenEC.y, origenEC.y,
@ -683,7 +690,7 @@ class previewFormas {
lomo.stroke = 'black'; lomo.stroke = 'black';
lomo.fill = '#F4F8F2'; lomo.fill = '#F4F8F2';
lomo.linewidth = 1; lomo.linewidth = 1;
// Cotas y textos // Cotas y textos
if (this.size != "thumbnail") { if (this.size != "thumbnail") {
// Cotas: // Cotas:
@ -722,7 +729,7 @@ class previewFormas {
origenEC.y - (altoLibro / 3), origenEC.y - (altoLibro / 3),
10); 10);
cotaPortada.linewidth = 2; cotaPortada.linewidth = 2;
// Textos: // Textos:
// Titulos generales // Titulos generales
let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' }; let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' };
@ -735,460 +742,18 @@ class previewFormas {
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;
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 // Cotas
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(altoLibro.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2; previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(altoLibro.toFixed(1) + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2; previewEC.makeText(this.alto.toFixed(1) + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor)).toFixed(1) + " mm", previewEC.makeText(((2 * anchoLibro) + (2 * (this.solapa + this.offsetSolapa)) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm",
origenEC.x, origenEC.x,
origenEC.y + (altoLibro / 2) + 50, origenEC.y + (altoLibro / 2) + 50,
styleCotas); styleCotas);
} }
previewEC.update(); previewEC.update();
} }
} }
export default previewFormas; export default previewFormas;
/*
// 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 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 (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;
}
// 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 (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(anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(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(lomoLibro + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + 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); // 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 (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;
}
// 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 (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(anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(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(anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
}
previewEC.update();
}
*/