Merge branch 'dev/añadir_palets_cajas' into 'main'

Dev/añadir palets cajas

See merge request jjimenez/safekat!247
This commit is contained in:
2024-05-19 18:34:52 +00:00
39 changed files with 152055 additions and 905 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
ci4/.env
.vscode/
xdebug.log
./xdebug.log

8
.idea/safekat.iml generated
View File

@ -1,7 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/ci4/app" isTestSource="false" packagePrefix="App\" />
<sourceFolder url="file://$MODULE_DIR$/ci4/app/Config" isTestSource="false" packagePrefix="Config\" />
<sourceFolder url="file://$MODULE_DIR$/ci4/app/ThirdParty/DatatablesEditor/" isTestSource="false" packagePrefix="DataTables\" />
<sourceFolder url="file://$MODULE_DIR$/ci4/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/ci4/tests/_support" isTestSource="true" packagePrefix="Tests\Support\" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>

View File

@ -5,34 +5,34 @@ const SK_PERMISSION_MATRIX = [
"clientes.edit",
"clientes.delete",
"clientes.menu",
"plantillaTarifa.create",
"plantillaTarifa.edit",
"plantillaTarifa.delete",
"plantillaTarifa.menu",
"plantilla-tarifa.create",
"plantilla-tarifa.edit",
"plantilla-tarifa.delete",
"plantilla-tarifa.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.delete",
"presupuesto.menu",
"tarifaPreimpresion.create",
"tarifaPreimpresion.edit",
"tarifaPreimpresion.delete",
"tarifaPreimpresion.menu",
"tarifaManipulado.create",
"tarifaManipulado.edit",
"tarifaManipulado.delete",
"tarifaManipulado.menu",
"tarifaAcabado.create",
"tarifaAcabado.edit",
"tarifaAcabado.delete",
"tarifaAcabado.menu",
"tarifaEncuadernacion.create",
"tarifaEncuadernacion.edit",
"tarifaEncuadernacion.delete",
"tarifaEncuadernacion.menu",
"tarifaEnvio.create",
"tarifaEnvio.edit",
"tarifaEnvio.delete",
"tarifaEnvio.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
"tarifa-preimpresion.menu",
"tarifa-manipulado.create",
"tarifa-manipulado.edit",
"tarifa-manipulado.delete",
"tarifa-manipulado.menu",
"tarifa-acabado.create",
"tarifa-acabado.edit",
"tarifa-acabado.delete",
"tarifa-acabado.menu",
"tarifa-encuadernacion.create",
"tarifa-encuadernacion.edit",
"tarifa-encuadernacion.delete",
"tarifa-encuadernacion.menu",
"tarifa-envio.create",
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.delete",
@ -45,8 +45,36 @@ const SK_PERMISSION_MATRIX = [
"actividad.edit",
"actividad.delete",
"actividad.menu",
"paises.create",
"paises.edit",
"paises.delete",
"paises.menu",
"maquinas.create",
"maquinas.edit",
"maquinas.delete",
"maquinas.menu",
"maquinas-defecto.create",
"maquinas-defecto.edit",
"maquinas-defecto.delete",
"maquinas-defecto.menu",
"papel-generico.create",
"papel-generico.edit",
"papel-generico.delete",
"papel-generico.menu",
"papel-impresion.create",
"papel-impresion.edit",
"papel-impresion.delete",
"papel-impresion.menu",
"usuarios.create",
"usuarios.edit",
"usuarios.delete",
"usuarios.menu",
"roles-permisos.create",
"roles-permisos.edit",
"roles-permisos.delete",
"roles-permisos.menu",
],
"cliente" => [
"cliente-admin" => [
"clientes.create",
"clientes.edit",
"clientes.delete",
@ -56,6 +84,52 @@ const SK_PERMISSION_MATRIX = [
"presupuesto.delete",
"presupuesto.menu",
],
"cliente-editor" => [
"clientes.create",
"clientes.edit",
"clientes.delete",
"clientes.menu",
"plantilla-tarifa.create",
"plantilla-tarifa.edit",
"plantilla-tarifa.delete",
"plantilla-tarifa.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.delete",
"presupuesto.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
"tarifa-preimpresion.menu",
"tarifa-manipulado.create",
"tarifa-manipulado.edit",
"tarifa-manipulado.delete",
"tarifa-manipulado.menu",
"tarifa-acabado.create",
"tarifa-acabado.edit",
"tarifa-acabado.delete",
"tarifa-acabado.menu",
"tarifa-encuadernacion.create",
"tarifa-encuadernacion.edit",
"tarifa-encuadernacion.delete",
"tarifa-encuadernacion.menu",
"tarifa-envio.create",
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.delete",
"proveedores.menu",
"ajustes.create",
"ajustes.edit",
"ajustes.delete",
"ajustes.menu",
"actividad.create",
"actividad.edit",
"actividad.delete",
"actividad.menu",
],
"comercial" => [
"token.token",
"token.menu",
@ -86,4 +160,50 @@ const SK_PERMISSION_MATRIX = [
"Profile.index",
"Profile.menu",
],
"beta" => [
"clientes.create",
"clientes.edit",
"clientes.delete",
"clientes.menu",
"plantilla-tarifa.create",
"plantilla-tarifa.edit",
"plantilla-tarifa.delete",
"plantilla-tarifa.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.delete",
"presupuesto.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
"tarifa-preimpresion.menu",
"tarifa-manipulado.create",
"tarifa-manipulado.edit",
"tarifa-manipulado.delete",
"tarifa-manipulado.menu",
"tarifa-acabado.create",
"tarifa-acabado.edit",
"tarifa-acabado.delete",
"tarifa-acabado.menu",
"tarifa-encuadernacion.create",
"tarifa-encuadernacion.edit",
"tarifa-encuadernacion.delete",
"tarifa-encuadernacion.menu",
"tarifa-envio.create",
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.delete",
"proveedores.menu",
"ajustes.create",
"ajustes.edit",
"ajustes.delete",
"ajustes.menu",
"actividad.create",
"actividad.edit",
"actividad.delete",
"actividad.menu",
],
];

View File

@ -0,0 +1,28 @@
<?php
const SK_PERMISSION_MATRIX = [
"superadmin"=> [
"admin.*",
"users.*",
"beta.*"
],
"admin"=> [
"admin.access",
"users.create",
"users.edit",
"users.delete",
"beta.access"
],
"developer"=> [
"admin.access",
"admin.settings",
"users.create",
"users.edit",
"beta.access"
],
"user"=> [
"users.list"
],
"beta"=> [
"beta.access"
]
];

View File

@ -5,34 +5,34 @@ const SK_PERMISSIONS = [
'clientes.edit' => 'Can edit',
'clientes.delete' => 'Can delete',
'clientes.menu' => 'Menu shall be visualize',
'plantillaTarifa.create' => 'Can create',
'plantillaTarifa.edit' => 'Can edit',
'plantillaTarifa.delete' => 'Can delete',
'plantillaTarifa.menu' => 'Menu shall be visualize',
'plantilla-tarifa.create' => 'Can create',
'plantilla-tarifa.edit' => 'Can edit',
'plantilla-tarifa.delete' => 'Can delete',
'plantilla-tarifa.menu' => 'Menu shall be visualize',
'presupuesto.create' => 'Can create',
'presupuesto.edit' => 'Can edit',
'presupuesto.delete' => 'Can delete',
'presupuesto.menu' => 'Menu shall be visualize',
'tarifaPreimpresion.create' => 'Can create',
'tarifaPreimpresion.edit' => 'Can edit',
'tarifaPreimpresion.delete' => 'Can delete',
'tarifaPreimpresion.menu' => 'Menu shall be visualize',
'tarifaManipulado.create' => 'Can create',
'tarifaManipulado.edit' => 'Can edit',
'tarifaManipulado.delete' => 'Can delete',
'tarifaManipulado.menu' => 'Menu shall be visualize',
'tarifaAcabado.create' => 'Can create',
'tarifaAcabado.edit' => 'Can edit',
'tarifaAcabado.delete' => 'Can delete',
'tarifaAcabado.menu' => 'Menu shall be visualize',
'tarifaEncuadernacion.create' => 'Can create',
'tarifaEncuadernacion.edit' => 'Can edit',
'tarifaEncuadernacion.delete' => 'Can delete',
'tarifaEncuadernacion.menu' => 'Menu shall be visualize',
'tarifaEnvio.create' => 'Can create',
'tarifaEnvio.edit' => 'Can edit',
'tarifaEnvio.delete' => 'Can delete',
'tarifaEnvio.menu' => 'Menu shall be visualize',
'tarifa-preimpresion.create' => 'Can create',
'tarifa-preimpresion.edit' => 'Can edit',
'tarifa-preimpresion.delete' => 'Can delete',
'tarifa-preimpresion.menu' => 'Menu shall be visualize',
'tarifa-manipulado.create' => 'Can create',
'tarifa-manipulado.edit' => 'Can edit',
'tarifa-manipulado.delete' => 'Can delete',
'tarifa-manipulado.menu' => 'Menu shall be visualize',
'tarifa-acabado.create' => 'Can create',
'tarifa-acabado.edit' => 'Can edit',
'tarifa-acabado.delete' => 'Can delete',
'tarifa-acabado.menu' => 'Menu shall be visualize',
'tarifa-encuadernacion.create' => 'Can create',
'tarifa-encuadernacion.edit' => 'Can edit',
'tarifa-encuadernacion.delete' => 'Can delete',
'tarifa-encuadernacion.menu' => 'Menu shall be visualize',
'tarifa-envio.create' => 'Can create',
'tarifa-envio.edit' => 'Can edit',
'tarifa-envio.delete' => 'Can delete',
'tarifa-envio.menu' => 'Menu shall be visualize',
'proveedores.create' => 'Can create',
'proveedores.edit' => 'Can edit',
'proveedores.delete' => 'Can delete',
@ -45,4 +45,32 @@ const SK_PERMISSIONS = [
'actividad.edit' => 'Can edit',
'actividad.delete' => 'Can delete',
'actividad.menu' => 'Menu shall be visualize',
'paises.create' => 'Can create',
'paises.edit' => 'Can edit',
'paises.delete' => 'Can delete',
'paises.menu' => 'Menu shall be visualize',
'maquinas.create' => 'Can create',
'maquinas.edit' => 'Can edit',
'maquinas.delete' => 'Can delete',
'maquinas.menu' => 'Menu shall be visualize',
'maquinas-defecto.create' => 'Can create',
'maquinas-defecto.edit' => 'Can edit',
'maquinas-defecto.delete' => 'Can delete',
'maquinas-defecto.menu' => 'Menu shall be visualize',
'papel-generico.create' => 'Can create',
'papel-generico.edit' => 'Can edit',
'papel-generico.delete' => 'Can delete',
'papel-generico.menu' => 'Menu shall be visualize',
'papel-impresion.create' => 'Can create',
'papel-impresion.edit' => 'Can edit',
'papel-impresion.delete' => 'Can delete',
'papel-impresion.menu' => 'Menu shall be visualize',
'usuarios.create' => 'Can create',
'usuarios.edit' => 'Can edit',
'usuarios.delete' => 'Can delete',
'usuarios.menu' => 'Menu shall be visualize',
'roles-permisos.create' => 'Can create',
'roles-permisos.edit' => 'Can edit',
'roles-permisos.delete' => 'Can delete',
'roles-permisos.menu' => 'Menu shall be visualize',
];

View File

@ -0,0 +1,11 @@
<?php
const SK_PERMISSIONS = [
'admin.access' => 'Can access the sites admin area',
'admin.settings' => 'Can access the main site settings',
'users.manage-admins' => 'Can manage other admins',
'users.list' => 'Can list user stuff',
'users.create' => 'Can create new non-admin users',
'users.edit' => 'Can edit existing non-admin users',
'users.delete' => 'Can delete existing non-admin users',
'beta.access' => 'Can access beta-level features',
];

View File

@ -0,0 +1,22 @@
{
"superadmin": {
"title": "Super Admin",
"description": "Complete control of the site."
},
"admin": {
"title": "Admin",
"description": "Day to day administrators of the site."
},
"developer": {
"title": "Developer",
"description": "Site programmers."
},
"user": {
"title": "User",
"description": "General users of the site. Often customers."
},
"beta": {
"title": "Beta User",
"description": "Has access to beta-level features."
}
}

View File

@ -3,12 +3,16 @@
const SK_ROLES = [
'admin' => [
'title' => 'Administrador',
'description' => 'Describeme',
],
'cliente' => [
'title' => 'Cliente',
'description' => '',
],
'cliente-admin' => [
'title' => 'Cliente administrador',
'description' => 'Rol de cliente con permisos de administración',
],
'cliente-editor' => [
'title' => 'Cliente editor',
'description' => 'Rol de cliente con permisos de edición',
],
'comercial' => [
'title' => 'Comercial',
'description' => '',
@ -37,4 +41,8 @@ const SK_ROLES = [
'title' => 'Editor',
'description' => '',
],
'beta' => [
'title' => 'Beta',
'description' => '',
],
];

View File

@ -0,0 +1,23 @@
<?php
const SK_ROLES = [
'superadmin' => [
'title' => 'Super Admin',
'description' => 'Complete control of the site.',
],
'admin' => [
'title' => 'Admin',
'description' => 'Day to day administrators of the site.',
],
'developer' => [
'title' => 'Developer',
'description' => 'Site programmers.',
],
'user' => [
'title' => 'User',
'description' => 'General users of the site. Often customers.',
],
'beta' => [
'title' => 'Beta User',
'description' => 'Has access to beta-level features.',
],
];

View File

@ -534,16 +534,17 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
$routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
$routes->get('list/(:num)', 'Presupuestocliente::list/$1', ['as' => 'listarPresupuestoCliente']); // HOMOGENIZAR CON ARGS DINAMICOS!!!
$routes->get('list', 'Presupuestocliente::list', ['as' => 'listaPresupuestos']);
$routes->post('datatable', 'Presupuestocliente::datatable', ['as' => 'datatableOfPresupuestos']);
$routes->get('add', 'Presupuestocliente::add', ['as' => 'nuevoPresupuestoCliente']);
$routes->post('add', 'Presupuestocliente::add', ['as' => 'crearPresupuestoCliente']);
$routes->post('edit/(:num)', 'Presupuestocliente::edit/$1', ['as' => 'editarPresupuestoCliente']);
$routes->post('datatable', 'Cosidotapablanda::datatable', ['as' => 'tablaPresupuestosCliente']);
$routes->post('getgramaje', 'Presupuestocliente::getGramaje', ['as' => 'obtenerGramaje']);
$routes->post('presupuesto', 'Presupuestocliente::presupuesto', ['as' => 'presupuestoCliente']);
$routes->post('getDireccionesCliente', 'Presupuestocliente::getDireccionesCliente', ['as' => 'getDirecciones']);
$routes->post('getDatosDireccion', 'Presupuestocliente::getDatosDireccion', ['as' => 'getDatosDireccion']);
$routes->post('getNuevaDireccion', 'Presupuestocliente::getNuevaDireccion', ['as' => 'nuevaDireccion']);
$routes->post('guardarPresupuesto', 'Presupuestocliente::guardarPresupuesto', ['as' => 'guardarPresupuesto']);
});
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);

View File

@ -111,5 +111,11 @@ class Js_loader extends BaseController
$this->response->setHeader('Content-Type', 'text/javascript');
return view('themes/vuexy/form/presupuestos/cliente/resumen.js');
}
function presupuestoClientePreview_js()
{
$this->response->setHeader('Content-Type', 'text/javascript');
return view('themes/vuexy/form/presupuestos/cliente/previews.js');
}
}

View File

@ -97,11 +97,11 @@ class Buscador extends \App\Controllers\BaseResourceController
$order1 = PresupuestoModel::SORTABLE[$requestedOrder1 >= 0 ? $requestedOrder1 : 0];
$dir1 = $reqData['order']['0']['dir'] ?? 'asc';
$requestedOrder2 = $reqData['order']['1']['column'] ?? 0;
$order2 = PresupuestoModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder1 : 0];
$dir2 = $reqData['order']['0']['dir'] ?? 'asc';
$order2 = PresupuestoModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder2 : 0];
$dir2 = $reqData['order']['1']['dir'] ?? 'asc';
$requestedOrder3 = $reqData['order']['2']['column'] ?? 0;
$order3 = PresupuestoModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder1 : 0];
$dir3 = $reqData['order']['0']['dir'] ?? 'asc';
$order3 = PresupuestoModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder3 : 0];
$dir3 = $reqData['order']['2']['dir'] ?? 'asc';
$searchValues = get_filter_datatables_columns($reqData);

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
"id" => null,
"presupuesto_id" => null,
"tarifa_encuadernado_id" => null,
"proveedor_id" => null,
"precio_unidad" => null,
"tiempo" => null,
"precio_total" => null,
@ -19,6 +20,7 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
protected $casts = [
"presupuesto_id" => "int",
"tarifa_encuadernado_id" => "int",
"proveedor_id" => "int",
"precio_unidad" => "float",
"tiempo" => "float",
"precio_total" => "float",

View File

@ -85,6 +85,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
"total_precio_unidad" => null,
"total_factor" => null,
"total_factor_ponderado" => null,
'total_aceptado' => null,
'iva_reducido' => null,
"acabado_cubierta_id" => null,
"acabado_sobrecubierta_id" => null,
"is_duplicado" => false,
@ -124,7 +126,6 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
"merma_cubierta" => "float",
"lomo_cubierta" => "?float",
"lomo_sobrecubierta" => "?float",
"total_presupuesto" => "?float",
"envios_recoge_cliente" => "boolean",
"aprobado_user_id" => "?int",
"is_deleted" => "int",
@ -148,6 +149,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
"total_precio_unidad" => "?float",
"total_factor" => "?float",
"total_factor_ponderado" => "?float",
'total_aceptado' => "?float",
'iva_reducido' => "?boolean",
"acabado_cubierta_id" => "int",
"acabado_sobrecubierta_id" => "int",
"is_duplicado" => "boolean",

View File

@ -19,6 +19,7 @@ return [
'presupuestoCosidotapaduraList' => 'Lista presupuestos Libros Cosido Tapa Dura',
'presupuestoCosidotapablandaList' => 'Lista presupuestos Libros Cosido Tapa Blanda',
'presupuesto' => 'Presupuesto',
'presupuestos' => 'Presupuestos',
'libroCosidoTapaBlanda' => "Cosido Tapa Blanda",
'libroCosidoTapaDura' => "Cosido Tapa Dura",

View File

@ -21,7 +21,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
4 => "t1.precio_total"
];
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "nombre", "precio_total", "precio_unidad", "margen"];
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "proveedor_id", "nombre", "precio_total", "precio_unidad", "tiempo", "margen"];
protected $returnType = "App\Entities\Presupuestos\PresupuestoEncuadernacionesEntity";
protected $useTimestamps = true;

View File

@ -12,7 +12,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
* @var bool
*/
protected $useAutoIncrement = true;
protected $allowedFields = [
"presupuesto_id",
"tipo",
@ -339,18 +339,18 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
public function updatePreciosLineasPresupuesto($id_linea, $new_linea)
{
$rot_total_impresion = $new_linea['fields']['precio_click_pedido']??0.0 +
$new_linea['fields']['precio_tinta']??0.0+$new_linea['fields']['total_Corte']??0.0;
$rot_total_impresion = $new_linea['fields']['precio_click_pedido'] ?? 0.0 +
$new_linea['fields']['precio_tinta'] ?? 0.0 + $new_linea['fields']['total_Corte'] ?? 0.0;
$data = [
"pliegos_precio" => $new_linea['fields']['precios_pliegos'],
"libro" => $new_linea['fields']['precio_libro'],
"total_papel_pedido" => round($new_linea['fields']['precio_pedido'], 2),
"margen_papel_pedido" => round($new_linea['fields']['margen_papel_pedido'], 2),
"mano" => $new_linea['fields']['mano'],
"precio_click" => round($new_linea['fields']['precio_click'], 6),
"precio_click_pedido" => round($new_linea['fields']['precio_click_pedido'], 2),
"margen_click_pedido" => round($new_linea['fields']['margen_click_pedido'], 2),
"precio_click" => round($new_linea['fields']['precio_click'], 6),
"precio_click_pedido" => round($new_linea['fields']['precio_click_pedido'], 2),
"margen_click_pedido" => round($new_linea['fields']['margen_click_pedido'], 2),
"tiempo_maquina" => strtotime($new_linea['fields']['tiempo_maquina']) - strtotime('TODAY'),
"tarifa_impresion_id" => $new_linea['fields']['tarifa_impresion_id'],
"rotativa_total_impresion" => $rot_total_impresion,
@ -387,16 +387,16 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
"rotativa_tiempo_corte" => $new_linea['fields']['tiempo_corte'] ?? 0,
"rotativa_precio_hora_corte" => $new_linea['fields']['precio_hora_corte'] ?? 0,
"rotativa_total_corte" => $new_linea['fields']['total_corte'] ?? 0,
"horas_maquina" => round($new_linea['fields']['horas_maquina'],4),
"horas_maquina" => round($new_linea['fields']['horas_maquina'], 4),
"precio_hora" => $new_linea['fields']['precio_hora'] ?? 0,
"precio_impresion" => $new_linea['fields']['precio_impresion_horas'] ?? 0,
"total_linea" => round($new_linea['fields']['total_impresion'], 2) ?? 0,
"margen_impresion" => $new_linea['fields']['margen_impresion_horas'] ?? 0,
];
if(array_key_exists('datosTipologias', $new_linea['fields'])){
if (array_key_exists('datosTipologias', $new_linea['fields'])) {
$data += [
"rotativa_negro" => $new_linea['fields']['datosTipologias']->negro ?? 0,
"rotativa_negro" => $new_linea['fields']['datosTipologias']->negro ?? 0,
"rotativa_cyan" => $new_linea['fields']['datosTipologias']->cyan ?? 0,
"rotativa_magenta" => $new_linea['fields']['datosTipologias']->magenta ?? 0,
"rotativa_amarillo" => $new_linea['fields']['datosTipologias']->amarillo ?? 0,
@ -404,7 +404,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
"rotativa_gota_negro" => $new_linea['fields']['datosTipologias']->gota_negro ?? 0,
"rotativa_gota_color" => $new_linea['fields']['datosTipologias']->gota_color
];
}
}
$this->db
->table($this->table . " t1")
->where('id', $id_linea)
@ -412,6 +412,124 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
->update();
}
public function insertLPFromBackend($presupuesto_id, $new_linea)
{
$rot_total_impresion = $new_linea['precio_click_pedido'] ?? 0.0 +
$new_linea['precio_tinta'] ?? 0.0 + $new_linea['total_Corte'] ?? 0.0;
$formas = json_encode(array(
'maquina_ancho'=> $new_linea['dimensiones_maquina'][0],
'maquina_alto' => $new_linea['dimensiones_maquina'][1],
'maquina_impresion_ancho'=> $new_linea['dimensiones_maquina_impresion'][0],
'maquina_impresion_alto' => $new_linea['dimensiones_maquina_impresion'][1],
'formas' => $new_linea['num_formas']['value'],
'formas_v'=> $new_linea['num_formas']['num_formas_verticales'],
'formas_h'=> $new_linea['num_formas']['num_formas_horizontales'],
'formas_orientacion'=> $new_linea['num_formas']['posicion_formas']
));
sscanf($new_linea['tiempo_maquina'], "%d:%d:%d", $hours, $minutes, $seconds);
$tiempo = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
$data = [
'presupuesto_id' => $presupuesto_id,
'tipo' => $new_linea['tipo_linea'],
'paginas' => $new_linea['paginas'],
'papel_id' => $new_linea['papel_generico_id'],
'papel_impresion_id' => $new_linea['papel_impresion_id'],
'formas' => $formas,
'gramaje' => $new_linea['gramaje'],
'pliegos_libro' => $new_linea['pliegos_libro'],
'pliegos_pedido' => $new_linea['pliegos_pedido'],
'pliegos_precio' => $new_linea['precios_pliegos'],
'libro' => $new_linea['precio_libro'],
'total_papel_pedido' => $new_linea['precio_pedido'],
'margen_papel_pedido' => $new_linea['margen_papel_pedido'],
'mano' => $new_linea['mano'],
'peso' => $new_linea['peso'],
'check_papel_total' => 1,
'check_impresion_total' => 1,
'maquina_id' => $new_linea['maquina_id'],
'tiempo_maquina' => $tiempo,
'tarifa_impresion_id' => $new_linea['tarifa_impresion_id'],
'precio_click' => $new_linea['precio_click'],
'precio_click_pedido' => $new_linea['precio_click_pedido'],
'maquina' => $new_linea['maquina'],
'papel_impresion' => $new_linea['papel_impresion'],
'maquina_tipo' => $new_linea['tipo_maquina'],
'horas_maquina' => $new_linea['horas_maquina'],
'precio_hora' => $new_linea['precio_hora'],
'precio_impresion' => $new_linea['precio_impresion_horas'],
'total_linea' => $new_linea['total_impresion'],
'margen_impresion' => $new_linea['margen_impresion_horas'],
'margen_click_pedido' => $new_linea['margen_click_pedido'],
];
if($new_linea['tipo_maquina'] =='inkjet'){
$data += [
'rotativa_total_impresion' => $rot_total_impresion,
'rotativa_negro' => $new_linea['datosTipologias']->negro ?? 0,
'rotativa_cyan' => $new_linea['datosTipologias']->cyan ?? 0,
'rotativa_magenta' => $new_linea['datosTipologias']->magenta ?? 0,
'rotativa_amarillo' => $new_linea['datosTipologias']->amarillo ?? 0,
'rotativa_cg' => $new_linea['datosTipologias']->cg ?? 0,
'rotativa_gota_negro' => $new_linea['datosTipologias']->gota_negro ?? 0,
'rotativa_gota_color' => $new_linea['datosTipologias']->gota_color ?? 0,
'rotativa_num_gotas_negro' => $new_linea['num_gotas_negro'] ?? 0,
'rotativa_num_gotas_cyan' => $new_linea['num_gotas_cyan'] ?? 0,
'rotativa_num_gotas_magenta' => $new_linea['num_gotas_magenta'] ?? 0,
'rotativa_num_gotas_amarillo' => $new_linea['num_gotas_amarillo'] ?? 0,
'rotativa_num_gotas_cg' => $new_linea['num_gotas_cg'] ?? 0,
'rotativa_peso_gotas_negro' => $new_linea['peso_gotas_negro'] ?? 0,
'rotativa_peso_gotas_cyan' => $new_linea['peso_gotas_cyan'] ?? 0,
'rotativa_peso_gotas_magenta' => $new_linea['peso_gotas_magenta'] ?? 0,
'rotativa_peso_gotas_amarillo' => $new_linea['peso_gotas_amarillo'] ?? 0,
'rotativa_peso_gotas_cg' => $new_linea['peso_gotas_cg'] ?? 0,
'rotativa_peso_gotas_negro_pedido' => $new_linea['peso_gotas_negro_pedido'] ?? 0,
'rotativa_peso_gotas_cyan_pedido' => $new_linea['peso_gotas_cyan_pedido'] ?? 0,
'rotativa_peso_gotas_magenta_pedido' => $new_linea['peso_gotas_magenta_pedido'] ?? 0,
'rotativa_peso_gotas_amarillo_pedido' => $new_linea['peso_gotas_amarillo_pedido'] ?? 0,
'rotativa_peso_gotas_cg_pedido' => $new_linea['peso_gotas_cg_pedido'] ?? 0,
'rotativa_pag_color' => $new_linea['paginas_color'],
'rotativa_resolucion' => $new_linea['resolucion'],
'rotativa_area_paginas' => $new_linea['superficie'],
'rotativa_precio_pag_negro' => $new_linea['precio_pagina_negro'],
'rotativa_precio_pag_color' => $new_linea['precio_pagina_color'],
'rotativa_factor_altura' => $new_linea['factor_altura'],
'rotativa_factor_anchura' => $new_linea['factor_anchura'],
'rotativa_pag_por_pliego' => $new_linea['paginas_por_pliego'],
'rotativa_clicks_libro' => $new_linea['clicks_libro'],
'rotativa_clicks_total' => $new_linea['clicks_pedido'],
'rotativa_precio_tinta' => $new_linea['precio_tinta'],
];
}
if (strpos($new_linea['tipo_linea'], 'rot') !== false) {
$data += [
'rotativa_mxm' => $new_linea['maquina_velocidad'],
'rotativa_metros_libro' => $new_linea['metros_papel_libro'],
'rotativa_metros_total' => $new_linea['metros_papel_total'],
'rotativa_velocidad_corte' => $new_linea['velocidad_corte'],
'rotativa_precio_hora_corte' => $new_linea['precio_hora_corte'],
'rotativa_tiempo_corte' => $new_linea['tiempo_corte'],
'rotativa_total_corte' => $new_linea['total_corte'],
'rotativa_a_favor_fibra' => $new_linea['a_favor_fibra']
];
}
if($new_linea['tipo_linea'] =='lp_guardas')
array_push($data, ['paginas_impresion' => $new_linea['paginas_impresion']]);
return $this->db
->table($this->table . " t1")
->set($data)
->insert();
}
public function deleteLineasPresupuesto($presupuesto_id)
{
$this->db
@ -431,7 +549,6 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
->where("t1.presupuesto_id", $presupuesto_id)
->insert($linea);
}
}
public function getResourceByNForPdf($presupuesto_id = -1)
@ -498,9 +615,4 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
->insert($linea);
}
}
}

View File

@ -2,6 +2,9 @@
namespace App\Models\Presupuestos;
use App\Models\Configuracion\TipoPresupuestoModel;
class PresupuestoModel extends \App\Models\BaseModel
{
protected $table = "presupuestos";
@ -27,6 +30,20 @@ class PresupuestoModel extends \App\Models\BaseModel
10 => "t6.estado",
];
const SORTABLE_CLIENTE = [
0 => "t1.id",
1 => "t1.created_at",
2 => "t7.codigo",
3 => "t2.nombre",
4 => "t3.first_name",
5 => "t1.titulo",
6 => "t5.nombre",
8 => "t1.paginas",
9 => "t1.tirada",
10 => "t1.total_presupuesto",
11 => "t6.estado",
];
protected $allowedFields = [
"cliente_id",
"user_created_id",
@ -103,6 +120,8 @@ class PresupuestoModel extends \App\Models\BaseModel
"total_precio_unidad",
"total_factor",
"total_factor_ponderado",
'total_aceptado',
'iva_reducido',
"acabado_cubierta_id",
"acabado_sobrecubierta_id",
"is_duplicado"
@ -262,10 +281,10 @@ class PresupuestoModel extends \App\Models\BaseModel
$builder->groupEnd();
return $builder;
}
}
public function removeIsDuplicado($presupuesto_id){
public function removeIsDuplicado($presupuesto_id)
{
$this->db
->table($this->table . " t1")
->where('id', $presupuesto_id)
@ -307,4 +326,207 @@ class PresupuestoModel extends \App\Models\BaseModel
return $builder;
}
function getListaPresupuestosCliente($search = [] , $clienteId){
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.created_at AS fecha, t7.codigo as codigo, t2.nombre AS cliente,
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t1.titulo AS titulo,
t5.nombre AS pais, t1.inc_rei AS inc_rei, t1.paginas AS paginas, t1.tirada AS tirada,
t1.total_presupuesto AS total_presupuesto, t1.total_presupuesto AS total_presupuesto,
t6.estado AS estado"
);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
$builder->join("users t3", "t1.user_update_id = t3.id", "left");
$builder->join("lg_paises t5", "t1.pais_id = t5.id", "left");
$builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left");
$builder->join("tipos_presupuestos t7", "t1.tipo_impresion_id = t7.id", "left");
if($clienteId != 0)
$builder->where("t1.cliente_id", $clienteId);
$builder->where("t1.is_deleted", 0);
if (empty($search))
return $builder;
else {
$builder->groupStart();
foreach ($search as $col_search) {
if ($col_search[0] != 1)
$builder->like(self::SORTABLE_CLIENTE[$col_search[0]], $col_search[2]);
else {
$dates = explode(" ", $col_search[2]);
$builder->where(self::SORTABLE_CLIENTE[$col_search[0]] . ">=", $dates[0]);
$builder->where(self::SORTABLE_CLIENTE[$col_search[0]] . "<=", $dates[1]);
}
}
$builder->groupEnd();
return $builder;
}
}
function confirmarPresupuesto($presupuesto_id)
{
$this->db
->table($this->table . " t1")
->where('t1.id', $presupuesto_id)
->set('t1.estado', 2)
->update();
}
function insertarPresupuestoCliente($tirada, $data, $data_cabecera, $extra_info, $resumen_totales, $iva_reducido, $tiradas_alternativas)
{
helper('date');
$model = model('App\Models\Configuracion\PapelFormatoModel');
$papel_formato_id = $model->where('ancho', $data['tamanio']['ancho'])->where('alto', $data['tamanio']['alto'])->first();
$is_cosido = (new TipoPresupuestoModel())->get_isCosido($data['tipo_impresion_id']);
$totalCostes = $resumen_totales['totalPapel'] + $resumen_totales['totalImpresion'] +
$resumen_totales['totalServicios']+$resumen_totales['coste_envio'];
$totalMargenes = $resumen_totales['margenPapel'] + $resumen_totales['margenImpresion'] +
$resumen_totales['margenServicios'] + $resumen_totales['margen_envio'];
$fields = [
'cliente_id' => $data['clienteId'],
'tipo_impresion_id' => $data['tipo_impresion_id'],
'pais_id' => 1,
'retractilado' => in_array(3, $data['servicios']) ? 1 : 0,
'retractilado5' => in_array(5, $data['servicios']) ? 1 : 0,
'guardas' => in_array(62, $data['servicios']) ? 1 : 0,
'faja_color' => in_array(16, $data['servicios']) ? 1 : 0,
'ferro' => in_array(24, $data['servicios']) ? 1 : 0,
'prototipo' => in_array(9, $data['servicios']) ? 1 : 0,
'papel_formato_id' => is_null($papel_formato_id) ? 0: $papel_formato_id->id,
'papel_formato_personalizado' => !$papel_formato_id ? 1:0,
'papel_formato_ancho' => !$papel_formato_id ? $data['tamanio']['ancho']:null,
'papel_formato_alto' => !$papel_formato_id ? $data['tamanio']['alto']:null,
'titulo' => $data_cabecera['titulo'],
'referencia_cliente' => $data_cabecera['referenciaCliente'],
'paginas' => $data['interior']['paginas'],
'tirada' => $tirada,
'solapas' => $data['cubierta']['solapasCubierta']>0 ? 1 : 0,
'solapas_ancho' => $data['cubierta']['solapasCubierta']>0 ? $data['cubierta']['solapasCubierta'] : 0,
'solapas_sobrecubierta' => is_null($data['sobrecubierta']) ? 0 :1,
'solapas_ancho_sobrecubierta' => is_null($data['sobrecubierta']) ? 0 : $data['sobrecubierta']['solapas'],
'cosido' => $is_cosido,
'merma' => $extra_info['merma'],
'merma_cubierta' => $extra_info['merma'],
'lomo_cubierta' => $extra_info['lomo_cubierta'],
'lomo_sobrecubierta' => $extra_info['lomo_sobrecubierta'],
'comparador_json_data' => $this->generateJson($data),
'acabado_cubierta_id' => $data['acabadoCubierta'],
'acabado_sobrecubierta_id' => is_null($data['sobrecubierta']) ? 0 : $data['sobrecubierta']['acabado'],
'comp_tipo_impresion' => $data['isHq']? ($data['isColor']? 'colorhq':'negrohq'):($data['isColor']? 'color':'negro'),
'user_created_id' => $extra_info['user_id'],
'created_at' => date('Y-m-d H:i:s', now()),
'updated_at' => date('Y-m-d H:i:s', now()),
'tirada_alternativa_json_data' => json_encode($tiradas_alternativas),
'total_coste_papel' => round($resumen_totales['totalPapel'], 2),
'total_margen_papel' => round($resumen_totales['margenPapel'], 2),
'total_margenPercent_papel' => round($resumen_totales['porcentajeMargenPapel'], 0),
'total_coste_impresion' => round($resumen_totales['totalImpresion'], 2),
'total_margen_impresion' => round($resumen_totales['margenImpresion'], 2),
'total_margenPercent_impresion' => round($resumen_totales['porcentajeMargenImpresion'], 0),
'total_coste_servicios' => round($resumen_totales['totalServicios'], 2),
'total_margen_servicios' => round($resumen_totales['margenServicios'], 2),
'total_margenPercent_servicios' => round($resumen_totales['porcentajeMargenServicios'], 2),
'total_coste_envios' => round($resumen_totales['coste_envio'], 2),
'total_margen_envios' => round($resumen_totales['margen_envio'], 2),
'total_costes' => round($totalCostes, 2),
'total_margenes' => round($totalMargenes, 2),
'total_antes_descuento' => round($totalCostes + $totalMargenes, 2),
'total_descuento' => 0,
'total_descuentoPercent' => 0,
'total_precio_unidad' => round(($totalCostes + $totalMargenes)/$tirada, 4),
'total_presupuesto' => round($totalCostes + $totalMargenes, 2),
'total_aceptado' => round($totalCostes + $totalMargenes, 2),
'total_factor' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactor'], 2),
'total_factor_ponderado' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactorPonderado'], 2),
'iva_reducido' => $iva_reducido,
];
$this->db->table($this->table)->insert($fields);
return $this->db->insertID();
}
private function generateJson($data)
{
$values = array();
if (is_array($data)) {
// -- INTERIOR --
// Si hay negro
if($data['interior']['paginas'] > $data['interior']['paginas_color']){
if($data['isHq'])
$key = 'bnhq';
else
$key = 'bn';
$values[$key] = array(
'paginas'=> intval($data['interior']['paginas'])-intval($data['interior']['paginas_color']),
'papel_id' => intval($data['interior']['papel_generico']['id']),
'gramaje' => intval($data['interior']['gramaje']),
);
}
// Si hay color
if($data['interior']['paginas_color']>0){
if($data['isHq'])
$key = 'colorhq';
else
$key = 'color';
$values[$key] = array(
'paginas'=> intval($data['interior']['paginas_color']),
'papel_id' => intval($data['interior']['papel_generico']['id']),
'gramaje' => intval($data['interior']['gramaje']),
);
}
// -- CUBIERTA --
$values['cubierta'] = array(
'papel_id' => intval($data['cubierta']['papel_generico_cubierta']['id']),
'gramaje' => intval($data['cubierta']['gramajeCubierta']),
'paginas' => intval($data['cubierta']['carasCubierta']),
);
// -- SOBRECUBIERTA --
if(!is_null($data['sobrecubierta'])){
$values['sobrecubierta'] = array(
'papel_id' => intval($data['sobrecubierta']['papel']),
'gramaje' => intval($data['sobrecubierta']['gramaje']),
'imprimir' => 1,
);
}
// -- GUARDAS --
if($data['datos_guardas'] != 0){
$values['guardas'] = array(
'papel_id' => intval($data['datos_guardas']['papel']),
'gramaje' => intval($data['datos_guardas']['gramaje']),
'paginas' => intval($data['datos_guardas']['caras']),
);
}
}
$json = json_encode($values);
return $json;
}
}

View File

@ -19,7 +19,7 @@ class PresupuestoServiciosExtraModel extends \App\Models\BaseModel
2 => "t1.precio_total"
];
protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "nombre", "precio_total", "precio_unidad", "margen"];
protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "precio_total", "precio_unidad", "margen"];
protected $returnType = "App\Entities\Presupuestos\PresupuestoServiciosExtraEntity";
protected $useTimestamps = true;

View File

@ -41,7 +41,7 @@ class PresupuestoClienteService extends BaseService
}
$total_rotativa = -1;
if (!$data['excluirRotativa'] && count($rotativa) > 0) {
if (!$data['excluirRotativa'] && count($rotativa) > 0 && $rotativa['num_formas']['posicion_formas'] != 'n/a') {
$total_rotativa = floatval($rotativa['total_impresion']);
}
if ($total_plana < 0 && $total_rotativa < 0)

View File

@ -1117,7 +1117,7 @@ class PresupuestoService extends BaseService
if( str_contains($linea->tipo, 'guardas') ){
$datos['uso'] = 'guardas';
$datos['datosPedido']->paginas_impresion = linea->paginas_impresion;
$datos['datosPedido']->paginas_impresion = $linea->paginas_impresion;
}
$comp_data = PresupuestoService::obtenerComparadorPlana($datos);
@ -1138,7 +1138,7 @@ class PresupuestoService extends BaseService
else{
$nueva_linea = PresupuestoService::obtenerValorLineaPresupuesto($data, $linea);
if(count($nueva_linea) >0){
if(round($nueva_linea['fields']['total_impresion'],2) != $linea->total_linea){
if(round($nueva_linea['fields']['total_impresion'],2) != round($linea->total_linea, 2)){
(new PresupuestoLineaModel())->updatePreciosLineasPresupuesto($linea->id, $nueva_linea);
$linea_to_save = (new PresupuestoLineaModel())->find($linea->id);
$cambios = true;
@ -1355,7 +1355,7 @@ class PresupuestoService extends BaseService
$nueva_tarifa = $model->getPrecioTarifa($servicio->tarifa_acabado_id, $input_data['tirada'], $input_data['POD']);
if($nueva_tarifa && count($nueva_tarifa)>0){
if(round($nueva_tarifa[0]->precio_unidad, 2) != $servicio->precio_unidad ||
if(round($nueva_tarifa[0]->precio_unidad, 2) != round($servicio->precio_unidad,2) ||
$nueva_tarifa[0]->margen != $servicio->margen){
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
@ -1386,7 +1386,7 @@ class PresupuestoService extends BaseService
$count = 0;
$nueva_tarifa = $model->getPrecioTarifa($servicio->tarifa_manipulado_id, $input_data['tirada'], $input_data['POD']);
if($nueva_tarifa && count($nueva_tarifa)>0){
if(round($nueva_tarifa[0]->precio_unidad, 2) != $servicio->precio_unidad ||
if(round($nueva_tarifa[0]->precio_unidad, 2) != round($servicio->precio_unidad,2) ||
$nueva_tarifa[0]->margen != $servicio->margen){
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
@ -1468,12 +1468,16 @@ class PresupuestoService extends BaseService
}
// Si el presupuesto no es duplicado, se comprueba que
// no ha cambiado el precio unidad
if(round($nueva_tarifa[0]->precio_unidad, 2) != $servicio->precio_unidad ||
$nueva_tarifa[0]->margen != $servicio->margen ||
$nueva_tarifa[0]->tiempo != $servicio->tiempo){
if($nueva_tarifa[0]->tiempo==null)
$nueva_tarifa[0]->tiempo = 0;
if($servicio->tiempo == null)
$servicio->tiempo = 0;
if(round($nueva_tarifa[0]->precio_unidad, 2) != round(floatval($servicio->precio_unidad),2) ||
$nueva_tarifa[0]->margen != floatval($servicio->margen) ||
$nueva_tarifa[0]->tiempo != floatval($servicio->tiempo)){
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
$servicio->tiempo = $nueva_tarifa[0]->tiempo==null?"": round($nueva_tarifa[0]->tiempo, 2);
$servicio->tiempo = $nueva_tarifa[0]->tiempo==null?0: round($nueva_tarifa[0]->tiempo, 2);
$servicio->precio_total = round($nueva_tarifa[0]->total, 2);
$servicio->margen = round($nueva_tarifa[0]->margen);
$cambio = true;

View File

@ -1,11 +1,8 @@
<div class="col-12 pb-2">
<div id="containerTiradasEnvios" class="row mb-3">
</div>
<div class="row mb-3">
<div class="col-sm-4 mb-3">
@ -22,12 +19,20 @@
<button id="insertarDireccion" type="button" class="btn btn-secondary waves-effect waves-light">Insertar</button>
</div>
<div id="errorDirecciones" class="fv-plugins-message-container invalid-feedback" style="display: none;">
</div>
</div>
<div class="row mb-3">
<div class="col-sm-4 mb-3">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="entregaPieCalle" name="entregaPieCalle" value="1">
<label class="form-check-label" for="add_entregaPieCalle"><?= lang('PresupuestosDirecciones.entregaPieCalle') ?></label>
</div>
</div>
</div>
<div id="divDirecciones" class="col-12 pb-2">
</div>
</div>

View File

@ -44,9 +44,11 @@
<div id="tapaDiv" class="row mt-3">
<div class="col-sm-3 mb-md-0 mb-2" id="tapaBlandaDiv">
<div id="tapaBlandaInnerDiv" class="form-check custom-option custom-option-tapa custom-option-basic checked">
<div id="tapaBlandaInnerDiv" class="form-check custom-option custom-option-tapa custom-option-basic
<?php echo ($datosPresupuesto->tapa == 'blanda' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="tapaBlanda">
<input name="tapaBlanda" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaBlanda" checked="">
<input name="tapaBlanda" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaBlanda"
<?php echo ($datosPresupuesto->tapa == 'blanda' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Tapa blanda</span>
</span>
@ -54,9 +56,11 @@
</div>
</div>
<div id="tapaDuraDiv" class="col-sm-3 mb-md-0 mb-2">
<div class="form-check custom-option custom-option-tapa custom-option-basic">
<div class="form-check custom-option custom-option-tapa custom-option-basic
<?php echo ($datosPresupuesto->tapa == 'dura' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="tapaDura">
<input name="tapaDura" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaDura">
<input name="tapaDura" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="" id="tapaDura"
<?php echo ($datosPresupuesto->tapa == 'dura' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Tapa Dura</span>
</span>
@ -182,7 +186,8 @@
<img style="height:120px;width:120px" src="<?= site_url("assets/img/grises.png") ?>" alt="">
</span>
</label>
<input name="colorNegro" class="form-check-input calcular-presupuesto" type="radio" value="colorNegro" id="colorNegro" checked="">
<input name="colorNegro" class="form-check-input calcular-presupuesto" type="radio" value="colorNegro" id="colorNegro"
<?php echo ($datosPresupuesto->color_impresion == 'negro' ? ' checked=""': ''); ?> >
</div>
</div>
@ -193,7 +198,8 @@
<img style="height:120px;width:120px" src="<?= site_url("assets/img//gamacolor.png") ?>" alt="">
</span>
</label>
<input name="colorColor" class="form-check-input calcular-presupuesto" type="radio" value="colorColor" id="colorColor">
<input name="colorColor" class="form-check-input calcular-presupuesto" type="radio" value="colorColor" id="colorColor"
<?php echo ($datosPresupuesto->color_impresion == 'color' ? ' checked=""': ''); ?> >
</div>
</div>
@ -212,9 +218,11 @@
<div class="row">
<div class="col-sm-3 mb-md-0 mb-2">
<div id="calidadEstandarDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic checked">
<div id="calidadEstandarDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic
<?php echo ($datosPresupuesto->calidad_impresion == 'estandar' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="calidadEstandar">
<input name="calidadEstandar" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadEstandar" checked="">
<input name="calidadEstandar" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadEstandar"
<?php echo ($datosPresupuesto->calidad_impresion == 'estandar' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Estándar</span>
</span>
@ -222,9 +230,11 @@
</div>
</div>
<div class="col-sm-3">
<div id="calidadPremiumDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic">
<div id="calidadPremiumDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic"
<?php echo ($datosPresupuesto->calidad_impresion == 'premium' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="calidadPremium">
<input name="calidadPremium" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadPremium">
<input name="calidadPremium" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadPremium"
<?php echo ($datosPresupuesto->calidad_impresion == 'premium' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Premium</span>
</span>
@ -565,6 +575,7 @@
<?= $this->section("additionalInlineJs") ?>
window.routes_disenio_libro = {
obtenerGramaje: "<?= route_to('obtenerGramaje') ?>",
presupuestoCliente: "<?= route_to('presupuestoCliente') ?>",

View File

@ -22,12 +22,12 @@
<p class="mb-3"><small id="resumenAcabadoCubierta">Acabado: Ninguno</small></p>
<h5 class="mb-1 resumen-sobrecubierta">Sobrecubierta</h5>
<p class="mb-0 resumen-sobrecubierta"><small id="resumenPapelSobrecubierta">Papel: Blanco Offset 70gr/m<sup>2</sup></small></p>
<p class="mb-0 resumen-sobrecubierta"><small id="resumenPapelSobrecubierta">Papel: Blanco Offset 70gr/m²</small></p>
<p class="mb-0 resumen-sobrecubierta"><small id="resumenSolapasCubierta">Ancho solapas: 25mm</small></p>
<p class="mb-3 resumen-sobrecubierta"><small id="resumenAcabadoCubierta">Acabado: Ninguno</small></p>
<h5 class="mb-1 resumen-guardas">Guardas</h5>
<p class="mb-0 resumen-guardas"><small id="resumenGuardasPapel">Papel: Blanco Offset 70gr/m<sup>2</sup></small></p>
<p class="mb-0 resumen-guardas"><small id="resumenGuardasPapel">Papel: Blanco Offset 70gr/m²</small></p>
<p class="mb-3 resumen-guardas"><small id="resumenGuardasCaras">Impresión: 1 cara</small></p>
<h5 class="mb-1 resumen-extras">Extras</h5>
@ -37,13 +37,19 @@
</div>
<div class="col-sm-6">
<h4 id="resumenTotal" class="mb-1">Total: 100</h4>
<h4 id="resumenTotalIVA" class="mb-1">Total: 100</h4>
<h6 id="resumenPrecioU" class="mb-0">10.4/ud</h6>
<h6 id="resumenTotalIVA"class="mb-0">Coste impresion (4% IVA): 104</h6>
<h6 id="resumenEnvio" class="mb-1">Envío: 30</h6>
<div id="shape-container">
<div id="pv_ec_shape" style="width:95%;height:550px;margin:2.5% auto;"></div>
</div>
</div>
</div>
</div>
<?= $this->section("additionalInlineJs") ?>
window.routes_resumen = {
guardarPresupuesto: "<?= route_to('guardarPresupuesto') ?>",
}
<?= $this->endSection() ?>

View File

@ -1,11 +1,24 @@
<div class="col-12 pb-2">
<div class="tipo_libro">
<input hidden readonly id="lomo_cubierta" name="lomo_cubierta" maxLength="12" class="form-control" value="<?= old('lomoCubierta', $presupuestoEntity->lomoCubierta) ?>">
<div class="row row-cols-3 mb-6 d-flex justify-content-center d-flex justify-content-center">
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="cosidoDiv"
class="form-check checked custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php
if($datosPresupuesto->tipo_libro == 'cosido' || $datosPresupuesto->tipo_libro == ''){
echo ' checked"';
}
else
{
echo '"';
}
?>
>
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoCosido">
<span class="custom-option-body">
@ -14,7 +27,13 @@
</span>
</label>
<input name="cosido" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoCosido"
id="tipoCosido" checked="">
id="tipoCosido"
<?php
if($datosPresupuesto->tipo_libro == 'cosido' || $datosPresupuesto->tipo_libro == ''){
echo 'checked=""';
}
?>
>
</div>
<h4 class="text-center">Rústica cosido</h4>
</div>
@ -23,7 +42,8 @@
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="fresadoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'fresado' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoFresado">
<span class="custom-option-body">
@ -32,7 +52,7 @@
</span>
</label>
<input name="fresado" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoFresado"
id="tipoFresado">
id="tipoFresado" <?php echo (($datosPresupuesto->tipo_libro)=='fresado'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Rústica fresado</h4>
</div>
@ -41,7 +61,8 @@
<div class="container col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="grapadoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'grapado' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoGrapado">
<span class="custom-option-body">
@ -50,7 +71,7 @@
</span>
</label>
<input name="grapado" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoGrapado"
id="tipoGrapado">
id="tipoGrapado" <?php echo (($datosPresupuesto->tipo_libro)=='grapado'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Cosido con grapas</h4>
</div>
@ -61,7 +82,8 @@
<div class="col-md-4 mb-6 d-flex justify-content-center">
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="espiralDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'espiral' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoEspiral">
<span class="custom-option-body">
@ -70,7 +92,7 @@
</span>
</label>
<input name="espiral" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoEspiral"
id="tipoEspiral">
id="tipoEspiral" <?php echo (($datosPresupuesto->tipo_libro)=='espiral'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Espiral</h4>
</div>
@ -79,7 +101,8 @@
<div class="col-md-4 mb-6 d-flex justify-content-center" >
<div>
<div style="max-width:200px;max-height:200px;padding-right:0px" id="wireoDiv"
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio">
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio
<?php echo ($datosPresupuesto->tipo_libro == 'wireo' ? ' checked"': '"'); ?> >
<label style="max-width:200px;max-height:200px;" class="form-check-label custom-option-content"
for="tipoWireO">
<span class="custom-option-body">
@ -88,7 +111,7 @@
</span>
</label>
<input name="wireo" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoWireO"
id="tipoWireO">
id="tipoWireO" <?php echo (($datosPresupuesto->tipo_libro)=='wireo'? 'checked=""':''); ?> >
</div>
<h4 class="text-center">Wire-o</h4>
</div>

View File

@ -37,9 +37,9 @@ function initTiradasDirecciones() {
let html = '';
html += '<div class="col-sm-3">';
html += '<div class="form-check custom-option custom-option-basic custom-option-tiradasDirecciones' + (i==1?' checked':'')+ ' ">';
html += '<div id=div-env_' + id + ' class="form-check custom-option custom-option-basic custom-option-tiradasDirecciones">';
html += '<label class="form-check-label custom-option-content" for="tiradaEnvios' + i + '">';
html += '<input name=env_"' + id + '" peso="' + peso + '" class="form-check-input" type="radio" value="" id="env_' + id + '">';
html += '<input name=env_"' + id + '" peso="' + peso + '" class="form-check-input" type="radio" value="" id="env_' + id + '"></input>';
html += '<span class="custom-option-header">';
html += '<span id="tiradaDireccionesValue' + i + '" class="h6 mb-0">' + $('#' + tirada_id).text().split(' ')[0] + '</span>';
html += '<span class="text-muted">' + $('#' + total_id).text() + '</span>';
@ -55,6 +55,7 @@ function initTiradasDirecciones() {
$('#' + id).hide();
}
$('#env_tiradaPrecio1').trigger('click');
}
const tiradasDireccionesList = [].slice.call(document.querySelectorAll('.custom-option-tiradasDirecciones .form-check-input'))
@ -76,10 +77,16 @@ function updateTiradasDireccionesCheck(el) {
const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-tiradasDirecciones'))
customRadioOptionList.map(function (customRadioOptionEL) {
customRadioOptionEL.closest('.custom-option-tiradasDirecciones').classList.remove('checked')
let id_temp = customRadioOptionEL.id.split('-')[1];
$('#' + id_temp).prop('checked', false);
})
}
el.closest('.custom-option-tiradasDirecciones').classList.add('checked')
const element = el.closest('.custom-option-tiradasDirecciones');
element.classList.add('checked');
let id = element.id.split('-')[1];
$('#' + id).prop('checked', true);
} else {
el.closest('.custom-option-tiradasDirecciones').classList.remove('checked')
}
@ -134,9 +141,12 @@ $('#insertarDireccion').on('click', function() {
data = {
id: $('#direcciones').val(),
peso: $('#env_tiradaPrecio' + number[0]).attr('peso'),
unidades: unidades
unidades: unidades,
entregaPieCalle: $('#entregaPieCalle').is(':checked')?1:0,
},
data = Object.assign(data, window.token_ajax)
$('#loader').show();
$.ajax({
url: window.routes_direcciones.getDatos,
@ -145,7 +155,7 @@ $('#insertarDireccion').on('click', function() {
success: function(response) {
if(response.data.length > 0) {
let html = '';
html += '<div id="envioId' + response.data[0].id + '" p= ' +response.data[0].coste + ' class="row mb-3">';
html += '<div id="envioId' + response.data[0].id + '" t="' +response.data[0].tipo + '" p= ' +response.data[0].coste + ' class="row mb-3">';
html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">';
html += '<span class="custom-option-header mb-2">';
@ -169,10 +179,12 @@ $('#insertarDireccion').on('click', function() {
$('#divDirecciones').append(html);
$('#errorDirecciones').hide();
$('#loader').hide();
}
},
error: function() {
$("#direcciones").empty();
$('#loader').hide();
},
});
}
@ -180,8 +192,6 @@ $('#insertarDireccion').on('click', function() {
$('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
$('#errorDirecciones').show();
}
}
return false;
})
@ -252,7 +262,6 @@ function saveAdd_callback(){
cp: $('#add_cp').val(),
telefono: $('#add_telefono').val(),
}
console.log(data);
data = Object.assign(data, window.token_ajax)
$.ajax({
@ -300,4 +309,26 @@ function validarEnvio(){
return false;
}
return true;
}
function getDireccionesEnvio(){
const elements = $('#divDirecciones').find('.row.mb-3');
let direcciones = [];
if(elements.length > 0) {
for (let index=0; index<elements.length; index++){
const unidades = parseInt($(elements[index]).find('div label span span').text().split(' ')[0]);
const id = $(elements[index]).attr('id').replace('envioId', '');
const tipo = $(elements[index]).attr('t');
direcciones.push({
unidades: unidades,
id: id,
tipo: tipo,
})
};
}
return direcciones;
}

View File

@ -156,8 +156,6 @@ function initDisenioLibro() {
$('#papelCubierta').val('').trigger('change');
$('#papelSobrecubierta').val('').trigger('change');
$('#enableSobrecubierta').trigger('change');
}
@ -670,47 +668,54 @@ async function calcularPresupuesto() {
data: datos,
success: function (response) {
error = false;
if(response.errors.interior.length > 0){
$('#errorInterior').show();
error = true;
}
else
$('#errorInterior').hide();
if(response.errors.cubierta.length > 0){
$('#errorCubierta').show();
error = true;
}
else
$('#errorCubierta').hide();
try{
if(response.errors.sobrecubierta.length > 0){
$('#errorSobrecubierta').show();
if(response.errors.interior.length > 0){
$('#errorInterior').show();
error = true;
}
else
$('#errorInterior').hide();
if(response.errors.cubierta.length > 0){
$('#errorCubierta').show();
error = true;
}
else
$('#errorSobrecubierta').hide();
$('#errorCubierta').hide();
if(response.errors.guardas.length > 0){
$('#errorGuardas').show();
error = true;
}
else
$('#errorGuardas').hide();
if(response.errors.servicios.length > 0 || response.errors.serviciosDefecto.length > 0){
error = true;
$('#errorGeneral').show();
}
else{
$('#errorGeneral').hide();
}
if(response.errors.sobrecubierta.length > 0){
$('#errorSobrecubierta').show();
error = true;
}
else
$('#errorSobrecubierta').hide();
if(response.errors.guardas.length > 0){
$('#errorGuardas').show();
error = true;
}
else
$('#errorGuardas').hide();
if(response.errors.servicios.length > 0 || response.errors.serviciosDefecto.length > 0){
error = true;
$('#errorGeneral').show();
}
else{
$('#errorGeneral').hide();
}
}
catch(error){
}
console.log(response);
$('#loader').hide();
$('#divTiradasPrecio').empty();
$('#lomo_cubierta').val(response.lomo_cubierta);
$('#precios').show();
for (i = 0; i < response.tiradas.length; i++) {
@ -719,7 +724,6 @@ async function calcularPresupuesto() {
let html = '';
html += '<div id="' + label + '" peso="' +response.peso[i]+ '" class="list-group" >';
html += '<a href="javascript:void(0);" class="list-group-item list-group-item-action">';
html += '<div class="li-wrapper d-flex justify-content-start align-items-center" >';

View File

@ -327,6 +327,7 @@
break;
case 0:
window.location.href = document.location.origin + '/presupuestocliente/list';
default:
break;

View File

@ -0,0 +1,735 @@
// Global parameters
var pvObj;
$('#toReview').on( "click", function() {
console.log('ec draw');
portadaTapaDura();
//previewEsquemaCubierta('ec', '','');
} );
function previewEsquemaCubierta() {
/*let tipoImpresion;
if ($("#tipoCosido").is(":checked")) {
tipoImpresion = parseInt()
}
let tipoImpresion = parseInt($('#tipo_impresion_id').val());
// Fresado TD y Cosido TD
if (tipoImpresion === 1 || tipoImpresion === 3) {
portadaTapaDura();
}
// Fresado TB y Cosido TB
else if (tipoImpresion === 2 || tipoImpresion === 4) {
portadaTapaBlanda();
}
// Espiral TD y TB, Wire-o TD y TB
else if (tipoImpresion === 5 || tipoImpresion === 6 ||
tipoImpresion === 7 || tipoImpresion === 8) {
portadaEspiral();
}
else if (tipoImpresion === 21) {
portadaGrapado();
}
else {
// ?
}*/
}
function portadaTapaDura() {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoCubierta, altoSangrado, anchoSangrado;
let styleCotas = {size: 12, family: 'Public Sans'};
let sangradoTexto = "Sangrado 20 mm";
let sangradoValor = parseFloat(20); // mm
let anchoPliegue = parseFloat(7); // mm
let altoPliegue = parseFloat(7); // mm
let anchoCarton = parseFloat(7); // mm
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC) -
anchoSangrado = 400; // px
altoSangrado = (anchoSangrado * 0.647 > 350) ? anchoSangrado * 0.647 : 350; // px
altoLibro = altoSangrado * 0.88;
anchoLibro = anchoSangrado * 0.39;
lomoLibro = anchoSangrado * 0.133;
anchoCubierta = (2 * anchoLibro) + lomoLibro;
// Clear the canvas element
$('#pv_ec_shape').empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById('pv_ec_shape');
var previewEC = new Two({fitted: true}).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
var libro = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
((2 * anchoLibro) + lomoLibro),
altoLibro);
libro.stroke = 'black';
libro.linewidth = 1;
var lomo = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
lomoLibro,
altoLibro);
lomo.stroke = 'black';
lomo.fill = '#F4F8F2';
lomo.linewidth = 1;
// Cotas
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);
previewEC.makeText("Lomo", origenEC.x, origenEC.y, stylesEC).rotation = -Math.PI / 2;
// Sangrados
let styleSangrado = {size: 10, family: 'Public Sans', style: 'italic', fill: 'red'};
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + 13), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + 13), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.lomoLibro + anchoCarton + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + anchoPliegue + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + anchoPliegue + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + altoPliegue + " mm", origenEC.x + (lomoLibro / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + altoPliegue + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + pvObj.lomoLibro + (2 * sangradoValor) + +(2 * anchoPliegue) + anchoCarton + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
previewEC.update();
}
function portadaTapaBlanda() {
// 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
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if (pvObj.anchoSolapa == 0) {
anchoSangrado = 600; // px
altoSangrado = (anchoSangrado * 0.647 > 350) ? anchoSangrado * 0.647 : 350; // px
altoLibro = altoSangrado * 0.97;
anchoLibro = anchoSangrado * 0.419;
anchoSolapa = 0;
lomoLibro = anchoSangrado * 0.133;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
} else {
anchoSangrado = 600; // px
altoSangrado = (anchoSangrado * 0.418 > 350) ? anchoSangrado * 0.418 : 350; // 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
$('#pv_ec_shape').empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById('pv_ec_shape');
var previewEC = new Two({fitted: true}).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if (pvObj.anchoSolapa != 0) {
var solapas = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoCubierta,
altoLibro);
solapas.stroke = 'black';
solapas.linewidth = 1;
// Cotas Solapas
var cotaSolapa2 = previewEC.makeDobleArrow(
origenEC.x - anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x - anchoLibro - lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa2.linewidth = 2;
var cotaSolapa1 = previewEC.makeDobleArrow(
origenEC.x + anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x + anchoLibro + lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa1.linewidth = 2;
// Textos Solapas
let stylesSolapa = {size: 18, family: 'Public Sans'};
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
var libro = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
((2 * anchoLibro) + lomoLibro),
altoLibro);
libro.stroke = 'black';
libro.linewidth = 1;
var lomo = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
lomoLibro,
altoLibro);
lomo.stroke = 'black';
lomo.fill = '#F4F8F2';
lomo.linewidth = 1;
// Cotas
var cotaAnchoCubierta = previewEC.makeDobleArrow(
origenEC.x - (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
origenEC.x + (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
10);
cotaAnchoCubierta.linewidth = 2;
var cotaAltoCubierta = previewEC.makeDobleArrow(
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y + (altoSangrado / 2),
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y - (altoSangrado / 2),
10);
cotaAltoCubierta.linewidth = 2;
var cotaAltoLibro = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y + (altoLibro / 2),
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y - (altoLibro / 2),
10);
cotaAltoLibro.linewidth = 2;
var cotaLomo = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
origenEC.x + (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
10);
cotaLomo.linewidth = 2;
var cotaContraportada = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
origenEC.x - (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
origenEC.x + (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
10);
cotaPortada.linewidth = 2;
// Textos:
// Titulos generales
let stylesEC = {size: 22, weight: 'bold', family: 'Public Sans'};
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
let a = previewEC.makeText("Lomo", origenEC.x, origenEC.y, stylesEC).rotation = -Math.PI / 2;
// Sangrados
let styleSangrado = {size: 10, family: 'Public Sans', style: 'italic', fill: 'red'};
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.lomoLibro + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + offsetSolapaValor)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
previewEC.update();
}
function portadaEspiral() {
// Variables locales
let altoLibro, anchoLibro, anchoCalle, anchoCubierta, altoSangrado, anchoSangrado, anchoSolapa, offsetCubierta;
let styleCotas = {size: 12, family: 'Public Sans'};
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
anchoSangrado = 600; // px
if((pvObj.anchoSolapa !== 0) && (isTapaDura === 0)){
altoSangrado = (anchoSangrado * 0.418 > 350) ? anchoSangrado * 0.418 : 350; // px
altoLibro = altoSangrado * 0.95;
anchoLibro = anchoSangrado * 0.28;
anchoCalle = anchoSangrado * 0.02;
anchoSolapa = anchoSangrado * 0.163;
sangrado = anchoSangrado * 0.03;
anchoCubierta = 2 * (anchoLibro + anchoSolapa+ sangrado) + anchoCalle;
offsetCubierta = anchoLibro/2 + anchoCalle/2 + anchoSolapa/2 + sangrado;
}
else {
altoSangrado = (anchoSangrado * 0.647 > 350) ? anchoSangrado * 0.647 : 350; // px
altoLibro = (isTapaDura) ? altoSangrado * 0.88 : altoSangrado * 0.97;
anchoLibro = (isTapaDura) ? anchoSangrado * 0.39 : anchoSangrado * 0.419;
anchoCalle = anchoSangrado * 0.02;
anchoSolapa = 0;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + anchoCalle;
offsetCubierta = anchoLibro/2 + anchoCalle/2 + anchoSolapa + sangradoValor;
}
// Clear the canvas element
$('#pv_ec_shape').empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById('pv_ec_shape');
var previewEC = new Two({fitted: true}).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if (pvObj.anchoSolapa != 0) {
var solapa1 = previewEC.makeRectangle(
origenEC.x + (anchoLibro + anchoCalle/2 + anchoSolapa/2 + sangradoValor),
origenEC.y,
anchoSolapa,
altoLibro);
solapa1.stroke = 'black';
solapa1.linewidth = 1;
var solapa2 = previewEC.makeRectangle(
origenEC.x - (anchoLibro + anchoCalle/2 + anchoSolapa/2 + sangradoValor),
origenEC.y,
anchoSolapa,
altoLibro);
solapa2.stroke = 'black';
solapa2.linewidth = 1;
// Cotas Solapas
var cotaSolapa2 = previewEC.makeDobleArrow(
origenEC.x - (anchoCalle/2 + sangradoValor + anchoLibro + anchoSolapa),
origenEC.y - (altoLibro / 3),
origenEC.x - (anchoLibro + sangradoValor + anchoCalle / 2),
origenEC.y - (altoLibro / 3),
10);
cotaSolapa2.linewidth = 2;
var cotaSolapa1 = previewEC.makeDobleArrow(
origenEC.x + (anchoCalle/2 + sangradoValor + anchoLibro + anchoSolapa),
origenEC.y - (altoLibro / 3),
origenEC.x + (anchoLibro + sangradoValor + anchoCalle / 2),
origenEC.y - (altoLibro / 3),
10);
cotaSolapa1.linewidth = 2;
// Textos Solapas
let stylesSolapa = {size: 18, family: 'Public Sans'};
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
var portada = previewEC.makeRectangle(
origenEC.x + (anchoLibro/2 + anchoCalle/2 + sangradoValor),
origenEC.y,
anchoLibro,
altoLibro);
portada.stroke = 'black';
portada.linewidth = 1;
var contraportada = previewEC.makeRectangle(
origenEC.x - (anchoLibro/2 + anchoCalle/2 + sangradoValor),
origenEC.y,
anchoLibro,
altoLibro);
contraportada.stroke = 'black';
contraportada.linewidth = 1;
var calle = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoCalle,
altoSangrado);
calle.stroke = 'black';
calle.dashes = [2, 5];
calle.fill = '#F4F8F2';
calle.linewidth = 1;
// Cotas
var cotaAnchoCubierta = previewEC.makeDobleArrow(
origenEC.x - (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
origenEC.x + (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
10);
cotaAnchoCubierta.linewidth = 2;
var cotaAltoCubierta = previewEC.makeDobleArrow(
origenEC.x + (anchoSangrado / 2) + 15,
origenEC.y + (altoSangrado / 2),
origenEC.x + (anchoSangrado / 2) + 15,
origenEC.y - (altoSangrado / 2),
10);
cotaAltoCubierta.linewidth = 2;
var cotaAltoLibro = previewEC.makeDobleArrow(
origenEC.x + (anchoCalle / 2) + 35,
origenEC.y + (altoLibro / 2),
origenEC.x + (anchoCalle / 2) + 35,
origenEC.y - (altoLibro / 2),
10);
cotaAltoLibro.linewidth = 2;
var cotaContraportada = previewEC.makeDobleArrow(
origenEC.x - (anchoCalle / 2 + anchoLibro + sangradoValor),
origenEC.y - (altoLibro / 3),
origenEC.x - ((anchoCalle / 2) + sangradoValor),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + ((anchoCalle / 2) + sangradoValor),
origenEC.y - (altoLibro / 3),
origenEC.x + (anchoCalle / 2 + anchoLibro + sangradoValor),
origenEC.y - (altoLibro / 3),
10);
cotaPortada.linewidth = 2;
// Textos:
// Titulos generales
let stylesEC = {size: 22, weight: 'bold', family: 'Public Sans'};
previewEC.makeText("Portada",
origenEC.x + anchoLibro/2 + anchoCalle/2 + sangradoValor + 15,
origenEC.y,
stylesEC
);
previewEC.makeText("Contraportada",
origenEC.x - (anchoLibro/2 + anchoCalle/2 + sangradoValor),
origenEC.y,
stylesEC
);
// Sangrados
let styleSangrado = {size: 10, family: 'Public Sans', style: 'italic', fill: 'red'};
previewEC.makeText(sangradoTexto, origenEC.x + offsetCubierta, origenEC.y + (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + offsetCubierta, origenEC.y - (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x - offsetCubierta, origenEC.y + (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x - offsetCubierta, origenEC.y - (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (anchoSangrado / 2) - 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (anchoSangrado / 2) + 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x - (offsetCubierta - anchoSolapa/2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x + (offsetCubierta - anchoSolapa/2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (anchoCalle / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm",
origenEC.x + (anchoSangrado / 2) + 30,
origenEC.y,
styleCotas
).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
previewEC.update();
}
function portadaGrapado() {
// 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
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if (pvObj.anchoSolapa == 0) {
anchoSangrado = 600; // px
altoSangrado = (anchoSangrado * 0.647 > 350) ? anchoSangrado * 0.647 : 350; // 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 {
anchoSangrado = 600; // px
altoSangrado = (anchoSangrado * 0.418 > 350) ? anchoSangrado * 0.418 : 350; // 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
$('#pv_ec_shape').empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById('pv_ec_shape');
var previewEC = new Two({fitted: true}).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if (pvObj.anchoSolapa != 0) {
var solapas = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoCubierta,
altoLibro);
solapas.stroke = 'black';
solapas.linewidth = 1;
// Cotas Solapas
var cotaSolapa2 = previewEC.makeDobleArrow(
origenEC.x - anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x - anchoLibro - lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa2.linewidth = 2;
var cotaSolapa1 = previewEC.makeDobleArrow(
origenEC.x + anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x + anchoLibro + lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa1.linewidth = 2;
// Textos Solapas
let stylesSolapa = {size: 18, family: 'Public Sans'};
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
var libro = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
((2 * anchoLibro) + lomoLibro),
altoLibro);
libro.stroke = 'black';
libro.linewidth = 1;
var lomo = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
lomoLibro,
altoLibro);
lomo.stroke = 'black';
lomo.fill = '#F4F8F2';
lomo.linewidth = 1;
// Cotas
var cotaAnchoCubierta = previewEC.makeDobleArrow(
origenEC.x - (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
origenEC.x + (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
10);
cotaAnchoCubierta.linewidth = 2;
var cotaAltoCubierta = previewEC.makeDobleArrow(
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y + (altoSangrado / 2),
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y - (altoSangrado / 2),
10);
cotaAltoCubierta.linewidth = 2;
var cotaAltoLibro = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y + (altoLibro / 2),
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y - (altoLibro / 2),
10);
cotaAltoLibro.linewidth = 2;
var cotaContraportada = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
origenEC.x - (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
origenEC.x + (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
10);
cotaPortada.linewidth = 2;
// Textos:
// Titulos generales
let stylesEC = {size: 22, weight: 'bold', family: 'Public Sans'};
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
// Sangrados
let styleSangrado = {size: 10, family: 'Public Sans', style: 'italic', fill: 'red'};
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + offsetSolapaValor)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
previewEC.update();
}
function getLomoLibro() {
const anchoLomoInputs = $("#tableLineasPresupuesto tbody tr:visible td input[id*='_lomo']");
const anchoLomo = Array.from(anchoLomoInputs).reduce((sum, input) => sum + parseFloat($(input).val()), 0);
return parseFloat(anchoLomo.toFixed(2));
}
function getObjetoToPreview() {
pvObj = {
lomoLibro: parseFloat('30.0'),
anchoSolapa: $('#solapasCubierta').is(':checked') ? parseFloat($('#anchoSolapasCubierta').val()) : parseFloat(0),
altoLibro: getDimensionLibro().alto,
anchoLibro: getDimensionLibro().ancho
};
//console.log(pvObj);
}

View File

@ -33,7 +33,7 @@ function generarResumen(){
let papelCubierta = $('#papelCubierta option:selected').text().trim() + ' ' +
$('#gramajeCubierta option:selected').text();
papelCubierta += 'gr/m<sup>2</sup>';
papelCubierta += 'gr/m²';
$('#resumenPapelCubierta').text(papelCubierta);
$('#resumenCarasCubierta').text('Impresión: ' + $('#carasCubierta option:selected').text())
$('#resumenAcabadoCubierta').text('Acabado: ' + $('#acabadosCubierta option:selected').text())
@ -81,17 +81,16 @@ function generarResumen(){
let id = "tiradaPrecio" + i;
if ($('#' + id).length > 0) {
const envio = getTotalEnvio();
let tirada_id = "ud_tiradaPrecio" + i;
if(parseInt($('#' + tirada_id).text().replace(' ud.', '')) != tirada){
continue;
}
let total_id = "tot_tiradaPrecio" + i;
let precio_u_id = "pu_tiradaPrecio" + i;
$('#resumenTotal').text($('#' + total_id).text());
$('#resumenPrecioU').text($('#' + precio_u_id).text());
let total = parseFloat($('#' + total_id).text().replace('€', '').replace('Total: ', ''));
let total = parseFloat($('#' + total_id).text().replace('€', '').replace('Total: ', '')) + envio;
let total_iva = 0.0;
if($('#ivaReducido').val() == '1'){
total_iva = total * 1.04;
@ -99,9 +98,9 @@ function generarResumen(){
else{
total_iva = total * 1.21;
}
const precio_u = total_iva/tirada;
$('#resumenTotalIVA').text('Total (I.V.A. ' + (($('#ivaReducido').val() == '1')?'4':'21') + '%): ' + total_iva.toFixed(2) + '€');
const envio = getTotalEnvio();
$('#resumenEnvio').text('Envío: ' + envio.toFixed(2) + '€');
$('#resumenPrecioU').text(precio_u.toFixed(4) + '€/ud');
}
}
@ -119,4 +118,133 @@ function getTotalEnvio(){
}
return total;
}
$('#btnSave').on('click', function() {
finalizarPresupuesto(false);
});
$('#btnConfirm').on('click', function() {
finalizarPresupuesto(true);
});
$('#btnBack').on('click', function() {
window.location.href = document.location.origin + '/presupuestocliente/list';
});
function finalizarPresupuesto(confirmar){
let servicios = [];
$('.servicio-extra:checked').each(function () {
servicios.push($(this).attr('serv_id'));
})
let datos_libro = {
tamanio: getDimensionLibro(),
tirada: getTiradas(),
paginas: $('#paginas').val(),
paginasColor: $('#paginasColor').val(),
tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
isColor: $('#colorNegroDiv').hasClass('checked') ? 0 : 1,
isHq: $('#calidadEstandarDiv').hasClass('checked') ? 0 : 1,
papelInterior: $('#papelInterior option:selected').val(),
papelInteriorNombre: $('#papelInterior option:selected').text().trim(),
gramajeInterior: $('#gramajeInterior option:selected').text(),
excluirRotativa: $('#excluirRotativa').is(':checked')? 1 : 0,
papelCubierta: $('#papelCubierta option:selected').val(),
papelCubiertaNombre: $('#papelCubierta option:selected').text().trim(),
gramajeCubierta: $('#gramajeCubierta option:selected').text(),
carasCubierta: $('#carasCubierta').val(),
acabadoCubierta: $('#acabadosCubierta').val(),
clienteId: $('#clienteId').val(),
servicios: servicios,
};
// Si hay solapas de cubierta
if ($('#solapasCubierta').is(':checked')) {
datos_libro.solapasCubierta = $('#anchoSolapasCubierta').val()
}
// Si hay sobrecubierta
if ($('.enable-sobrecubierta').is(':visible')) {
if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
datos_libro.sobrecubierta = {
papel: $('#papelSobrecubierta option:selected').val(),
papel_nombre: $('#papelSobrecubierta option:selected').text().trim(),
gramaje: $('#gramajeSobrecubierta option:selected').text(),
acabado: $('#acabadosSobrecubierta').val()
}
datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
}
}
if ($('.guardas').is(':visible')) {
datos_libro.guardas = {
papel: $('#papelGuardas option:selected').val(),
papel_nombre: $('#papelGuardas option:selected').text().trim(),
gramaje: 170,
caras: $('#impresionGuardas option:selected').val()
}
}
let datos_cabecera = {
titulo: $('#titulo').val(),
referenciaCliente: $('#referenciaCliente').val(),
}
const seleccion = $('.custom-option-tiradasDirecciones.checked');
let tirada = 0;
let peso_libro = 0;
if(seleccion.length != 0) {
const element_tirada =($(seleccion[0]).find('label input')[0]);
const number = element_tirada.id.match(/\d+$/);
if (number.length != 0) {
tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
peso_libro = ($(seleccion[0])).find('label input').attr('peso');
}
}
let direcciones = getDireccionesEnvio();
datos = {
datos_libro : datos_libro,
datos_cabecera: datos_cabecera,
direcciones: direcciones,
tirada: tirada,
peso: peso_libro,
iva_reducido: $('#ivaReducido').val()==1?1:0,
confirmar: confirmar,
},
datos = Object.assign(datos, window.token_ajax)
$('#loader').show();
$.ajax({
url: window.routes_resumen.guardarPresupuesto,
type: 'POST',
data: datos,
success: function(response) {
if(Object.keys(response).length > 0) {
if(response.status > 0){
window.location.href = response.url;
}
}
$('#loader').hide();
},
error: function() {
$('#loader').hide();
},
});
}

View File

@ -0,0 +1,342 @@
<?=$this->include('themes/_commonPartialsBs/select2bs5') ?>
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?=$this->section('content'); ?>
<div class="row">
<div class="col-md-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $pageTitle ?></h3>
</div><!--//.card-header -->
<div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfPresupuestos" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th>Número</th>
<th><?= lang('Presupuestos.created_at') ?></th>
<th><?= lang('Presupuestos.tipoPresupuesto') ?></th>
<?php if ($clienteId == 0): ?>
<th><?= lang('Clientes.cliente') ?></th>
<?php endif; ?>
<th><?= lang('Presupuestos.titulo') ?></th>
<th class='noFilter'><?= lang('Presupuestos.paginas') ?></th>
<th class='noFilter'><?= lang('Presupuestos.tirada') ?></th>
<th class='noFilter'><?= lang('Presupuestos.totalPresupuesto') ?></th>
<th><?= lang('Presupuestos.presupuestoEstado') ?></th>
<th class="noFilter text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div><!--//.card-body -->
<div class="card-footer">
</div><!--//.card-footer -->
</div><!--//.card -->
</div><!--//.col -->
</div><!--//.row -->
<?=$this->endSection() ?>
<?=$this->section('additionalInlineJs') ?>
const lastColNr = $('#tableOfPresupuestos').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `
<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
</div>
</td>`;
};
// Setup - add a text input to each footer cell
$('#tableOfPresupuestos thead tr').clone(true).appendTo('#tableOfPresupuestos thead');
$('#tableOfPresupuestos thead tr:eq(1) th').each(function (i) {
if (!$(this).hasClass("noFilter")) {
var title = $(this).text();
if(i==1){
$(this).html('<input id="bs-rangepicker-range" type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
var bsRangePickerRange = $('#bs-rangepicker-range')
bsRangePickerRange.daterangepicker({
ranges: {
'<?= lang('datePicker.hoy') ?>': [moment(), moment()],
'<?= lang('datePicker.ayer') ?>': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'<?= lang('datePicker.ultimos7') ?>': [moment().subtract(6, 'days'), moment()],
'<?= lang('datePicker.ultimos30') ?>': [moment().subtract(29, 'days'), moment()],
'<?= lang('datePicker.esteMes') ?>': [moment().startOf('month'), moment().endOf('month')],
'<?= lang('datePicker.ultimoMes') ?>': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
opens: 'right',
language: '<?= config('Basics')->i18n ?>',
"locale": {
"customRangeLabel": "<?= lang('datePicker.personalizar') ?>",
"format": "YYYY-MM-DD",
"separator": " ",
"applyLabel": "<?= lang('datePicker.aplicar') ?>",
"cancelLabel": "<?= lang('datePicker.limpiar') ?>",
},
"alwaysShowCalendars": true,
autoUpdateInput: false,
});
bsRangePickerRange.on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' ' + picker.endDate.format('YYYY-MM-DD'));
theTable
.column(i)
.search(this.value)
.draw();
});
bsRangePickerRange.on('cancel.daterangepicker', function(ev, picker) {
$(this).val('');
theTable
.column(i)
.search(this.value)
.draw();
});
}
else if (i == 2) {
// Agregar un selector en la tercera columna
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
// Agregar opciones al selector
var selector = $('select', this);
selector.append('<option value="">Todos</option>'); // Opción vacía
selector.append('<option value="libroCosidoTapaBlanda"><?= lang('Presupuestos.libroCosidoTapaBlanda') ?></option>');
selector.append('<option value="libroCosidoTapaDura"><?= lang('Presupuestos.libroCosidoTapaDura') ?></option>');
selector.append('<option value="libroFresadoTapaBlanda"><?= lang('Presupuestos.libroFresadoTapaBlanda') ?></option>');
selector.append('<option value="libroFresadoTapaDura"><?= lang('Presupuestos.libroFresadoTapaDura') ?></option>');
selector.append('<option value="libroEspiralTapaDura"><?= lang('Presupuestos.libroEspiralTapaDura') ?></option>');
selector.append('<option value="libroEspiralTapaBlanda"><?= lang('Presupuestos.libroEspiralTapaBlanda') ?></option>');
selector.append('<option value="libroWireoTapaDura"><?= lang('Presupuestos.libroWireoTapaDura') ?></option>');
selector.append('<option value="libroWireoTapaBlanda"><?= lang('Presupuestos.libroWireoTapaBlanda') ?></option>');
selector.append('<option value="libroGrapado"><?= lang('Presupuestos.libroGrapado') ?></option>');
selector.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
theTable.column(i).search(val).draw();
});
}
else{
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
$('input', this).on('change clear', function () {
if (theTable.column(i).search() !== this.value) {
theTable
.column(i)
.search(this.value)
.draw();
}
});
}
}
else {
$(this).html('<span></span>');
}
});
theTable = $('#tableOfPresupuestos').DataTable({
orderCellsTop: true,
fixedHeader: true,
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 50,
lengthChange: true,
"dom": '<"mb-3"l>Brtip',
"buttons": [
'colvis', 'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: false,
order: [[1, 'asc']],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('datatableOfPresupuestos') ?>',
method: 'POST',
data: function(q) {
q.cliente = <? echo $clienteId; ?>;
},
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
}
],
columns : [
{ 'data': 'id' },
{ 'data': 'fecha' },
{ 'data': 'codigo',
render: function(data, type, row, meta) {
switch(data){
case "libroCosidoTapaBlanda":
return '<?= lang('Presupuestos.libroCosidoTapaBlanda') ?>';
break;
case "libroCosidoTapaDura":
return '<?= lang('Presupuestos.libroCosidoTapaDura') ?>';
break;
case "libroFresadoTapaBlanda":
return '<?= lang('Presupuestos.libroFresadoTapaBlanda') ?>';
break;
case "libroFresadoTapaDura":
return '<?= lang('Presupuestos.libroFresadoTapaDura') ?>';
break;
case "libroEspiralTapaDura":
return '<?= lang('Presupuestos.libroEspiralTapaDura') ?>';
break;
case "libroEspiralTapaBlanda":
return '<?= lang('Presupuestos.libroEspiralTapaBlanda') ?>';
break;
case "libroWireoTapaDura":
return '<?= lang('Presupuestos.libroWireoTapaDura') ?>';
break;
case "libroWireoTapaBlanda":
return '<?= lang('Presupuestos.libroWireoTapaBlanda') ?>';
break;
case "libroGrapado":
return '<?= lang('Presupuestos.libroGrapado') ?>';
break;
default:
return data; // Debug
break;
}
},
},
<?php if ($clienteId == 0): ?>
{ 'data': 'cliente' },
<?php endif; ?>
{ 'data': 'titulo' },
{ 'data': 'paginas' },
{ 'data': 'tirada' },
{ 'data': 'total_presupuesto' },
{ 'data': 'estado' ,
'render': function ( data, type, row, meta ) {
if(data=='borrador')
return '<?= lang('Presupuestos.presupuestoEstadoBorrador') ?>';
else if(data=='aceptado')
return '<?= lang('Presupuestos.presupuestoEstadoAceptado') ?>';
}
},
{ 'data': actionBtns }
]
});
theTable.on( 'draw.dt', function () {
const dateCols = [1];
const priceCols = [7];
for (let coln of dateCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
const datestr = cell.innerHTML;
const dateStrLen = datestr.toString().trim().length;
if (dateStrLen > 0) {
let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values
dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one
const d = new Date(...dateTimeParts); // new Date(datestr);
cell.innerHTML = d.toLocaleDateString();
}
});
}
for (let coln of priceCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = parseFloat(cell.innerHTML).toFixed(2);
});
}
});
$(document).on('click', '.btn-edit', function(e) {
window.location.href = `/presupuestos/presupuestocliente/edit/${$(this).attr('data-id')}/`;
});
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
$.ajax({
url: `/presupuestos/presupuestocliente/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle');
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});
<?=$this->endSection() ?>
<?=$this->section('css') ?>
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/fixedheader/fixedHeader.dataTables.min.css") ?>">
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.css') ?>" />
<?=$this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.colVis.min.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/moment/moment.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.js') ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
<?=$this->endSection() ?>

View File

@ -86,9 +86,9 @@
<?= view("themes/vuexy/form/presupuestos/cliente/_tipoLibroItems") ?>
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-label-secondary btn-prev waves-effect">
<button class="btn btn-primary btn-prev waves-effect waves-light">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none">Anterior</span>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Volver</span>
</button>
<button class="btn btn-primary btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Siguiente</span>
@ -105,9 +105,9 @@
<?= view("themes/vuexy/form/presupuestos/cliente/_disenioLibroItems") ?>
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-label-secondary btn-prev waves-effect">
<button class="btn btn-primary btn-prev waves-effect waves-light">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none">Anterior</span>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Anterior</span>
</button>
<button class="btn btn-primary btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Siguiente</span>
@ -124,11 +124,11 @@
<?= view("themes/vuexy/form/presupuestos/cliente/_direccionesItems") ?>
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-label-secondary btn-prev waves-effect">
<button class="btn btn-primary btn-prev waves-effect waves-light">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none">Anterior</span>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Anterior</span>
</button>
<button class="btn btn-primary btn-next waves-effect waves-light">
<button id="toReview" class="btn btn-primary btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Siguiente</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
@ -145,19 +145,25 @@
</div>
<div class="col-12 d-flex justify-content-between mt-4">
<div class="col-6 d-flex flex-row">
<button class="btn btn-label-secondary btn-prev waves-effect">
<button class="btn btn-primary btn-prev waves-effect waves-light">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none">Anterior</span>
<span class="align-middle d-sm-inline-block d-none me-sm-1">Anterior</span>
</button>
</div>
<div class="col-6 d-flex flex-row-reverse">
<button class="btn btn-primary btn-submit waves-effect waves-light ml-2">
<?php if ($presupuestoEntity->estado_id == 1) : ?>
<button id="btnSave" class="btn btn-primary btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
<button class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
</button>
</button>
<button id="btnConfirm" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
</button>
<?php else: ?>
<button id="btnBack" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Volver</span><i class="ti ti-check ti-xs"></i>
</button>
<?php endif; ?>
</div>
</div>
</div>
@ -223,21 +229,23 @@ initDisenioLibro();
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("themes/vuexy/vendor/libs/bs-stepper/bs-stepper.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/select/dataTables.select.min.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script>
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoCliente_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteTipoLibro_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteDisenioLibro_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteDirecciones_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteResumen_js') ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/bs-stepper/bs-stepper.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/select/dataTables.select.min.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteResumen_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoCliente_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteTipoLibro_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteDisenioLibro_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteDirecciones_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClientePreview_js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -62,7 +62,7 @@ async function get_coste_envio_tiradasAlternativas(tirada){
if(datos_tarifa.id!=null){
if(peso_envio>parseFloat(datos_tarifa.peso_max)){
coste += parseFloat(datos_tarifa.peso_min) + (peso_envio-parseFloat(datos_tarifa.peso_min))*parseFloat(datos_tarifa.precio_adicional);
coste += (parseFloat(datos_tarifa.precio_min) + (peso_envio-parseFloat(datos_tarifa.peso_min)) * parseFloat(datos_tarifa.precio_adicional)).toFixed(2);
}
// si no se calcula linealmente
else{
@ -130,7 +130,7 @@ async function updateTablaEnvios(tirada_inicial = null, tirada = null){
if(datos_tarifa.id!=null){
if(peso_envio>parseFloat(datos_tarifa.peso_max)){
if(peso_envio>parseFloat(datos_tarifa.peso_max) || parseFloat(datos_tarifa.peso_max) == 0){
datos_tarifa.precio = parseFloat(datos_tarifa.peso_min) + (peso_envio-parseFloat(datos_tarifa.peso_min))*parseFloat(datos_tarifa.precio_adicional);
}
// si no se calcula linealmente

View File

@ -590,14 +590,18 @@ function init_servicio_encuadernado(){
}
function convertirTiempo(horas){
if(horas != null){
const seconds = parseFloat(horas) * 3600;
// se convierte a formato hh:mm:ss
const h = Math.floor(seconds / 3600);
const minutos = Math.floor((seconds % 3600) / 60);
const segundos = seconds % 60;
return h + ':' + minutos + ':' + segundos;
if(horas != null && horas.length>0){
if(parseFloat(horas)>0){
const seconds = parseFloat(horas) * 3600;
// se convierte a formato hh:mm:ss
const h = Math.floor(seconds / 3600);
const minutos = Math.floor((seconds % 3600) / 60);
const segundos = seconds % 60;
return h + ':' + minutos + ':' + segundos;
}
else{
return "";
}
}
else{
return "";

View File

@ -317,8 +317,8 @@
const ancho_libro = getDimensionLibro().ancho;
// ancho_libro*2 + lomo + solapas*2 <= 640
const limite_1 = ((640 - ancho_libro*2 - getLomoLineasPresupuesto()) / 2.0).toFixed(1);
// ancho_libro*2 + lomo + solapas*2 <= 630
const limite_1 = ((630 - ancho_libro*2 - getLomoLineasPresupuesto()) / 2.0).toFixed(1);
// solapas <= ancho_libro - 10
const limite_2 = ancho_libro - 10;
const limite = Math.min(limite_1, limite_2);
@ -339,8 +339,8 @@
const ancho_libro = getDimensionLibro().ancho;
// ancho_libro*2 + lomo + solapas*2 <= 640
const limite_1 = ((640 - ancho_libro*2 - getLomoLineasPresupuesto()) / 2.0).toFixed(1);
// ancho_libro*2 + lomo + solapas*2 <= 630
const limite_1 = ((630 - ancho_libro*2 - getLomoLineasPresupuesto()) / 2.0).toFixed(1);
// solapas <= ancho_libro - 10
const limite_2 = ancho_libro - 10;
const limite = Math.min(limite_1, limite_2);

View File

@ -186,14 +186,14 @@ $('#saveDireccionEnvio').on('click', function(){
var precios = []
for (var i = 0; i < data.length; i++) {
if(peso_envio>data[i].peso_max){
data[i].precio = (data[i].peso_min + (peso_envio-data[i].peso_min)*data[i].precio_adicional).toFixed(2);
if(peso_envio>data[i].peso_max || data[i].precio_max == 0){
data[i].precio = (parseFloat(data[i].precio_min) + (peso_envio-parseFloat(data[i].peso_min))*parseFloat(data[i].precio_adicional)).toFixed(2);
}
// si no se calcula linealmente
else{
m=((data[i].precio_max-data[i].precio_min)/(data[i].peso_max-data[i].peso_min))
b=data[i].precio_max-m*data[i].peso_max
data[i].precio = (m*peso_envio+b).toFixed(2);
data[i].precio = parseFloat(m*peso_envio+b).toFixed(2);
}
data[i].margen = data[i].margen
}

View File

@ -55,14 +55,25 @@
*/
if (auth()->user()->inGroup('beta')) {
?>
<li class="menu-header small text-uppercase">
<span class="menu-header-text">Test JJO</span>
</li>
<li class="menu-item">
<a href="<?= route_to('nuevoPresupuestoCliente') ?>" class="menu-link">
<i class="menu-icon tf-icons ti ti-settings"></i>
Test
<a href="javascript:void(0);" class="menu-link menu-toggle">
<i class="menu-icon tf-icons ti ti-currency-dollar"></i>
Presupuestos cliente
</a>
<ul class="menu-sub">
<li class="menu-item">
<a href="<?= route_to("listaPresupuestos") ?>" class="menu-link">
Mis presupuestos
</a>
</li>
</ul>
<ul class="menu-sub">
<li class="menu-item">
<a href="<?= route_to('nuevoPresupuestoCliente') ?>" class="menu-link">
Añadir
</a>
</li>
</ul>
</li>
<?php } ?>

148881
xdebug.log

File diff suppressed because one or more lines are too long