mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'mod/presupuesto_admin' into 'main'
Mod/presupuesto admin See merge request jjimenez/safekat!479
This commit is contained in:
@ -9,10 +9,10 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"plantilla-tarifa.edit",
|
"plantilla-tarifa.edit",
|
||||||
"plantilla-tarifa.delete",
|
"plantilla-tarifa.delete",
|
||||||
"plantilla-tarifa.menu",
|
"plantilla-tarifa.menu",
|
||||||
"perfil.create",
|
"direcciones.create",
|
||||||
"perfil.edit",
|
"direcciones.edit",
|
||||||
"perfil.delete",
|
"direcciones.delete",
|
||||||
"perfil.menu",
|
"direcciones.menu",
|
||||||
"presupuesto.create",
|
"presupuesto.create",
|
||||||
"presupuesto.edit",
|
"presupuesto.edit",
|
||||||
"presupuesto.delete",
|
"presupuesto.delete",
|
||||||
@ -21,6 +21,14 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"presupuesto-cliente.edit",
|
"presupuesto-cliente.edit",
|
||||||
"presupuesto-cliente.delete",
|
"presupuesto-cliente.delete",
|
||||||
"presupuesto-cliente.menu",
|
"presupuesto-cliente.menu",
|
||||||
|
"pedidos-activos.view",
|
||||||
|
"pedidos-activos.menu",
|
||||||
|
"pedidos-finalizados.view",
|
||||||
|
"pedidos-finalizados.menu",
|
||||||
|
"pedidos-cancelados.view",
|
||||||
|
"pedidos-cancelados.menu",
|
||||||
|
"pedidos-todos.view",
|
||||||
|
"pedidos-todos.menu",
|
||||||
"tarifa-preimpresion.create",
|
"tarifa-preimpresion.create",
|
||||||
"tarifa-preimpresion.edit",
|
"tarifa-preimpresion.edit",
|
||||||
"tarifa-preimpresion.delete",
|
"tarifa-preimpresion.delete",
|
||||||
@ -41,10 +49,6 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"tarifa-envio.edit",
|
"tarifa-envio.edit",
|
||||||
"tarifa-envio.delete",
|
"tarifa-envio.delete",
|
||||||
"tarifa-envio.menu",
|
"tarifa-envio.menu",
|
||||||
"tarifa-extra.create",
|
|
||||||
"tarifa-extra.edit",
|
|
||||||
"tarifa-extra.delete",
|
|
||||||
"tarifa-extra.menu",
|
|
||||||
"proveedores.create",
|
"proveedores.create",
|
||||||
"proveedores.edit",
|
"proveedores.edit",
|
||||||
"proveedores.delete",
|
"proveedores.delete",
|
||||||
@ -61,10 +65,6 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"paises.edit",
|
"paises.edit",
|
||||||
"paises.delete",
|
"paises.delete",
|
||||||
"paises.menu",
|
"paises.menu",
|
||||||
"formas-pago.create",
|
|
||||||
"formas-pago.edit",
|
|
||||||
"formas-pago.delete",
|
|
||||||
"formas-pago.menu",
|
|
||||||
"maquinas.create",
|
"maquinas.create",
|
||||||
"maquinas.edit",
|
"maquinas.edit",
|
||||||
"maquinas.delete",
|
"maquinas.delete",
|
||||||
@ -89,48 +89,48 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"roles-permisos.edit",
|
"roles-permisos.edit",
|
||||||
"roles-permisos.delete",
|
"roles-permisos.delete",
|
||||||
"roles-permisos.menu",
|
"roles-permisos.menu",
|
||||||
"ubicaciones.create",
|
|
||||||
"ubicaciones.edit",
|
|
||||||
"ubicaciones.delete",
|
|
||||||
"ubicaciones.menu",
|
|
||||||
"series-facturas.create",
|
|
||||||
"series-facturas.edit",
|
|
||||||
"series-facturas.delete",
|
|
||||||
"series-facturas.menu",
|
|
||||||
],
|
],
|
||||||
"cliente-admin" => [
|
"cliente-admin" => [
|
||||||
"perfil.edit",
|
|
||||||
"perfil.menu",
|
|
||||||
"direcciones.create",
|
|
||||||
"direcciones.edit",
|
|
||||||
"direcciones.delete",
|
|
||||||
"direcciones.menu",
|
|
||||||
"presupuesto-cliente.create",
|
"presupuesto-cliente.create",
|
||||||
"presupuesto-cliente.edit",
|
"presupuesto-cliente.edit",
|
||||||
"presupuesto-cliente.delete",
|
"presupuesto-cliente.delete",
|
||||||
"presupuesto-cliente.menu",
|
"presupuesto-cliente.menu",
|
||||||
|
"pedidos-activos.view",
|
||||||
|
"pedidos-activos.menu",
|
||||||
|
"pedidos-finalizados.view",
|
||||||
|
"pedidos-finalizados.menu",
|
||||||
|
"pedidos-cancelados.view",
|
||||||
|
"pedidos-cancelados.menu",
|
||||||
|
"pedidos-todos.view",
|
||||||
|
"pedidos-todos.menu",
|
||||||
],
|
],
|
||||||
"cliente-editor" => [
|
"cliente-editor" => [
|
||||||
"perfil.create",
|
|
||||||
"perfil.edit",
|
|
||||||
"perfil.delete",
|
|
||||||
"perfil.menu",
|
|
||||||
"direcciones.create",
|
|
||||||
"direcciones.edit",
|
|
||||||
"direcciones.delete",
|
|
||||||
"direcciones.menu",
|
|
||||||
"presupuesto-cliente.create",
|
"presupuesto-cliente.create",
|
||||||
"presupuesto-cliente.edit",
|
"presupuesto-cliente.edit",
|
||||||
"presupuesto-cliente.delete",
|
|
||||||
"presupuesto-cliente.menu",
|
"presupuesto-cliente.menu",
|
||||||
|
"pedidos-activos.view",
|
||||||
|
"pedidos-activos.menu",
|
||||||
|
"pedidos-finalizados.view",
|
||||||
|
"pedidos-finalizados.menu",
|
||||||
|
"pedidos-cancelados.view",
|
||||||
|
"pedidos-cancelados.menu",
|
||||||
|
"pedidos-todos.view",
|
||||||
|
"pedidos-todos.menu",
|
||||||
],
|
],
|
||||||
"comercial" => [
|
"comercial" => [
|
||||||
"token.token",
|
"token.token",
|
||||||
"token.menu",
|
"token.menu",
|
||||||
],
|
],
|
||||||
"produccion" => [
|
"produccion" => [
|
||||||
"token.token",
|
"clientes.create",
|
||||||
"token.menu",
|
"clientes.edit",
|
||||||
|
"clientes.menu",
|
||||||
|
"direcciones.create",
|
||||||
|
"direcciones.edit",
|
||||||
|
"direcciones.menu",
|
||||||
|
"presupuesto.create",
|
||||||
|
"presupuesto.edit",
|
||||||
|
"presupuesto.menu",
|
||||||
],
|
],
|
||||||
"maquina" => [
|
"maquina" => [
|
||||||
"token.token",
|
"token.token",
|
||||||
@ -163,10 +163,10 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"plantilla-tarifa.edit",
|
"plantilla-tarifa.edit",
|
||||||
"plantilla-tarifa.delete",
|
"plantilla-tarifa.delete",
|
||||||
"plantilla-tarifa.menu",
|
"plantilla-tarifa.menu",
|
||||||
"perfil.create",
|
"direcciones.create",
|
||||||
"perfil.edit",
|
"direcciones.edit",
|
||||||
"perfil.delete",
|
"direcciones.delete",
|
||||||
"perfil.menu",
|
"direcciones.menu",
|
||||||
"presupuesto.create",
|
"presupuesto.create",
|
||||||
"presupuesto.edit",
|
"presupuesto.edit",
|
||||||
"presupuesto.delete",
|
"presupuesto.delete",
|
||||||
@ -175,6 +175,14 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"presupuesto-cliente.edit",
|
"presupuesto-cliente.edit",
|
||||||
"presupuesto-cliente.delete",
|
"presupuesto-cliente.delete",
|
||||||
"presupuesto-cliente.menu",
|
"presupuesto-cliente.menu",
|
||||||
|
"pedidos-activos.view",
|
||||||
|
"pedidos-activos.menu",
|
||||||
|
"pedidos-finalizados.view",
|
||||||
|
"pedidos-finalizados.menu",
|
||||||
|
"pedidos-cancelados.view",
|
||||||
|
"pedidos-cancelados.menu",
|
||||||
|
"pedidos-todos.view",
|
||||||
|
"pedidos-todos.menu",
|
||||||
"tarifa-preimpresion.create",
|
"tarifa-preimpresion.create",
|
||||||
"tarifa-preimpresion.edit",
|
"tarifa-preimpresion.edit",
|
||||||
"tarifa-preimpresion.delete",
|
"tarifa-preimpresion.delete",
|
||||||
@ -195,10 +203,6 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"tarifa-envio.edit",
|
"tarifa-envio.edit",
|
||||||
"tarifa-envio.delete",
|
"tarifa-envio.delete",
|
||||||
"tarifa-envio.menu",
|
"tarifa-envio.menu",
|
||||||
"tarifa-extra.create",
|
|
||||||
"tarifa-extra.edit",
|
|
||||||
"tarifa-extra.delete",
|
|
||||||
"tarifa-extra.menu",
|
|
||||||
"proveedores.create",
|
"proveedores.create",
|
||||||
"proveedores.edit",
|
"proveedores.edit",
|
||||||
"proveedores.delete",
|
"proveedores.delete",
|
||||||
@ -239,13 +243,5 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"roles-permisos.edit",
|
"roles-permisos.edit",
|
||||||
"roles-permisos.delete",
|
"roles-permisos.delete",
|
||||||
"roles-permisos.menu",
|
"roles-permisos.menu",
|
||||||
"ubicaciones.create",
|
|
||||||
"ubicaciones.edit",
|
|
||||||
"ubicaciones.delete",
|
|
||||||
"ubicaciones.menu",
|
|
||||||
"series-facturas.create",
|
|
||||||
"series-facturas.edit",
|
|
||||||
"series-facturas.delete",
|
|
||||||
"series-facturas.menu",
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -76,6 +76,8 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function (
|
|||||||
$routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']);
|
$routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']);
|
||||||
$routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']);
|
$routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']);
|
||||||
$routes->get('select', 'TarifaAcabados::show_select', ["as" => "showSelectTarifaAcabado"]);
|
$routes->get('select', 'TarifaAcabados::show_select', ["as" => "showSelectTarifaAcabado"]);
|
||||||
|
$routes->get('gettarifas', 'TarifaAcabados::getSelect2');
|
||||||
|
|
||||||
$routes->group('lineas', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) {
|
$routes->group('lineas', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) {
|
||||||
$routes->post('datatable', 'TarifaAcabadosLineas::datatable', ['as' => 'tarifaAcabadoLineasDT']);
|
$routes->post('datatable', 'TarifaAcabadosLineas::datatable', ['as' => 'tarifaAcabadoLineasDT']);
|
||||||
$routes->post('datatable_editor', 'TarifaAcabadosLineas::datatable_editor', ['as' => 'tarifaAcabadoLineasDTE']);
|
$routes->post('datatable_editor', 'TarifaAcabadosLineas::datatable_editor', ['as' => 'tarifaAcabadoLineasDTE']);
|
||||||
@ -171,6 +173,7 @@ $routes->group('tarifapreimpresion', ['namespace' => 'App\Controllers\Tarifas'],
|
|||||||
$routes->get('delete/(:num)', 'Tarifapreimpresion::delete/$1', ['as' => 'deleteTarifapreimpresion']);
|
$routes->get('delete/(:num)', 'Tarifapreimpresion::delete/$1', ['as' => 'deleteTarifapreimpresion']);
|
||||||
$routes->post('allmenuitems', 'Tarifapreimpresion::allItemsSelect', ['as' => 'select2ItemsOfTarifaspreimpresion']);
|
$routes->post('allmenuitems', 'Tarifapreimpresion::allItemsSelect', ['as' => 'select2ItemsOfTarifaspreimpresion']);
|
||||||
$routes->post('menuitems', 'Tarifapreimpresion::menuItems', ['as' => 'menuItemsOfTarifaspreimpresion']);
|
$routes->post('menuitems', 'Tarifapreimpresion::menuItems', ['as' => 'menuItemsOfTarifaspreimpresion']);
|
||||||
|
$routes->get('gettarifas', 'Tarifapreimpresion::getSelect2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -185,6 +188,7 @@ $routes->group('tarifaextra', ['namespace' => 'App\Controllers\Tarifas'], functi
|
|||||||
$routes->get('delete/(:num)', 'Tarifaextra::delete/$1', ['as' => 'deleteTarifaextra']);
|
$routes->get('delete/(:num)', 'Tarifaextra::delete/$1', ['as' => 'deleteTarifaextra']);
|
||||||
$routes->post('allmenuitems', 'Tarifaextra::allItemsSelect', ['as' => 'select2ItemsOfTarifasextra']);
|
$routes->post('allmenuitems', 'Tarifaextra::allItemsSelect', ['as' => 'select2ItemsOfTarifasextra']);
|
||||||
$routes->post('menuitems', 'Tarifaextra::menuItems', ['as' => 'menuItemsOfTarifasextra']);
|
$routes->post('menuitems', 'Tarifaextra::menuItems', ['as' => 'menuItemsOfTarifasextra']);
|
||||||
|
$routes->get('gettarifas', 'Tarifaextra::getSelect2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -200,6 +204,7 @@ $routes->group('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas'],
|
|||||||
$routes->post('allmenuitems', 'Tarifasmanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasManipulado']);
|
$routes->post('allmenuitems', 'Tarifasmanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasManipulado']);
|
||||||
$routes->post('menuitems', 'Tarifasmanipulado::menuItems', ['as' => 'menuItemsOfTarifasManipulado']);
|
$routes->post('menuitems', 'Tarifasmanipulado::menuItems', ['as' => 'menuItemsOfTarifasManipulado']);
|
||||||
$routes->get('select', 'Tarifasmanipulado::show_select', ["as" => "showSelectTarifaManipulado"]);
|
$routes->get('select', 'Tarifasmanipulado::show_select', ["as" => "showSelectTarifaManipulado"]);
|
||||||
|
$routes->get('gettarifas', 'Tarifasmanipulado::getSelect2');
|
||||||
});
|
});
|
||||||
$routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasmanipulado', 'except' => 'show,new,create,update']);
|
$routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasmanipulado', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
@ -495,6 +500,7 @@ $routes->group('tarifasencuadernacion', ['namespace' => 'App\Controllers\Tarifas
|
|||||||
$routes->post('datatable', 'Tarifasencuadernacion::datatable', ['as' => 'dataTableOfTarifasEncuadernacion']);
|
$routes->post('datatable', 'Tarifasencuadernacion::datatable', ['as' => 'dataTableOfTarifasEncuadernacion']);
|
||||||
$routes->post('allmenuitems', 'Tarifasencuadernacion::allItemsSelect', ['as' => 'select2ItemsOfTarifasEncuadernacion']);
|
$routes->post('allmenuitems', 'Tarifasencuadernacion::allItemsSelect', ['as' => 'select2ItemsOfTarifasEncuadernacion']);
|
||||||
$routes->post('menuitems', 'Tarifasencuadernacion::menuItems', ['as' => 'menuItemsOfTarifasEncuadernacion']);
|
$routes->post('menuitems', 'Tarifasencuadernacion::menuItems', ['as' => 'menuItemsOfTarifasEncuadernacion']);
|
||||||
|
$routes->get('gettarifas', 'Tarifasencuadernacion::getSelect2');
|
||||||
});
|
});
|
||||||
$routes->resource('tarifasencuadernacion', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasencuadernacion', 'except' => 'show,new,create,update']);
|
$routes->resource('tarifasencuadernacion', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasencuadernacion', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
@ -619,6 +625,16 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos
|
|||||||
$routes->post('datatable_2', 'Presupuestoadmin::datatable_2', ['as' => 'updateDataOfPresupuestoAdmin']);
|
$routes->post('datatable_2', 'Presupuestoadmin::datatable_2', ['as' => 'updateDataOfPresupuestoAdmin']);
|
||||||
$routes->post('allmenuitems', 'Presupuestoadmin::allItemsSelect', ['as' => 'select2ItemsOfPresupuestoAdmin']);
|
$routes->post('allmenuitems', 'Presupuestoadmin::allItemsSelect', ['as' => 'select2ItemsOfPresupuestoAdmin']);
|
||||||
$routes->post('menuitems', 'Presupuestoadmin::menuItems', ['as' => 'menuItemsOfPresupuestoAdmin']);
|
$routes->post('menuitems', 'Presupuestoadmin::menuItems', ['as' => 'menuItemsOfPresupuestoAdmin']);
|
||||||
|
|
||||||
|
$routes->get('cargar/(:any)', 'Presupuestoadmin::cargar/$1');
|
||||||
|
$routes->post('comparadorinterior', 'Presupuestoadmin::obtenerComparadorInterior');
|
||||||
|
$routes->post('comparadorexteriores', 'Presupuestoadmin::obtenerComparadorExteriores');
|
||||||
|
$routes->post('comparadorguardas', 'Presupuestoadmin::obtenerComparadorGuardas');
|
||||||
|
$routes->get('papelgenerico', 'Presupuestoadmin::getPapelGenerico');
|
||||||
|
$routes->get('papelgramaje', 'Presupuestoadmin::getGramaje');
|
||||||
|
$routes->get('papelimpresion', 'Presupuestoadmin::getPapelImpresion');
|
||||||
|
$routes->get('maquinas', 'Presupuestoadmin::getMaquinas');
|
||||||
|
$routes->post('getlinea', 'Presupuestoadmin::getLineaPresupuesto');
|
||||||
});
|
});
|
||||||
$routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']);
|
$routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
@ -643,32 +659,43 @@ $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuest
|
|||||||
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);
|
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
$routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
$routes->post('datatable', 'Presupuestoacabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']);
|
$routes->get('getacabados', 'Presupuestoacabados::getAcabados');
|
||||||
|
$routes->post('getvalues', 'Presupuestoacabados::getRowValues');
|
||||||
$routes->post('menuitems', 'Presupuestoacabados::menuItems', ['as' => 'menuItemsOfPresupuestoAcabados']);
|
$routes->post('menuitems', 'Presupuestoacabados::menuItems', ['as' => 'menuItemsOfPresupuestoAcabados']);
|
||||||
$routes->post('edit/(:num)', 'Presupuestoacabados::edit/$1', ['as' => 'updatePresupuestoacabados']);
|
$routes->post('edit/(:num)', 'Presupuestoacabados::edit/$1', ['as' => 'updatePresupuestoacabados']);
|
||||||
$routes->get('getacabados', 'Presupuestoacabados::getAcabados');
|
$routes->get('cargar', 'Presupuestoacabados::cargar');
|
||||||
|
$routes->post('update/(:num)', 'Presupuestoacabados::update/$1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
$routes->post('datatable', 'Presupuestoencuadernaciones::datatable', ['as' => 'dataTableOfPresupuestoEncuadernaciones']);
|
$routes->post('datatable', 'Presupuestoencuadernaciones::datatable', ['as' => 'dataTableOfPresupuestoEncuadernaciones']);
|
||||||
|
$routes->post('getvalues', 'Presupuestoencuadernaciones::getRowValues');
|
||||||
$routes->post('menuitems', 'Presupuestoencuadernaciones::menuItems', ['as' => 'menuItemsOfPresupuestoEncuadernaciones']);
|
$routes->post('menuitems', 'Presupuestoencuadernaciones::menuItems', ['as' => 'menuItemsOfPresupuestoEncuadernaciones']);
|
||||||
$routes->get('delete/(:num)', 'Presupuestoencuadernaciones::delete/$1', ['as' => 'deletePresupuestoencuadernaciones']);
|
$routes->get('delete/(:num)', 'Presupuestoencuadernaciones::delete/$1', ['as' => 'deletePresupuestoencuadernaciones']);
|
||||||
$routes->post('edit/(:num)', 'Presupuestoencuadernaciones::edit/$1', ['as' => 'updatePresupuestoencuadernaciones']);
|
$routes->post('edit/(:num)', 'Presupuestoencuadernaciones::edit/$1', ['as' => 'updatePresupuestoencuadernaciones']);
|
||||||
|
$routes->post('update/(:num)', 'Presupuestoencuadernaciones::update/$1');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('serviciosmanipulados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('serviciosmanipulados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
|
$routes->post('getvalues', 'Presupuestomanipulados::getRowValues');
|
||||||
$routes->post('datatable', 'Presupuestomanipulados::datatable', ['as' => 'dataTableOfPresupuestoManipulados']);
|
$routes->post('datatable', 'Presupuestomanipulados::datatable', ['as' => 'dataTableOfPresupuestoManipulados']);
|
||||||
$routes->post('edit/(:num)', 'Presupuestomanipulados::edit/$1', ['as' => 'updatePresupuestomanipulados']);
|
$routes->post('edit/(:num)', 'Presupuestomanipulados::edit/$1', ['as' => 'updatePresupuestomanipulados']);
|
||||||
|
$routes->post('update/(:num)', 'Presupuestomanipulados::update/$1');
|
||||||
|
$routes->get('serviciosolapas', 'Presupuestomanipulados::getServicioSolapas');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('serviciospreimpresiones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('serviciospreimpresiones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
|
$routes->post('getvalues', 'Presupuestopreimpresiones::getRowValues');
|
||||||
$routes->post('datatable', 'Presupuestopreimpresiones::datatable', ['as' => 'dataTableOfPresupuestoPreimpresiones']);
|
$routes->post('datatable', 'Presupuestopreimpresiones::datatable', ['as' => 'dataTableOfPresupuestoPreimpresiones']);
|
||||||
$routes->post('edit/(:num)', 'Presupuestopreimpresiones::edit/$1', ['as' => 'updatePresupuestopreimpresiones']);
|
$routes->post('edit/(:num)', 'Presupuestopreimpresiones::edit/$1', ['as' => 'updatePresupuestopreimpresiones']);
|
||||||
|
$routes->get('cargar', 'Presupuestopreimpresiones::getSelect2');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('serviciosextra', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('serviciosextra', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
$routes->post('datatable', 'Presupuestoserviciosextra::datatable', ['as' => 'dataTableOfPresupuestoServiciosExtra']);
|
$routes->post('datatable', 'Presupuestoserviciosextra::datatable', ['as' => 'dataTableOfPresupuestoServiciosExtra']);
|
||||||
$routes->post('edit/(:num)', 'Presupuestoserviciosextra::edit/$1', ['as' => 'updatePresupuestoServiciosExtra']);
|
$routes->post('edit/(:num)', 'Presupuestoserviciosextra::edit/$1', ['as' => 'updatePresupuestoServiciosExtra']);
|
||||||
|
$routes->post('getvalues', 'Presupuestoserviciosextra::getRowValues');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
|
|||||||
@ -89,6 +89,8 @@ class Users extends \App\Controllers\GoBaseController
|
|||||||
|
|
||||||
// Marcar el username como NULL
|
// Marcar el username como NULL
|
||||||
$sanitizedData = $this->sanitized($postData, true);
|
$sanitizedData = $this->sanitized($postData, true);
|
||||||
|
$email = $sanitizedData['email'];
|
||||||
|
unset($sanitizedData['email']);
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
|
|
||||||
@ -100,7 +102,7 @@ class Users extends \App\Controllers\GoBaseController
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
// The Email is unique
|
// The Email is unique
|
||||||
if ($this->user_model->isEmailUnique($sanitizedData['email'])) {
|
if ($this->user_model->isEmailUnique($email)) {
|
||||||
|
|
||||||
// Crear el usuario si pasa la validación
|
// Crear el usuario si pasa la validación
|
||||||
$user = new \CodeIgniter\Shield\Entities\User([
|
$user = new \CodeIgniter\Shield\Entities\User([
|
||||||
@ -109,8 +111,6 @@ class Users extends \App\Controllers\GoBaseController
|
|||||||
'last_name' => $sanitizedData['last_name'],
|
'last_name' => $sanitizedData['last_name'],
|
||||||
'cliente_id' => $sanitizedData['cliente_id'],
|
'cliente_id' => $sanitizedData['cliente_id'],
|
||||||
'comments' => $sanitizedData['comments'],
|
'comments' => $sanitizedData['comments'],
|
||||||
'email' => $sanitizedData['email'],
|
|
||||||
'password' => $sanitizedData['password'],
|
|
||||||
'status' => $sanitizedData['status'] ?? 0,
|
'status' => $sanitizedData['status'] ?? 0,
|
||||||
'active' => $sanitizedData['active'] ?? 0,
|
'active' => $sanitizedData['active'] ?? 0,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -33,13 +33,6 @@ class Js_loader extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function datosLibro_js()
|
|
||||||
{
|
|
||||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
|
||||||
return view('themes/vuexy/form/presupuestos/admin/_datosLibroItems.js');
|
|
||||||
}
|
|
||||||
|
|
||||||
function previsualizador_js()
|
function previsualizador_js()
|
||||||
{
|
{
|
||||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||||
|
|||||||
@ -69,30 +69,61 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
|||||||
return;
|
return;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$postData = $this->request->getJSON();
|
$postData = $this->request->getPost();
|
||||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
$datos_tarifas = $postData['datos'] ?? [];
|
||||||
$tirada = $postData->tirada ?? 0;
|
$tirada = $postData['tirada'] ?? 0;
|
||||||
$POD = $postData->POD ?? 0;
|
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||||
$result = [];
|
|
||||||
|
|
||||||
if (count($tarifas) > 0) {
|
$result = $this->getServiciosAcabados($datos_tarifas, $tirada, $POD);
|
||||||
foreach ($tarifas as $tarifa) {
|
|
||||||
$values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD);
|
|
||||||
array_push($result, $values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
$data = [
|
$data = [
|
||||||
'lines' => $result,
|
'lineas' => $result,
|
||||||
$csrfTokenName => $newTokenHash
|
$csrfTokenName => $newTokenHash
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function datatable()
|
public function getServiciosAcabados($datos_tarifas, $tirada, $POD){
|
||||||
|
|
||||||
|
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||||
|
$result = [];
|
||||||
|
if (count($datos_tarifas) > 0) {
|
||||||
|
foreach ($datos_tarifas as $tarifa) {
|
||||||
|
$proveedor = $tarifa['proveedor_id'] == '' ? -1 : $tarifa['proveedor_id'];
|
||||||
|
|
||||||
|
$values = $model->getPrecioTarifa($tarifa['tarifa_id'], $tirada, $proveedor, $POD);
|
||||||
|
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
|
||||||
|
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
|
||||||
|
array_push($result, $values[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cargar()
|
||||||
|
{
|
||||||
|
if($this->request->isAJAX()) {
|
||||||
|
$presupuesto_id = $this->request->getGet('presupuesto_id') ?? null;
|
||||||
|
|
||||||
|
$rows = $this->model->getResource($presupuesto_id)->get()->getResultObject();
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
$data = [
|
||||||
|
'rows' => $rows,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRowValues()
|
||||||
{
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
$reqData = $this->request->getPost();
|
$reqData = $this->request->getPost();
|
||||||
@ -100,7 +131,7 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
|||||||
$tarifa_acabado_id = $reqData['tarifa_acabado_id'] ?? 0;
|
$tarifa_acabado_id = $reqData['tarifa_acabado_id'] ?? 0;
|
||||||
$tirada = $reqData['tirada'] ?? 0;
|
$tirada = $reqData['tirada'] ?? 0;
|
||||||
$proveedor_id = $reqData['proveedor_id'] ?? -1;
|
$proveedor_id = $reqData['proveedor_id'] ?? -1;
|
||||||
$POD = $reqData['POD'] ?? 0;
|
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||||
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
@ -195,4 +226,6 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
|||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -126,6 +126,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$this->viewData['POD'] = $POD;
|
$this->viewData['POD'] = $POD;
|
||||||
$this->viewData['lomo_maximo'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('lomo_maximo')->value;
|
$this->viewData['lomo_maximo'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('lomo_maximo')->value;
|
||||||
$this->viewData['lomo_minimo_fresado_cosido'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('lomo_minimo_fresado_cosido')->value;
|
$this->viewData['lomo_minimo_fresado_cosido'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('lomo_minimo_fresado_cosido')->value;
|
||||||
|
$this->viewData['eb'] = 0;
|
||||||
|
|
||||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.addNewSuffix');
|
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.addNewSuffix');
|
||||||
|
|
||||||
@ -166,6 +167,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$this->viewData['POD'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
$this->viewData['POD'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||||
$this->viewData['lomo_maximo'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('lomo_maximo')->value;
|
$this->viewData['lomo_maximo'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('lomo_maximo')->value;
|
||||||
$this->viewData['lomo_minimo_fresado_cosido'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('lomo_minimo_fresado_cosido')->value;
|
$this->viewData['lomo_minimo_fresado_cosido'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('lomo_minimo_fresado_cosido')->value;
|
||||||
|
$this->viewData['eb'] = $presupuestoEntity->envio_base;
|
||||||
|
|
||||||
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
|
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
|
||||||
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
|
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
|
||||||
if ($presupuestoEntity->is_duplicado) {
|
if ($presupuestoEntity->is_duplicado) {
|
||||||
@ -308,7 +311,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$datosPedido = (object) array(
|
$datosPedido = (object) array(
|
||||||
'paginas' => $paginas,
|
'paginas' => $paginas,
|
||||||
'tirada' => $tirada[0],
|
'tirada' => $tirada[0],
|
||||||
'merma' => $tirada[0] > $POD ? $this->calcular_merma($tirada[0], $POD) : 0,
|
'merma' => $this->calcular_merma($tirada[0], $POD),
|
||||||
'ancho' => intval($tamanio['ancho']) ?? 100000,
|
'ancho' => intval($tamanio['ancho']) ?? 100000,
|
||||||
'alto' => intval($tamanio['alto']) ?? 100000,
|
'alto' => intval($tamanio['alto']) ?? 100000,
|
||||||
'isCosido' => $is_cosido,
|
'isCosido' => $is_cosido,
|
||||||
@ -345,6 +348,51 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$lomo += floatval($linea['mano']);
|
$lomo += floatval($linea['mano']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Guardas
|
||||||
|
$guardas = $reqData['guardas'] ?? [];
|
||||||
|
if ($guardas != "false" && $guardas != null) {
|
||||||
|
$datos_guardas = [
|
||||||
|
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
|
||||||
|
'gramaje' => intval($guardas['gramaje']),
|
||||||
|
'caras' => intval($guardas['caras']),
|
||||||
|
];
|
||||||
|
} else
|
||||||
|
$datos_guardas = false;
|
||||||
|
$guardas = [];
|
||||||
|
$peso_guardas = 0.0;
|
||||||
|
$coste_guardas = 0.0;
|
||||||
|
if ($datos_guardas != 0) {
|
||||||
|
if (count($datos_guardas) != 0 && $datos_guardas) {
|
||||||
|
|
||||||
|
$guardas = $datos_guardas;
|
||||||
|
$input_data['papel_generico'] = $datos_guardas['papel'] ?? 0;
|
||||||
|
$input_data['gramaje'] = $datos_guardas['gramaje'] ?? 0;
|
||||||
|
$input_data['datosPedido']->paginas = 8;
|
||||||
|
$input_data['paginas_color'] = 8;
|
||||||
|
$input_data['datosPedido']->paginas_impresion = $datos_guardas['caras'] ?? 0;
|
||||||
|
$input_data['datosPedido']->solapas_ancho = 0;
|
||||||
|
$input_data['datosPedido']->solapas = 0;
|
||||||
|
$input_data['isColor'] = 1;
|
||||||
|
$input_data['isHq'] = 1;
|
||||||
|
$input_data['uso'] = 'guardas';
|
||||||
|
|
||||||
|
// Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico
|
||||||
|
// y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral
|
||||||
|
// o wire-o tapa dura, las guardas se imprimen como hojas sueltas
|
||||||
|
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
||||||
|
$input_data['datosPedido']->isCosido = true;
|
||||||
|
} else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
|
||||||
|
$input_data['datosPedido']->isCosido = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$guardas = PresupuestoClienteService::obtenerGuardas($input_data);
|
||||||
|
|
||||||
|
if ($guardas != null && count($guardas) > 0) {
|
||||||
|
$lomo += floatval($guardas['mano']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$lomo = round($lomo, 2);
|
$lomo = round($lomo, 2);
|
||||||
$errors = [
|
$errors = [
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
@ -368,8 +416,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = (object) array('lomo' => $lomo,
|
$data = (object) array(
|
||||||
'errors' => $errors);
|
'lomo' => $lomo,
|
||||||
|
'errors' => $errors
|
||||||
|
);
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -377,9 +427,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calcular()
|
public function calcular($data = -1)
|
||||||
{
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request) {
|
||||||
|
if ($this->request->isAJAX())
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
} else {
|
||||||
|
if ($data == -1) {
|
||||||
|
return "Error: sin datos";
|
||||||
|
}
|
||||||
|
$reqData = $data;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -392,6 +450,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$cliente_id = $reqData['clienteId'] ?? -1;
|
$cliente_id = $reqData['clienteId'] ?? -1;
|
||||||
|
|
||||||
$tirada = $reqData['tirada'] ?? 0;
|
$tirada = $reqData['tirada'] ?? 0;
|
||||||
|
$selectedTirada = $reqData['selectedTirada'] ?? -1;
|
||||||
$tamanio = $reqData['tamanio'];
|
$tamanio = $reqData['tamanio'];
|
||||||
$paginas = $reqData['paginas'] ?? 0;
|
$paginas = $reqData['paginas'] ?? 0;
|
||||||
$paginas_color = $reqData['paginasColor'] ?? 0;
|
$paginas_color = $reqData['paginasColor'] ?? 0;
|
||||||
@ -504,21 +563,66 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($direcciones) > 1) {
|
// calculo del envio base (tirada_maxima)
|
||||||
|
$return_data['eb'] = [];
|
||||||
|
for ($i = 0; $i < count($tirada); $i++) {
|
||||||
|
$direccion = [];
|
||||||
|
$coste_direccion = $this->getCosteEnvio(
|
||||||
|
$direccion,
|
||||||
|
$return_data['peso'][$i],
|
||||||
|
$tirada[$i],
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!property_exists($coste_direccion, 'coste')) {
|
||||||
|
$errorModel = new ErrorPresupuesto();
|
||||||
|
$data['direccion'] = 'Sin direccion';
|
||||||
|
$data['peso'] = $return_data['peso'][$i];
|
||||||
|
$data['palets'] = 'Sin direccion';
|
||||||
|
$errorModel->insertError(
|
||||||
|
$id,
|
||||||
|
auth()->user()->id,
|
||||||
|
'No se ha podido calcular el coste de envío',
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
$return_data = [
|
||||||
|
'errors' => (object) ([
|
||||||
|
'status' => 1
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
return $return_data;
|
||||||
|
} else {
|
||||||
|
$return_data['eb'][$i] = round($coste_direccion->coste, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$envio_base = true;
|
||||||
|
if (count($direcciones) > 0) {
|
||||||
|
|
||||||
for ($i = 0; $i < count($tirada); $i++) {
|
for ($i = 0; $i < count($tirada); $i++) {
|
||||||
|
|
||||||
$coste_envio = 0.0;
|
$coste_envio = 0.0;
|
||||||
$primer_envio = false;
|
|
||||||
foreach ($direcciones as $direccion) {
|
foreach ($direcciones as $direccion) {
|
||||||
|
// El primer envio no se calcula ya que se añade el base
|
||||||
|
if ($envio_base) {
|
||||||
|
//aporte del envio al precio unidad
|
||||||
|
$coste_envio += ($return_data['eb'][$i] / $tirada[$i]);
|
||||||
|
$envio_base = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($selectedTirada > 0) {
|
||||||
|
$unidades = floor($direccion['unidades'] * $tirada[$i] / $selectedTirada);
|
||||||
|
} else {
|
||||||
|
$unidades = $direccion['unidades'];
|
||||||
|
}
|
||||||
$coste_direccion = $this->getCosteEnvio(
|
$coste_direccion = $this->getCosteEnvio(
|
||||||
$direccion['id'],
|
$direccion['direccion'],
|
||||||
$return_data['peso'][$i],
|
$return_data['peso'][$i],
|
||||||
!$primer_envio ? intval($tirada[$i]) : $direccion['unidades'],
|
$unidades,
|
||||||
$direccion['entregaPalets'] == 'true' ? 1 : 0
|
$direccion['entregaPalets'] == 'true' ? 1 : 0,
|
||||||
)[0];
|
false,
|
||||||
|
);
|
||||||
$primer_envio = true;
|
|
||||||
|
|
||||||
if (!property_exists($coste_direccion, 'coste')) {
|
if (!property_exists($coste_direccion, 'coste')) {
|
||||||
|
|
||||||
@ -539,50 +643,35 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
];
|
];
|
||||||
return $return_data;
|
return $return_data;
|
||||||
} else {
|
} else {
|
||||||
$coste_envio += $coste_direccion->coste;
|
//aporte del envio al precio unidad
|
||||||
|
$coste_envio += ($coste_direccion->coste / $tirada[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio / $tirada[$i], 4);
|
$return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio, 4);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for ($i = 0; $i < count($tirada); $i++) {
|
for ($i = 0; $i < count($tirada); $i++) {
|
||||||
|
|
||||||
$coste_envio = 0.0;
|
$coste_envio = 0.0;
|
||||||
$coste_direccion = $this->getCosteEnvio(null, $return_data['peso'][$i], $tirada[$i], false)[0];
|
$coste_envio += ($return_data['eb'][$i] / $tirada[$i]);
|
||||||
|
$return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio, 4);
|
||||||
if (!property_exists($coste_direccion, 'coste')) {
|
|
||||||
$errorModel = new ErrorPresupuesto();
|
|
||||||
$data['direccion'] = 'Sin direccion';
|
|
||||||
$data['peso'] = $return_data['peso'][$i];
|
|
||||||
$data['palets'] = 'Sin direccion';
|
|
||||||
$errorModel->insertError(
|
|
||||||
$id,
|
|
||||||
auth()->user()->id,
|
|
||||||
'No se ha podido calcular el coste de envío',
|
|
||||||
$data
|
|
||||||
);
|
|
||||||
$return_data = [
|
|
||||||
'errors' => (object) ([
|
|
||||||
'status' => 1
|
|
||||||
]),
|
|
||||||
];
|
|
||||||
return $return_data;
|
|
||||||
} else {
|
|
||||||
$coste_envio += $coste_direccion->coste;
|
|
||||||
}
|
|
||||||
|
|
||||||
$return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio / $tirada[$i], 4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($this->request) {
|
||||||
|
if ($this->request->isAJAX())
|
||||||
return $this->respond($return_data);
|
return $this->respond($return_data);
|
||||||
} catch (Exception $e) {
|
|
||||||
return $this->failServerError($e->getMessage() . ' - ' . $e->getFile() . ' - ' . $e->getLine());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $return_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if ($this->request) {
|
||||||
|
if ($this->request->isAJAX())
|
||||||
|
return $this->failServerError($e->getMessage() . ' - ' . $e->getFile() . ' - ' . $e->getLine());
|
||||||
|
} else {
|
||||||
|
return "Error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -659,7 +748,20 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
if ($interior == null) {
|
if ($interior == null) {
|
||||||
return $this->failServerError('Error al calcular el interior');
|
return $this->failServerError('Error al calcular el interior');
|
||||||
}
|
}
|
||||||
$anchoTotal = $interior[0]['mano'];
|
|
||||||
|
$anchoTotal = 0;
|
||||||
|
if (count($interior) == 2) {
|
||||||
|
|
||||||
|
if (count($interior[0]) > 0)
|
||||||
|
$anchoTotal += $interior[0]['mano'];
|
||||||
|
if (count($interior[1]) > 0)
|
||||||
|
$anchoTotal += $interior[1]['mano'];
|
||||||
|
} else {
|
||||||
|
if (count($interior) > 0)
|
||||||
|
$anchoTotal += $interior['mano'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// le añadimos 2*ancho libro
|
// le añadimos 2*ancho libro
|
||||||
$anchoTotal += 2 * $datosPedido->ancho;
|
$anchoTotal += 2 * $datosPedido->ancho;
|
||||||
// le añadimos los dobleces de las solapas
|
// le añadimos los dobleces de las solapas
|
||||||
@ -839,17 +941,20 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$datosCabecera = $reqData['datosCabecera'] ?? [];
|
$datosCabecera = $reqData['datosCabecera'] ?? [];
|
||||||
|
|
||||||
|
|
||||||
$confirmar = $reqData['confirmar'] ?? 0;
|
$confirmar = $reqData['confirmar'] ?? 0;
|
||||||
$confirmar = intval($confirmar);
|
$confirmar = intval($confirmar);
|
||||||
|
|
||||||
$cliente_id = $reqData['clienteId'] ?? -1;
|
$cliente_id = $reqData['clienteId'] ?? -1;
|
||||||
|
|
||||||
$tirada = $reqData['tirada'] ?? 0;
|
$tirada = $reqData['tirada'] ?? [];
|
||||||
$selected_tirada = $reqData['selectedTirada'] ?? 0;
|
$selected_tirada = $reqData['selectedTirada'] ?? 0;
|
||||||
$tamanio = $reqData['tamanio'];
|
$tamanio = $reqData['tamanio'];
|
||||||
$paginas = $reqData['paginas'] ?? 0;
|
$paginas = $reqData['paginas'] ?? 0;
|
||||||
$paginas_color = $reqData['paginasColor'] ?? 0;
|
$paginas_color = $reqData['paginasColor'] ?? 0;
|
||||||
|
|
||||||
|
$envio_base = $reqData['eb'] ?? 0;
|
||||||
|
|
||||||
$posPaginasColor = $reqData['posPaginasColor'] ?? "";
|
$posPaginasColor = $reqData['posPaginasColor'] ?? "";
|
||||||
$paginasColorConsecutivas = $reqData['pagColorConsecutivas'] ?? 0;
|
$paginasColorConsecutivas = $reqData['pagColorConsecutivas'] ?? 0;
|
||||||
$papelInteriorDiferente = $reqData['papelInteriorDiferente'] ?? 0;
|
$papelInteriorDiferente = $reqData['papelInteriorDiferente'] ?? 0;
|
||||||
@ -977,42 +1082,118 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
// seleccionamos el peso de la tirada seleccionada
|
// seleccionamos el peso de la tirada seleccionada
|
||||||
$peso_libro = $resultado_presupuesto['peso'][array_search($selected_tirada, $tirada)];
|
$peso_libro = $resultado_presupuesto['peso'][array_search($selected_tirada, $tirada)];
|
||||||
|
|
||||||
|
// calculo del envio base (tirada_maxima)
|
||||||
|
$resultado_presupuesto['eb'] = [];
|
||||||
|
$datos_presupuesto['envio_base'] = 0;
|
||||||
|
for ($i = 0; $i < count($tirada); $i++) {
|
||||||
|
$direccion = [];
|
||||||
|
$coste_direccion = $this->getCosteEnvio(
|
||||||
|
$direccion,
|
||||||
|
$resultado_presupuesto['peso'][$i],
|
||||||
|
$tirada[$i],
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
if (intval($selected_tirada) == intval($tirada[$i])) {
|
||||||
|
$datos_presupuesto['envio_base'] = round($coste_direccion->coste * (1 + $coste_direccion->margen / 100.0), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!property_exists($coste_direccion, 'coste')) {
|
||||||
|
$errorModel = new ErrorPresupuesto();
|
||||||
|
$data['direccion'] = 'Sin direccion';
|
||||||
|
$data['peso'] = $resultado_presupuesto['peso'][$i];
|
||||||
|
$data['palets'] = 'Sin direccion';
|
||||||
|
$errorModel->insertError(
|
||||||
|
$id,
|
||||||
|
auth()->user()->id,
|
||||||
|
'No se ha podido calcular el coste de envío',
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
$resultado_presupuesto = [
|
||||||
|
'errors' => (object) ([
|
||||||
|
'status' => 1
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
return $resultado_presupuesto;
|
||||||
|
} else {
|
||||||
|
$resultado_presupuesto['eb'][$i] = round($coste_direccion->coste, 2);
|
||||||
|
$resultado_presupuesto['eb_margen'][$i] = round($coste_direccion->margen, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (count($direcciones) > 1) {
|
|
||||||
|
|
||||||
for ($i = 0; $i < count($tirada); $i++) {
|
for ($i = 0; $i < count($tirada); $i++) {
|
||||||
|
|
||||||
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] = 0.0;
|
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] = 0.0;
|
||||||
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] = 0.0;
|
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] = 0.0;
|
||||||
|
|
||||||
$coste_envio = 0.0;
|
|
||||||
foreach ($direcciones as $direccion) {
|
|
||||||
$precio_envio = $this->getCosteEnvio(
|
|
||||||
$direccion['id'],
|
|
||||||
$resultado_presupuesto['peso'][$i],
|
|
||||||
$direccion['unidades'],
|
|
||||||
$direccion['entregaPalets'] == 'true' ? 1 : 0
|
|
||||||
)[0];
|
|
||||||
$coste_envio += $precio_envio->coste;
|
|
||||||
$margen_envio = $precio_envio->margen;
|
|
||||||
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] += $coste_envio - $margen_envio;
|
|
||||||
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] += $margen_envio;
|
|
||||||
}
|
}
|
||||||
$resultado_presupuesto['precio_u'][$i] = round(floatval($resultado_presupuesto['precio_u'][$i]) + $coste_envio / $tirada[$i], 4);
|
if (count($direcciones) > 0) {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
for ($i = 0; $i < count($tirada); $i++) {
|
for ($i = 0; $i < count($tirada); $i++) {
|
||||||
$coste_envio = 0.0;
|
|
||||||
$precio_envio = $this->getCosteEnvio(null, $resultado_presupuesto['peso'][$i], $tirada[$i], false)[0];
|
|
||||||
$coste_envio += $precio_envio->coste;
|
|
||||||
$margen_envio = $precio_envio->margen;
|
|
||||||
$resultado_presupuesto['precio_u'][$i] = round(floatval($resultado_presupuesto['precio_u'][$i]) + $coste_envio / $tirada[$i], 4);
|
|
||||||
|
|
||||||
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] = $coste_envio - $margen_envio;
|
$envio_base = true;
|
||||||
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] = $margen_envio;
|
$coste_envio = 0.0;
|
||||||
|
$margen_envio = 0.0;
|
||||||
|
foreach ($direcciones as $direccion) {
|
||||||
|
// El primer envio no se calcula ya que se añade el base
|
||||||
|
if ($envio_base) {
|
||||||
|
//aporte del envio al precio unidad
|
||||||
|
$coste_envio += ($resultado_presupuesto['eb'][$i] / $tirada[$i]);
|
||||||
|
$margen_envio += ($resultado_presupuesto['eb_margen'][$i] / $tirada[$i]);
|
||||||
|
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] += $resultado_presupuesto['eb'][$i] - $resultado_presupuesto['eb_margen'][$i];
|
||||||
|
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] += $resultado_presupuesto['eb_margen'][$i];
|
||||||
|
$envio_base = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$unidades = floor($direccion['unidades'] * $tirada[$i] / $selected_tirada);
|
||||||
|
$coste_direccion = $this->getCosteEnvio(
|
||||||
|
$direccion['direccion'],
|
||||||
|
$resultado_presupuesto['peso'][$i],
|
||||||
|
$unidades,
|
||||||
|
$direccion['entregaPalets'] == 'true' ? 1 : 0,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!property_exists($coste_direccion, 'coste')) {
|
||||||
|
|
||||||
|
$errorModel = new ErrorPresupuesto();
|
||||||
|
$data['direccion'] = $direccion;
|
||||||
|
$data['peso'] = $resultado_presupuesto['peso'][$i];
|
||||||
|
$data['palets'] = $direccion['entregaPalets'] == 'true' ? 1 : 0;
|
||||||
|
$errorModel->insertError(
|
||||||
|
$id,
|
||||||
|
auth()->user()->id,
|
||||||
|
'No se ha podido calcular el coste de envío',
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
$resultado_presupuesto = [
|
||||||
|
'errors' => (object) ([
|
||||||
|
'status' => 1
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
return $resultado_presupuesto;
|
||||||
|
} else {
|
||||||
|
//aporte del envio al precio unidad
|
||||||
|
$coste_envio += ($coste_direccion->coste / $tirada[$i]);
|
||||||
|
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] += $coste_direccion->coste - $coste_direccion->margen;
|
||||||
|
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] += $coste_direccion->margen;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$resultado_presupuesto['precio_u'][$i] = round(floatval($resultado_presupuesto['precio_u'][$i]) + $coste_envio, 4);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for ($i = 0; $i < count($tirada); $i++) {
|
||||||
|
$coste_envio = 0.0;
|
||||||
|
$coste_envio += ($resultado_presupuesto['eb'][$i] / $tirada[$i]);
|
||||||
|
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] = $resultado_presupuesto['eb'][$i] - $resultado_presupuesto['eb_margen'][$i];
|
||||||
|
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] = $resultado_presupuesto['eb_margen'][$i];
|
||||||
|
$resultado_presupuesto['precio_u'][$i] = round(floatval($resultado_presupuesto['precio_u'][$i]) + $coste_envio, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$model_presupuesto = new PresupuestoModel();
|
$model_presupuesto = new PresupuestoModel();
|
||||||
$tiradas_alternativas = [];
|
$tiradas_alternativas = [];
|
||||||
@ -1057,6 +1238,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$datos_presupuesto['retractilado5'] = $retractilado5;
|
$datos_presupuesto['retractilado5'] = $retractilado5;
|
||||||
$datos_presupuesto['entrega_taller'] = $reqData['entrega_taller'] ?? 0;
|
$datos_presupuesto['entrega_taller'] = $reqData['entrega_taller'] ?? 0;
|
||||||
|
|
||||||
|
|
||||||
|
$resultado_presupuesto['info']['merma'] = $this->calcular_merma($selected_tirada, $POD);
|
||||||
|
|
||||||
$id = $model_presupuesto->insertarPresupuestoCliente(
|
$id = $model_presupuesto->insertarPresupuestoCliente(
|
||||||
$id,
|
$id,
|
||||||
$selected_tirada,
|
$selected_tirada,
|
||||||
@ -1074,17 +1258,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$this->borrarRelacionesPresupuesto($id);
|
$this->borrarRelacionesPresupuesto($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($resultado_presupuesto['info']['interior'] as $linea) {
|
foreach ($resultado_presupuesto['values']['interior'] as $linea) {
|
||||||
|
|
||||||
if (count($linea) > 0)
|
if (count($linea) > 0)
|
||||||
$this->guardarLineaPresupuesto($id, $linea);
|
$this->guardarLineaPresupuesto($id, $linea);
|
||||||
}
|
}
|
||||||
if (count($resultado_presupuesto['info']['cubierta']) > 0)
|
if (count($resultado_presupuesto['values']['cubierta']) > 0)
|
||||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['info']['cubierta']);
|
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['cubierta']);
|
||||||
if (count($resultado_presupuesto['info']['sobrecubierta']) > 0)
|
if (count($resultado_presupuesto['values']['sobrecubierta']) > 0)
|
||||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['info']['sobrecubierta']);
|
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['sobrecubierta']);
|
||||||
if (count($resultado_presupuesto['info']['guardas']) > 0)
|
if (count($resultado_presupuesto['values']['guardas']) > 0)
|
||||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['info']['guardas']);
|
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['guardas']);
|
||||||
|
|
||||||
// Servicios
|
// Servicios
|
||||||
if ($sobrecubierta) {
|
if ($sobrecubierta) {
|
||||||
@ -1110,13 +1294,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
foreach ($resultado_presupuesto['info']['serviciosDefecto']['encuadernacion'] as $servicio) {
|
foreach ($resultado_presupuesto['values']['serviciosDefecto']['encuadernacion'] as $servicio) {
|
||||||
$this->guardarServicio($id, $servicio, 'encuadernacion');
|
$this->guardarServicio($id, $servicio, 'encuadernacion');
|
||||||
}
|
}
|
||||||
foreach ($resultado_presupuesto['info']['serviciosDefecto']['manipulado'] as $servicio) {
|
foreach ($resultado_presupuesto['values']['serviciosDefecto']['manipulado'] as $servicio) {
|
||||||
$this->guardarServicio($id, $servicio, 'manipulado');
|
$this->guardarServicio($id, $servicio, 'manipulado');
|
||||||
}
|
}
|
||||||
foreach ($resultado_presupuesto['info']['servicios_automaticos'] as $servicio) {
|
foreach ($resultado_presupuesto['values']['servicios_automaticos'] as $servicio) {
|
||||||
if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) {
|
if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) {
|
||||||
// Servicios acabado
|
// Servicios acabado
|
||||||
$this->guardarServicio($id, $servicio, 'acabado');
|
$this->guardarServicio($id, $servicio, 'acabado');
|
||||||
@ -1171,6 +1355,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
if ($presupuesto) {
|
if ($presupuesto) {
|
||||||
$data['lc'] = $presupuesto->lomo_cubierta;
|
$data['lc'] = $presupuesto->lomo_cubierta;
|
||||||
$data['lsc'] = $presupuesto->lomo_sobrecubierta;
|
$data['lsc'] = $presupuesto->lomo_sobrecubierta;
|
||||||
|
$data['eb'] = $presupuesto->envio_base;
|
||||||
$data['state'] = intval($presupuesto->estado_id);
|
$data['state'] = intval($presupuesto->estado_id);
|
||||||
$data['datosGenerales']['titulo'] = $presupuesto->titulo;
|
$data['datosGenerales']['titulo'] = $presupuesto->titulo;
|
||||||
$data['datosGenerales']['autor'] = $presupuesto->autor;
|
$data['datosGenerales']['autor'] = $presupuesto->autor;
|
||||||
@ -1180,6 +1365,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$data['datosGenerales']['paginas'] = $presupuesto->paginas;
|
$data['datosGenerales']['paginas'] = $presupuesto->paginas;
|
||||||
$data['datosGenerales']['paginasCuadernillo'] = $presupuesto->paginasCuadernillo;
|
$data['datosGenerales']['paginasCuadernillo'] = $presupuesto->paginasCuadernillo;
|
||||||
$data['datosGenerales']['tirada'] = $presupuesto->tirada;
|
$data['datosGenerales']['tirada'] = $presupuesto->tirada;
|
||||||
|
$data['datosGenerales']['selectedTirada'] = $presupuesto->tirada;
|
||||||
$data['datosGenerales']['ivaReducido'] = $presupuesto->iva_reducido;
|
$data['datosGenerales']['ivaReducido'] = $presupuesto->iva_reducido;
|
||||||
$data['datosGenerales']['excluirRotativa'] = $presupuesto->excluir_rotativa;
|
$data['datosGenerales']['excluirRotativa'] = $presupuesto->excluir_rotativa;
|
||||||
$data['datosGenerales']['clienteId'] = $presupuesto->cliente_id;
|
$data['datosGenerales']['clienteId'] = $presupuesto->cliente_id;
|
||||||
@ -1205,9 +1391,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$data['datosGenerales']['retractilado5'] = $presupuesto->retractilado5;
|
$data['datosGenerales']['retractilado5'] = $presupuesto->retractilado5;
|
||||||
|
|
||||||
$datos_papel = $this->obtenerDatosPapel($presupuesto->id);
|
$datos_papel = $this->obtenerDatosPapel($presupuesto->id);
|
||||||
$data['interior'] = $datos_papel['interior'] ? $datos_papel['interior'] : [];
|
if (array_key_exists('interior', $datos_papel)) {
|
||||||
|
$data['interior'] = $datos_papel['interior'];
|
||||||
|
} else {
|
||||||
|
$data['interior'] = [];
|
||||||
|
}
|
||||||
|
|
||||||
$data['cubierta'] = $datos_papel['cubierta'] ? $datos_papel['cubierta'] : [];
|
if (array_key_exists('cubierta', $datos_papel)) {
|
||||||
|
$data['cubierta'] = $datos_papel['cubierta'];
|
||||||
|
} else {
|
||||||
|
$data['cubierta'] = [];
|
||||||
|
}
|
||||||
$data['cubierta']['tapa'] = $this->obtenerTipoTapa($presupuesto->tipo_impresion_id ?? null);
|
$data['cubierta']['tapa'] = $this->obtenerTipoTapa($presupuesto->tipo_impresion_id ?? null);
|
||||||
$data['cubierta']['lomoRedondo'] = $presupuesto->lomo_redondo ? 1 : 0;
|
$data['cubierta']['lomoRedondo'] = $presupuesto->lomo_redondo ? 1 : 0;
|
||||||
$data['cubierta']['solapas'] = $presupuesto->solapas ? 1 : 0;
|
$data['cubierta']['solapas'] = $presupuesto->solapas ? 1 : 0;
|
||||||
@ -1243,7 +1437,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
if (intval($presupuesto->recoger_en_taller) == 1) {
|
if (intval($presupuesto->recoger_en_taller) == 1) {
|
||||||
$data['direcciones']['entrega_taller'] = 1;
|
$data['direcciones']['entrega_taller'] = 1;
|
||||||
} else {
|
} else {
|
||||||
$data['direcciones']['entrega_taller'] = 0;
|
|
||||||
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
|
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1410,26 +1603,27 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$peso_envio = $peso_libro * $unidades / 1000.0;
|
$peso_envio = $peso_libro * $unidades / 1000.0;
|
||||||
|
|
||||||
$data = $this->getCosteEnvio(
|
$data = $this->getCosteEnvio(
|
||||||
$direccion['id'],
|
$direccion['direccion'],
|
||||||
$peso_libro,
|
$peso_libro,
|
||||||
$direccion['unidades'],
|
$direccion['unidades'],
|
||||||
$direccion['entregaPalets'] == 'false' ? 0 : 1
|
$direccion['entregaPalets'] == 'false' ? 0 : 1,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($data) > 0) {
|
if (isset($data->coste)) {
|
||||||
|
|
||||||
$data[0]->presupuesto_id = $presupuestoId;
|
$data->presupuesto_id = $presupuestoId;
|
||||||
$data[0]->tarifa_id = $data[0]->id;
|
$data->tarifa_id = $data->id;
|
||||||
unset($data[0]->id);
|
unset($data->id);
|
||||||
$data[0]->precio = $data[0]->coste;
|
$data->precio = $data->coste;
|
||||||
unset($data[0]->coste);
|
unset($data->coste);
|
||||||
$data[0]->entregaPieCalle = $direccion['entregaPalets'] == 'false' ? 0 : 1;
|
$data->entregaPieCalle = $direccion['entregaPalets'] == 'false' ? 0 : 1;
|
||||||
unset($data[0]->tipo);
|
unset($data->tipo);
|
||||||
$data[0]->peso = $peso_envio;
|
$data->peso = $peso_envio;
|
||||||
$data[0]->cantidad = $unidades;
|
$data->cantidad = $unidades;
|
||||||
|
|
||||||
$model = new PresupuestoDireccionesModel();
|
$model = new PresupuestoDireccionesModel();
|
||||||
$model->insert($data[0]);
|
$model->insert($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1495,18 +1689,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function getCosteEnvio($direccionId = null, $peso, $unidades, $entregaPieCalle)
|
protected function getCosteEnvio($direccion, $peso, $unidades, $entregaPieCalle, $calcular_envio_base)
|
||||||
{
|
{
|
||||||
|
$return_data = $direccion;
|
||||||
|
|
||||||
if ($direccionId != null) {
|
if ($calcular_envio_base) {
|
||||||
$model = model('App\Models\Clientes\ClienteDireccionesModel');
|
|
||||||
$data = $model->getDireccion($direccionId);
|
$pais_id = 1; // españa
|
||||||
|
$cp = 18000; // envio nacional
|
||||||
} else {
|
} else {
|
||||||
$data = [];
|
$pais_id = $direccion['pais_id'];
|
||||||
array_push($data, (object) [
|
$cp = $direccion['cp'];
|
||||||
'pais_id' => 1, // españa
|
|
||||||
'cp' => 18000, // envio nacional
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1514,9 +1707,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$coste = 0;
|
$coste = 0;
|
||||||
$margen = 0;
|
$margen = 0;
|
||||||
|
|
||||||
if (count($data) > 0) {
|
|
||||||
$peso_envio = round(floatval($peso * $unidades / 1000.0)); // peso libro * unidades y se pasa a kilogramos
|
$peso_envio = round(floatval(floatval($peso) * floatval($unidades) / 1000.0)); // peso libro * unidades y se pasa a kilogramos
|
||||||
$tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($data[0]->pais_id, $data[0]->cp, $peso_envio, $entregaPieCalle ? 'palets' : 'cajas');
|
$tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($pais_id, $cp, $peso_envio, $entregaPieCalle ? 'palets' : 'cajas');
|
||||||
for ($i = 0; $i < count($tarifas_envio); $i++) {
|
for ($i = 0; $i < count($tarifas_envio); $i++) {
|
||||||
if ($peso_envio > $tarifas_envio[$i]->peso_max || floatval($tarifas_envio[$i]->precio_max) == 0) {
|
if ($peso_envio > $tarifas_envio[$i]->peso_max || floatval($tarifas_envio[$i]->precio_max) == 0) {
|
||||||
$tarifas_envio[$i]->precio = number_format(floatval($tarifas_envio[$i]->precio_min) + ($peso_envio - floatval($tarifas_envio[$i]->peso_min)) * floatval($tarifas_envio[$i]->precio_adicional), 2);
|
$tarifas_envio[$i]->precio = number_format(floatval($tarifas_envio[$i]->precio_min) + ($peso_envio - floatval($tarifas_envio[$i]->peso_min)) * floatval($tarifas_envio[$i]->precio_adicional), 2);
|
||||||
@ -1538,17 +1731,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
} else {
|
} else {
|
||||||
if (count($tarifas_envio) > 0)
|
if (count($tarifas_envio) > 0)
|
||||||
$coste = $tarifas_envio[0]->precio;
|
$coste = $tarifas_envio[0]->precio;
|
||||||
}
|
$margen = $tarifas_envio[0]->margen;
|
||||||
}
|
|
||||||
if (count($data) > 0 && count($tarifas_envio) > 0) {
|
|
||||||
$data[0]->coste = $coste;
|
|
||||||
$data[0]->tipo = $entregaPieCalle ? 'palets' : 'cajas';
|
|
||||||
$data[0]->margen = $margen;
|
|
||||||
$data[0]->proveedor = $tarifas_envio[0]->proveedor;
|
|
||||||
$data[0]->proveedor_id = $tarifas_envio[0]->proveedor_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
$return_data['coste'] = $coste;
|
||||||
|
$return_data['tipo'] = $entregaPieCalle ? 'palets' : 'cajas';
|
||||||
|
$return_data['margen'] = $margen;
|
||||||
|
$return_data['proveedor'] = $tarifas_envio[0]->proveedor;
|
||||||
|
$return_data['proveedor_id'] = $tarifas_envio[0]->proveedor_id;
|
||||||
|
|
||||||
|
return (object) $return_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcular_presupuesto($datos_entrada, $selected_tirada, $extra_info = false)
|
protected function calcular_presupuesto($datos_entrada, $selected_tirada, $extra_info = false)
|
||||||
@ -1630,7 +1822,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$datosPedido = (object) array(
|
$datosPedido = (object) array(
|
||||||
'paginas' => $paginas,
|
'paginas' => $paginas,
|
||||||
'tirada' => $tirada[$t],
|
'tirada' => $tirada[$t],
|
||||||
'merma' => $tirada[$t] > $POD ? $this->calcular_merma($tirada[$t], $POD) : 0,
|
'merma' => $this->calcular_merma($tirada[$t], $POD),
|
||||||
'ancho' => intval($tamanio['ancho']) ?? 100000,
|
'ancho' => intval($tamanio['ancho']) ?? 100000,
|
||||||
'alto' => intval($tamanio['alto']) ?? 100000,
|
'alto' => intval($tamanio['alto']) ?? 100000,
|
||||||
'isCosido' => $is_cosido,
|
'isCosido' => $is_cosido,
|
||||||
@ -2261,15 +2453,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$return_data['info'] = $info;
|
$return_data['info'] = $info;
|
||||||
|
|
||||||
|
|
||||||
if ($extra_info) { // && $tirada[$t] == $selected_tirada) {
|
if ($extra_info && ($tirada[$t] == $selected_tirada)) {
|
||||||
|
|
||||||
$return_data['info']['interior'] = $interior;
|
$return_data['values']['interior'] = $interior;
|
||||||
$return_data['info']['cubierta'] = $cubierta;
|
$return_data['values']['cubierta'] = $cubierta;
|
||||||
$return_data['info']['sobrecubierta'] = $linea_sobrecubierta;
|
$return_data['values']['sobrecubierta'] = $linea_sobrecubierta;
|
||||||
$return_data['info']['guardas'] = $guardas;
|
$return_data['values']['guardas'] = $guardas;
|
||||||
$return_data['info']['serviciosDefecto']['encuadernacion'] = $servDefectoEnc;
|
$return_data['values']['serviciosDefecto']['encuadernacion'] = $servDefectoEnc;
|
||||||
$return_data['info']['serviciosDefecto']['manipulado'] = $servDefectoMan;
|
$return_data['values']['serviciosDefecto']['manipulado'] = $servDefectoMan;
|
||||||
$return_data['info']['servicios_automaticos'] = $serviciosAutomaticos;
|
$return_data['values']['servicios_automaticos'] = $serviciosAutomaticos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2384,7 +2576,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$merma = 0;
|
$merma = 0;
|
||||||
|
|
||||||
if ($tirada > $POD) {
|
if ($tirada > $POD) {
|
||||||
$merma = $tirada * 0.1 <= 30 ? $tirada * 0.1 : 30;
|
$merma = $tirada * 0.1;
|
||||||
} else {
|
} else {
|
||||||
$merma_lineas = [];
|
$merma_lineas = [];
|
||||||
foreach ($formas_lineas_interior as $formas_linea) {
|
foreach ($formas_lineas_interior as $formas_linea) {
|
||||||
@ -2547,7 +2739,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
{
|
{
|
||||||
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||||
$model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel');
|
$model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||||
$direcciones = $model->where('presupuesto_id', $id)->findAll();
|
$direcciones = $model->where('presupuesto_id', $id)->asArray()->findAll();
|
||||||
|
|
||||||
|
return $direcciones;
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
$temp = [];
|
$temp = [];
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
|
|||||||
$att = $reqData['att'] ?? "";
|
$att = $reqData['att'] ?? "";
|
||||||
$email = $reqData['email'] ?? "";
|
$email = $reqData['email'] ?? "";
|
||||||
$direccion = $reqData['direccion'] ?? "";
|
$direccion = $reqData['direccion'] ?? "";
|
||||||
$pais_id = $reqData['paisId'] ?? -1;
|
$pais_id = $reqData['pais_id'] ?? -1;
|
||||||
$provincia = $reqData['provincia'] ?? "";
|
$provincia = $reqData['provincia'] ?? "";
|
||||||
$municipio = $reqData['municipio'] ?? "";
|
$municipio = $reqData['municipio'] ?? "";
|
||||||
$cp = $reqData['cp'] ?? "";
|
$cp = $reqData['cp'] ?? "";
|
||||||
@ -145,6 +145,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
|
|||||||
$reqData = $this->request->getJSON();
|
$reqData = $this->request->getJSON();
|
||||||
|
|
||||||
if($reqData->tipo=='get_tarifa'){
|
if($reqData->tipo=='get_tarifa'){
|
||||||
|
|
||||||
$peso = $reqData->peso ?? 0;
|
$peso = $reqData->peso ?? 0;
|
||||||
$paisId = $reqData->paisId ?? 0;
|
$paisId = $reqData->paisId ?? 0;
|
||||||
$cp = $reqData->cp ?? 0;
|
$cp = $reqData->cp ?? 0;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php namespace App\Controllers\Presupuestos;
|
<?php
|
||||||
|
namespace App\Controllers\Presupuestos;
|
||||||
|
|
||||||
|
|
||||||
use App\Controllers\BaseResourceController;
|
use App\Controllers\BaseResourceController;
|
||||||
@ -35,20 +36,19 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
|||||||
public function edit($requestedId = null)
|
public function edit($requestedId = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($requestedId == null) :
|
if ($requestedId == null):
|
||||||
return;
|
return;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$postData = $this->request->getJSON();
|
$postData = $this->request->getJSON();
|
||||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||||
if(count($tarifas)>0){
|
if (count($tarifas) > 0) {
|
||||||
$this->model->deleteServiciosNotInArray($requestedId, $tarifas);
|
$this->model->deleteServiciosNotInArray($requestedId, $tarifas);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$this->model->deleteAllServicios($requestedId);
|
$this->model->deleteAllServicios($requestedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($tarifas)>0){
|
if (count($tarifas) > 0) {
|
||||||
$this->model->updateTarifas($requestedId, $postData->datos);
|
$this->model->updateTarifas($requestedId, $postData->datos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,51 +65,60 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
|||||||
{
|
{
|
||||||
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||||
|
|
||||||
if ($requestedId == null) :
|
if ($requestedId == null):
|
||||||
return;
|
return;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$postData = $this->request->getJSON();
|
$postData = $this->request->getPost();
|
||||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
$datos_tarifas = $postData['datos'] ?? [];
|
||||||
$tirada = $postData->tirada ?? 0;
|
$tirada = $postData['tirada'] ?? 0;
|
||||||
$paginas = $postData->paginas ?? 0;
|
$paginas = $postData['paginas'] ?? 0;
|
||||||
$POD = $postData->POD ?? 0;
|
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||||
$ancho = $postData->ancho ?? 0;
|
$ancho = $postData['ancho'] ?? 0;
|
||||||
$alto = $postData->alto ?? 0;
|
$alto = $postData['alto'] ?? 0;
|
||||||
$result = [];
|
|
||||||
|
|
||||||
if(count($tarifas)>0){
|
$result = $this->getServiciosEncuadernacion($datos_tarifas, $tirada, $paginas, $ancho, $alto, $POD);
|
||||||
foreach ($tarifas as $tarifa){
|
|
||||||
if($tarifaModel->isTarifaPorHoras($tarifa)){
|
|
||||||
$values = $this->model->getPrecioTarifaHoras($tarifa, $paginas, $tirada, -1, $POD);
|
|
||||||
}else{
|
|
||||||
$values = $this->model->getPrecioTarifa($tarifa, $paginas, $tirada, $ancho, $alto, -1, $POD);
|
|
||||||
}
|
|
||||||
array_push($result, $values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
$data = [
|
$data = [
|
||||||
'lines' => $result,
|
'lineas' => $result,
|
||||||
$csrfTokenName => $newTokenHash
|
$csrfTokenName => $newTokenHash
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getServiciosEncuadernacion($datos_tarifas, $tirada, $paginas, $ancho, $alto, $POD)
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||||
|
$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
||||||
|
|
||||||
|
|
||||||
|
if (count($datos_tarifas) > 0) {
|
||||||
|
foreach ($datos_tarifas as $tarifa) {
|
||||||
|
if ($tarifaModel->isTarifaPorHoras($tarifa['tarifa_id'])) {
|
||||||
|
$values = $model->getPrecioTarifaHoras($tarifa['tarifa_id'], $paginas, $tirada, -1, $POD);
|
||||||
|
} else {
|
||||||
|
$values = $model->getPrecioTarifa($tarifa['tarifa_id'], $paginas, $tirada, $ancho, $alto, -1, $POD);
|
||||||
|
}
|
||||||
|
array_push($result, $values[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function datatable()
|
public function datatable()
|
||||||
{
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
$reqData = $this->request->getPost();
|
$reqData = $this->request->getPost();
|
||||||
$tipo = $reqData['tipo'] ?? null;
|
$tipo = $reqData['tipo'] ?? null;
|
||||||
if(is_null($tipo) || $tipo=='tarifa'){
|
if (is_null($tipo) || $tipo == 'tarifa') {
|
||||||
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? 0;
|
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? 0;
|
||||||
$proveedor_id = $reqData['proveedor_id'] ?? 0;
|
$proveedor_id = $reqData['proveedor_id'] ?? 0;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$solapas = $reqData['solapas'] ?? 0;
|
$solapas = $reqData['solapas'] ?? 0;
|
||||||
}
|
}
|
||||||
$paginas = $reqData['paginas'] ?? 0;
|
$paginas = $reqData['paginas'] ?? 0;
|
||||||
@ -124,24 +133,19 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
|||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||||
if(is_null($tipo)){
|
if (is_null($tipo)) {
|
||||||
if($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
if ($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)) {
|
||||||
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo);
|
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo);
|
||||||
}else{
|
} else {
|
||||||
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
|
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
|
||||||
}
|
}
|
||||||
}
|
} else if ($tipo == 'tarifa') {
|
||||||
|
if ($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)) {
|
||||||
else if($tipo=='tarifa'){
|
|
||||||
if($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
|
||||||
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, -1, $POD);
|
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, -1, $POD);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, -1, $POD);
|
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, -1, $POD);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else{
|
|
||||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
||||||
$values = $this->model->initPresupuesto($tipo_impresion_id, $solapas, $tirada, $paginas, $ancho, $alto, $POD);
|
$values = $this->model->initPresupuesto($tipo_impresion_id, $solapas, $tirada, $paginas, $ancho, $alto, $POD);
|
||||||
}
|
}
|
||||||
@ -159,39 +163,76 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRowValues()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
|
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||||
|
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
|
||||||
|
$tarifa_enc_id = $reqData['tarifa_enc_id'] ?? 0;
|
||||||
|
$tirada = $reqData['tirada'] ?? 0;
|
||||||
|
$paginas = $reqData['paginas'] ?? 0;
|
||||||
|
$ancho = $reqData['ancho'] ?? 0;
|
||||||
|
$alto = $reqData['alto'] ?? 0;
|
||||||
|
$proveedor_id = $reqData['proveedor_id'] ?? -1;
|
||||||
|
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? 32;
|
||||||
|
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||||
|
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
if ($tarifaModel->isTarifaPorHoras($tarifa_enc_id)) {
|
||||||
|
$values = $this->model->getPrecioTarifaHoras($tarifa_enc_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo);
|
||||||
|
} else {
|
||||||
|
$values = $this->model->getPrecioTarifa($tarifa_enc_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'values' => $values,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function menuItems()
|
public function menuItems()
|
||||||
{
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
$reqData = $this->request->getPost();
|
$reqData = $this->request->getPost();
|
||||||
try{
|
try {
|
||||||
|
|
||||||
$tarifa_id = $reqData['tarifa_id'] ?? -1;
|
$tarifa_id = $reqData['tarifa_id'] ?? -1;
|
||||||
$paginas = $reqData['paginas'] ?? 0;
|
$paginas = $reqData['paginas'] ?? 0;
|
||||||
$tirada = $reqData['tirada'] ?? 0;
|
$tirada = $reqData['tirada'] ?? 0;
|
||||||
$ancho = $reqData['ancho'] ?? 0;
|
$ancho = $reqData['ancho'] ?? 0;
|
||||||
$alto = $reqData['alto'] ?? 0;
|
$alto = $reqData['alto'] ?? 0;
|
||||||
//$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? 32;
|
||||||
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
$menu = $this->model->getProveedoresForSelector($tarifa_id, $paginas, $tirada, $ancho, $alto);
|
$menu = $this->model->getProveedoresForSelector($tarifa_id, $paginas, $tirada, $ancho, $alto, $paginas_cuadernillo);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'menu' => $menu,
|
'menu' => $menu,
|
||||||
$csrfTokenName => $newTokenHash
|
$csrfTokenName => $newTokenHash
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch(Exception $e){
|
|
||||||
$data = [
|
$data = [
|
||||||
'error' => $e,
|
'error' => $e,
|
||||||
$csrfTokenName => $newTokenHash
|
$csrfTokenName => $newTokenHash
|
||||||
];
|
];
|
||||||
}
|
} finally {
|
||||||
finally{
|
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -63,6 +63,27 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
|||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getServicioSolapas(){
|
||||||
|
|
||||||
|
if($this->request->isAJAX()){
|
||||||
|
|
||||||
|
$servicio = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas')->value;
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'service' => $servicio,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function update($requestedId = null)
|
public function update($requestedId = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -70,29 +91,39 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
|||||||
return;
|
return;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$postData = $this->request->getJSON();
|
$postData = $this->request->getPost();
|
||||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
$tarifas = $postData['datos'] ?? [];
|
||||||
$tirada = $postData->tirada ?? 0;
|
$tirada = $postData['tirada'] ?? 0;
|
||||||
$POD = $postData->POD ?? 0;
|
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||||
$result = [];
|
|
||||||
|
|
||||||
if(count($tarifas)>0){
|
$result = $this->getServiciosManipulado($tarifas, $tirada, $POD);
|
||||||
foreach ($tarifas as $tarifa){
|
|
||||||
$values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD);
|
|
||||||
array_push($result, $values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
$data = [
|
$data = [
|
||||||
'lines' => $result,
|
'lineas' => $result,
|
||||||
$csrfTokenName => $newTokenHash
|
$csrfTokenName => $newTokenHash
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getServiciosManipulado($datos_tarifas, $tirada, $POD)
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
$model = model('App\Models\Presupuestos\PresupuestoManipuladosModel');
|
||||||
|
|
||||||
|
if (count($datos_tarifas) > 0) {
|
||||||
|
foreach ($datos_tarifas as $tarifa) {
|
||||||
|
$values = $model->getPrecioTarifa($tarifa['tarifa_id'], $tirada, $POD);
|
||||||
|
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
|
||||||
|
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
|
||||||
|
array_push($result, $values[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function datatable()
|
public function datatable()
|
||||||
{
|
{
|
||||||
@ -101,7 +132,7 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$tarifa_manipulado_id = $reqData['tarifa_manipulado_id'] ?? 0;
|
$tarifa_manipulado_id = $reqData['tarifa_manipulado_id'] ?? 0;
|
||||||
$tirada = $reqData['tirada'] ?? 0;
|
$tirada = $reqData['tirada'] ?? 0;
|
||||||
$POD = $reqData['POD'] ?? 0;
|
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||||
$tipo = $reqData['tipo'] ?? null;
|
$tipo = $reqData['tipo'] ?? null;
|
||||||
|
|
||||||
|
|
||||||
@ -129,4 +160,29 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRowValues()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
|
||||||
|
$tarifa_manipulado_id = $reqData['tarifa_manipulado_id'] ?? 0;
|
||||||
|
$tirada = $reqData['tirada'] ?? 0;
|
||||||
|
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$values = $this->model->getPrecioTarifa($tarifa_manipulado_id, $tirada, $POD);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'values' => $values,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,4 +110,47 @@ class Presupuestopreimpresiones extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRowValues()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
|
||||||
|
$tarifa_preimpresion_id = $reqData['tarifa_preimpresion_id'] ?? 0;
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$values = $this->model->getPrecioTarifa($tarifa_preimpresion_id);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'values' => $values,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cargar()
|
||||||
|
{
|
||||||
|
if($this->request->isAJAX()) {
|
||||||
|
$presupuesto_id = $this->request->getGet('presupuesto_id') ?? null;
|
||||||
|
|
||||||
|
$rows = $this->model->getResource($presupuesto_id)->get()->getResultObject();
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
$data = [
|
||||||
|
'rows' => $rows,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,4 +110,28 @@ class Presupuestoserviciosextra extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRowValues()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
|
||||||
|
$tarifa_extra_id = $reqData['tarifa_extra_id'] ?? 0;
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$values = $this->model->getPrecioTarifa($tarifa_extra_id);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'values' => $values,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,7 +82,12 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
|||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$id = $reqData['id'] ?? 0;
|
||||||
|
|
||||||
$json_data = $reqData['json_tiradas'] ?? null;
|
$json_data = $reqData['json_tiradas'] ?? null;
|
||||||
|
$json_data_acabados = $reqData['json_acabados'] ?? null;
|
||||||
|
$json_data_encuadernacion = $reqData['json_encuadernaciones'] ?? null;
|
||||||
|
$json_data_manipulado = $reqData['json_manipulado'] ?? null;
|
||||||
$cliente_id = $reqData['cliente_id'] ?? 0;
|
$cliente_id = $reqData['cliente_id'] ?? 0;
|
||||||
|
|
||||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
||||||
@ -95,7 +100,7 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
|||||||
|
|
||||||
foreach ($data as $linea) {
|
foreach ($data as $linea) {
|
||||||
// Se obtienen los valores de cada linea para el calculo del precio
|
// Se obtienen los valores de cada linea para el calculo del precio
|
||||||
$datosPedido = (object)array(
|
$datosPedido = (object) array(
|
||||||
'paginas' => intval($linea['paginas']) ?? 0,
|
'paginas' => intval($linea['paginas']) ?? 0,
|
||||||
'tirada' => intval($reqData['tirada']) ?? 0,
|
'tirada' => intval($reqData['tirada']) ?? 0,
|
||||||
'merma' => intval($reqData['merma']) ?? 0,
|
'merma' => intval($reqData['merma']) ?? 0,
|
||||||
@ -145,23 +150,23 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
|||||||
$tipo = strpos($linea['row_id'], "_bn") !== false ? 'negro' : 'color';
|
$tipo = strpos($linea['row_id'], "_bn") !== false ? 'negro' : 'color';
|
||||||
$paginas_negro = isset($linea['numPagColor']) ? intval($datosPedido->paginas) - intval($linea['numPagColor']) : 0;
|
$paginas_negro = isset($linea['numPagColor']) ? intval($datosPedido->paginas) - intval($linea['numPagColor']) : 0;
|
||||||
$paginas_color = $linea['numPagColor'] ?? 0;
|
$paginas_color = $linea['numPagColor'] ?? 0;
|
||||||
$paginas = (object)array(
|
$paginas = (object) array(
|
||||||
'negro' => $paginas_negro,
|
'negro' => $paginas_negro,
|
||||||
'color' => $paginas_color,
|
'color' => $paginas_color,
|
||||||
);
|
);
|
||||||
$parametrosRotativa = (object)array(
|
$parametrosRotativa = (object) array(
|
||||||
'a_favor_fibra' => $datosPedido->a_favor_fibra,
|
'a_favor_fibra' => $datosPedido->a_favor_fibra,
|
||||||
'bnPages' => $paginas->negro,
|
'bnPages' => $paginas->negro,
|
||||||
'colorPages' => $paginas->color,
|
'colorPages' => $paginas->color,
|
||||||
'rotativa_gota_negro' => 0,
|
'rotativa_gota_negro' => 0,
|
||||||
'rotativa_gota_color' => 0,
|
'rotativa_gota_color' => 0,
|
||||||
);
|
);
|
||||||
$parametrosRotativa->rotativa_gota_negro = floatval($linea['gotaNegro']?? 0);
|
$parametrosRotativa->rotativa_gota_negro = floatval($linea['gotaNegro'] ?? 0);
|
||||||
$parametrosRotativa->rotativa_gota_color = floatval($linea['gotaColor']?? 0);
|
$parametrosRotativa->rotativa_gota_color = floatval($linea['gotaColor'] ?? 0);
|
||||||
$parametrosRotativa->rotativa_negro = floatval($linea['cobNegro'] ?? 0);
|
$parametrosRotativa->rotativa_negro = floatval($linea['cobNegro'] ?? 0);
|
||||||
$parametrosRotativa->rotativa_cyan = floatval($linea['cobCyan'] ?? 0);
|
$parametrosRotativa->rotativa_cyan = floatval($linea['cobCyan'] ?? 0);
|
||||||
$parametrosRotativa->rotativa_magenta = floatval($linea['cobMagenta']?? 0);
|
$parametrosRotativa->rotativa_magenta = floatval($linea['cobMagenta'] ?? 0);
|
||||||
$parametrosRotativa->rotativa_amarillo = floatval($linea['cobAmarillo']?? 0);
|
$parametrosRotativa->rotativa_amarillo = floatval($linea['cobAmarillo'] ?? 0);
|
||||||
break;
|
break;
|
||||||
case 'lp_cubierta':
|
case 'lp_cubierta':
|
||||||
$uso = 'cubierta';
|
$uso = 'cubierta';
|
||||||
@ -194,14 +199,14 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
|||||||
$datosTipolog = $linea['gotaNegro'] ?? null;
|
$datosTipolog = $linea['gotaNegro'] ?? null;
|
||||||
if (!is_null($datosTipolog)) {
|
if (!is_null($datosTipolog)) {
|
||||||
$datosTipolog = [];
|
$datosTipolog = [];
|
||||||
$data_temp = (object)array(
|
$data_temp = (object) array(
|
||||||
'negro' => floatval($linea['cobNegro'] ?? 0),
|
'negro' => floatval($linea['cobNegro'] ?? 0),
|
||||||
'cyan' => floatval($linea['cobCyan'] ?? 0),
|
'cyan' => floatval($linea['cobCyan'] ?? 0),
|
||||||
'magenta' => floatval($linea['cobMagenta']?? 0),
|
'magenta' => floatval($linea['cobMagenta'] ?? 0),
|
||||||
'amarillo' => floatval($linea['cobAmarillo']?? 0),
|
'amarillo' => floatval($linea['cobAmarillo'] ?? 0),
|
||||||
'cg' => floatval($linea['cobCG'] ?? 0),
|
'cg' => floatval($linea['cobCG'] ?? 0),
|
||||||
'gota_negro' => floatval($linea['gotaNegro']?? 0),
|
'gota_negro' => floatval($linea['gotaNegro'] ?? 0),
|
||||||
'gota_color' => floatval($linea['gotaColor']?? 0),
|
'gota_color' => floatval($linea['gotaColor'] ?? 0),
|
||||||
);
|
);
|
||||||
array_push($datosTipolog, $data_temp);
|
array_push($datosTipolog, $data_temp);
|
||||||
}
|
}
|
||||||
@ -213,13 +218,13 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
|||||||
$datosLinea['datosPedido'] = $datosPedido;
|
$datosLinea['datosPedido'] = $datosPedido;
|
||||||
$datosLinea['cliente_id'] = $cliente_id;
|
$datosLinea['cliente_id'] = $cliente_id;
|
||||||
$datosLinea['papel'] = $papel;
|
$datosLinea['papel'] = $papel;
|
||||||
if(isset($isColor))
|
if (isset($isColor))
|
||||||
$datosLinea['isColor'] = $isColor;
|
$datosLinea['isColor'] = $isColor;
|
||||||
if(isset($opciones_papel))
|
if (isset($opciones_papel))
|
||||||
$datosLinea['opciones_papel'] = $opciones_papel;
|
$datosLinea['opciones_papel'] = $opciones_papel;
|
||||||
if(isset($parametrosRotativa))
|
if (isset($parametrosRotativa))
|
||||||
$datosLinea['parametrosRotativa'] = $parametrosRotativa;
|
$datosLinea['parametrosRotativa'] = $parametrosRotativa;
|
||||||
if(isset($paginas))
|
if (isset($paginas))
|
||||||
$datosLinea['paginas'] = $paginas;
|
$datosLinea['paginas'] = $paginas;
|
||||||
$datosLinea['maquina'] = $maquina;
|
$datosLinea['maquina'] = $maquina;
|
||||||
$datosLinea['papel_generico'] = $papel_generico;
|
$datosLinea['papel_generico'] = $papel_generico;
|
||||||
@ -270,6 +275,100 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
|||||||
unset($linea_coste['fields']);
|
unset($linea_coste['fields']);
|
||||||
array_push($values, $linea_coste);
|
array_push($values, $linea_coste);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculo de los servicios (presimpresion y extra no dependen de nada)
|
||||||
|
$servicios = (object) (['coste' => 0.0, 'margen' => 0.0]);
|
||||||
|
|
||||||
|
if ($json_data_acabados) {
|
||||||
|
$json_data_acabados = json_decode($json_data_acabados, true);
|
||||||
|
if (count($json_data_acabados) > 0) {
|
||||||
|
|
||||||
|
$acabados = new Presupuestoacabados();
|
||||||
|
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||||
|
$result = $acabados->getServiciosAcabados($json_data_acabados, $reqData['tirada'], $POD);
|
||||||
|
if (count($result) > 0) {
|
||||||
|
foreach ($result as $servicio) {
|
||||||
|
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||||
|
$margen = round($servicio->total - $coste, 2);
|
||||||
|
$servicios->coste += $coste;
|
||||||
|
$servicios->margen += $margen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($json_data_encuadernacion) {
|
||||||
|
$json_data_encuadernacion = json_decode($json_data_encuadernacion, true);
|
||||||
|
if (count($json_data_encuadernacion) > 0) {
|
||||||
|
|
||||||
|
$encuadernacion = new Presupuestoencuadernaciones();
|
||||||
|
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||||
|
$result = $encuadernacion->getServiciosEncuadernacion($json_data_encuadernacion, $reqData['tirada'], $reqData['paginas'], $reqData['ancho'], $reqData['alto'], $POD);
|
||||||
|
if (count($result) > 0) {
|
||||||
|
foreach ($result as $servicio) {
|
||||||
|
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||||
|
$margen = round($servicio->total - $coste, 2);
|
||||||
|
$servicios->coste += $coste;
|
||||||
|
$servicios->margen += $margen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($json_data_manipulado) {
|
||||||
|
$json_data_manipulado = json_decode($json_data_manipulado, true);
|
||||||
|
if (count($json_data_manipulado) > 0) {
|
||||||
|
$manipulados = new Presupuestomanipulados();
|
||||||
|
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||||
|
$result = $manipulados->getServiciosManipulado($json_data_manipulado, $reqData['tirada'], $POD);
|
||||||
|
if (count($result) > 0) {
|
||||||
|
foreach ($result as $servicio) {
|
||||||
|
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||||
|
$margen = round($servicio->total - $coste, 2);
|
||||||
|
$servicios->coste += $coste;
|
||||||
|
$servicios->margen += $margen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$json_envios = $reqData['json_envios'] ?? null;
|
||||||
|
$coste_envio = 0.0;
|
||||||
|
$margen_envio = 0.0;
|
||||||
|
$tirada_base = floatval($reqData['tirada_base']);
|
||||||
|
$peso_libro = floatval($reqData['peso_libro']);
|
||||||
|
// el primer envio con la tirada base
|
||||||
|
$model = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||||
|
$envios = $model->getTarifaEnvio(1, 18000, $tirada_base * $peso_libro/1000.0, "cajas");
|
||||||
|
$resultado = $this->calcular_envio($envios, $tirada_base * $peso_libro/1000.0);
|
||||||
|
$coste_envio += $resultado->coste;
|
||||||
|
$margen_envio += $resultado->margen;
|
||||||
|
|
||||||
|
if ($json_envios) {
|
||||||
|
$json_envios = json_decode($json_envios, true);
|
||||||
|
if (count($json_envios) > 0) {
|
||||||
|
//la primera linea es el envio base
|
||||||
|
for($i = 1; $i < count($json_envios); $i++) {
|
||||||
|
|
||||||
|
$porcentaje = ($json_envios[$i]['cantidad']) / $tirada_base * 100.0;
|
||||||
|
$cantidad = floor($reqData['tirada'] * $porcentaje / 100.0);
|
||||||
|
$peso_envio = $cantidad * $peso_libro / 1000.0;
|
||||||
|
|
||||||
|
$paisId = $json_envios[$i]['pais_id'];
|
||||||
|
$cp = $json_envios[$i]['cp'];
|
||||||
|
$tipo_envio = $json_envios[$i]['entregaPieCalle'] == 1 ? 'palets' : 'cajas';
|
||||||
|
|
||||||
|
$model = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||||
|
$envios = $model->getTarifaEnvio($paisId, $cp, $peso_envio, $tipo_envio);
|
||||||
|
|
||||||
|
$resultado = $this->calcular_envio($envios, $peso_envio);
|
||||||
|
$coste_envio += $resultado->coste;
|
||||||
|
$margen_envio += $resultado->margen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$values = [];
|
$values = [];
|
||||||
}
|
}
|
||||||
@ -279,8 +378,36 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
|||||||
|
|
||||||
$response[$csrfTokenName] = $newTokenHash;
|
$response[$csrfTokenName] = $newTokenHash;
|
||||||
$response['lineas'] = $values;
|
$response['lineas'] = $values;
|
||||||
|
$response['servicios'] = $servicios;
|
||||||
|
$response['envios'] = (object) (['coste' => $coste_envio, 'margen' => $margen_envio]);
|
||||||
|
|
||||||
return $this->respond($response);
|
return $this->respond($response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function calcular_envio($envio, $peso_envio)
|
||||||
|
{
|
||||||
|
$coste_envio = 0.0;
|
||||||
|
$margen_envio = 0.0;
|
||||||
|
if (count(value: $envio) > 0) {
|
||||||
|
$envio = $envio[0];
|
||||||
|
if ($envio->id != null) {
|
||||||
|
|
||||||
|
if ($peso_envio > $envio->peso_max || floatval($envio->precio_max) == 0) {
|
||||||
|
$coste_envio += number_format(floatval($envio->precio_min) + ($peso_envio - floatval($envio->peso_min)) * floatval($envio->precio_adicional), 2);
|
||||||
|
}
|
||||||
|
// si no se calcula linealmente
|
||||||
|
else {
|
||||||
|
$m = (($envio->precio_max - $envio->precio_min) / ($envio->peso_max - $envio->peso_min));
|
||||||
|
$b = $envio->precio_max - $m * $envio->peso_max;
|
||||||
|
$coste_envio = number_format($m * $peso_envio + $b, 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$margen_envio += $coste_envio * $envio->margen / 100.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (object) (['coste' => $coste_envio, 'margen' => $margen_envio]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -336,4 +336,25 @@ class TarifaAcabados extends BaseResourceController
|
|||||||
}
|
}
|
||||||
return $this->response->setJSON($query->get()->getResultObject());
|
return $this->response->setJSON($query->get()->getResultObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSelect2()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$query = $this->model->builder()->select(
|
||||||
|
[
|
||||||
|
"id",
|
||||||
|
"nombre as name"
|
||||||
|
]
|
||||||
|
)->where("deleted_at", null);
|
||||||
|
if ($this->request->getGet("q")) {
|
||||||
|
$query->groupStart()
|
||||||
|
->orLike("lg_tarifas_acabado.nombre", $this->request->getGet("q"))
|
||||||
|
->groupEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->setJSON($query->get()->getResultObject());
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -239,4 +239,25 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSelect2()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$query = $this->model->builder()->select(
|
||||||
|
[
|
||||||
|
"id",
|
||||||
|
"nombre as name"
|
||||||
|
]
|
||||||
|
)->where("deleted_at", null)
|
||||||
|
->where("mostrar_en_presupuesto", 1);
|
||||||
|
if ($this->request->getGet("q")) {
|
||||||
|
$query->groupStart()
|
||||||
|
->orLike("tarifa_extra.nombre", $this->request->getGet("q"))
|
||||||
|
->groupEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->setJSON($query->get()->getResultObject());
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -242,4 +242,25 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSelect2()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$query = $this->model->builder()->select(
|
||||||
|
[
|
||||||
|
"id",
|
||||||
|
"nombre as name"
|
||||||
|
]
|
||||||
|
)->where("deleted_at", null)
|
||||||
|
->where("mostrar_en_presupuesto", 1);
|
||||||
|
if ($this->request->getGet("q")) {
|
||||||
|
$query->groupStart()
|
||||||
|
->orLike("lg_tarifa_preimpresion.nombre", $this->request->getGet("q"))
|
||||||
|
->groupEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->setJSON($query->get()->getResultObject());
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -356,4 +356,26 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
return $dimensiones;
|
return $dimensiones;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSelect2()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$query = $this->model->builder()->select(
|
||||||
|
[
|
||||||
|
"id",
|
||||||
|
"nombre as name"
|
||||||
|
]
|
||||||
|
)->where("deleted_at", null)
|
||||||
|
->where("mostrar_en_presupuesto", 1);
|
||||||
|
if ($this->request->getGet("q")) {
|
||||||
|
$query->groupStart()
|
||||||
|
->orLike("tarifa_encuadernacion.nombre", $this->request->getGet("q"))
|
||||||
|
->groupEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->setJSON($query->get()->getResultObject());
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -310,4 +310,26 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
return $this->response->setJSON($query->get()->getResultObject());
|
return $this->response->setJSON($query->get()->getResultObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSelect2()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$query = $this->model->builder()->select(
|
||||||
|
[
|
||||||
|
"id",
|
||||||
|
"nombre as name"
|
||||||
|
]
|
||||||
|
)->where("deleted_at", null)
|
||||||
|
->where("mostrar_en_presupuesto", 1);
|
||||||
|
if ($this->request->getGet("q")) {
|
||||||
|
$query->groupStart()
|
||||||
|
->orLike("lg_tarifa_manipulado.nombre", $this->request->getGet("q"))
|
||||||
|
->groupEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->setJSON($query->get()->getResultObject());
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,6 +63,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"comentarios_pdf" => null,
|
"comentarios_pdf" => null,
|
||||||
"comentarios_tarifa" => null,
|
"comentarios_tarifa" => null,
|
||||||
"comentarios_produccion" => null,
|
"comentarios_produccion" => null,
|
||||||
|
"comentarios_presupuesto" => null,
|
||||||
"lomo_cubierta" => null,
|
"lomo_cubierta" => null,
|
||||||
"lomo_sobrecubierta" => null,
|
"lomo_sobrecubierta" => null,
|
||||||
"total_presupuesto" => null,
|
"total_presupuesto" => null,
|
||||||
@ -107,6 +108,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
|||||||
'paginasCuadernillo' => null,
|
'paginasCuadernillo' => null,
|
||||||
'lomo_redondo' => null,
|
'lomo_redondo' => null,
|
||||||
'cabezada' => null,
|
'cabezada' => null,
|
||||||
|
'envio_base' => null,
|
||||||
];
|
];
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
"cliente_id" => "int",
|
"cliente_id" => "int",
|
||||||
@ -116,7 +118,6 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"tipologia_id" => "?int",
|
"tipologia_id" => "?int",
|
||||||
"pais_id" => "int",
|
"pais_id" => "int",
|
||||||
"estado_id" => "int",
|
"estado_id" => "int",
|
||||||
"inc_rei" => "?int",
|
|
||||||
"retractilado" => "boolean",
|
"retractilado" => "boolean",
|
||||||
"retractilado5" => "boolean",
|
"retractilado5" => "boolean",
|
||||||
"guardas" => "boolean",
|
"guardas" => "boolean",
|
||||||
|
|||||||
@ -13,6 +13,7 @@ class UserEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"status" => null,
|
"status" => null,
|
||||||
"status_message" => null,
|
"status_message" => null,
|
||||||
'active' => null,
|
'active' => null,
|
||||||
|
"comments" => null,
|
||||||
"last_active" => null,
|
"last_active" => null,
|
||||||
"created_at" => null,
|
"created_at" => null,
|
||||||
"updated_at" => null,
|
"updated_at" => null,
|
||||||
|
|||||||
@ -143,6 +143,7 @@ return [
|
|||||||
'libro' => 'Libro',
|
'libro' => 'Libro',
|
||||||
'totalPapelPedido' => 'Papel pedido',
|
'totalPapelPedido' => 'Papel pedido',
|
||||||
'lomo' => 'Lomo',
|
'lomo' => 'Lomo',
|
||||||
|
'lomoRedondo' => 'Lomo redondo',
|
||||||
'peso' => 'Peso',
|
'peso' => 'Peso',
|
||||||
'click' => 'Click',
|
'click' => 'Click',
|
||||||
'totalClicks' => 'Total clicks',
|
'totalClicks' => 'Total clicks',
|
||||||
@ -195,6 +196,7 @@ return [
|
|||||||
'totalLinea' => 'TOTAL LÍNEA',
|
'totalLinea' => 'TOTAL LÍNEA',
|
||||||
'verCalculos' => 'Cálculos',
|
'verCalculos' => 'Cálculos',
|
||||||
'metrosMinuto' => 'Metros x min.',
|
'metrosMinuto' => 'Metros x min.',
|
||||||
|
'clicksMinuto' => 'Clicks x min.',
|
||||||
'resolucion' => 'Resolución (dpi)',
|
'resolucion' => 'Resolución (dpi)',
|
||||||
'areaPaginas' => 'Área páginas (in)',
|
'areaPaginas' => 'Área páginas (in)',
|
||||||
'gotasNegro' => 'Nº gotas negro',
|
'gotasNegro' => 'Nº gotas negro',
|
||||||
@ -313,7 +315,7 @@ return [
|
|||||||
'tiradasAlternativas' => 'Tiradas alternativas',
|
'tiradasAlternativas' => 'Tiradas alternativas',
|
||||||
'tiradasInfoIVA' => 'Los precios mostrados no incluyen IVA',
|
'tiradasInfoIVA' => 'Los precios mostrados no incluyen IVA',
|
||||||
'tiradaMargen' => 'Margen',
|
'tiradaMargen' => 'Margen',
|
||||||
'tiradaEnvio' => 'Coste Envío',
|
'tiradaEnvio' => 'Precio Envío',
|
||||||
'tiradaImpresion' => 'Coste Impresión',
|
'tiradaImpresion' => 'Coste Impresión',
|
||||||
'duplicado' => 'DUPLICADO',
|
'duplicado' => 'DUPLICADO',
|
||||||
|
|
||||||
@ -369,6 +371,9 @@ return [
|
|||||||
'paginas' => 'El campo páginas tiene que ser mayor que cero',
|
'paginas' => 'El campo páginas tiene que ser mayor que cero',
|
||||||
'paginasLP' => 'El número de páginas no coincide con el total',
|
'paginasLP' => 'El número de páginas no coincide con el total',
|
||||||
'tiradas' => 'El campo tiradas tiene que ser mayor que cero',
|
'tiradas' => 'El campo tiradas tiene que ser mayor que cero',
|
||||||
|
'seleccionePapel' => 'Seleccione un papel',
|
||||||
|
'seleccioneGramaje' => 'Seleccione un gramaje',
|
||||||
|
'seleccioneCliente' => 'Seleccione un cliente',
|
||||||
'dimension' => 'La dimensión del libro tiene que ser mayor que 60mm',
|
'dimension' => 'La dimensión del libro tiene que ser mayor que 60mm',
|
||||||
'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto',
|
'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto',
|
||||||
'errorRotColor' => 'Papeles y gramajes deben ser iguales en color y BN',
|
'errorRotColor' => 'Papeles y gramajes deben ser iguales en color y BN',
|
||||||
|
|||||||
@ -9,6 +9,7 @@ return [
|
|||||||
'id' => 'ID',
|
'id' => 'ID',
|
||||||
'moduleTitle' => 'Tarifas Acabado',
|
'moduleTitle' => 'Tarifas Acabado',
|
||||||
'nombre' => 'Nombre',
|
'nombre' => 'Nombre',
|
||||||
|
'margen' => 'Margen',
|
||||||
'precioMin' => 'Precio Mínimo',
|
'precioMin' => 'Precio Mínimo',
|
||||||
'importeFijo' => 'Importe Fijo',
|
'importeFijo' => 'Importe Fijo',
|
||||||
'mostrar_en_presupuesto' => 'Mostrar en presupuesto',
|
'mostrar_en_presupuesto' => 'Mostrar en presupuesto',
|
||||||
|
|||||||
@ -99,7 +99,7 @@ class ClienteDireccionesModel extends \App\Models\BaseModel
|
|||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS id, t1.cliente_id AS cliente_id, t2.nombre as cliente_nombre, t1.att AS att, t1.alias AS alias,
|
"t1.id AS id, t1.cliente_id AS cliente_id, t2.nombre as cliente_nombre, t1.att AS att, t1.alias AS alias,
|
||||||
t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t3.nombre AS pais,
|
t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t3.nombre AS pais, t3.nombre AS pais,
|
||||||
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono"
|
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -330,7 +330,7 @@ class MaquinaModel extends \App\Models\BaseModel
|
|||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->distinct('t1.id')
|
->distinct('t1.id')
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS maquina_id, t1.nombre AS maquina, t1.ancho_impresion AS ancho_impresion,
|
"t1.id AS id, t1.id AS maquina_id, t1.nombre AS maquina, t1.nombre AS nombre, t1.ancho_impresion AS ancho_impresion,
|
||||||
t1.alto_impresion AS alto_impresion, t1.ancho AS ancho, t1.alto AS alto,
|
t1.alto_impresion AS alto_impresion, t1.ancho AS ancho, t1.alto AS alto,
|
||||||
t1.is_rotativa AS is_rotativa, t1.is_inkjet AS is_inkjet, t1.alto_click AS alto_click, t1.velocidad AS velocidad,
|
t1.is_rotativa AS is_rotativa, t1.is_inkjet AS is_inkjet, t1.alto_click AS alto_click, t1.velocidad AS velocidad,
|
||||||
t1.precio_tinta_negro AS precio_tinta_negro, t1.precio_tinta_color AS precio_tinta_color, t1.precio_tinta_cg AS precio_tinta_cg,
|
t1.precio_tinta_negro AS precio_tinta_negro, t1.precio_tinta_color AS precio_tinta_color, t1.precio_tinta_cg AS precio_tinta_cg,
|
||||||
@ -361,7 +361,7 @@ class MaquinaModel extends \App\Models\BaseModel
|
|||||||
$builder->where("t2.uso", $uso_tarifa);
|
$builder->where("t2.uso", $uso_tarifa);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
return $builder;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,128 +142,172 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getPapelForComparador($tipo, $is_cubierta = false, $is_sobrecubierta = false, $rotativa = false, $is_guardas = false, $mostrar_cliente = null)
|
public function getPapelForComparador(
|
||||||
{
|
$tipo,
|
||||||
|
$is_cubierta = false,
|
||||||
|
$is_sobrecubierta = false,
|
||||||
|
$rotativa = false,
|
||||||
|
$is_guardas = false,
|
||||||
|
$tapa_dura = false,
|
||||||
|
$POD = false
|
||||||
|
) {
|
||||||
/*
|
/*
|
||||||
1.-> Tipo impresion
|
1.-> Tipo impresion
|
||||||
2.-> Maquina
|
2.-> Maquina
|
||||||
3.-> Papeles impresion asociados a esa maquina
|
3.-> Papeles impresion asociados a esa maquina
|
||||||
4.-> papeles genericos que aparecen en esos papeles impresion
|
4.-> papeles genericos que aparecen en esos papeles impresion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) {
|
||||||
|
if ($tipo == 'color')
|
||||||
|
$tipo = 'colorhq';
|
||||||
|
else if ($tipo == 'negro')
|
||||||
|
$tipo = 'negrohq';
|
||||||
|
}
|
||||||
|
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id as id, t1.nombre AS nombre"
|
"t1.id as id, t1.nombre AS nombre",
|
||||||
// for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
|
// for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
|
||||||
)
|
)
|
||||||
->distinct('t1.id')
|
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
|
||||||
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "left")
|
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
|
||||||
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left")
|
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
|
||||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
|
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
|
||||||
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left")
|
|
||||||
|
|
||||||
->where("t1.is_deleted", 0)
|
->where("t1.is_deleted", 0)
|
||||||
|
->where("t1.show_in_client", 1)
|
||||||
->where("t2.is_deleted", 0)
|
->where("t2.is_deleted", 0)
|
||||||
->where("t2.isActivo", 1)
|
->where("t2.isActivo", 1)
|
||||||
->where("t3.active", 1)
|
->where("t3.active", 1)
|
||||||
->where("t4.is_deleted", 0)
|
->where("t4.is_deleted", 0)
|
||||||
->where("t4.tipo", "impresion")
|
->where("t4.tipo", "impresion")
|
||||||
->where("t5.is_deleted", 0)
|
->where("t5.is_deleted", 0)
|
||||||
->where("t5.tipo", $tipo);
|
->where("t5.tipo", $tipo)
|
||||||
|
->distinct('t1.id');
|
||||||
|
|
||||||
|
// Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1
|
||||||
|
$builder->whereIn("t1.id", function ($subQuery) {
|
||||||
|
$subQuery->select("t1_inner.id")
|
||||||
|
->from("lg_papel_generico t1_inner")
|
||||||
|
->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner")
|
||||||
|
->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner")
|
||||||
|
->where("t3_inner.active", 1);
|
||||||
|
});
|
||||||
|
|
||||||
if ($is_cubierta == true) {
|
if ($is_cubierta == true) {
|
||||||
|
|
||||||
$builder->where("t2.cubierta", 1);
|
$builder->where("t2.cubierta", 1);
|
||||||
$builder->where("t5.uso", 'cubierta');
|
$builder->where("t5.uso", 'cubierta');
|
||||||
|
if ($tapa_dura == true) {
|
||||||
|
$builder->where("t2.use_for_tapa_dura", 1);
|
||||||
}
|
}
|
||||||
|
} else if ($is_sobrecubierta == true) {
|
||||||
if ($is_sobrecubierta == true) {
|
|
||||||
$builder->where("t2.sobrecubierta", 1);
|
$builder->where("t2.sobrecubierta", 1);
|
||||||
$builder->where("t5.uso", 'sobrecubierta');
|
$builder->where("t5.uso", 'sobrecubierta');
|
||||||
}
|
} else if ($is_guardas == true) {
|
||||||
|
|
||||||
if ($is_cubierta == false && $is_sobrecubierta == false) {
|
|
||||||
$builder->where("t5.uso", 'interior');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($is_guardas == true) {
|
|
||||||
$builder->where("t2.guardas", 1);
|
$builder->where("t2.guardas", 1);
|
||||||
|
} else {
|
||||||
|
$builder->where("t2.interior", 1);
|
||||||
|
$builder->where("t5.uso", 'interior');
|
||||||
|
if ($tipo == 'negro' || $tipo == 'negrohq')
|
||||||
|
$builder->where("t2.bn", 1);
|
||||||
|
else if ($tipo == 'color' || $tipo == 'colorhq')
|
||||||
|
$builder->where("t2.color", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rotativa == true) {
|
if ($tipo == 'colorhq' || $tipo == 'negrohq') {
|
||||||
|
$builder->where("t2.rotativa", 0);
|
||||||
|
} else if ($rotativa && $POD == false) {
|
||||||
$builder->where("t2.rotativa", 1);
|
$builder->where("t2.rotativa", 1);
|
||||||
|
} else if ($POD) {
|
||||||
|
$builder->where("t2.rotativa", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mostrar_cliente != null) {
|
//$query = $this->db->getLastQuery();
|
||||||
$builder->where("t1.show_in_client", $mostrar_cliente);
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
public function getGramajeForComparador(
|
||||||
//var_dump($this->db->getLastQuery());
|
$tipo,
|
||||||
return $data;
|
$selected_papel_id,
|
||||||
}
|
$is_cubierta = false,
|
||||||
|
$is_sobrecubierta = false,
|
||||||
public function getGramajeComparador(string $papel_generico_nombre = "", $uso = "", $ejemplares = 0)
|
$rotativa = false,
|
||||||
{
|
$is_guardas = false,
|
||||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta')
|
$tapa_dura = false,
|
||||||
|
$POD = false
|
||||||
|
) {
|
||||||
|
if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) {
|
||||||
|
if ($tipo == 'color')
|
||||||
$tipo = 'colorhq';
|
$tipo = 'colorhq';
|
||||||
else
|
else if ($tipo == 'negro')
|
||||||
$tipo = $uso; // color y colorhq valen para los dos
|
$tipo = 'negrohq';
|
||||||
if ($uso == 'bn')
|
}
|
||||||
$tipo = "negro";
|
|
||||||
if ($uso == 'bnhq')
|
|
||||||
$tipo = "negrohq";
|
|
||||||
|
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t2.gramaje AS text"
|
"t2.gramaje as id, t2.gramaje as nombre",
|
||||||
|
// for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
|
||||||
)
|
)
|
||||||
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "left")
|
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
|
||||||
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left")
|
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
|
||||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
|
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
|
||||||
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left")
|
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
|
||||||
|
|
||||||
|
->where("t1.id", $selected_papel_id)
|
||||||
->where("t1.is_deleted", 0)
|
->where("t1.is_deleted", 0)
|
||||||
|
->where("t1.show_in_client", 1)
|
||||||
->where("t2.is_deleted", 0)
|
->where("t2.is_deleted", 0)
|
||||||
->where("t2.isActivo", 1)
|
->where("t2.isActivo", 1)
|
||||||
->where("t3.active", 1)
|
->where("t3.active", 1)
|
||||||
->where("t4.is_deleted", 0)
|
->where("t4.is_deleted", 0)
|
||||||
->where("t4.tipo", "impresion")
|
->where("t4.tipo", "impresion")
|
||||||
|
->where("t5.is_deleted", 0)
|
||||||
->where("t5.tipo", $tipo)
|
->where("t5.tipo", $tipo)
|
||||||
->where("t1.nombre", $papel_generico_nombre);
|
->distinct('t2.gramaje');
|
||||||
|
|
||||||
$uso_tarifa = 'interior';
|
// Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1
|
||||||
|
$builder->whereIn("t1.id", function ($subQuery) {
|
||||||
|
$subQuery->select("t1_inner.id")
|
||||||
|
->from("lg_papel_generico t1_inner")
|
||||||
|
->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner")
|
||||||
|
->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner")
|
||||||
|
->where("t3_inner.active", 1);
|
||||||
|
});
|
||||||
|
|
||||||
if ($uso == 'bn' || $uso == 'bnhq')
|
if ($is_cubierta == true) {
|
||||||
$builder->where("t2.bn", 1);
|
|
||||||
else if ($uso == 'color' || $uso == 'colorhq')
|
|
||||||
$builder->where("t2.color", 1);
|
|
||||||
else if ($uso == 'cubierta') {
|
|
||||||
$uso_tarifa = 'cubierta';
|
|
||||||
$builder->where("t2.cubierta", 1);
|
$builder->where("t2.cubierta", 1);
|
||||||
} else if ($uso == 'sobrecubierta') {
|
$builder->where("t5.uso", 'cubierta');
|
||||||
$uso_tarifa = 'sobrecubierta';
|
if ($tapa_dura == true) {
|
||||||
|
$builder->where("t2.use_for_tapa_dura", 1);
|
||||||
|
}
|
||||||
|
} else if ($is_sobrecubierta == true) {
|
||||||
$builder->where("t2.sobrecubierta", 1);
|
$builder->where("t2.sobrecubierta", 1);
|
||||||
|
$builder->where("t5.uso", 'sobrecubierta');
|
||||||
|
} else if ($is_guardas == true) {
|
||||||
|
$builder->where("t2.guardas", 1);
|
||||||
|
} else {
|
||||||
|
$builder->where("t2.interior", 1);
|
||||||
|
$builder->where("t5.uso", 'interior');
|
||||||
|
if ($tipo == 'negro' || $tipo == 'negrohq')
|
||||||
|
$builder->where("t2.bn", 1);
|
||||||
|
else if ($tipo == 'color' || $tipo == 'colorhq')
|
||||||
|
$builder->where("t2.color", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->where("t5.uso", $uso_tarifa);
|
if ($tipo == 'colorhq' || $tipo == 'negrohq') {
|
||||||
|
$builder->where("t2.rotativa", 0);
|
||||||
$builder->where("t4.min <=", $ejemplares);
|
} else if ($rotativa && $POD == false) {
|
||||||
$builder->where("t4.max >=", $ejemplares);
|
$builder->where("t2.rotativa", 1);
|
||||||
|
} else if ($POD) {
|
||||||
$values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
|
$builder->where("t2.rotativa", 0);
|
||||||
$id = 1;
|
|
||||||
foreach ($values as $value) {
|
|
||||||
$value->id = $id;
|
|
||||||
$id++;
|
|
||||||
}
|
}
|
||||||
$values_array = array_map(function ($value) {
|
|
||||||
return $value->text;
|
|
||||||
}, $values);
|
|
||||||
$unique_values = array_unique($values_array);
|
|
||||||
return array_values(array_intersect_key($values, $unique_values));
|
|
||||||
|
|
||||||
|
//$query = $this->db->getLastQuery();
|
||||||
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
//tipo: negro, negrohq, color, colorhq
|
//tipo: negro, negrohq, color, colorhq
|
||||||
@ -323,7 +367,6 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
|||||||
}, $values);
|
}, $values);
|
||||||
$unique_values = array_unique($values_array);
|
$unique_values = array_unique($values_array);
|
||||||
return array_values(array_intersect_key($values, $unique_values));
|
return array_values(array_intersect_key($values, $unique_values));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -337,9 +380,9 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) {
|
if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) {
|
||||||
if($tipo == 'color')
|
if ($tipo == 'color')
|
||||||
$tipo = 'colorhq';
|
$tipo = 'colorhq';
|
||||||
else if($tipo == 'negro')
|
else if ($tipo == 'negro')
|
||||||
$tipo = 'negrohq';
|
$tipo = 'negrohq';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +446,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
|||||||
if ($is_cubierta == true) {
|
if ($is_cubierta == true) {
|
||||||
$builder->where("t2.cubierta", 1);
|
$builder->where("t2.cubierta", 1);
|
||||||
$builder->where("t5.uso", 'cubierta');
|
$builder->where("t5.uso", 'cubierta');
|
||||||
if($tapa_dura == true){
|
if ($tapa_dura == true) {
|
||||||
$builder->where("t2.use_for_tapa_dura", 1);
|
$builder->where("t2.use_for_tapa_dura", 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -417,19 +460,16 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
if ($papel_especial == true) {
|
if ($papel_especial == true) {
|
||||||
$builder->where("t1.show_in_client_special", 1);
|
$builder->where("t1.show_in_client_special", 1);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$builder->where("t1.show_in_client_special", 0);
|
$builder->where("t1.show_in_client_special", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tipo == 'colorhq' || $tipo == 'negrohq') {
|
if ($tipo == 'colorhq' || $tipo == 'negrohq') {
|
||||||
$builder->where("t2.rotativa", 0);
|
$builder->where("t2.rotativa", 0);
|
||||||
}
|
} else {
|
||||||
else{
|
if ($POD == false) {
|
||||||
if($POD == false){
|
|
||||||
$builder->where("t2.rotativa", 1);
|
$builder->where("t2.rotativa", 1);
|
||||||
}
|
} else if ($POD == true) {
|
||||||
else if ($POD == true){
|
|
||||||
$builder->where("t2.rotativa", 0);
|
$builder->where("t2.rotativa", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -279,8 +279,15 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
//tipo: negro, negrohq, color, colorhq
|
//tipo: negro, negrohq, color, colorhq
|
||||||
//uso: interior, rotativa, cubierta, sobrecubierta
|
//uso: interior, rotativa, cubierta, sobrecubierta
|
||||||
public function getPapelesImpresionForMenu($papel_generico = null, $gramaje = null, $tipo = null, $uso = "")
|
public function getPapelesImpresionForMenu(
|
||||||
{
|
$papel_generico = null,
|
||||||
|
$gramaje = null,
|
||||||
|
$tipo = null,
|
||||||
|
$uso = "",
|
||||||
|
$tapaDura = false,
|
||||||
|
$forInkjet = false
|
||||||
|
) {
|
||||||
|
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->distinct("t1.id")
|
->distinct("t1.id")
|
||||||
@ -289,7 +296,7 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
|||||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
|
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
|
||||||
->join("lg_maquinas_tarifas_impresion t5", "t4.id = t5.maquina_id", "left")
|
->join("lg_maquinas_tarifas_impresion t5", "t4.id = t5.maquina_id", "left")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS id, t1.nombre AS text"
|
"t1.id AS id, t1.nombre AS nombre"
|
||||||
);
|
);
|
||||||
|
|
||||||
$builder->where("t1.is_deleted", 0);
|
$builder->where("t1.is_deleted", 0);
|
||||||
@ -304,24 +311,31 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
|||||||
$builder->where("t2.id", $papel_generico);
|
$builder->where("t2.id", $papel_generico);
|
||||||
$builder->where("t1.gramaje", $gramaje);
|
$builder->where("t1.gramaje", $gramaje);
|
||||||
|
|
||||||
if ($uso == 'cubierta')
|
if ($uso == 'cubierta') {
|
||||||
|
if ($tapaDura)
|
||||||
|
$builder->where("t1.use_for_tapa_dura", 1);
|
||||||
$builder->where("t1.cubierta", 1);
|
$builder->where("t1.cubierta", 1);
|
||||||
else if ($uso == 'sobrecubierta')
|
} else if ($uso == 'sobrecubierta')
|
||||||
$builder->where("t1.sobrecubierta", 1);
|
$builder->where("t1.sobrecubierta", 1);
|
||||||
else if ($uso == 'guardas')
|
else if ($uso == 'guardas')
|
||||||
$builder->where("t1.guardas", 1);
|
$builder->where("t1.guardas", 1);
|
||||||
else {
|
else {
|
||||||
|
$builder->where("t1.interior", 1);
|
||||||
if ($tipo == 'negro' || $tipo == 'negrohq')
|
if ($tipo == 'negro' || $tipo == 'negrohq')
|
||||||
$builder->where("t1.bn", 1);
|
$builder->where("t1.bn", 1);
|
||||||
else if ($tipo == 'color' || $tipo == 'colorhq')
|
else if ($tipo == 'color' || $tipo == 'colorhq')
|
||||||
$builder->where("t1.color", 1);
|
$builder->where("t1.color", 1);
|
||||||
}
|
}
|
||||||
if ($uso == 'rotativa')
|
if ($uso == 'rotativa') {
|
||||||
$builder->where("t1.rotativa", 1);
|
$builder->where("t1.rotativa", 1);
|
||||||
else
|
$builder->where("t4.is_rotativa", 1);
|
||||||
|
} else
|
||||||
$builder->where("t1.rotativa", 0);
|
$builder->where("t1.rotativa", 0);
|
||||||
|
|
||||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
if ($forInkjet)
|
||||||
|
$builder->where("t1.inkjet", 1);
|
||||||
|
|
||||||
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNombre($id)
|
public function getNombre($id)
|
||||||
|
|||||||
@ -72,25 +72,37 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
|||||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoAcabado($tarifa_acabado_id, $tirada, $proveedor_id);
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoAcabado($tarifa_acabado_id, $tirada, $proveedor_id);
|
||||||
if (count($tarifa_value)>0) {
|
if (count($tarifa_value)>0) {
|
||||||
|
|
||||||
$result_data = $this->calcularTarifa($tarifa_value[0], $tirada, $POD<$tirada?false:true);
|
$ret_array = [];
|
||||||
$ret_array[] = (object)[
|
foreach ($tarifa_value as $tarifa) {
|
||||||
'tarifa_id'=> $tarifa_value[0]->tarifa_acabado_id,
|
$result_data = $this->calcularTarifa($tarifa, $tirada, $POD<$tirada?false:true);
|
||||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_acabado_nombre,
|
array_push($ret_array, (object)[
|
||||||
'precio_unidad'=> $result_data[0],
|
'tarifa_id'=> $tarifa->tarifa_acabado_id,
|
||||||
'total'=> $result_data[1],
|
'tarifa_nombre'=> $tarifa->tarifa_acabado_nombre,
|
||||||
|
'nombre'=> $tarifa->tarifa_acabado_nombre,
|
||||||
|
'precio_unidad'=> round($result_data[0], 2),
|
||||||
|
'total'=> round($result_data[1], 2),
|
||||||
|
'precio_total'=> round($result_data[1], 2),
|
||||||
'margen'=> $result_data[2],
|
'margen'=> $result_data[2],
|
||||||
'proveedor' => $tarifa_value[0]->proveedor_nombre,
|
'proveedor' => $tarifa->proveedor_nombre,
|
||||||
'proveedor_id' => $tarifa_value[0]->proveedor_id,
|
'proveedor_id' => $tarifa->proveedor_id,
|
||||||
];
|
]);
|
||||||
|
}
|
||||||
|
usort($ret_array, function($a, $b) {
|
||||||
|
return $a->precio_total <=> $b->precio_total;
|
||||||
|
});
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$ret_array[] = (object)[
|
$ret_array[] = (object)[
|
||||||
'tarifa_id'=> $tarifa_acabado_id,
|
'tarifa_id'=> $tarifa_acabado_id,
|
||||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
|
'tarifa_nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
|
||||||
|
'nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
|
||||||
'precio_unidad' => 0,
|
'precio_unidad' => 0,
|
||||||
|
'total' => 0,
|
||||||
|
'precio_total' => 0,
|
||||||
'margen' => 0,
|
'margen' => 0,
|
||||||
'total'=> 0,
|
'proveedor' => '',
|
||||||
|
'proveedor_id' => 0,
|
||||||
];
|
];
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
}
|
}
|
||||||
@ -194,7 +206,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad,
|
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.tarifa_acabado_id AS tarifa_id, t1.precio_unidad AS precio_unidad,
|
||||||
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta,
|
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta,
|
||||||
t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor,"
|
t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor,"
|
||||||
);
|
);
|
||||||
|
|||||||
@ -84,9 +84,11 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
$datos = [
|
$datos = [
|
||||||
'tarifa_id'=> $tarifa['tarifa_id'],
|
'tarifa_id'=> $tarifa['tarifa_id'],
|
||||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||||
|
'nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||||
'precio_unidad'=> $result_data[0],
|
'precio_unidad'=> $result_data[0],
|
||||||
'tiempo' => $tiempo,
|
'tiempo' => $tiempo,
|
||||||
'total'=> $result_data[1],
|
'total'=> $result_data[1],
|
||||||
|
'precio_total'=> $result_data[1],
|
||||||
'margen' => $result_data[2],
|
'margen' => $result_data[2],
|
||||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||||
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
||||||
@ -117,10 +119,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
(object)[
|
(object)[
|
||||||
'tarifa_id'=> $tarifa['tarifa_id'],
|
'tarifa_id'=> $tarifa['tarifa_id'],
|
||||||
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
|
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
|
||||||
|
'nombre'=> $tarifa['tarifa_nombre'],
|
||||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||||
'precio_unidad'=> 0,
|
'precio_unidad'=> 0,
|
||||||
'tiempo' => null,
|
'tiempo' => null,
|
||||||
'total'=> 0,
|
'total'=> 0,
|
||||||
|
'precio_total'=> 0,
|
||||||
'margen' => 0,
|
'margen' => 0,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -135,9 +139,11 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
array_push($result_array, (object)[
|
array_push($result_array, (object)[
|
||||||
'tarifa_id'=> $tarifa_proveedor->tarifa_enc_id,
|
'tarifa_id'=> $tarifa_proveedor->tarifa_enc_id,
|
||||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||||
|
'nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||||
'precio_unidad'=> $result_data[0],
|
'precio_unidad'=> $result_data[0],
|
||||||
'tiempo' => null,
|
'tiempo' => null,
|
||||||
'total'=> $result_data[1],
|
'total'=> $result_data[1],
|
||||||
|
'precio_total'=> $result_data[1],
|
||||||
'margen'=> $result_data[2],
|
'margen'=> $result_data[2],
|
||||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||||
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
||||||
@ -159,10 +165,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
(object)[
|
(object)[
|
||||||
'tarifa_id'=> $tarifa['tarifa_id'] ,
|
'tarifa_id'=> $tarifa['tarifa_id'] ,
|
||||||
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
|
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
|
||||||
|
'nombre'=> $tarifa['tarifa_nombre'],
|
||||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||||
'precio_unidad'=> 0,
|
'precio_unidad'=> 0,
|
||||||
'tiempo' => null,
|
'tiempo' => null,
|
||||||
'total'=> 0,
|
'total'=> 0,
|
||||||
|
'precio_total'=> 0,
|
||||||
'margen' => 0,
|
'margen' => 0,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -173,17 +181,17 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getProveedoresForSelector($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto){
|
public function getProveedoresForSelector($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $paginasCuadernillo = 32){
|
||||||
|
|
||||||
$proveedores = [];
|
$proveedores = [];
|
||||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||||
|
|
||||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
|
||||||
|
|
||||||
if($modelTarifa->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
if($modelTarifa->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
||||||
|
$tiempo = $this->calcularTiempoCosido(16, $paginas, $tirada, $paginasCuadernillo); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada);
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto);
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto);
|
||||||
}
|
}
|
||||||
if (count($tarifa_value)>0) {
|
if (count($tarifa_value)>0) {
|
||||||
@ -215,9 +223,11 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
array_push($ret_array, (object)[
|
array_push($ret_array, (object)[
|
||||||
'tarifa_id'=> $tarifa->tarifa_enc_id,
|
'tarifa_id'=> $tarifa->tarifa_enc_id,
|
||||||
'tarifa_nombre'=> $tarifa->tarifa_enc_nombre,
|
'tarifa_nombre'=> $tarifa->tarifa_enc_nombre,
|
||||||
|
'nombre'=> $tarifa->tarifa_enc_nombre,
|
||||||
'precio_unidad'=> $result_data[0],
|
'precio_unidad'=> $result_data[0],
|
||||||
'tiempo' => null,
|
'tiempo' => null,
|
||||||
'total'=> $result_data[1],
|
'total'=> $result_data[1],
|
||||||
|
'precio_total'=> $result_data[1],
|
||||||
'margen'=> $result_data[2],
|
'margen'=> $result_data[2],
|
||||||
'proveedor' => $tarifa->proveedor_nombre,
|
'proveedor' => $tarifa->proveedor_nombre,
|
||||||
'proveedor_id' => $tarifa->proveedor_id,
|
'proveedor_id' => $tarifa->proveedor_id,
|
||||||
@ -237,10 +247,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
$ret_array[] = (object)[
|
$ret_array[] = (object)[
|
||||||
'tarifa_id'=> $tarifa_encuadernacion_id,
|
'tarifa_id'=> $tarifa_encuadernacion_id,
|
||||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
'tarifa_nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||||
|
'nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||||
'precio_unidad'=> 0,
|
'precio_unidad'=> 0,
|
||||||
'tiempo' => null,
|
'tiempo' => null,
|
||||||
'total'=> 0,
|
'total'=> 0,
|
||||||
|
'precio_total'=> 0,
|
||||||
'margen'=> 0,
|
'margen'=> 0,
|
||||||
];
|
];
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
@ -286,9 +298,11 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
(object)[
|
(object)[
|
||||||
'tarifa_id'=> $tarifa_proveedor->tarifa_enc_id,
|
'tarifa_id'=> $tarifa_proveedor->tarifa_enc_id,
|
||||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||||
|
'nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||||
'precio_unidad'=> $result_data[0],
|
'precio_unidad'=> $result_data[0],
|
||||||
'tiempo' => $tiempo,
|
'tiempo' => $tiempo,
|
||||||
'paginas_por_cuadernillo' => $paginas_cuadernillo,
|
'paginas_por_cuadernillo' => $paginas_cuadernillo,
|
||||||
|
'precio_total'=> $result_data[1],
|
||||||
'total'=> $result_data[1],
|
'total'=> $result_data[1],
|
||||||
'margen' => $result_data[2],
|
'margen' => $result_data[2],
|
||||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||||
@ -310,11 +324,13 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
$ret_array[] = (object)[
|
$ret_array[] = (object)[
|
||||||
'tarifa_id'=> $tarifa_encuadernacion_id,
|
'tarifa_id'=> $tarifa_encuadernacion_id,
|
||||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
'tarifa_nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||||
|
'nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||||
'precio_unidad'=> 0,
|
'precio_unidad'=> 0,
|
||||||
'tiempo' => null,
|
'tiempo' => null,
|
||||||
'paginas_por_cuadernillo' => null,
|
'paginas_por_cuadernillo' => null,
|
||||||
'total'=> 0,
|
'total'=> 0,
|
||||||
|
'precio_total'=> 0,
|
||||||
'margen' => 0,
|
'margen' => 0,
|
||||||
];
|
];
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
|
|||||||
@ -330,8 +330,9 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"*"
|
"*, t2.nombre AS papel_generico"
|
||||||
)
|
)
|
||||||
|
->join("lg_papel_generico t2", "t1.papel_id = t2.id", "left")
|
||||||
->where("t1.presupuesto_id", $presupuesto_id);
|
->where("t1.presupuesto_id", $presupuesto_id);
|
||||||
|
|
||||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||||
|
|||||||
@ -50,28 +50,37 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
|
|||||||
$modelTarifa = model('App\Models\Tarifas\TarifaManipuladoModel');
|
$modelTarifa = model('App\Models\Tarifas\TarifaManipuladoModel');
|
||||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoManipulado($tarifa_manipulado_id, $tirada);
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoManipulado($tarifa_manipulado_id, $tirada);
|
||||||
if (count($tarifa_value)>0) {
|
if (count($tarifa_value)>0) {
|
||||||
|
$ret_array = [];
|
||||||
$result_data = $this->calcularTarifa($tarifa_value[0], $tirada, $POD<$tirada?false:true);
|
foreach($tarifa_value as $tarifa){
|
||||||
$ret_array[] = (object)[
|
$result_data = $this->calcularTarifa($tarifa, $tirada, $POD<$tirada?false:true);
|
||||||
'tarifa_id'=> $tarifa_value[0]->tarifa_manipulado_id,
|
array_push($ret_array, (object)[
|
||||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
|
'tarifa_id'=> $tarifa->tarifa_manipulado_id,
|
||||||
|
'tarifa_nombre'=> $tarifa->tarifa_manipulado_nombre,
|
||||||
|
'nombre'=> $tarifa->tarifa_manipulado_nombre,
|
||||||
'precio_unidad'=> $result_data[0],
|
'precio_unidad'=> $result_data[0],
|
||||||
'total'=> $result_data[1],
|
'total'=> $result_data[1],
|
||||||
|
'precio_total'=> $result_data[1],
|
||||||
'margen' => $result_data[2],
|
'margen' => $result_data[2],
|
||||||
];
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($ret_array, function($a, $b) {
|
||||||
|
return $a->precio_total <=> $b->precio_total;
|
||||||
|
});
|
||||||
|
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$ret_array[] = (object)[
|
$ret_array[] = (object)[
|
||||||
'tarifa_id'=> $tarifa_manipulado_id,
|
'tarifa_id'=> $tarifa_manipulado_id,
|
||||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
|
'tarifa_nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
|
||||||
|
'nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
|
||||||
'precio_unidad' => 0,
|
'precio_unidad' => 0,
|
||||||
'total'=> 0,
|
'total'=> 0,
|
||||||
'margen' => 0,
|
'margen' => 0,
|
||||||
];
|
];
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
}
|
}
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calcularTarifa($tarifa, $tirada, $is_POD=false){
|
private function calcularTarifa($tarifa, $tirada, $is_POD=false){
|
||||||
@ -170,8 +179,10 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
|
|||||||
array_push($tarifas, (object)[
|
array_push($tarifas, (object)[
|
||||||
'tarifa_id'=> $tarifa_value[0]->tarifa_manipulado_id,
|
'tarifa_id'=> $tarifa_value[0]->tarifa_manipulado_id,
|
||||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
|
'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
|
||||||
|
'nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
|
||||||
'precio_unidad'=> $result_data[0],
|
'precio_unidad'=> $result_data[0],
|
||||||
'total'=> $result_data[1],
|
'total'=> $result_data[1],
|
||||||
|
'precio_total'=> $result_data[1],
|
||||||
'margen'=> $result_data[2],
|
'margen'=> $result_data[2],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -180,8 +191,10 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
|
|||||||
(object)[
|
(object)[
|
||||||
'tarifa_id'=> $tarifa['tarifa_id'] ,
|
'tarifa_id'=> $tarifa['tarifa_id'] ,
|
||||||
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
|
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
|
||||||
|
'nombre'=> $tarifa['tarifa_nombre'],
|
||||||
'precio_unidad' => 0,
|
'precio_unidad' => 0,
|
||||||
'total'=> 0,
|
'total'=> 0,
|
||||||
|
'precio_total'=> 0,
|
||||||
'margen' => 0,
|
'margen' => 0,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
"comentarios_safekat",
|
"comentarios_safekat",
|
||||||
"comentarios_pdf",
|
"comentarios_pdf",
|
||||||
"comentarios_tarifa",
|
"comentarios_tarifa",
|
||||||
|
"comentarios_presupuesto",
|
||||||
"comentarios_produccion",
|
"comentarios_produccion",
|
||||||
"lomo_cubierta",
|
"lomo_cubierta",
|
||||||
"lomo_sobrecubierta",
|
"lomo_sobrecubierta",
|
||||||
@ -132,6 +133,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
'paginasCuadernillo',
|
'paginasCuadernillo',
|
||||||
'lomo_redondo',
|
'lomo_redondo',
|
||||||
'cabezada',
|
'cabezada',
|
||||||
|
'envio_base',
|
||||||
];
|
];
|
||||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
|
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
|
||||||
|
|
||||||
@ -412,6 +414,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
'ferro_digital' => $data['ferro_digital'] ? 1 : 0,
|
'ferro_digital' => $data['ferro_digital'] ? 1 : 0,
|
||||||
'marcapaginas' => $data['marcapaginas'] ? 1 : 0,
|
'marcapaginas' => $data['marcapaginas'] ? 1 : 0,
|
||||||
'prototipo' => $data['prototipo'] ? 1 : 0,
|
'prototipo' => $data['prototipo'] ? 1 : 0,
|
||||||
|
'envio_base' => $data['envio_base'],
|
||||||
'papel_formato_id' => is_null($papel_formato_id) ? 0 : $papel_formato_id->id,
|
'papel_formato_id' => is_null($papel_formato_id) ? 0 : $papel_formato_id->id,
|
||||||
'papel_formato_personalizado' => !$papel_formato_id ? 1 : 0,
|
'papel_formato_personalizado' => !$papel_formato_id ? 1 : 0,
|
||||||
'papel_formato_ancho' => !$papel_formato_id ? $data['tamanio']['ancho'] : null,
|
'papel_formato_ancho' => !$papel_formato_id ? $data['tamanio']['ancho'] : null,
|
||||||
@ -557,7 +560,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
// -- SOBRECUBIERTA --
|
// -- SOBRECUBIERTA --
|
||||||
if ($data['sobrecubierta']) {
|
if ($data['sobrecubierta']) {
|
||||||
$values['sobrecubierta'] = array(
|
$values['sobrecubierta'] = array(
|
||||||
'papel_id' => intval($data['sobrecubierta']['papel']),
|
'papel_id' => intval($data['sobrecubierta']['papel']['id']),
|
||||||
'gramaje' => intval($data['sobrecubierta']['gramaje']),
|
'gramaje' => intval($data['sobrecubierta']['gramaje']),
|
||||||
'imprimir' => 1,
|
'imprimir' => 1,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -51,19 +51,30 @@ class PresupuestoPreimpresionesModel extends \App\Models\BaseModel
|
|||||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoPreimpresion($tarifa_preimpresion_id);
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoPreimpresion($tarifa_preimpresion_id);
|
||||||
if (count($tarifa_value)>0) {
|
if (count($tarifa_value)>0) {
|
||||||
|
|
||||||
$result_data = $this->calcularTarifa($tarifa_value[0]);
|
|
||||||
$ret_array[] = (object)[
|
$ret_array = [];
|
||||||
'tarifa_id'=> $tarifa_value[0]->tarifa_preimpresion_id,
|
foreach ($tarifa_value as $tarifa) {
|
||||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_preimpresion_nombre,
|
$result_data = $this->calcularTarifa($tarifa);
|
||||||
|
array_push($ret_array, (object)[
|
||||||
|
'tarifa_id'=> $tarifa->tarifa_preimpresion_id,
|
||||||
|
'tarifa_nombre'=> $tarifa->tarifa_preimpresion_nombre,
|
||||||
|
'nombre'=> $tarifa->tarifa_preimpresion_nombre,
|
||||||
'precio'=> $result_data[0],
|
'precio'=> $result_data[0],
|
||||||
'margen'=> $result_data[1],
|
'margen'=> $result_data[1],
|
||||||
];
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($ret_array, function($a, $b) {
|
||||||
|
return $a->precio <=> $b->precio;
|
||||||
|
});
|
||||||
|
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$ret_array[] = (object)[
|
$ret_array[] = (object)[
|
||||||
'tarifa_id'=> $tarifa_preimpresion_id,
|
'tarifa_id'=> $tarifa_preimpresion_id,
|
||||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_preimpresion_id)[0]->nombre,
|
'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_preimpresion_id)[0]->nombre,
|
||||||
|
'nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_preimpresion_id)[0]->nombre,
|
||||||
'precio' => 0,
|
'precio' => 0,
|
||||||
'margen' => 0,
|
'margen' => 0,
|
||||||
];
|
];
|
||||||
@ -146,7 +157,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\BaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio AS precio, t1.margen AS margen, t2.nombre AS nombre"
|
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.tarifa_preimpresion_id AS tarifa_id, t1.precio AS precio, t1.margen AS margen, t2.nombre AS nombre"
|
||||||
);
|
);
|
||||||
|
|
||||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||||
|
|||||||
@ -50,19 +50,27 @@ class PresupuestoServiciosExtraModel extends \App\Models\BaseModel
|
|||||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoExtra($tarifa_extra_id);
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoExtra($tarifa_extra_id);
|
||||||
if (count($tarifa_value)>0) {
|
if (count($tarifa_value)>0) {
|
||||||
|
|
||||||
$result_data = $this->calcularTarifa($tarifa_value[0]);
|
$ret_array = [];
|
||||||
$ret_array[] = (object)[
|
foreach($tarifa_value as $tarifa){
|
||||||
'tarifa_id'=> $tarifa_value[0]->tarifa_extra_id,
|
$result_data = $this->calcularTarifa($tarifa);
|
||||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_extra_nombre,
|
array_push($ret_array, (object)[
|
||||||
|
'tarifa_id'=> $tarifa->tarifa_extra_id,
|
||||||
|
'tarifa_nombre'=> $tarifa->tarifa_extra_nombre,
|
||||||
|
'nombre'=> $tarifa->tarifa_extra_nombre,
|
||||||
'precio'=> $result_data[0],
|
'precio'=> $result_data[0],
|
||||||
'margen'=> $result_data[1],
|
'margen'=> $result_data[1],
|
||||||
];
|
]);
|
||||||
|
}
|
||||||
|
usort($ret_array, function($a, $b) {
|
||||||
|
return $a->precio <=> $b->precio;
|
||||||
|
});
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$ret_array[] = (object)[
|
$ret_array[] = (object)[
|
||||||
'tarifa_id'=> $tarifa_extra_id,
|
'tarifa_id'=> $tarifa_extra_id,
|
||||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaExtra($tarifa_extra_id)[0]->nombre,
|
'tarifa_nombre'=> $modelTarifa->getNombreTarifaExtra($tarifa_extra_id)[0]->nombre,
|
||||||
|
'tarifa'=> $modelTarifa->getNombreTarifaExtra($tarifa_extra_id)[0]->nombre,
|
||||||
'precio' => 0,
|
'precio' => 0,
|
||||||
'margen' => 0,
|
'margen' => 0,
|
||||||
];
|
];
|
||||||
|
|||||||
@ -98,12 +98,14 @@ class TarifaEnvioModel extends \App\Models\BaseModel
|
|||||||
// Si el pais es españa se tienen que tener en cuenta los postales
|
// Si el pais es españa se tienen que tener en cuenta los postales
|
||||||
// Se busca primero la tarifa a la que corresponde
|
// Se busca primero la tarifa a la que corresponde
|
||||||
$builder = $this->db->table($this->table . " t1")
|
$builder = $this->db->table($this->table . " t1")
|
||||||
->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo")
|
->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo, t3.nombre as pais")
|
||||||
->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id")
|
->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id")
|
||||||
|
->join("lg_paises t3", "t1.pais_id = t3.id")
|
||||||
->where("t1.pais_id", $paisId)
|
->where("t1.pais_id", $paisId)
|
||||||
->where("t1.is_deleted", 0)
|
->where("t1.is_deleted", 0)
|
||||||
->where("t2.is_deleted", 0);
|
->where("t2.is_deleted", 0);
|
||||||
|
|
||||||
|
|
||||||
if ($paisId == 1) { // España
|
if ($paisId == 1) { // España
|
||||||
$builder->where("CAST(t2.cp_inicial AS UNSIGNED)<=", intval($cp))
|
$builder->where("CAST(t2.cp_inicial AS UNSIGNED)<=", intval($cp))
|
||||||
->where("CAST(t2.cp_final AS UNSIGNED) >=", intval($cp));
|
->where("CAST(t2.cp_final AS UNSIGNED) >=", intval($cp));
|
||||||
@ -117,10 +119,12 @@ class TarifaEnvioModel extends \App\Models\BaseModel
|
|||||||
$precio_tarifas = $model->getEnvioPrecio($tarifa->tarifa_envio_id, $peso, $tipo_envio);
|
$precio_tarifas = $model->getEnvioPrecio($tarifa->tarifa_envio_id, $peso, $tipo_envio);
|
||||||
foreach ($precio_tarifas as $precio_tarifa) {
|
foreach ($precio_tarifas as $precio_tarifa) {
|
||||||
$precio_tarifa->importe_fijo = $tarifa->importe_fijo;
|
$precio_tarifa->importe_fijo = $tarifa->importe_fijo;
|
||||||
|
$precio_tarifa->pais = $tarifa->pais;
|
||||||
array_push($resultado, $precio_tarifa);
|
array_push($resultado, $precio_tarifa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $resultado;
|
return $resultado;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,14 +20,13 @@ class UserModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
protected $allowedFields = [
|
protected $allowedFields = [
|
||||||
"username",
|
"username",
|
||||||
"email",
|
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
"client_id",
|
"client_id",
|
||||||
"status",
|
"status",
|
||||||
"status_message",
|
"status_message",
|
||||||
"active",
|
"active",
|
||||||
"country",
|
"comments",
|
||||||
"last_active",
|
"last_active",
|
||||||
"created_at",
|
"created_at",
|
||||||
"updated_at",
|
"updated_at",
|
||||||
@ -39,143 +38,25 @@ class UserModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
|
|
||||||
protected $validationRules = [
|
protected $validationRules = [
|
||||||
"address" => [
|
|
||||||
"label" => "Users.address",
|
|
||||||
"rules" => "trim|max_length[255]",
|
|
||||||
],
|
|
||||||
"blocked" => [
|
|
||||||
"label" => "Users.blocked",
|
|
||||||
"rules" => "required|permit_empty",
|
|
||||||
],
|
|
||||||
"city" => [
|
|
||||||
"label" => "Users.city",
|
|
||||||
"rules" => "trim|max_length[255]",
|
|
||||||
],
|
|
||||||
"country" => [
|
|
||||||
"label" => "Users.country",
|
|
||||||
"rules" => "trim|max_length[2]",
|
|
||||||
],
|
|
||||||
"date_birth" => [
|
|
||||||
"label" => "Users.dateBirth",
|
|
||||||
"rules" => "valid_date|permit_empty",
|
|
||||||
],
|
|
||||||
"email" => [
|
|
||||||
"label" => "Users.email",
|
|
||||||
"rules" => "trim|required|max_length[150]|valid_email",
|
|
||||||
],
|
|
||||||
"email_confirmed" => [
|
|
||||||
"label" => "Users.emailConfirmed",
|
|
||||||
"rules" => "required|integer",
|
|
||||||
],
|
|
||||||
"first_name" => [
|
"first_name" => [
|
||||||
"label" => "Users.firstName",
|
"label" => "Users.firstName",
|
||||||
"rules" => "trim|max_length[150]",
|
"rules" => "trim|max_length[150]",
|
||||||
],
|
],
|
||||||
"language" => [
|
|
||||||
"label" => "Users.language",
|
|
||||||
"rules" => "trim|max_length[10]",
|
|
||||||
],/*
|
|
||||||
"last_access" => [
|
|
||||||
"label" => "Users.lastAccess",
|
|
||||||
"rules" => "valid_date",
|
|
||||||
],*/
|
|
||||||
"last_ip" => [
|
|
||||||
"label" => "Users.lastIp",
|
|
||||||
"rules" => "max_length[50]",
|
|
||||||
],
|
|
||||||
"last_name" => [
|
"last_name" => [
|
||||||
"label" => "Users.lastName",
|
"label" => "Users.lastName",
|
||||||
"rules" => "trim|max_length[150]",
|
"rules" => "trim|max_length[150]",
|
||||||
],
|
],
|
||||||
"mobile" => [
|
|
||||||
"label" => "Users.mobile",
|
|
||||||
"rules" => "trim|max_length[50]",
|
|
||||||
],
|
|
||||||
"password" => [
|
|
||||||
"label" => "Users.password",
|
|
||||||
"rules" => "required|max_length[35]",
|
|
||||||
],
|
|
||||||
"picture" => [
|
|
||||||
"label" => "Users.picture",
|
|
||||||
"rules" => "trim|max_length[150]",
|
|
||||||
],
|
|
||||||
"state" => [
|
|
||||||
"label" => "Users.state",
|
|
||||||
"rules" => "trim|max_length[255]",
|
|
||||||
],
|
|
||||||
"zip_code" => [
|
|
||||||
"label" => "Users.zipCode",
|
|
||||||
"rules" => "trim|max_length[50]",
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $validationMessages = [
|
protected $validationMessages = [
|
||||||
"address" => [
|
|
||||||
"max_length" => "Users.validation.address.max_length",
|
|
||||||
],
|
|
||||||
|
|
||||||
"blocked" => [
|
|
||||||
"required" => "Users.validation.email_confirmed.required",
|
|
||||||
],
|
|
||||||
"city" => [
|
|
||||||
"max_length" => "Users.validation.city.max_length",
|
|
||||||
],
|
|
||||||
"country" => [
|
|
||||||
"max_length" => "Users.validation.country.max_length",
|
|
||||||
"required" => "Users.validation.country.required",
|
|
||||||
],
|
|
||||||
"date_birth" => [
|
|
||||||
"valid_date" => "Users.validation.date_birth.valid_date",
|
|
||||||
],
|
|
||||||
"email" => [
|
|
||||||
"max_length" => "Users.validation.email.max_length",
|
|
||||||
"required" => "Users.validation.email.required",
|
|
||||||
"valid_email" => "Users.validation.email.valid_email",
|
|
||||||
],
|
|
||||||
"email_confirmed" => [
|
|
||||||
"integer" => "Users.validation.email_confirmed.integer",
|
|
||||||
"required" => "Users.validation.email_confirmed.required",
|
|
||||||
],
|
|
||||||
"first_name" => [
|
"first_name" => [
|
||||||
"max_length" => "Users.validation.first_name.max_length",
|
"max_length" => "Users.validation.first_name.max_length",
|
||||||
"required" => "Users.validation.first_name.required",
|
"required" => "Users.validation.first_name.required",
|
||||||
],
|
],
|
||||||
|
|
||||||
"language" => [
|
|
||||||
"max_length" => "Users.validation.language.max_length",
|
|
||||||
"required" => "Users.validation.language.required",
|
|
||||||
],
|
|
||||||
"last_access" => [
|
|
||||||
"required" => "Users.validation.last_access.required",
|
|
||||||
"valid_date" => "Users.validation.last_access.valid_date",
|
|
||||||
],
|
|
||||||
"last_ip" => [
|
|
||||||
"max_length" => "Users.validation.last_ip.max_length",
|
|
||||||
"required" => "Users.validation.last_ip.required",
|
|
||||||
],
|
|
||||||
"last_name" => [
|
"last_name" => [
|
||||||
"max_length" => "Users.validation.last_name.max_length",
|
"max_length" => "Users.validation.last_name.max_length",
|
||||||
"required" => "Users.validation.last_name.required",
|
"required" => "Users.validation.last_name.required",
|
||||||
],
|
],
|
||||||
"mobile" => [
|
|
||||||
"max_length" => "Users.validation.mobile.max_length",
|
|
||||||
"required" => "Users.validation.mobile.required",
|
|
||||||
],
|
|
||||||
"password" => [
|
|
||||||
"max_length" => "Users.validation.password.max_length",
|
|
||||||
"required" => "Users.validation.password.required",
|
|
||||||
],
|
|
||||||
"picture" => [
|
|
||||||
"max_length" => "Users.validation.picture.max_length",
|
|
||||||
"required" => "Users.validation.picture.required",
|
|
||||||
],
|
|
||||||
"state" => [
|
|
||||||
"max_length" => "Users.validation.state.max_length",
|
|
||||||
"required" => "Users.validation.state.required",
|
|
||||||
],
|
|
||||||
"zip_code" => [
|
|
||||||
"max_length" => "Users.validation.zip_code.max_length",
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getGroupsTitles($user_token){
|
public function getGroupsTitles($user_token){
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class PresupuestoClienteService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function obtenerCubierta($data)
|
public static function obtenerCubierta($data, $return_raw=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$uso = $data['uso'];
|
$uso = $data['uso'];
|
||||||
@ -76,7 +76,6 @@ class PresupuestoClienteService extends BaseService
|
|||||||
$isColor = $data['isColor'];
|
$isColor = $data['isColor'];
|
||||||
$isHq = $data['isHq'];
|
$isHq = $data['isHq'];
|
||||||
$cliente_id = $data['cliente_id'];
|
$cliente_id = $data['cliente_id'];
|
||||||
$paginas_color = $data['paginas_color'];
|
|
||||||
$lomoRedondo = $data['lomoRedondo'];
|
$lomoRedondo = $data['lomoRedondo'];
|
||||||
|
|
||||||
$lineas_cubierta = [];
|
$lineas_cubierta = [];
|
||||||
@ -102,6 +101,14 @@ class PresupuestoClienteService extends BaseService
|
|||||||
}
|
}
|
||||||
if (count($lineas_cubierta) > 0) {
|
if (count($lineas_cubierta) > 0) {
|
||||||
|
|
||||||
|
if($return_raw){
|
||||||
|
$lineas_cubierta = array_values(array_unique($lineas_cubierta, SORT_REGULAR));
|
||||||
|
|
||||||
|
return[
|
||||||
|
'cubierta' => $lineas_cubierta
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
usort(
|
usort(
|
||||||
$lineas_cubierta,
|
$lineas_cubierta,
|
||||||
function ($a, $b) {
|
function ($a, $b) {
|
||||||
@ -119,7 +126,7 @@ class PresupuestoClienteService extends BaseService
|
|||||||
return $lineas_cubierta;
|
return $lineas_cubierta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function obtenerSobrecubierta($data)
|
public static function obtenerSobrecubierta($data, $return_raw=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$uso = $data['uso'];
|
$uso = $data['uso'];
|
||||||
@ -154,6 +161,14 @@ class PresupuestoClienteService extends BaseService
|
|||||||
}
|
}
|
||||||
if (count($lineas_sobrecubierta) > 0) {
|
if (count($lineas_sobrecubierta) > 0) {
|
||||||
|
|
||||||
|
if($return_raw){
|
||||||
|
$lineas_sobrecubierta = array_values(array_unique($lineas_sobrecubierta, SORT_REGULAR));
|
||||||
|
|
||||||
|
return[
|
||||||
|
'sobrecubierta' => $lineas_sobrecubierta
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
usort(
|
usort(
|
||||||
$lineas_sobrecubierta,
|
$lineas_sobrecubierta,
|
||||||
function ($a, $b) {
|
function ($a, $b) {
|
||||||
@ -171,7 +186,7 @@ class PresupuestoClienteService extends BaseService
|
|||||||
return $lineas_sobrecubierta;
|
return $lineas_sobrecubierta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function obtenerGuardas($data)
|
public static function obtenerGuardas($data, $return_raw=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$uso = $data['uso'];
|
$uso = $data['uso'];
|
||||||
@ -205,6 +220,14 @@ class PresupuestoClienteService extends BaseService
|
|||||||
}
|
}
|
||||||
if (count($lineas_guardas) > 0) {
|
if (count($lineas_guardas) > 0) {
|
||||||
|
|
||||||
|
if($return_raw){
|
||||||
|
$lineas_guardas = array_values(array_unique($lineas_guardas, SORT_REGULAR));
|
||||||
|
|
||||||
|
return[
|
||||||
|
'guardas' => $lineas_guardas
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
usort(
|
usort(
|
||||||
$lineas_guardas,
|
$lineas_guardas,
|
||||||
function ($a, $b) {
|
function ($a, $b) {
|
||||||
@ -241,28 +264,31 @@ class PresupuestoClienteService extends BaseService
|
|||||||
* - isHq: si es alta calidad
|
* - isHq: si es alta calidad
|
||||||
* - paginas_color: número de páginas a color
|
* - paginas_color: número de páginas a color
|
||||||
*/
|
*/
|
||||||
private static function obtenerPresupuestoClienteInterior($data)
|
public static function obtenerPresupuestoClienteInterior($data, $return_raw = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$uso = $data['uso'];
|
$uso = $data['uso'];
|
||||||
$tipo_impresion_id = $data['tipo_impresion_id'];
|
$tipo_impresion_id = $data['tipo_impresion_id'];
|
||||||
$datosPedido = $data['datosPedido'];
|
$datosPedido = $data['datosPedido'];
|
||||||
|
$paginas_color = $data['paginas_color'];
|
||||||
if ($data['papelInteriorDiferente'] == false)
|
if ($data['papelInteriorDiferente'] == false)
|
||||||
$papel_generico = $data['papel_generico'];
|
$papel_generico = $data['papel_generico'];
|
||||||
else {
|
else {
|
||||||
$papel_generico = $data['papel_generico']['negro'];
|
$papel_generico = $data['papel_generico']['negro'];
|
||||||
|
if($paginas_color>0)
|
||||||
$papel_generico_color = $data['papel_generico']['color'];
|
$papel_generico_color = $data['papel_generico']['color'];
|
||||||
}
|
}
|
||||||
if ($data['papelInteriorDiferente'] == false)
|
if ($data['papelInteriorDiferente'] == false)
|
||||||
$gramaje = $data['gramaje'];
|
$gramaje = $data['gramaje'];
|
||||||
else {
|
else {
|
||||||
$gramaje = $data['gramaje']['negro'];
|
$gramaje = $data['gramaje']['negro'];
|
||||||
|
if($paginas_color>0)
|
||||||
$gramaje_color = $data['gramaje']['color'];
|
$gramaje_color = $data['gramaje']['color'];
|
||||||
}
|
}
|
||||||
$isColor = $data['isColor'];
|
$isColor = $data['isColor'];
|
||||||
$isHq = $data['isHq'];
|
$isHq = $data['isHq'];
|
||||||
$cliente_id = $data['cliente_id'];
|
$cliente_id = $data['cliente_id'];
|
||||||
$paginas_color = $data['paginas_color'];
|
|
||||||
|
|
||||||
$paginas_negro = $datosPedido->paginas - $paginas_color;
|
$paginas_negro = $datosPedido->paginas - $paginas_color;
|
||||||
|
|
||||||
@ -293,6 +319,14 @@ class PresupuestoClienteService extends BaseService
|
|||||||
}
|
}
|
||||||
if (count($linea_negro_plana) > 0) {
|
if (count($linea_negro_plana) > 0) {
|
||||||
|
|
||||||
|
/*if($return_raw){
|
||||||
|
$linea_negro_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR));
|
||||||
|
|
||||||
|
return[
|
||||||
|
'negro' => $linea_negro_plana
|
||||||
|
];
|
||||||
|
}*/
|
||||||
|
|
||||||
usort(
|
usort(
|
||||||
$linea_negro_plana,
|
$linea_negro_plana,
|
||||||
function ($a, $b) {
|
function ($a, $b) {
|
||||||
@ -335,6 +369,14 @@ class PresupuestoClienteService extends BaseService
|
|||||||
}
|
}
|
||||||
if (count($linea_color_plana) > 0) {
|
if (count($linea_color_plana) > 0) {
|
||||||
|
|
||||||
|
/*if($return_raw){
|
||||||
|
$linea_color_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR));
|
||||||
|
|
||||||
|
return[
|
||||||
|
'color' => $linea_color_plana
|
||||||
|
];
|
||||||
|
}*/
|
||||||
|
|
||||||
usort(
|
usort(
|
||||||
$linea_color_plana,
|
$linea_color_plana,
|
||||||
function ($a, $b) {
|
function ($a, $b) {
|
||||||
@ -349,6 +391,16 @@ class PresupuestoClienteService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($return_raw){
|
||||||
|
$linea_negro_plana = array_values(array_unique($linea_negro_plana, SORT_REGULAR));
|
||||||
|
$linea_color_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR));
|
||||||
|
|
||||||
|
return[
|
||||||
|
'negro' => $linea_negro_plana,
|
||||||
|
'color' => $linea_color_plana
|
||||||
|
];
|
||||||
|
}
|
||||||
// Si hay negro y color, y se hace con el mismo papel, hay que buscar la combinación
|
// Si hay negro y color, y se hace con el mismo papel, hay que buscar la combinación
|
||||||
// más económica con la misma máquna
|
// más económica con la misma máquna
|
||||||
if (
|
if (
|
||||||
@ -493,7 +545,7 @@ class PresupuestoClienteService extends BaseService
|
|||||||
* - isHq: si es alta calidad
|
* - isHq: si es alta calidad
|
||||||
* - paginas_color: número de páginas a color
|
* - paginas_color: número de páginas a color
|
||||||
*/
|
*/
|
||||||
private static function obtenerPresupuestoClienteInteriorRotativa($data)
|
public static function obtenerPresupuestoClienteInteriorRotativa($data, $return_raw = false)
|
||||||
{
|
{
|
||||||
$datosPedido = $data['datosPedido'];
|
$datosPedido = $data['datosPedido'];
|
||||||
$papel_generico = $data['papel_generico'];
|
$papel_generico = $data['papel_generico'];
|
||||||
@ -532,6 +584,14 @@ class PresupuestoClienteService extends BaseService
|
|||||||
|
|
||||||
if (count($linea_rotativa) > 0) {
|
if (count($linea_rotativa) > 0) {
|
||||||
|
|
||||||
|
if($return_raw){
|
||||||
|
$linea_rotativa = array_values(array_unique($linea_rotativa, SORT_REGULAR));
|
||||||
|
|
||||||
|
return[
|
||||||
|
'rotativa' => $linea_rotativa,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
usort(
|
usort(
|
||||||
$linea_rotativa,
|
$linea_rotativa,
|
||||||
function ($a, $b) {
|
function ($a, $b) {
|
||||||
|
|||||||
@ -462,7 +462,7 @@ class PresupuestoService extends BaseService
|
|||||||
[$data['ancho'], $data['alto']] = PresupuestoService::calculoDimForma($datosPedido, $parametrosRotativa);
|
[$data['ancho'], $data['alto']] = PresupuestoService::calculoDimForma($datosPedido, $parametrosRotativa);
|
||||||
|
|
||||||
// calculo de papel y clicks
|
// calculo de papel y clicks
|
||||||
$factor_anchura = round($maquina->ancho_impresion / $data['ancho'], 2);
|
$factor_anchura = floor($maquina->ancho_impresion / $data['ancho']);
|
||||||
$factor_altura = round($maquina->alto_impresion / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
|
$factor_altura = round($maquina->alto_impresion / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
|
||||||
$factor_altura_click = round($maquina->alto_click / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
|
$factor_altura_click = round($maquina->alto_click / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
|
||||||
|
|
||||||
@ -470,13 +470,13 @@ class PresupuestoService extends BaseService
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$multiplicador_pliego = $datosPedido->isCosido ? 4 : 2;
|
//$multiplicador_pliego = $datosPedido->isCosido ? 4 : 2;
|
||||||
$paginas_por_pliego = round(floor($factor_anchura) * $factor_altura * $multiplicador_pliego, 2);
|
$paginas_por_pliego = round($factor_anchura * $factor_altura * 2 /** $multiplicador_pliego*/, 2);
|
||||||
$pliegos_libro = round($paginas_por_pliego ? $datosPedido->paginas / $paginas_por_pliego : 0, 2);
|
$pliegos_libro = round($paginas_por_pliego ? $datosPedido->paginas / $paginas_por_pliego : 0, 2);
|
||||||
$metros_papel_libro = round($pliegos_libro * ($maquina->alto_impresion / 1000.0), 2);
|
$metros_papel_libro = round($pliegos_libro * ($maquina->alto_impresion / 1000.0), 2);
|
||||||
$metros_papel_total = round($metros_papel_libro * ($datosPedido->tirada + $datosPedido->merma), 2);
|
$metros_papel_total = round($metros_papel_libro * ($datosPedido->tirada + $datosPedido->merma), 2);
|
||||||
|
|
||||||
$paginas_por_pliego_click = round(floor($factor_anchura) * $factor_altura_click * $multiplicador_pliego, 2);
|
$paginas_por_pliego_click = round($factor_anchura * $factor_altura_click * 2/** $multiplicador_pliego*/, 2);
|
||||||
$pliegos_libro_click = round($paginas_por_pliego_click ? $datosPedido->paginas / $paginas_por_pliego_click : 0, 2);
|
$pliegos_libro_click = round($paginas_por_pliego_click ? $datosPedido->paginas / $paginas_por_pliego_click : 0, 2);
|
||||||
$clicks_libro = round(ceil($pliegos_libro_click) * 2, 2);
|
$clicks_libro = round(ceil($pliegos_libro_click) * 2, 2);
|
||||||
$clicks_pedido = round($clicks_libro * ($datosPedido->tirada + $datosPedido->merma), 2);
|
$clicks_pedido = round($clicks_libro * ($datosPedido->tirada + $datosPedido->merma), 2);
|
||||||
@ -843,7 +843,7 @@ class PresupuestoService extends BaseService
|
|||||||
$ancho_total = 0;
|
$ancho_total = 0;
|
||||||
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
|
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
|
||||||
if ($datosPedido->ancho >= 210) {
|
if ($datosPedido->ancho >= 210) {
|
||||||
$sangre_cubierta = 15;
|
$sangre_cubierta = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($datosPedido) {
|
if ($datosPedido) {
|
||||||
@ -925,7 +925,7 @@ class PresupuestoService extends BaseService
|
|||||||
$alto_total = floatval($datosPedido->alto);
|
$alto_total = floatval($datosPedido->alto);
|
||||||
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
|
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
|
||||||
if ($datosPedido->alto >= 297) {
|
if ($datosPedido->alto >= 297) {
|
||||||
$sangre_cubierta = 15;
|
$sangre_cubierta = 10;
|
||||||
}
|
}
|
||||||
// Tapa dura (cosido y fresado)
|
// Tapa dura (cosido y fresado)
|
||||||
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
||||||
@ -1687,7 +1687,7 @@ class PresupuestoService extends BaseService
|
|||||||
uso_tarifa: $uso,
|
uso_tarifa: $uso,
|
||||||
tirada: $datosPedido->tirada + $datosPedido->merma,
|
tirada: $datosPedido->tirada + $datosPedido->merma,
|
||||||
papel_impresion_id: $papel->id,
|
papel_impresion_id: $papel->id,
|
||||||
);
|
)->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||||
|
|
||||||
$data['uso'] = $uso;
|
$data['uso'] = $uso;
|
||||||
$data['tipo'] = $tipo;
|
$data['tipo'] = $tipo;
|
||||||
@ -1775,7 +1775,7 @@ class PresupuestoService extends BaseService
|
|||||||
uso_tarifa: ($uso == 'guardas') ? 'interior' : $uso,
|
uso_tarifa: ($uso == 'guardas') ? 'interior' : $uso,
|
||||||
tirada: $datosPedido->tirada + $datosPedido->merma,
|
tirada: $datosPedido->tirada + $datosPedido->merma,
|
||||||
papel_impresion_id: $papel->id,
|
papel_impresion_id: $papel->id,
|
||||||
);
|
)->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||||
|
|
||||||
// Se recorren las máquinas y se calcula el coste de linea por cada una
|
// Se recorren las máquinas y se calcula el coste de linea por cada una
|
||||||
foreach ($maquinas as $maquina) {
|
foreach ($maquinas as $maquina) {
|
||||||
|
|||||||
@ -158,7 +158,7 @@
|
|||||||
<!-- Código JS comportamiento ?????. -->
|
<!-- Código JS comportamiento ?????. -->
|
||||||
<!------------------------------------------------------->
|
<!------------------------------------------------------->
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
|
/*
|
||||||
$("textarea[name*='comentarios_']").each(function(){
|
$("textarea[name*='comentarios_']").each(function(){
|
||||||
if (!$.trim($(this).val())) {
|
if (!$.trim($(this).val())) {
|
||||||
// textarea is empty or contains only white-space
|
// textarea is empty or contains only white-space
|
||||||
@ -167,7 +167,7 @@ $("textarea[name*='comentarios_']").each(function(){
|
|||||||
$("#mostrar_" + $(this).attr('name')).show();
|
$("#mostrar_" + $(this).attr('name')).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,423 +0,0 @@
|
|||||||
const actionBtns_direcciones = function(data) {
|
|
||||||
return `
|
|
||||||
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-add mx-2" data-id="${data.id}"></i></a></span>
|
|
||||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas delete-add-row mx-2"></i></a>
|
|
||||||
`;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Funcion para obtener el peso total del libro
|
|
||||||
function get_peso_libro(){
|
|
||||||
|
|
||||||
var peso_total_libro = 0.0
|
|
||||||
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
peso_total_libro += parseFloat(rowData.peso)
|
|
||||||
})
|
|
||||||
return peso_total_libro;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function get_precio_envio(peso, paisId, cp, tipo_envio){
|
|
||||||
|
|
||||||
data = {
|
|
||||||
tipo: 'get_tarifa',
|
|
||||||
peso: peso,
|
|
||||||
paisId: paisId,
|
|
||||||
cp: cp,
|
|
||||||
tipo_envio: tipo_envio,
|
|
||||||
}
|
|
||||||
data = Object.assign(data, window.token_ajax);
|
|
||||||
|
|
||||||
const response = await fetch(window.location.origin + window.url_get_precio_envio , {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify(data),
|
|
||||||
headers: {
|
|
||||||
"Content-type": "application/json; charset=UTF-8",
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const values = await response.json();
|
|
||||||
yeniden(values[window.csrf_token]);
|
|
||||||
return values.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function get_coste_envio_tiradasAlternativas(tirada){
|
|
||||||
|
|
||||||
var peso_libro = get_peso_libro();
|
|
||||||
var tirada_inicial = parseInt($('#tirada').val());
|
|
||||||
var coste = 0.0;
|
|
||||||
var margen = 0.0;
|
|
||||||
|
|
||||||
const table = $('#tableOfDireccionesEnvio').DataTable();
|
|
||||||
const rows = table.rows().nodes();
|
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; i++) {
|
|
||||||
const rowData = table.row(rows[i]).data();
|
|
||||||
const porcentaje = parseInt(rowData.cantidad)/tirada_inicial*100.0;
|
|
||||||
const cantidad = Math.floor(tirada*porcentaje/100.0);
|
|
||||||
const peso_envio = cantidad*peso_libro/1000.0;
|
|
||||||
const datos_tarifa = await get_precio_envio(peso_envio, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
|
|
||||||
|
|
||||||
if(datos_tarifa.id!=null){
|
|
||||||
|
|
||||||
if(peso_envio>parseFloat(datos_tarifa.peso_max)){
|
|
||||||
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{
|
|
||||||
m=((parseFloat(datos_tarifa.precio_max)-parseFloat(datos_tarifa.precio_min))/(parseFloat(datos_tarifa.peso_max)-parseFloat(datos_tarifa.peso_min)));
|
|
||||||
b=parseFloat(datos_tarifa.precio_max)-m*parseFloat(datos_tarifa.peso_max);
|
|
||||||
coste += parseFloat(m*peso_envio+b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
margen += coste*datos_tarifa.margen/100.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {coste, margen};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function checkInsertar(){
|
|
||||||
|
|
||||||
var cantidad_total = 0
|
|
||||||
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var data = this.data();
|
|
||||||
cantidad_total += parseInt(data.cantidad )
|
|
||||||
} );
|
|
||||||
var htmlString = ''
|
|
||||||
if(cantidad_total < parseInt($('#tirada').val())){
|
|
||||||
$('#rowInsertar').css('display', 'flex')
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$('#rowInsertar').css('display', 'none')
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cantidad_total != parseInt($('#tirada').val())){
|
|
||||||
htmlString = `
|
|
||||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
|
||||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
|
||||||
<i class="ti ti-bell ti-sm"></i>
|
|
||||||
</span>
|
|
||||||
<div class="d-flex flex-column ps-1">
|
|
||||||
<h5 class="alert-heading mb-2">` +
|
|
||||||
window.Presupuestos.validation.ejemplares_envio +
|
|
||||||
`</h5>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
$('#alert-envios').html(htmlString)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function updateTablaEnvios(tirada_inicial = null, tirada = null){
|
|
||||||
|
|
||||||
var peso_total_libro = get_peso_libro();
|
|
||||||
|
|
||||||
$('#tableOfDireccionesEnvio').DataTable().rows().every(async function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
|
|
||||||
var rowData = this.data();
|
|
||||||
|
|
||||||
if(tirada_inicial!=null && tirada!=null){
|
|
||||||
const porcentaje = parseInt(rowData.cantidad)/tirada_inicial*100.0;
|
|
||||||
const cantidad = Math.floor(tirada*porcentaje/100.0);
|
|
||||||
rowData.cantidad = cantidad
|
|
||||||
}
|
|
||||||
const peso_envio = peso_total_libro*parseInt(rowData.cantidad)/1000.0;
|
|
||||||
|
|
||||||
var datos_tarifa = await get_precio_envio(peso_envio, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
|
|
||||||
|
|
||||||
|
|
||||||
if(datos_tarifa.id!=null){
|
|
||||||
|
|
||||||
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
|
|
||||||
else{
|
|
||||||
m=((parseFloat(datos_tarifa.precio_max)-parseFloat(datos_tarifa.precio_min))/(parseFloat(datos_tarifa.peso_max)-parseFloat(datos_tarifa.peso_min)));
|
|
||||||
b=parseFloat(datos_tarifa.precio_max)-m*parseFloat(datos_tarifa.peso_max);
|
|
||||||
datos_tarifa.precio = parseFloat(m*peso_envio+b);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
datos_tarifa.cantidad = parseInt($('#add_cantidad').val());
|
|
||||||
datos_tarifa.peso = peso_envio;
|
|
||||||
|
|
||||||
$('#tableOfDireccionesEnvio').DataTable().row(rowIdx)
|
|
||||||
.data({
|
|
||||||
'tarifa_id': datos_tarifa.id,
|
|
||||||
'cantidad': rowData.cantidad,
|
|
||||||
'peso': datos_tarifa.peso.toFixed(3),
|
|
||||||
'att': rowData.att,
|
|
||||||
'email': rowData.email,
|
|
||||||
'direccion': rowData.direccion,
|
|
||||||
'cp': rowData.cp,
|
|
||||||
'municipio': rowData.municipio,
|
|
||||||
'provincia': rowData.provincia,
|
|
||||||
'paisId': rowData.paisId,
|
|
||||||
'telefono': rowData.telefono,
|
|
||||||
'proveedor': datos_tarifa.proveedor,
|
|
||||||
'proveedor_id': datos_tarifa.proveedor_id,
|
|
||||||
'precio': datos_tarifa.precio.toFixed(2),
|
|
||||||
'margen': datos_tarifa.margen,
|
|
||||||
'entregaPieCalle': rowData.entregaPieCalle,
|
|
||||||
'actionBtns_direcciones': actionBtns_direcciones,
|
|
||||||
})
|
|
||||||
.draw();
|
|
||||||
|
|
||||||
checkInsertar()
|
|
||||||
//updateTotales(false, false, true)
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: false,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
popErrorAlert(window.error_no_tarifa_envio, 'error-tarifa')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#insertar_direccion').on('click', function(){
|
|
||||||
|
|
||||||
$("#addressForm").attr('action','create')
|
|
||||||
var $newAddDialog = $("#addressForm")
|
|
||||||
var maximaCantidad = parseInt($('#tirada').val())
|
|
||||||
$("#add_cantidad").attr("max" , maximaCantidad);
|
|
||||||
$("#add_cantidad").val( maximaCantidad);
|
|
||||||
$("#add_cantidad").on('change', function(){
|
|
||||||
$("#add_cantidad").val(parseInt($("#add_cantidad").val())>maximaCantidad ? maximaCantidad : $("#add_cantidad").val())
|
|
||||||
})
|
|
||||||
|
|
||||||
cantidad_total = 0
|
|
||||||
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var data = this.data();
|
|
||||||
cantidad_total += parseInt(data.cantidad)
|
|
||||||
} );
|
|
||||||
$('#add_cantidad').attr('max-value', parseInt($('#tirada').val())-cantidad_total)
|
|
||||||
$('#add_cantidad').val(parseInt($('#tirada').val())-cantidad_total)
|
|
||||||
$newAddDialog.modal('show')
|
|
||||||
})
|
|
||||||
|
|
||||||
const lastColNr_direcciones = $('#tableOfDireccionesEnvio').find("tr:first th").length - 1;
|
|
||||||
|
|
||||||
|
|
||||||
$(document).on('click', '.delete-add-row', function(e) {
|
|
||||||
const row = $(this).closest('tr');
|
|
||||||
tableEnvios.row( row )
|
|
||||||
.remove()
|
|
||||||
.draw();
|
|
||||||
checkInsertar()
|
|
||||||
//updateTotales(false, false, true)
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: false,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true
|
|
||||||
})
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
$(document).on('click', '.btn-edit-add', function(e) {
|
|
||||||
const row = $(this).closest('tr');
|
|
||||||
var data = tableEnvios.row( row ).data()
|
|
||||||
|
|
||||||
$("#addressForm").attr('action','edit')
|
|
||||||
$("#addressForm").attr('row', row[0]._DT_RowIndex)
|
|
||||||
$("#addressForm").attr('presupuestodireccion_id', $(this).attr('data-id'))
|
|
||||||
var $newAddDialog = $("#addressForm")
|
|
||||||
var maximaCantidad = parseInt($('#tirada').val())
|
|
||||||
$("#add_cantidad").attr("max" , maximaCantidad);
|
|
||||||
$("#add_cantidad").val( maximaCantidad);
|
|
||||||
$("#add_cantidad").on('change', function(){
|
|
||||||
$("#add_cantidad").val(parseInt($("#add_cantidad").val())>maximaCantidad ? maximaCantidad : $("#add_cantidad").val())
|
|
||||||
})
|
|
||||||
|
|
||||||
cantidad_total = 0
|
|
||||||
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var data2 = this.data();
|
|
||||||
cantidad_total += parseInt(data2.cantidad)
|
|
||||||
} );
|
|
||||||
cantidad_total -= parseInt(data.cantidad) // Si es editar tienes que restar los de la linea actual
|
|
||||||
$('#add_cantidad').attr('max-value', parseInt($('#tirada').val())-cantidad_total)
|
|
||||||
$('#add_cantidad').val(parseInt($('#tirada').val())-cantidad_total)
|
|
||||||
|
|
||||||
$('#add_att').val(data.att)
|
|
||||||
$('#add_direccion').val(data.direccion)
|
|
||||||
$('#add_email').val(data.email)
|
|
||||||
$('#add_cp').val(data.cp)
|
|
||||||
$('#add_municipio').val(data.municipio)
|
|
||||||
$('#add_provincia').val(data.provincia)
|
|
||||||
$('#add_pais_id').val(data.paisId)
|
|
||||||
$('#add_telefono').val(data.telefono)
|
|
||||||
$('#add_cantidad').val(data.cantidad)
|
|
||||||
$('#add_entregaPieCalle').prop('checked', data.entregaPieCalle==1?true:false)
|
|
||||||
|
|
||||||
$newAddDialog.modal('show')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#recoger_en_taller').change(function(){
|
|
||||||
if(this.checked) {
|
|
||||||
$('#rowTable').css('display', 'none')
|
|
||||||
$('#rowInsertar').css('display', 'none')
|
|
||||||
tableEnvios.clear().draw()
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$('#rowTable').css('display', 'flex')
|
|
||||||
$('#rowInsertar').css('display', 'flex')
|
|
||||||
tableEnvios.columns.adjust();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
let tableEnvios = $('#tableOfDireccionesEnvio').DataTable( {
|
|
||||||
draw:5,
|
|
||||||
serverSide: false,
|
|
||||||
processing: true,
|
|
||||||
autoWidth: true,
|
|
||||||
responsive: true,
|
|
||||||
order: [[ 0, "asc" ]],
|
|
||||||
pageLength: 20,
|
|
||||||
lengthChange: false,
|
|
||||||
searching: false,
|
|
||||||
paging: false,
|
|
||||||
info: false,
|
|
||||||
scrollX: true,
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
{ 'data': 'tarifa_id' },
|
|
||||||
{ 'data': 'cantidad' },
|
|
||||||
{ 'data': 'peso' },
|
|
||||||
{ 'data': 'att' },
|
|
||||||
{ 'data': 'email' },
|
|
||||||
{ 'data': 'direccion' },
|
|
||||||
{ 'data': 'cp' },
|
|
||||||
{ 'data': 'municipio' },
|
|
||||||
{ 'data': 'paisId' ,
|
|
||||||
render: function(data, type, row, meta) {
|
|
||||||
var pais = window.paisList.find(element => element.id == data);
|
|
||||||
return pais['nombre'];
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ 'data': 'telefono' },
|
|
||||||
{ 'data': 'proveedor'},
|
|
||||||
{ 'data': 'proveedor_id'},
|
|
||||||
{ 'data': 'precio' },
|
|
||||||
{ 'data': 'margen' },
|
|
||||||
{ 'data': 'entregaPieCalle' },
|
|
||||||
{
|
|
||||||
data: actionBtns_direcciones,
|
|
||||||
className: 'row-edit dt-center'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
columnDefs: [
|
|
||||||
{
|
|
||||||
orderable: false,
|
|
||||||
searchable: false,
|
|
||||||
targets: [lastColNr_direcciones]
|
|
||||||
},
|
|
||||||
{"orderData": [ 0], "targets": 0 },
|
|
||||||
|
|
||||||
],
|
|
||||||
columnDefs: [
|
|
||||||
{
|
|
||||||
target: [0,11,13,14],
|
|
||||||
visible: false,
|
|
||||||
searchable: false
|
|
||||||
},
|
|
||||||
],
|
|
||||||
language: {
|
|
||||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
|
||||||
},
|
|
||||||
|
|
||||||
} );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function save_datos_envios(){
|
|
||||||
|
|
||||||
var id = $('#presupuesto_id').val()
|
|
||||||
|
|
||||||
$.post( window.routes_envios.dataTableOfPresupuestoDirecciones,
|
|
||||||
Object.assign({tipo: "clear_lineas", presupuesto_id: id}, window.token_ajax))
|
|
||||||
.done(function( data ) {
|
|
||||||
|
|
||||||
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var data = this.data();
|
|
||||||
$.post( '/presupuestos/presupuestodirecciones/add',
|
|
||||||
Object.assign({
|
|
||||||
presupuesto_id : id,
|
|
||||||
tarifa_id : data.tarifa_id,
|
|
||||||
cantidad : data.cantidad,
|
|
||||||
peso : data.peso,
|
|
||||||
att : data.att,
|
|
||||||
email : data.email,
|
|
||||||
direccion : data.direccion,
|
|
||||||
paisId : data.paisId,
|
|
||||||
provincia : data.provincia,
|
|
||||||
municipio : data.municipio,
|
|
||||||
cp : data.cp,
|
|
||||||
telefono : data.telefono,
|
|
||||||
precio : data.precio,
|
|
||||||
margen : data.margen,
|
|
||||||
proveedor : data.proveedor,
|
|
||||||
proveedor_id : data.proveedor_id,
|
|
||||||
entregaPieCalle : data.entregaPieCalle}, window.token_ajax))
|
|
||||||
});
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function load_datos_envios(){
|
|
||||||
|
|
||||||
window.direccionesList.forEach((linea) => {
|
|
||||||
tableEnvios.row
|
|
||||||
.add({
|
|
||||||
'tarifa_id': linea.tarifa_id,
|
|
||||||
'cantidad': linea.cantidad,
|
|
||||||
'peso': linea.peso,
|
|
||||||
'att': linea.att,
|
|
||||||
'email': linea.email,
|
|
||||||
'direccion': linea.direccion,
|
|
||||||
'cp': linea.cp,
|
|
||||||
'municipio': linea.municipio,
|
|
||||||
'provincia': linea.provincia,
|
|
||||||
'paisId': linea.pais_id,
|
|
||||||
'telefono': linea.telefono,
|
|
||||||
'proveedor': linea.proveedor,
|
|
||||||
'proveedor_id': linea.proveedor_id,
|
|
||||||
'precio': linea.precio,
|
|
||||||
'margen': linea.margen,
|
|
||||||
'entregaPieCalle': linea.entregaPieCalle,
|
|
||||||
'actionBtns_direcciones': actionBtns_direcciones,
|
|
||||||
})
|
|
||||||
.draw();
|
|
||||||
checkInsertar()
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: false,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: false
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -10,11 +10,20 @@
|
|||||||
<div class="accordion-body">
|
<div class="accordion-body">
|
||||||
<div id='alert-envios'></div>
|
<div id='alert-envios'></div>
|
||||||
<?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?>
|
<?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?>
|
||||||
|
<div class='row'>
|
||||||
|
<div class='col-md-12 col-lg-4 px-4 py-2'>
|
||||||
|
<label for='envio_base' class='form-label'>
|
||||||
|
Envio base
|
||||||
|
</label>
|
||||||
|
<input readonly type='text' class='form-control' id='envio_base' name='envio_base' value='<?= $presupuestoEntity->envio_base ?>' />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
<div id='rowTable' class='row'>
|
<div id='rowTable' class='row'>
|
||||||
<table id="tableOfDireccionesEnvio" class="table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;">
|
<table id="tableOfDireccionesEnvio" class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="lp-header">Tarifa_id</th>
|
<th class="lp-header">TARIFA ID</th>
|
||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
|
||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
|
||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
|
||||||
@ -23,12 +32,13 @@
|
|||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
|
||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
|
||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
|
||||||
|
<th class="lp-header">pais_id</th>
|
||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
|
||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
|
||||||
<th>Proveedor_id</th>
|
<th class="lp-header">Proveedor_id</th>
|
||||||
<th class="lp-header"><?= lang('PresupuestosDirecciones.precio') ?></th>
|
<th class="lp-header"><?= lang('PresupuestosDirecciones.precio') ?></th>
|
||||||
<th>Margen</th>
|
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
|
||||||
<th>Entrega a pie</th>
|
<th class="lp-header">Pallets?</th>
|
||||||
<th style="min-width:120px !important;" class="lp-header"><?= lang('Basic.global.Action') ?></th>
|
<th style="min-width:120px !important;" class="lp-header"><?= lang('Basic.global.Action') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -55,24 +65,3 @@
|
|||||||
</div> <!-- //.accordion-item -->
|
</div> <!-- //.accordion-item -->
|
||||||
</div> <!-- //.accordion -->
|
</div> <!-- //.accordion -->
|
||||||
|
|
||||||
<!------------------------------------------->
|
|
||||||
<!-- Código JS comportamiento general pag. -->
|
|
||||||
<!------------------------------------------->
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
|
|
||||||
window.paisList = <?php echo json_encode($paisList); ?>;
|
|
||||||
window.direccionesList = <?php echo json_encode($direccionesList); ?>;
|
|
||||||
|
|
||||||
window.routes_envios = {
|
|
||||||
dataTableOfPresupuestoDirecciones: '<?= route_to('dataTableOfPresupuestoDirecciones') ?>'
|
|
||||||
}
|
|
||||||
|
|
||||||
window.url_get_precio_envio = '<?= route_to('processDataDirecciones') ?>';
|
|
||||||
window.error_no_tarifa_envio = '<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>'
|
|
||||||
window.token_ajax= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
|
|
||||||
|
|
||||||
$( document ).ready(function() {
|
|
||||||
load_datos_envios();
|
|
||||||
});
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
@ -1,144 +0,0 @@
|
|||||||
$('#paginas').on("change", function () {
|
|
||||||
|
|
||||||
const url2 = window.location.href;
|
|
||||||
const url_parts2 = url2.split('/');
|
|
||||||
|
|
||||||
if($('#tipo_impresion_id').val() == 21){
|
|
||||||
if(parseInt($('#paginas').val()) > 80){
|
|
||||||
$('#paginas').val(80)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(url_parts2[url_parts2.length-2] == 'edit'){
|
|
||||||
|
|
||||||
checkPaginasPresupuesto()
|
|
||||||
|
|
||||||
// Si es negro o color
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
|
|
||||||
$('#tipoImpresion').select2('data')[0].id == 'color') {
|
|
||||||
$('#compPaginasNegro').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColor').val()));
|
|
||||||
$('#compPaginasNegro').trigger('change')
|
|
||||||
}
|
|
||||||
// Si es negrohq o colorhq
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
|
|
||||||
$('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
|
||||||
$('#compPaginasNegrohq').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColorhq').val()));
|
|
||||||
$('#compPaginasNegrohq').trigger('change');
|
|
||||||
}
|
|
||||||
|
|
||||||
//update_servicios(false)
|
|
||||||
//updateLineasPresupuesto()
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: true,
|
|
||||||
update_servicios: true,
|
|
||||||
update_envios: true,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$('#tirada').on("change", function (update_tiradas_alternativas = true) {
|
|
||||||
|
|
||||||
calcular_mermas()
|
|
||||||
|
|
||||||
const url2 = window.location.href;
|
|
||||||
const url_parts2 = url2.split('/');
|
|
||||||
|
|
||||||
if(url_parts2[url_parts2.length-2] == 'edit'){
|
|
||||||
//update_servicios(false)
|
|
||||||
//updateLineasPresupuesto()
|
|
||||||
if(update_tiradas_alternativas)
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: true,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: false,
|
|
||||||
update_tiradas_alternativas: false
|
|
||||||
})
|
|
||||||
else
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: true,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: false,
|
|
||||||
update_tiradas_alternativas: false
|
|
||||||
})
|
|
||||||
checkInsertar()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function calcular_mermas(){
|
|
||||||
|
|
||||||
const tirada = parseInt($('#tirada').val())
|
|
||||||
var merma = 0
|
|
||||||
htmlString = ''
|
|
||||||
|
|
||||||
if(tirada> parseInt($('#POD').val())){
|
|
||||||
merma = tirada*0.1<=30 ? tirada*0.1 : 30
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
merma_lineas = []
|
|
||||||
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){
|
|
||||||
const formas_linea = parseInt($('#isCosido').val())==0?parseInt(rowData.formas):parseInt(rowData.formas)/2
|
|
||||||
if(formas_linea > tirada)
|
|
||||||
merma_lineas.push(formas_linea-tirada)
|
|
||||||
else
|
|
||||||
merma_lineas.push(tirada%formas_linea)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if(merma_lineas.length>0)
|
|
||||||
merma = Math.max(...merma_lineas)
|
|
||||||
else{
|
|
||||||
htmlString = `
|
|
||||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
|
||||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
|
||||||
<i class="ti ti-bell ti-sm"></i>
|
|
||||||
</span>
|
|
||||||
<div class="d-flex flex-column ps-1">
|
|
||||||
<h5 class="alert-heading mb-2">` +
|
|
||||||
window.Presupuestos.validation.no_lp_for_merma +
|
|
||||||
`</h5>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
|
|
||||||
|
|
||||||
merma = 0
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
$('#mermacubierta').val(parseInt(merma))
|
|
||||||
$('#merma').val(parseInt(merma))
|
|
||||||
$('#alert-datosLibro').html(htmlString)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$('#papelFormatoPersonalizado').on("click",function(){
|
|
||||||
|
|
||||||
if($('#papelFormatoPersonalizado').is(':checked')){
|
|
||||||
document.getElementById("papelFormatoAncho").style.display = "block";
|
|
||||||
document.getElementById("papelFormatoAlto").style.display = "block";
|
|
||||||
$('#papelFormatoId').hide();
|
|
||||||
$('#papelFormatoId').val(0).change();
|
|
||||||
document.getElementById("label_papelFormatoId").innerHTML =
|
|
||||||
window.Presupuestos.papelFormatoId + " (" +
|
|
||||||
window.Presupuestos.papelFormatoAncho + " x " + window.Presupuestos.papelFormatoAncho + ")*";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
document.getElementById("papelFormatoAncho").value= "";
|
|
||||||
document.getElementById("papelFormatoAlto").value= "";
|
|
||||||
document.getElementById("papelFormatoAncho").style.display = "none";
|
|
||||||
document.getElementById("papelFormatoAlto").style.display = "none";
|
|
||||||
$('#papelFormatoId').show();
|
|
||||||
document.getElementById("label_papelFormatoId").innerHTML =
|
|
||||||
window.Presupuestos.papelFormatoId + '*';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
<label for="paginas" class="form-label">
|
<label for="paginas" class="form-label">
|
||||||
<?= lang('Presupuestos.paginas') ?>*
|
<?= lang('Presupuestos.paginas') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="number" id="paginas" name="paginas" tabindex="1" maxLength="11" class="form-control" value="<?= old('paginas', $presupuestoEntity->paginas) ?>" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
|
<input type="number" id="paginas" name="paginas" tabindex="1" maxLength="11" class="form-control" value="" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -30,7 +30,7 @@
|
|||||||
<label for="tirada" class="form-label">
|
<label for="tirada" class="form-label">
|
||||||
<?= lang('Presupuestos.tirada') ?>*
|
<?= lang('Presupuestos.tirada') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="number" id="tirada" name="tirada" tabindex="2" maxLength="11" class="form-control" value="<?= old('tirada', $presupuestoEntity->tirada) ?>">
|
<input type="number" id="tirada" name="tirada" tabindex="2" maxLength="11" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
@ -41,28 +41,22 @@
|
|||||||
<label id="label_papelFormatoId" for="papelFormatoId" class="form-label">
|
<label id="label_papelFormatoId" for="papelFormatoId" class="form-label">
|
||||||
<?= lang('Presupuestos.papelFormatoId') ?>*
|
<?= lang('Presupuestos.papelFormatoId') ?>*
|
||||||
</label>
|
</label>
|
||||||
|
<div class="row tamanio-estandar">
|
||||||
<select id="papelFormatoId" <?= $presupuestoEntity->papel_formato_personalizado == false ? '' : 'style="display: none"'; ?> name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
<select id="papelFormatoId" name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
||||||
|
|
||||||
<?php if (isset($papelFormatoList) && is_array($papelFormatoList) && !empty($papelFormatoList)) :
|
|
||||||
foreach ($papelFormatoList as $formato) : ?>
|
|
||||||
<option value="<?= $formato->id ?>" <?= $formato->id == $presupuestoEntity->papel_formato_id ? ' selected' : '' ?>>
|
|
||||||
<?= $formato->tamanio ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach;
|
|
||||||
endif; ?>
|
|
||||||
</select>
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-lg-6">
|
<div class="col-md-12 col-lg-6 tamanio-personalizado d-none">
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
<input <?= $presupuestoEntity->papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="0.01" class="form-control formato_libro" value="<?= old('papel_formato_ancho', $presupuestoEntity->papel_formato_ancho) ?>">
|
<input type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="0.01" class="form-control formato_libro" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
<div class="col-md-12 col-lg-6">
|
<div class="col-md-12 col-lg-6 tamanio-personalizado d-none">
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
<input <?= $presupuestoEntity->papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="0.01" class="form-control formato_libro" value="<?= old('papel_formato_alto', $presupuestoEntity->papel_formato_alto) ?>">
|
<input type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="0.01" class="form-control formato_libro" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
</div>
|
</div>
|
||||||
@ -76,7 +70,7 @@
|
|||||||
<label for="merma" class="form-label">
|
<label for="merma" class="form-label">
|
||||||
<?= lang('Presupuestos.merma') ?>*
|
<?= lang('Presupuestos.merma') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input readonly style="background: #E8E8E8;" id="merma" name="merma" maxLength="8" tabindex="4" step="1" placeholder="10" class="form-control" value="<?= old('merma', $presupuestoEntity->merma) ?>">
|
<input readonly style="background: #E8E8E8;" id="merma" name="merma" maxLength="8" tabindex="4" step="1" placeholder="10" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
@ -85,7 +79,7 @@
|
|||||||
<label for="mermacubierta" class="form-label">
|
<label for="mermacubierta" class="form-label">
|
||||||
<?= lang('Presupuestos.mermacubierta') ?>*
|
<?= lang('Presupuestos.mermacubierta') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input readonly style="background: #E8E8E8;" id="mermacubierta" name="merma_cubierta" tabindex="5" placeholder="10" maxLength="8" step="1" class="form-control" value="<?= old('merma_cubierta', $presupuestoEntity->merma_cubierta) ?>">
|
<input readonly style="background: #E8E8E8;" id="mermacubierta" name="merma_cubierta" tabindex="5" placeholder="10" maxLength="8" step="1" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
@ -96,37 +90,33 @@
|
|||||||
<!-- Fila 2 -->
|
<!-- Fila 2 -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-lg-2 px-4">
|
<div class="col-md-12 col-lg-2 px-4">
|
||||||
<?php if($tipo_impresion_id != 1 && $tipo_impresion_id != 3 && $tipo_impresion_id != 5 && $tipo_impresion_id != 7): ?>
|
<div class="row solapas-cubierta-div">
|
||||||
<div class="row">
|
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
<div class="form-check form-switch mb-2">
|
<div class="form-check form-switch mb-2">
|
||||||
<input class="form-check-input solapas_cubierta" type="checkbox" id="solapas" name="solapas" tabindex="6" value="1" <?= $presupuestoEntity->solapas == true ? 'checked' : ''; ?>>
|
<input class="form-check-input solapas_cubierta" type="checkbox" id="solapas" name="solapas" tabindex="6" value="1">
|
||||||
<label class="form-check-label" for="solapas"><?= lang('Presupuestos.solapasCubierta') ?></label>
|
<label class="form-check-label" for="solapas"><?= lang('Presupuestos.solapasCubierta') ?></label>
|
||||||
</div>
|
</div>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12 col-lg-2 px-4">
|
<div class="col-md-12 col-lg-2 px-4">
|
||||||
<?php if ($tipo_impresion_id != 5 && $tipo_impresion_id != 6 && $tipo_impresion_id != 7 && $tipo_impresion_id != 8 && $tipo_impresion_id != 21) : ?>
|
<div class="row solapas-sobrecubierta-div">
|
||||||
<div class="row">
|
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
<div class="form-check form-switch mb-2">
|
<div class="form-check form-switch mb-2">
|
||||||
<input class="form-check-input solapas_sobrecubierta" type="checkbox" id="solapas_sobrecubierta" name="solapas_sobrecubierta" tabindex="6" value="1" <?= $presupuestoEntity->solapas_sobrecubierta == true ? 'checked' : ''; ?>>
|
<input class="form-check-input solapas_sobrecubierta" type="checkbox" id="solapas_sobrecubierta" name="solapas_sobrecubierta" tabindex="6" value="1" onclick="return false;">
|
||||||
<label class="form-check-label" for="solapas_sobrecubierta"><?= lang('Presupuestos.solapasSobrecubierta') ?></label>
|
<label class="form-check-label" for="solapas_sobrecubierta"><?= lang('Presupuestos.solapasSobrecubierta') ?></label>
|
||||||
</div>
|
</div>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12 col-lg-6 px-4">
|
<div class="col-md-12 col-lg-6 px-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
<div class="form-check form-switch mb-2">
|
<div class="form-check form-switch mb-2">
|
||||||
<input class="form-check-input" type="checkbox" id="papelFormatoPersonalizado" name="papel_formato_personalizado" value="1" <?= $presupuestoEntity->papel_formato_personalizado == true ? 'checked' : ''; ?>>
|
<input class="form-check-input" type="checkbox" id="papelFormatoPersonalizado" name="papel_formato_personalizado" value="1">
|
||||||
<label class="form-check-label" for="papelFormatoPersonalizado"><?= lang('Presupuestos.papelFormatoPersonalizado') ?></label>
|
<label class="form-check-label" for="papelFormatoPersonalizado"><?= lang('Presupuestos.papelFormatoPersonalizado') ?></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -136,35 +126,24 @@
|
|||||||
|
|
||||||
<!-- Fila 3 -->
|
<!-- Fila 3 -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-lg-2 px-4">
|
|
||||||
<?php if($tipo_impresion_id != 1 && $tipo_impresion_id != 3 && $tipo_impresion_id != 5 && $tipo_impresion_id != 7): ?>
|
|
||||||
<?php if($presupuestoEntity->solapas == true): ?>
|
|
||||||
<div class="mb-1" id="div_solapas_ancho">
|
|
||||||
<?php else: ?>
|
|
||||||
<div class="mb-1" id="div_solapas_ancho" style="display:none;">
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
<div class="col-md-12 col-lg-2 px-4">
|
||||||
|
<div class="mb-1 solapas-cubierta-div d-none" id="div_solapas_ancho">
|
||||||
<label for="solapas_ancho" class="form-label">
|
<label for="solapas_ancho" class="form-label">
|
||||||
<?= lang('Presupuestos.solapasAnchoCubierta') ?>*
|
<?= lang('Presupuestos.solapasAnchoCubierta') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="number" id="solapas_ancho" name="solapas_ancho" placeholder="0" maxLength="8" step="1" class="form-control solapas_cubierta" value="<?= old('solapas_ancho', $presupuestoEntity->solapas_ancho) ?>">
|
<input type="number" id="solapas_ancho" name="solapas_ancho" placeholder="0" maxLength="8" step="1" class="form-control solapas_cubierta" value="">
|
||||||
</div><!--//.mb-1 -->
|
</div><!--//.mb-1 -->
|
||||||
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12 col-lg-2 px-4">
|
<div class="col-md-12 col-lg-2 px-4">
|
||||||
<?php if ($tipo_impresion_id != 5 && $tipo_impresion_id != 6 && $tipo_impresion_id != 7 && $tipo_impresion_id != 8 && $tipo_impresion_id != 21) : ?>
|
<div class="mb-1 solapas-sobrecubierta-div d-none" id="div_solapas_ancho_sobrecubierta">
|
||||||
<?php if($presupuestoEntity->solapas_sobrecubierta == true): ?>
|
|
||||||
<div class="mb-1" id="div_solapas_ancho_sobrecubierta">
|
|
||||||
<?php else: ?>
|
|
||||||
<div class="mb-1" id="div_solapas_ancho_sobrecubierta" style="display:none;">
|
|
||||||
<?php endif; ?>
|
|
||||||
<label for="solapas_ancho_sobrecubierta" class="form-label">
|
<label for="solapas_ancho_sobrecubierta" class="form-label">
|
||||||
<?= lang('Presupuestos.solapasAnchoSobrecubierta') ?>*
|
<?= lang('Presupuestos.solapasAnchoSobrecubierta') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="number" id="solapas_ancho_sobrecubierta" name="solapas_ancho_sobrecubierta" placeholder="0" maxLength="8" step="1" class="form-control solapas_sobrecubierta" value="<?= old('solapas_ancho', $presupuestoEntity->solapas_ancho_sobrecubierta) ?>">
|
<input type="number" id="solapas_ancho_sobrecubierta" name="solapas_ancho_sobrecubierta" placeholder="60" min="60" maxLength="8" step="1" class="form-control solapas_sobrecubierta" value="">
|
||||||
</div><!--//.mb-1 -->
|
</div><!--//.mb-1 -->
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -187,44 +166,24 @@
|
|||||||
<?= lang('Presupuestos.acabadoCubierta') ?>*
|
<?= lang('Presupuestos.acabadoCubierta') ?>*
|
||||||
</label>
|
</label>
|
||||||
<select id="acabado_cubierta_id" name="acabado_cubierta_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
<select id="acabado_cubierta_id" name="acabado_cubierta_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
||||||
<?php if (isset($acabadosCubierta) && is_array($acabadosCubierta) && !empty($acabadosCubierta)) :
|
|
||||||
foreach ($acabadosCubierta as $acabado) : ?>
|
|
||||||
<option value="<?= $acabado->id ?>" <?= $acabado->id == $presupuestoEntity->acabado_cubierta_id ? ' selected' : '' ?>>
|
|
||||||
<?= $acabado->label ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach;
|
|
||||||
endif; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 col-lg-6 px-4">
|
<div class="col-md-12 col-lg-6 px-4">
|
||||||
<?php if ($tipo_impresion_id != 5 && $tipo_impresion_id != 6 && $tipo_impresion_id != 7 && $tipo_impresion_id != 8 && $tipo_impresion_id != 21) : ?>
|
<div class="row impresion-con-sobrecubierta">
|
||||||
<div class="row">
|
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
<label id="label_acabado_cubierta_id" for="acabado_sobrecubierta_id" class="form-label">
|
<label id="label_acabado_cubierta_id" for="acabado_sobrecubierta_id" class="form-label">
|
||||||
<?= lang('Presupuestos.acabadoSobrecubierta') ?>*
|
<?= lang('Presupuestos.acabadoSobrecubierta') ?>*
|
||||||
</label>
|
</label>
|
||||||
<select id="acabado_sobrecubierta_id" name="acabado_sobrecubierta_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
<select id="acabado_sobrecubierta_id" name="acabado_sobrecubierta_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
||||||
<?php if (isset($acabadosSobrecubierta) && is_array($acabadosSobrecubierta) && !empty($acabadosSobrecubierta)) :
|
|
||||||
foreach ($acabadosSobrecubierta as $acabado) : ?>
|
|
||||||
<option value="<?= $acabado->id ?>" <?= $acabado->id == $presupuestoEntity->acabado_sobrecubierta_id ? ' selected' : '' ?>>
|
|
||||||
<?= $acabado->label ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach;
|
|
||||||
endif; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!----------------------------------------------------------------------------->
|
<!----------------------------------------------------------------------------->
|
||||||
<div class="divider divider-dark text-start mb-1">
|
<div class="divider divider-dark text-start mb-1">
|
||||||
<div class="divider-text">
|
<div class="divider-text">
|
||||||
@ -237,7 +196,7 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<label for="retractilado" class="form-check-label">
|
<label for="retractilado" class="form-check-label">
|
||||||
<input type="checkbox" id="retractilado" name="retractilado" value="1" class="form-check-input" <?= $presupuestoEntity->retractilado == true ? 'checked' : ''; ?>>
|
<input type="checkbox" id="retractilado" name="retractilado" value="1" class="form-check-input" >
|
||||||
<?= lang('Presupuestos.retractilado') ?>
|
<?= lang('Presupuestos.retractilado') ?>
|
||||||
</label>
|
</label>
|
||||||
</div><!--//.form-check -->
|
</div><!--//.form-check -->
|
||||||
@ -248,30 +207,18 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<label for="retractilado5" class="form-check-label">
|
<label for="retractilado5" class="form-check-label">
|
||||||
<input type="checkbox" id="retractilado5" name="retractilado_5" value="1" class="form-check-input" <?= $presupuestoEntity->retractilado5 == true ? 'checked' : ''; ?>>
|
<input type="checkbox" id="retractilado5" name="retractilado_5" value="1" class="form-check-input" >
|
||||||
<?= lang('Presupuestos.retractilado5') ?>
|
<?= lang('Presupuestos.retractilado5') ?>
|
||||||
</label>
|
</label>
|
||||||
</div><!--//.form-check -->
|
</div><!--//.form-check -->
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-12 col-lg-3 px-4">
|
|
||||||
<div class="mb-3">
|
|
||||||
<div class="form-check">
|
|
||||||
<label for="fajaColor" class="form-check-label">
|
|
||||||
<input type="checkbox" id="fajaColor" name="faja_color" value="1" class="form-check-input" <?= $presupuestoEntity->faja_color == true ? 'checked' : ''; ?>>
|
|
||||||
<?= lang('Presupuestos.fajaColor') ?>
|
|
||||||
</label>
|
|
||||||
</div><!--//.form-check -->
|
|
||||||
</div><!--//.mb-3 -->
|
|
||||||
</div><!--//.col -->
|
|
||||||
|
|
||||||
<div class="col-md-12 col-lg-3 px-4">
|
<div class="col-md-12 col-lg-3 px-4">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<label for="prototipo" class="form-check-label">
|
<label for="prototipo" class="form-check-label">
|
||||||
<input type="checkbox" id="prototipo" name="prototipo" value="1" class="form-check-input" <?= $presupuestoEntity->prototipo == true ? 'checked' : ''; ?>>
|
<input type="checkbox" id="prototipo" name="prototipo" value="1" class="form-check-input" >
|
||||||
<?= lang('Presupuestos.prototipo') ?>
|
<?= lang('Presupuestos.prototipo') ?>
|
||||||
</label>
|
</label>
|
||||||
</div><!--//.form-check -->
|
</div><!--//.form-check -->
|
||||||
@ -291,7 +238,7 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<label for="ferro" class="form-check-label">
|
<label for="ferro" class="form-check-label">
|
||||||
<input type="checkbox" id="ferro" name="ferro" value="1" class="form-check-input" <?= $presupuestoEntity->ferro == true ? 'checked' : ''; ?>>
|
<input type="checkbox" id="ferro" name="ferro" value="1" class="form-check-input" >
|
||||||
<?= lang('Presupuestos.ferro') ?>
|
<?= lang('Presupuestos.ferro') ?>
|
||||||
</label>
|
</label>
|
||||||
</div><!--//.form-check -->
|
</div><!--//.form-check -->
|
||||||
@ -303,7 +250,7 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<label for="ferroDigital" class="form-check-label">
|
<label for="ferroDigital" class="form-check-label">
|
||||||
<input type="checkbox" id="ferroDigital" name="ferro_digital" value="1" class="form-check-input" <?= $presupuestoEntity->ferro_digital == true ? 'checked' : ''; ?>>
|
<input type="checkbox" id="ferroDigital" name="ferro_digital" value="1" class="form-check-input">
|
||||||
<?= lang('Presupuestos.ferroDigital') ?>
|
<?= lang('Presupuestos.ferroDigital') ?>
|
||||||
</label>
|
</label>
|
||||||
</div><!--//.form-check -->
|
</div><!--//.form-check -->
|
||||||
@ -314,7 +261,7 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<label for="marcapaginas" class="form-check-label">
|
<label for="marcapaginas" class="form-check-label">
|
||||||
<input type="checkbox" id="marcapaginas" name="marcapaginas" value="1" class="form-check-input" <?= $presupuestoEntity->marcapaginas == true ? 'checked' : ''; ?>>
|
<input type="checkbox" id="marcapaginas" name="marcapaginas" value="1" class="form-check-input" >
|
||||||
<?= lang('Presupuestos.marcapaginas') ?>
|
<?= lang('Presupuestos.marcapaginas') ?>
|
||||||
</label>
|
</label>
|
||||||
</div><!--//.form-check -->
|
</div><!--//.form-check -->
|
||||||
@ -330,114 +277,4 @@
|
|||||||
</div> <!-- //.accordion-item -->
|
</div> <!-- //.accordion-item -->
|
||||||
</div> <!-- //.accordion -->
|
</div> <!-- //.accordion -->
|
||||||
|
|
||||||
<!------------------------------------------->
|
|
||||||
<!-- Código JS comportamiento general pag. -->
|
|
||||||
<!------------------------------------------->
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
|
|
||||||
$('#papelFormatoId').select2({
|
|
||||||
allowClear: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
<?php if(str_contains($formAction,'edit')): ?>
|
|
||||||
var ancho_libro = getDimensionLibro().ancho;
|
|
||||||
var alto_libro = getDimensionLibro().alto;
|
|
||||||
|
|
||||||
$('#retractilado').on("change", function () {
|
|
||||||
checkRetractiladoComparador(this);
|
|
||||||
servicioRetractilado()
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$('#retractilado5').on("change", function () {
|
|
||||||
checkRetractiladoComparador(this);
|
|
||||||
servicioRetractilado5()
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#fajaColor').on("change", function () {
|
|
||||||
servicioFajaColor()
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#ferro').on("change", function () {
|
|
||||||
servicioFerro()
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#prototipo').on("change", function () {
|
|
||||||
servicioPrototipo()
|
|
||||||
servicioFerro()
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$('#papelFormatoId').on('select2:select', event_change_formato)
|
|
||||||
$('.formato_libro').on('change', event_change_formato)
|
|
||||||
|
|
||||||
function event_change_formato(){
|
|
||||||
ancho_libro = getDimensionLibro().ancho;
|
|
||||||
alto_libro = getDimensionLibro().alto;
|
|
||||||
|
|
||||||
|
|
||||||
// Si es negro o color
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
|
|
||||||
$('#tipoImpresion').select2('data')[0].id == 'color') {
|
|
||||||
$('#compPaginasNegro').trigger('change')
|
|
||||||
}
|
|
||||||
// Si es negrohq o colorhq
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
|
|
||||||
$('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
|
||||||
$('#compPaginasNegrohq').trigger('change');
|
|
||||||
}
|
|
||||||
|
|
||||||
$('.solapas_cubierta').trigger('change')
|
|
||||||
$('.solapas_sobrecubierta').trigger('change')
|
|
||||||
|
|
||||||
checkPaginasPresupuesto()
|
|
||||||
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: true,
|
|
||||||
update_servicios: true,
|
|
||||||
update_envios: true,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true
|
|
||||||
})
|
|
||||||
//updateLineasPresupuesto()
|
|
||||||
//update_servicios(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
|
||||||
<?php if($tipo_impresion_id != 1 && $tipo_impresion_id != 3 && $tipo_impresion_id != 5 && $tipo_impresion_id != 7): ?>
|
|
||||||
$("#solapas").on("click", function () {
|
|
||||||
var e = document.getElementById('div_solapas_ancho');
|
|
||||||
if (document.getElementById('solapas').checked) {
|
|
||||||
e.style.display = "block";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
e.style.display = "none";
|
|
||||||
$('#solapas_ancho').val(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#serv_default').click()
|
|
||||||
});
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
$("#solapas_sobrecubierta").on("click", function () {
|
|
||||||
var e = document.getElementById('div_solapas_ancho_sobrecubierta');
|
|
||||||
if (document.getElementById('solapas_sobrecubierta').checked) {
|
|
||||||
e.style.display = "block";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
e.style.display = "none";
|
|
||||||
$('#solapas_ancho_sobrecubierta').val(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#serv_default').click()
|
|
||||||
});
|
|
||||||
|
|
||||||
let initTamanioPersonalizado = <?php echo ($presupuestoEntity->papel_formato_personalizado==true?1:0); ?>;
|
|
||||||
if(initTamanioPersonalizado != null){
|
|
||||||
if ( initTamanioPersonalizado){
|
|
||||||
$('#papelFormatoId').next(".select2-container").hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@
|
|||||||
<label for="id" class="form-label">
|
<label for="id" class="form-label">
|
||||||
<?= lang('Presupuestos.id') ?>
|
<?= lang('Presupuestos.id') ?>
|
||||||
</label>
|
</label>
|
||||||
<input readonly style="background: #E8E8E8;" id="id" name="id" maxLength="12" class="form-control" value="<?= old('id', $presupuestoEntity->id) ?>">
|
<input readonly style="background: #E8E8E8;" id="id" name="id" maxLength="12" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
@ -26,9 +26,9 @@
|
|||||||
<?= lang('Presupuestos.created_at') ?>
|
<?= lang('Presupuestos.created_at') ?>
|
||||||
</label>
|
</label>
|
||||||
<?php if(str_contains($formAction,'edit')): ?>
|
<?php if(str_contains($formAction,'edit')): ?>
|
||||||
<input readonly style="background: #E8E8E8;" id="updated_at" name="updated_at" maxLength="12" class="form-control" value="<?= old('created_at', (isset($presupuestoEntity->updated_at)) ? date ('d/m/Y', strtotime($presupuestoEntity->updated_at)) : "") ?>">
|
<input readonly style="background: #E8E8E8;" id="updated_at" name="updated_at" maxLength="12" class="form-control" value="">
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<input readonly style="background: #E8E8E8;" id="created_at" name="created_at" maxLength="12" class="form-control" value="<?= old('created_at', (isset($presupuestoEntity->created_at)) ? date ('d/m/Y', strtotime($presupuestoEntity->created_at)) : "") ?>">
|
<input readonly style="background: #E8E8E8;" id="created_at" name="created_at" maxLength="12" class="form-control" value="">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
@ -38,11 +38,11 @@
|
|||||||
<label for="estado_id" class="form-label">
|
<label for="estado_id" class="form-label">
|
||||||
<?= lang('Presupuestos.presupuestoEstado') ?>
|
<?= lang('Presupuestos.presupuestoEstado') ?>
|
||||||
</label>
|
</label>
|
||||||
<select disabled id="estado_id" name="estado_id" maxLength="11" style="background-color: #E8E8E8;" class="form-control" value="<?= old(1, $presupuestoEntity->estado_id) ?>">
|
<select disabled id="estado_id" name="estado_id" maxLength="11" style="background-color: #E8E8E8;" class="form-control select2bs" value="">
|
||||||
<option value=1 <?= $presupuestoEntity->estado_id==1? ' selected':''?>>
|
<option value=1 >
|
||||||
<?=lang('Presupuestos.presupuestoEstadoBorrador') ?>
|
<?=lang('Presupuestos.presupuestoEstadoBorrador') ?>
|
||||||
</option>
|
</option>
|
||||||
<option value=2 <?= $presupuestoEntity->estado_id==2? ' selected':''?>>
|
<option value=2 >
|
||||||
<?=lang('Presupuestos.presupuestoEstadoAceptado') ?>
|
<?=lang('Presupuestos.presupuestoEstadoAceptado') ?>
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@ -54,15 +54,11 @@
|
|||||||
<label for="incRei" class="form-label">
|
<label for="incRei" class="form-label">
|
||||||
<?= lang('Presupuestos.incRei') ?>
|
<?= lang('Presupuestos.incRei') ?>
|
||||||
</label>
|
</label>
|
||||||
<select id="incRei" name="inc_rei" maxLength="11" class="form-control" value="<?= old('inc_rei', $presupuestoEntity->inc_rei) ?>">
|
<select id="incRei" name="inc_rei" maxLength="11" class="form-control select2bs" value="">
|
||||||
<?php if (isset($incReiList) && is_array($incReiList) && !empty($incReiList)) : ?>
|
<option value="0">No</option>
|
||||||
<option> </option>
|
<option value="incidencia">Incidencia</option>
|
||||||
<?php foreach ($incReiList as $k => $v) : ?>
|
<option value="reimpresion">Reimpresion</option>
|
||||||
<option value="<?= $k ?>" <?= $k == $presupuestoEntity->inc_rei ? ' selected' : '' ?>>
|
<option value="sin_cargo">Sin cargo</option>
|
||||||
<?= $v ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach;
|
|
||||||
endif; ?>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
@ -77,7 +73,7 @@
|
|||||||
<label for="titulo" class="form-label">
|
<label for="titulo" class="form-label">
|
||||||
<?=lang('Presupuestos.titulo') ?>*
|
<?=lang('Presupuestos.titulo') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="titulo" name="titulo" maxLength="300" class="form-control" value="<?=old('titulo', $presupuestoEntity->titulo) ?>">
|
<input type="text" id="titulo" name="titulo" maxLength="300" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
@ -87,7 +83,7 @@
|
|||||||
<label for="autor" class="form-label">
|
<label for="autor" class="form-label">
|
||||||
<?=lang('Presupuestos.autor') ?>
|
<?=lang('Presupuestos.autor') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="autor" name="autor" maxLength="150" class="form-control" value="<?=old('autor', $presupuestoEntity->autor) ?>">
|
<input type="text" id="autor" name="autor" maxLength="150" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
@ -101,7 +97,7 @@
|
|||||||
<label for="coleccion" class="form-label">
|
<label for="coleccion" class="form-label">
|
||||||
<?=lang('Presupuestos.coleccion') ?>
|
<?=lang('Presupuestos.coleccion') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="coleccion" name="coleccion" maxLength="255" class="form-control" value="<?=old('coleccion', $presupuestoEntity->coleccion) ?>">
|
<input type="text" id="coleccion" name="coleccion" maxLength="255" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -110,7 +106,7 @@
|
|||||||
<label for="numeroEdicion" class="form-label">
|
<label for="numeroEdicion" class="form-label">
|
||||||
<?=lang('Presupuestos.numeroEdicion') ?>
|
<?=lang('Presupuestos.numeroEdicion') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="numeroEdicion" name="numero_edicion" maxLength="50" class="form-control" value="<?=old('numero_edicion', $presupuestoEntity->numero_edicion) ?>">
|
<input type="text" id="numeroEdicion" name="numero_edicion" maxLength="50" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -119,7 +115,7 @@
|
|||||||
<label for="isbn" class="form-label">
|
<label for="isbn" class="form-label">
|
||||||
<?=lang('Presupuestos.isbn') ?>
|
<?=lang('Presupuestos.isbn') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="isbn" name="isbn" maxLength="50" class="form-control" value="<?=old('isbn', $presupuestoEntity->isbn) ?>">
|
<input type="text" id="isbn" name="isbn" maxLength="50" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -129,12 +125,6 @@
|
|||||||
<?=lang('Presupuestos.paisId') ?>
|
<?=lang('Presupuestos.paisId') ?>
|
||||||
</label>
|
</label>
|
||||||
<select id="paisId" name="pais_id" class="form-control select2bs" style="width: 100%;" >
|
<select id="paisId" name="pais_id" class="form-control select2bs" style="width: 100%;" >
|
||||||
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('Presupuestos.paisId')]) ?></option>
|
|
||||||
<?php foreach ($paisList as $item) : ?>
|
|
||||||
<option value="<?=$item->id ?>"<?=$item->id==$presupuestoEntity->pais_id ? ' selected':'' ?>>
|
|
||||||
<?=$item->nombre ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div>
|
</div>
|
||||||
@ -150,14 +140,6 @@
|
|||||||
<?= lang('Presupuestos.clienteId') ?>*
|
<?= lang('Presupuestos.clienteId') ?>*
|
||||||
</label>
|
</label>
|
||||||
<select id="clienteId" name="cliente_id" class="form-control select2bs2" style="width: 100%;">
|
<select id="clienteId" name="cliente_id" class="form-control select2bs2" style="width: 100%;">
|
||||||
|
|
||||||
<?php if (isset($clienteList) && is_array($clienteList) && !empty($clienteList)) :
|
|
||||||
foreach ($clienteList as $k => $v) : ?>
|
|
||||||
<option value="<?= $k ?>" <?= $k == $presupuestoEntity->cliente_id ? ' selected' : '' ?>>
|
|
||||||
<?= $v ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach;
|
|
||||||
endif; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
@ -167,7 +149,7 @@
|
|||||||
<label for="referenciaCliente" class="form-label">
|
<label for="referenciaCliente" class="form-label">
|
||||||
<?=lang('Presupuestos.referenciaCliente') ?>
|
<?=lang('Presupuestos.referenciaCliente') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="referenciaCliente" name="referencia_cliente" maxLength="100" class="form-control" value="<?=old('referencia_cliente', $presupuestoEntity->referencia_cliente) ?>">
|
<input type="text" id="referenciaCliente" name="referencia_cliente" maxLength="100" class="form-control" value="">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -93,6 +93,8 @@
|
|||||||
<th><?= lang('Proveedores.proveedor') ?></th>
|
<th><?= lang('Proveedores.proveedor') ?></th>
|
||||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||||
|
<th><?= lang('Tarifaacabado.margen') ?></th>
|
||||||
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -103,12 +105,6 @@
|
|||||||
<div class="row mb-3 px-4">
|
<div class="row mb-3 px-4">
|
||||||
<div class="col-md-12 col-lg-4 py-4">
|
<div class="col-md-12 col-lg-4 py-4">
|
||||||
<select id="add_servicio_acabado_list" class="select2bs2" style="width: 100%;">
|
<select id="add_servicio_acabado_list" class="select2bs2" style="width: 100%;">
|
||||||
<option></option>
|
|
||||||
<?php foreach ($serviciosAcabado as $item) : ?>
|
|
||||||
<option value="<?= $item->value ?>" >
|
|
||||||
<?= $item->label ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||||
@ -131,7 +127,7 @@
|
|||||||
<th><?= lang('Tarifapreimpresion.tarifapreimpresion') ?></th>
|
<th><?= lang('Tarifapreimpresion.tarifapreimpresion') ?></th>
|
||||||
<th><?= lang('Tarifapreimpresion.coste') ?></th>
|
<th><?= lang('Tarifapreimpresion.coste') ?></th>
|
||||||
<th><?= lang('Presupuestos.precio') ?></th>
|
<th><?= lang('Presupuestos.precio') ?></th>
|
||||||
<th></th>
|
<th><?= lang('Tarifaacabado.margen') ?></th>
|
||||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -141,12 +137,6 @@
|
|||||||
<div class="row mb-3 px-4">
|
<div class="row mb-3 px-4">
|
||||||
<div class="col-md-12 col-lg-4 py-4">
|
<div class="col-md-12 col-lg-4 py-4">
|
||||||
<select id="add_servicio_preimpresion_list" class="select2bs2" style="width: 100%;">
|
<select id="add_servicio_preimpresion_list" class="select2bs2" style="width: 100%;">
|
||||||
<option></option>
|
|
||||||
<?php foreach ($serviciosPreimpresion as $item) : ?>
|
|
||||||
<option value="<?= $item->value ?>" >
|
|
||||||
<?= $item->label ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||||
@ -168,11 +158,11 @@
|
|||||||
<th><?= lang('Presupuestos.id') ?></th>
|
<th><?= lang('Presupuestos.id') ?></th>
|
||||||
<th><?= lang('Presupuestos.tarifa') ?></th>
|
<th><?= lang('Presupuestos.tarifa') ?></th>
|
||||||
<th><?= lang('Proveedores.proveedor') ?></th>
|
<th><?= lang('Proveedores.proveedor') ?></th>
|
||||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
|
||||||
<th><?= lang('Presupuestos.paginasCuadernillo') ?></th>
|
<th><?= lang('Presupuestos.paginasCuadernillo') ?></th>
|
||||||
<th><?= lang('Presupuestos.tiempo') ?></th>
|
<th><?= lang('Presupuestos.tiempo') ?></th>
|
||||||
|
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||||
<th></th>
|
<th><?= lang('Tarifaacabado.margen') ?></th>
|
||||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -183,12 +173,6 @@
|
|||||||
<div class="row mb-3 px-4">
|
<div class="row mb-3 px-4">
|
||||||
<div class="col-md-12 col-lg-4 py-4">
|
<div class="col-md-12 col-lg-4 py-4">
|
||||||
<select id="add_servicio_enc_list" class="select2bs2" style="width: 100%;">
|
<select id="add_servicio_enc_list" class="select2bs2" style="width: 100%;">
|
||||||
<option></option>
|
|
||||||
<?php foreach ($serviciosEncuadernacion as $item) : ?>
|
|
||||||
<option value="<?= $item->value ?>" >
|
|
||||||
<?= $item->label ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||||
@ -211,7 +195,7 @@
|
|||||||
<th><?= lang('Tarifamanipulado.tarifamanipulado') ?></th>
|
<th><?= lang('Tarifamanipulado.tarifamanipulado') ?></th>
|
||||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||||
<th></th>
|
<th><?= lang('Tarifaacabado.margen') ?></th>
|
||||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -221,12 +205,6 @@
|
|||||||
<div class="row mb-3 px-4">
|
<div class="row mb-3 px-4">
|
||||||
<div class="col-md-12 col-lg-4 py-4">
|
<div class="col-md-12 col-lg-4 py-4">
|
||||||
<select id="add_servicio_manipulado_list" class="select2bs2" style="width: 100%;">
|
<select id="add_servicio_manipulado_list" class="select2bs2" style="width: 100%;">
|
||||||
<option></option>
|
|
||||||
<?php foreach ($serviciosManipulado as $item) : ?>
|
|
||||||
<option value="<?= $item->value ?>" >
|
|
||||||
<?= $item->label ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||||
@ -249,7 +227,7 @@
|
|||||||
<th><?= lang('Tarifaextra.tarifaextra') ?></th>
|
<th><?= lang('Tarifaextra.tarifaextra') ?></th>
|
||||||
<th><?= lang('Tarifaextra.coste') ?></th>
|
<th><?= lang('Tarifaextra.coste') ?></th>
|
||||||
<th><?= lang('Presupuestos.precio') ?></th>
|
<th><?= lang('Presupuestos.precio') ?></th>
|
||||||
<th></th>
|
<th><?= lang('Tarifaacabado.margen') ?></th>
|
||||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -259,12 +237,6 @@
|
|||||||
<div class="row mb-3 px-4">
|
<div class="row mb-3 px-4">
|
||||||
<div class="col-md-12 col-lg-4 py-4">
|
<div class="col-md-12 col-lg-4 py-4">
|
||||||
<select id="add_servicio_extra_list" class="select2bs2" style="width: 100%;">
|
<select id="add_servicio_extra_list" class="select2bs2" style="width: 100%;">
|
||||||
<option></option>
|
|
||||||
<?php foreach ($serviciosExtra as $item) : ?>
|
|
||||||
<option value="<?= $item->value ?>" >
|
|
||||||
<?= $item->label ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||||
@ -280,90 +252,3 @@
|
|||||||
</div> <!-- //.accordion-collapse -->
|
</div> <!-- //.accordion-collapse -->
|
||||||
</div> <!-- //.accordion-item -->
|
</div> <!-- //.accordion-item -->
|
||||||
</div> <!-- //.accordion -->
|
</div> <!-- //.accordion -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
|
|
||||||
// Generación de la lista de servicios de acabado (id, nombre)
|
|
||||||
window.acabadosList = <?php echo json_encode($serviciosAcabado); ?>;
|
|
||||||
window.serviciosacabadosList = <?php echo json_encode($serviciosAcabadosList); ?>;
|
|
||||||
window.serviciosAutomaticos = <?php echo json_encode($serviciosAutomaticos); ?>;
|
|
||||||
|
|
||||||
window.serviciosencuadernadosList = <?php echo json_encode($serviciosEncuadernacionList); ?>;
|
|
||||||
|
|
||||||
window.serviciosmanipuladoList = <?php echo json_encode($serviciosManipuladoList); ?>;
|
|
||||||
|
|
||||||
window.serviciospreimpresionList = <?php echo json_encode($serviciosPreimpresionList); ?>;
|
|
||||||
|
|
||||||
window.serviciosextraList = <?php echo json_encode($serviciosExtraList); ?>;
|
|
||||||
|
|
||||||
window.routes_servicios = {
|
|
||||||
dataTableOfPresupuestoAcabados: "<?=route_to('dataTableOfPresupuestoAcabados') ?>",
|
|
||||||
menuItemsOfPresupuestoAcabados: '<?= route_to("menuItemsOfPresupuestoAcabados") ?>',
|
|
||||||
dataTableOfPresupuestoPreimpresion: "<?=route_to('dataTableOfPresupuestoPreimpresiones') ?>",
|
|
||||||
dataTableOfPresupuestoEncuadernaciones: "<?=route_to('dataTableOfPresupuestoEncuadernaciones') ?>",
|
|
||||||
dataTableOfPresupuestoManipulados: "<?=route_to('dataTableOfPresupuestoManipulados') ?>",
|
|
||||||
menuItemsOfPresupuestoEncuadernaciones: '<?= route_to("menuItemsOfPresupuestoEncuadernaciones") ?>',
|
|
||||||
dataTableOfPresupuestoServiciosExtra: "<?=route_to('dataTableOfPresupuestoServiciosExtra') ?>",
|
|
||||||
}
|
|
||||||
|
|
||||||
init_servicio_acabado()
|
|
||||||
|
|
||||||
init_servicio_encuadernado()
|
|
||||||
|
|
||||||
init_servicio_manipulado()
|
|
||||||
|
|
||||||
init_servicio_preimpresion()
|
|
||||||
|
|
||||||
init_servicio_extra()
|
|
||||||
|
|
||||||
/* ELIMINADO PARA COMPROBAR EL MAXIMO DE SOLAPAS DESDE EL BACKEND
|
|
||||||
PENDIENTE
|
|
||||||
$('.solapas_cubierta').on('change', function(){
|
|
||||||
|
|
||||||
const ancho_libro = getDimensionLibro().ancho;
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
if(parseInt($('#solapas_ancho').val()) > limite){
|
|
||||||
$('#solapas_ancho').val(limite)
|
|
||||||
asyncMessageDialog(
|
|
||||||
window.Presupuestos.advertencia,
|
|
||||||
window.Presupuestos.actualizacionSolapasCubierta,
|
|
||||||
function(){});
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#compGramajeCubierta').trigger('change')
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
$('.solapas_sobrecubierta').on('change', function(){
|
|
||||||
|
|
||||||
const ancho_libro = getDimensionLibro().ancho;
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
if(parseInt($('#solapas_ancho_sobrecubierta').val()) > limite){
|
|
||||||
$('#solapas_ancho_sobrecubierta').val(limite)
|
|
||||||
asyncMessageDialog(
|
|
||||||
window.Presupuestos.advertencia,
|
|
||||||
window.Presupuestos.actualizacionSolapasSobrecubierta,
|
|
||||||
function(){});
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#compGramajeSobrecubierta').trigger('change')
|
|
||||||
})
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -70,33 +70,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!------------------------------------------->
|
|
||||||
<!-- Código JS de las lineas de presupuesto. -->
|
|
||||||
<!------------------------------------------->
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
window.papelGenericoNegroList = <?php echo json_encode($papelGenericoNegroList); ?>;
|
|
||||||
window.papelGenericoNegroHQList = <?php echo json_encode($papelGenericoNegroHQList); ?>;
|
|
||||||
window.papelGenericoColorList = <?php echo json_encode($papelGenericoColorList); ?>;
|
|
||||||
window.papelGenericoColorHQList = <?php echo json_encode($papelGenericoColorHQList); ?>;
|
|
||||||
window.papelGenericoCubiertaList = <?php echo json_encode($papelGenericoCubiertaList); ?>;
|
|
||||||
window.papelGenericoSobrecubiertaList = <?php echo json_encode($papelGenericoSobrecubiertaList); ?>;
|
|
||||||
window.papelGenericoRotativaNegroList = <?php echo json_encode($papelGenericoRotativaNegroList); ?>;
|
|
||||||
window.papelGenericoRotativaColorList = <?php echo json_encode($papelGenericoRotativaColorList); ?>;
|
|
||||||
|
|
||||||
<?php if($tipo_impresion_id == 1 || $tipo_impresion_id == 3 || $tipo_impresion_id == 5 || $tipo_impresion_id == 7): ?>
|
|
||||||
window.papelGenericoGuardasList = <?php echo json_encode($papelGenericoGuardasList); ?>;
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
window.lineasPresupuestoList = <?php echo json_encode($lineasPresupuesto); ?>;
|
|
||||||
|
|
||||||
window.routes_lp = {
|
|
||||||
menuItemsOfPresupuestoAdmin: '<?= route_to("menuItemsOfPresupuestoAdmin") ?>',
|
|
||||||
updateDataOfPresupuestoAdmin: '<?= route_to("updateDataOfPresupuestoAdmin") ?>',
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fill_lp_from_bbdd()
|
|
||||||
|
|
||||||
checkPaginasPresupuesto()
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
@ -2,16 +2,17 @@
|
|||||||
<div class="modal-dialog modal-lg modal-simple">
|
<div class="modal-dialog modal-lg modal-simple">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h4 id="labelTitleConfirmDialog" class="modal-title"><?= lang('PresupuestosDirecciones.direccionTitle') ?></h4>
|
<h4 id="labelTitleConfirmDialog" class="modal-title">
|
||||||
|
<?= lang('PresupuestosDirecciones.direccionTitle') ?></h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<div id='error-tarifa'></div>
|
<div id='error-tarifa'></div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_clientedAdd" class="form-label">
|
<label for="add_clientedAdd" class="form-label">
|
||||||
<?=lang('PresupuestosDirecciones.clientedAdd') ?>*
|
<?= lang('PresupuestosDirecciones.clientedAdd') ?>*
|
||||||
</label>
|
</label>
|
||||||
<select id="add_clientedAdd" class="form-control select2bs" style="width: 100%;" >
|
<select id="add_clientedAdd" class="form-control select2bs" style="width: 100%;">
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
@ -44,15 +45,9 @@
|
|||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_pais_id" class="form-label">
|
<label for="add_pais_id" class="form-label">
|
||||||
<?=lang('PresupuestosDirecciones.pais') ?>*
|
<?= lang('PresupuestosDirecciones.pais') ?>*
|
||||||
</label>
|
</label>
|
||||||
<select id="add_pais_id" class="form-control select2bs new-address" style="width: 100%;" >
|
<select id="add_pais_id" class="form-control select2bs new-address" style="width: 100%;">
|
||||||
<option value="" disabled selected><?=lang('PresupuestosDirecciones.selectPais') ?></option>
|
|
||||||
<?php foreach ($paisList as $item) : ?>
|
|
||||||
<option value="<?=$item->id ?>"<?=$item->id==1 ? ' selected':'' ?>>
|
|
||||||
<?=$item->nombre ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
</select>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
@ -63,7 +58,7 @@
|
|||||||
<div id='divMunicipio' class="col-md-12 col-lg-12 pl-4">
|
<div id='divMunicipio' class="col-md-12 col-lg-12 pl-4">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_municipio" class="form-label">
|
<label for="add_municipio" class="form-label">
|
||||||
<?=lang('PresupuestosDirecciones.municipio') ?>*
|
<?= lang('PresupuestosDirecciones.municipio') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="add_municipio" maxLength="100" class="form-control new-address">
|
<input type="text" id="add_municipio" maxLength="100" class="form-control new-address">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
@ -72,7 +67,7 @@
|
|||||||
<div class="col-md-12 col-lg-6 pl-4 spain-data" style="display: none;">
|
<div class="col-md-12 col-lg-6 pl-4 spain-data" style="display: none;">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_provincia" class="form-label">
|
<label for="add_provincia" class="form-label">
|
||||||
<?=lang('PresupuestosDirecciones.provincia') ?>*
|
<?= lang('PresupuestosDirecciones.provincia') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="add_provincia" maxLength="100" class="form-control new-address">
|
<input type="text" id="add_provincia" maxLength="100" class="form-control new-address">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
@ -85,7 +80,7 @@
|
|||||||
<div class="col-md-12 col-lg-6 pl-4">
|
<div class="col-md-12 col-lg-6 pl-4">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_cp" class="form-label">
|
<label for="add_cp" class="form-label">
|
||||||
<?=lang('PresupuestosDirecciones.cp') ?>*
|
<?= lang('PresupuestosDirecciones.cp') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="add_cp" maxLength="100" class="form-control new-address">
|
<input type="text" id="add_cp" maxLength="100" class="form-control new-address">
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
@ -94,9 +89,10 @@
|
|||||||
<div class="col-md-12 col-lg-6 pl-4">
|
<div class="col-md-12 col-lg-6 pl-4">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="add_telefono" class="form-label">
|
<label for="add_telefono" class="form-label">
|
||||||
<?=lang('PresupuestosDirecciones.telefono') ?>*
|
<?= lang('PresupuestosDirecciones.telefono') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="add_telefono" maxLength="100" class="form-control new-address"></input>
|
<input type="text" id="add_telefono" maxLength="100"
|
||||||
|
class="form-control new-address"></input>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -104,15 +100,19 @@
|
|||||||
|
|
||||||
<div class="col-md-12 col-lg-6 pl-4">
|
<div class="col-md-12 col-lg-6 pl-4">
|
||||||
<div class="form-check form-switch mb-2">
|
<div class="form-check form-switch mb-2">
|
||||||
<input class="form-check-input" type="checkbox" id="add_entregaPieCalle" name="add_entregaPieCalle" value="1" >
|
<input class="form-check-input" type="checkbox" id="add_entregaPieCalle"
|
||||||
<label class="form-check-label" for="add_entregaPieCalle"><?= lang('PresupuestosDirecciones.entregaPieCalle') ?></label>
|
name="add_entregaPieCalle" value="1">
|
||||||
|
<label class="form-check-label"
|
||||||
|
for="add_entregaPieCalle"><?= lang('PresupuestosDirecciones.entregaPieCalle') ?></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12 col-lg-6 pl-4">
|
<div class="col-md-12 col-lg-6 pl-4">
|
||||||
<div class="form-check form-switch mb-2">
|
<div class="form-check form-switch mb-2">
|
||||||
<input class="form-check-input" type="checkbox" id="add_saveDirection" name="add_saveDirection" value="1" >
|
<input class="form-check-input" type="checkbox" id="add_saveDirection" name="add_saveDirection"
|
||||||
<label class="form-check-label" for="add_saveDirection"><?= lang('PresupuestosDirecciones.saveDirection') ?></label>
|
value="1">
|
||||||
|
<label class="form-check-label"
|
||||||
|
for="add_saveDirection"><?= lang('PresupuestosDirecciones.saveDirection') ?></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -120,279 +120,15 @@
|
|||||||
<label style="display:none" for="add_alias" class="form-label save-alias">
|
<label style="display:none" for="add_alias" class="form-label save-alias">
|
||||||
<?= lang('PresupuestosDirecciones.alias') ?>*
|
<?= lang('PresupuestosDirecciones.alias') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="add_alias" maxLength="100" class="form-control new-address save-alias" style='display: none;'>
|
<input type="text" id="add_alias" maxLength="100" class="form-control new-address save-alias"
|
||||||
|
style='display: none;'>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button id="saveDireccionEnvio"
|
<button id="saveDireccionEnvio" type="button" class="btn btn-primary">Guardar</button>
|
||||||
type="button"
|
<button id="cancelAdd" type="button" class="btn btn-default">Cancelar</button>
|
||||||
class="btn btn-primary"
|
|
||||||
>Guardar</button>
|
|
||||||
<button id="cancelAdd"
|
|
||||||
type="button"
|
|
||||||
class="btn btn-default"
|
|
||||||
>Cancelar</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
|
|
||||||
$('#cancelAdd').on('click', function(){
|
|
||||||
$('#addressForm').modal("hide");
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
$('#add_cantidad').on('change', function(){
|
|
||||||
if(parseInt($('#add_cantidad').val()) > $('#add_cantidad').attr('max-value'))
|
|
||||||
$('#add_cantidad').val($('#add_cantidad').attr('max-value'))
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
$('#saveDireccionEnvio').on('click', function(){
|
|
||||||
|
|
||||||
if(validate_fields()){
|
|
||||||
|
|
||||||
if($('#addressForm').attr('action')=='edit'){
|
|
||||||
tableEnvios.row( $("#addressForm").attr('row') )
|
|
||||||
.remove()
|
|
||||||
.draw();
|
|
||||||
}
|
|
||||||
var peso_total_libro = 0
|
|
||||||
|
|
||||||
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
peso_total_libro += parseFloat(rowData.peso)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
const peso_envio = peso_total_libro*parseInt($('#add_cantidad').val())/1000.0
|
|
||||||
|
|
||||||
|
|
||||||
$.post( '<?= route_to('dataTableOfPresupuestoDirecciones') ?>',
|
|
||||||
{
|
|
||||||
tipo: "get_tarifa",
|
|
||||||
peso: peso_envio,
|
|
||||||
paisId: $("#add_pais_id").val(),
|
|
||||||
cp: $('#add_cp').val(),
|
|
||||||
tipo_envio: $('#add_entregaPieCalle').is(":checked")?'palets':'cajas',
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
|
||||||
})
|
|
||||||
.done(function( data ) {
|
|
||||||
if(data.length >0){
|
|
||||||
|
|
||||||
var precios = []
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
|
||||||
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 = parseFloat(m*peso_envio+b).toFixed(2);
|
|
||||||
}
|
|
||||||
data[i].margen = data[i].margen
|
|
||||||
}
|
|
||||||
|
|
||||||
const tarifa_final = data.reduce((previous, current) => {
|
|
||||||
return current.precio < previous.precio ? current : previous;
|
|
||||||
});
|
|
||||||
tarifa_final.cantidad=parseInt($('#add_cantidad').val())
|
|
||||||
tarifa_final.peso=peso_envio
|
|
||||||
|
|
||||||
|
|
||||||
tableEnvios.row
|
|
||||||
.add({
|
|
||||||
'tarifa_id': tarifa_final.id,
|
|
||||||
'cantidad': tarifa_final.cantidad,
|
|
||||||
'peso': tarifa_final.peso.toFixed(3),
|
|
||||||
'att': $('#add_att').val(),
|
|
||||||
'email': $('#add_email').val(),
|
|
||||||
'direccion': $('#add_direccion').val(),
|
|
||||||
'cp': $('#add_cp').val(),
|
|
||||||
'municipio': $('#add_municipio').val(),
|
|
||||||
'provincia': $('#add_provincia').val(),
|
|
||||||
'paisId': $('#add_pais_id').val(),
|
|
||||||
'telefono': $('#add_telefono').val(),
|
|
||||||
'proveedor': tarifa_final.proveedor,
|
|
||||||
'proveedor_id': tarifa_final.proveedor_id,
|
|
||||||
'precio': tarifa_final.precio,
|
|
||||||
'margen': tarifa_final.margen,
|
|
||||||
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked")?1:0,
|
|
||||||
'actionBtns_direcciones': actionBtns_direcciones,
|
|
||||||
})
|
|
||||||
.draw();
|
|
||||||
|
|
||||||
|
|
||||||
// Se guarda la dirección
|
|
||||||
if($('#add_saveDirection').is(":checked") &&
|
|
||||||
$('#add_alias').val().length>0){
|
|
||||||
$.post( '/clientes/clientedirecciones/add',
|
|
||||||
{
|
|
||||||
cliente_id: $('#clienteId').val(),
|
|
||||||
'att': $('#add_att').val(),
|
|
||||||
'email': $('#add_email').val(),
|
|
||||||
'direccion': $('#add_direccion').val(),
|
|
||||||
'cp': $('#add_cp').val(),
|
|
||||||
'municipio': $('#add_municipio').val(),
|
|
||||||
'provincia': $('#add_provincia').val(),
|
|
||||||
'paisId': $('#add_pais_id').val(),
|
|
||||||
'telefono': $('#add_telefono').val(),
|
|
||||||
'alias': $('#add_alias').val(),
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
|
||||||
})
|
|
||||||
.done(function( data ) {
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
checkInsertar()
|
|
||||||
//updateTotales(false, false, true)
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: false,
|
|
||||||
update_servicios: true,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true
|
|
||||||
})
|
|
||||||
$('#addressForm').modal("hide");
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function validate_fields(){
|
|
||||||
|
|
||||||
$( ".error-text-form" ).remove();
|
|
||||||
|
|
||||||
var returnValue = false
|
|
||||||
|
|
||||||
$("input.new-address").each( function() {
|
|
||||||
if($('#' + this.id).val().length == 0 && $('#' + this.id).css('display') != 'none'){
|
|
||||||
$('#' + this.id).after(
|
|
||||||
"<p style='font-size: 11px !important;" +
|
|
||||||
"padding: 0 !important; " +
|
|
||||||
"color: #b11f1f !important;' " +
|
|
||||||
"class='error-text-form'>" +'<?= lang('PresupuestosDirecciones.validation.required'); ?>' + '</p>')
|
|
||||||
}
|
|
||||||
returnValue = true
|
|
||||||
})
|
|
||||||
return returnValue
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$('#add_saveDirection').change(function() {
|
|
||||||
if(this.checked) {
|
|
||||||
$('.save-alias').css('display', 'inline')
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$('.save-alias').css('display', 'none')
|
|
||||||
}
|
|
||||||
$('#add_saveDirection').val(this.checked);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#add_clientedAdd').select2({
|
|
||||||
allowClear: false,
|
|
||||||
minimumResultsForSearch: Infinity,
|
|
||||||
dropdownParent: $('#addressForm'),
|
|
||||||
ajax: {
|
|
||||||
url: '<?= route_to("menuItemsOfClienteDirecciones") ?>',
|
|
||||||
type: 'post',
|
|
||||||
dataType: 'json',
|
|
||||||
|
|
||||||
data: function (params) {
|
|
||||||
return {
|
|
||||||
cliente_id: $('#clienteId').val(),
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
|
||||||
};
|
|
||||||
},
|
|
||||||
delay: 60,
|
|
||||||
processResults: function (response) {
|
|
||||||
|
|
||||||
yeniden(response.<?= csrf_token() ?>);
|
|
||||||
|
|
||||||
return {
|
|
||||||
results: response.menu
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
cache: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
$('#add_clientedAdd').on('select2:select', function (e) {
|
|
||||||
|
|
||||||
$('.save-alias').css('display', 'none')
|
|
||||||
$('#add_alias').val('')
|
|
||||||
$('#add_saveDirection').attr("disabled", true)
|
|
||||||
|
|
||||||
var data = e.params.data;
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: '<?=route_to('dataTableOfClienteDirecciones') ?>',
|
|
||||||
dataType: 'json',
|
|
||||||
data: {
|
|
||||||
tipo: 'direccion',
|
|
||||||
id: data.id,
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
|
||||||
|
|
||||||
},
|
|
||||||
success: function (data) {
|
|
||||||
if(data.length>0){
|
|
||||||
$('#add_att').val(data[0].att)
|
|
||||||
$('#add_direccion').val(data[0].direccion)
|
|
||||||
$('#add_cp').val(data[0].cp)
|
|
||||||
$('#add_municipio').val(data[0].municipio)
|
|
||||||
$('#add_provincia').val(data[0].provincia)
|
|
||||||
$('#add_telefono').val(data[0].telefono)
|
|
||||||
$('#add_email').val(data[0].email)
|
|
||||||
$('#add_pais_id').val(data[0].pais_id).change();
|
|
||||||
}
|
|
||||||
yeniden(data.<?= csrf_token() ?>);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
error: function(e){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.new-address').on('change', function(e){
|
|
||||||
if (e.originalEvent) {
|
|
||||||
// user-triggered event
|
|
||||||
$('#add_clientedAdd').val(null).trigger('change');
|
|
||||||
$('#add_saveDirection').removeAttr("disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// clear modal items when close
|
|
||||||
$('#addressForm').on('hidden.bs.modal', function () {
|
|
||||||
$('#add_alias').val("")
|
|
||||||
$('#add_att').val("")
|
|
||||||
$('#add_email').val("")
|
|
||||||
$('#add_direccion').val("")
|
|
||||||
$("#add_pais_id").val(1).change()
|
|
||||||
$("#add_clientedAdd").val("").change()
|
|
||||||
$('#add_municipio').val("")
|
|
||||||
$('#add_provincia').val("")
|
|
||||||
$('#add_cp').val("")
|
|
||||||
$('#add_telefono').val("")
|
|
||||||
$('#add_saveDirection').prop('checked', false)
|
|
||||||
$('#add_entregaPieCalle').prop('checked', false)
|
|
||||||
})
|
|
||||||
|
|
||||||
<?=$this->endSection() ?>
|
|
||||||
@ -1,91 +0,0 @@
|
|||||||
async function updatePresupuesto(
|
|
||||||
{
|
|
||||||
update_lineas = false,
|
|
||||||
update_servicios = false,
|
|
||||||
update_envios = false,
|
|
||||||
update_resumen = false,
|
|
||||||
update_tiradas_alternativas = false
|
|
||||||
}) {
|
|
||||||
|
|
||||||
new Promise(
|
|
||||||
async function(resolve, reject){
|
|
||||||
if(update_lineas){
|
|
||||||
await updateLineasPresupuesto()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
).then(function(){
|
|
||||||
new Promise(
|
|
||||||
async function(resolve, reject){
|
|
||||||
if(update_servicios){
|
|
||||||
await actualizar_servicios()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}).then(function(){
|
|
||||||
new Promise(
|
|
||||||
function(resolve, reject){
|
|
||||||
if(update_envios){
|
|
||||||
updateTablaEnvios()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}).then(function(){
|
|
||||||
new Promise(
|
|
||||||
function(resolve, reject){
|
|
||||||
if(update_resumen){
|
|
||||||
updateTotales()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}).then(function(){
|
|
||||||
new Promise(
|
|
||||||
async function(resolve, reject){
|
|
||||||
if(update_tiradas_alternativas){
|
|
||||||
await actualizar_tiradas_alternativas()
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateLineasPresupuesto(){
|
|
||||||
|
|
||||||
$('#tableLineasPresupuesto tbody tr:visible ').each(async function(){
|
|
||||||
|
|
||||||
if(this.id.endsWith('lp_bn')){
|
|
||||||
await calcularPresupuesto_bn({}, true);
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_bnhq')){
|
|
||||||
await calcularPresupuesto_bnhq({}, true);
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_color')){
|
|
||||||
await calcularPresupuesto_color({}, true);
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_colorhq')){
|
|
||||||
await calcularPresupuesto_colorhq({}, true);
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_rot_bn')){
|
|
||||||
await calcularPresupuesto_rot_bn(false, true, {})
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('lp_rot_color')){
|
|
||||||
await calcularPresupuesto_rot_color(false, true, {})
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('_cubierta')){
|
|
||||||
await calcularPresupuesto_cubierta(false, {})
|
|
||||||
}
|
|
||||||
else if(this.id.endsWith('_guardas')){
|
|
||||||
await calcularPresupuesto_guardas(false, {})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -171,7 +171,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -206,6 +206,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_bn_shape" class="draw-shapes"></div>
|
<div id="pv_bn_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -249,7 +252,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -284,6 +287,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_bnhq_shape" class="draw-shapes"></div>
|
<div id="pv_bnhq_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -327,7 +333,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -362,6 +368,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_color_shape" class="draw-shapes"></div>
|
<div id="pv_color_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -405,7 +414,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -440,6 +449,10 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="pv_colorhq_shape" class="draw-shapes"></div>
|
<div id="pv_colorhq_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -483,7 +496,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -516,6 +529,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_rot_bn_shape" class="draw-rot-shapes"></div>
|
<div id="pv_rot_bn_shape" class="draw-rot-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -560,7 +576,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -593,6 +609,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_rot_color_shape" class="draw-rot-shapes"></div>
|
<div id="pv_rot_color_shape" class="draw-rot-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -636,7 +655,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -671,6 +690,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_guardas_shape" class="draw-shapes"></div>
|
<div id="pv_guardas_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -714,7 +736,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -752,6 +774,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewCubierta") ?></h6>
|
<h6><?= lang("Presupuestos.previewCubierta") ?></h6>
|
||||||
|
|
||||||
<div id="pv-cubierta-container">
|
<div id="pv-cubierta-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_cubierta_shape" class="draw-shapes"></div>
|
<div id="pv_cubierta_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -795,7 +820,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -817,6 +842,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewConfiguracionEsquemaCubierta") ?></h6>
|
<h6><?= lang("Presupuestos.previewConfiguracionEsquemaCubierta") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_ec_shape" class="draw-shapes"></div>
|
<div id="pv_ec_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -860,7 +888,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="mx-n4"/>
|
<hr class="mx-n4" />
|
||||||
|
|
||||||
<!-- Detalles del presupuesto -->
|
<!-- Detalles del presupuesto -->
|
||||||
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
|
||||||
@ -918,69 +946,68 @@
|
|||||||
<!-- Código JS comportamiento ?????. -->
|
<!-- Código JS comportamiento ?????. -->
|
||||||
<!------------------------------------------------------->
|
<!------------------------------------------------------->
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
|
/*
|
||||||
|
|
||||||
$('#tab-pv-bn').on( "click", function() {
|
$('#tab-pv-bn').on( "click", function() {
|
||||||
|
|
||||||
previewInteriorPlana('bn', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewInteriorPlana('bn', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#tab-pv-bnhq').on( "click", function() {
|
$('#tab-pv-bnhq').on( "click", function() {
|
||||||
|
|
||||||
previewInteriorPlana('bnhq', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewInteriorPlana('bnhq', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#tab-pv-color').on( "click", function() {
|
$('#tab-pv-color').on( "click", function() {
|
||||||
|
|
||||||
previewInteriorPlana('color', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewInteriorPlana('color', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#tab-pv-colorhq').on( "click", function() {
|
$('#tab-pv-colorhq').on( "click", function() {
|
||||||
|
|
||||||
|
|
||||||
previewInteriorPlana('colorhq', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewInteriorPlana('colorhq', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#tab-pv-rot-bn').on( "click", function() {
|
$('#tab-pv-rot-bn').on( "click", function() {
|
||||||
|
|
||||||
previewRotativa('rot_bn', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewRotativa('rot_bn', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#tab-pv-rot-color').on( "click", function() {
|
$('#tab-pv-rot-color').on( "click", function() {
|
||||||
|
|
||||||
previewRotativa('rot_color', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewRotativa('rot_color', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#tab-pv-guardas').on( "click", function() {
|
$('#tab-pv-guardas').on( "click", function() {
|
||||||
|
|
||||||
previewInteriorPlana('guardas', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewInteriorPlana('guardas', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#tab-pv-cubierta').on( "click", function() {
|
$('#tab-pv-cubierta').on( "click", function() {
|
||||||
|
|
||||||
previewInteriorPlana('cubierta', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewInteriorPlana('cubierta', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#tab-pv-esquema-cubierta').on( "click", function() {
|
$('#tab-pv-esquema-cubierta').on( "click", function() {
|
||||||
|
|
||||||
previewEsquemaCubierta('ec', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewEsquemaCubierta('ec', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#tab-pv-sobrecubierta').on( "click", function() {
|
$('#tab-pv-sobrecubierta').on( "click", function() {
|
||||||
|
|
||||||
previewInteriorPlana('sobrecubierta', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
previewInteriorPlana('sobrecubierta', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
*/
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -18,55 +18,57 @@
|
|||||||
<!-- Price Details -->
|
<!-- Price Details -->
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-5 py-1 fw-normal text-end">Coste papel</dt>
|
<dt class="col-5 py-1 fw-normal text-end">Coste papel</dt>
|
||||||
<dd id="totalCostePapel" class="py-1 col-6 text-end"><?= old('0', $presupuestoEntity->total_coste_papel) ?>€</dd>
|
<dd id="totalCostePapel" class="py-1 col-6 text-end"></dd>
|
||||||
<dt class="col-5 py-1 fw-normal text-end">Margen papel</dt>
|
<dt class="col-5 py-1 fw-normal text-end">Margen papel</dt>
|
||||||
<dd id="porcentajeMargenPapel" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_papel) ?>%</dd>
|
<dd id="porcentajeMargenPapel" class="col-3 text-end py-1"></dd>
|
||||||
<dd id="margenPapel" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_papel) ?>€</dd>
|
<dd id="margenPapel" class="col-3 text-end py-1"></dd>
|
||||||
|
|
||||||
<dt class="col-5 fw-normal text-end">Coste impresión</dt>
|
<dt class="col-5 fw-normal text-end">Coste impresión</dt>
|
||||||
<dd id="totalCosteImpresion" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_coste_impresion) ?>€</dd>
|
<dd id="totalCosteImpresion" class="col-6 text-end"></dd>
|
||||||
<dt class="col-5 py-1 fw-normal text-end">Margen impresión</dt>
|
<dt class="col-5 py-1 fw-normal text-end">Margen impresión</dt>
|
||||||
<dd id="porcentajeMargenImpresion" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_impresion) ?>%</dd>
|
<dd id="porcentajeMargenImpresion" class="col-3 text-end py-1"></dd>
|
||||||
<dd id="margenImpresion" class="col-3 py-1 text-end"><?= old('0', $presupuestoEntity->total_margen_impresion) ?>€</dd>
|
<dd id="margenImpresion" class="col-3 py-1 text-end"></dd>
|
||||||
|
|
||||||
<dt class="col-5 fw-normal text-end">Coste servicios</dt>
|
<dt class="col-5 fw-normal text-end">Coste servicios</dt>
|
||||||
<dd id="totalServicios" class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_coste_servicios) ?>€</dd>
|
<dd id="totalServicios" class="col-6 text-end py-1"></dd>
|
||||||
<dt class="col-5 fw-normal text-end">Margen servicios</dt>
|
<dt class="col-5 fw-normal text-end">Margen servicios</dt>
|
||||||
<dd id="porcentajeMargenServicios" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_servicios) ?>%</dd>
|
<dd id="porcentajeMargenServicios" class="col-3 text-end py-1"></dd>
|
||||||
<dd id="margenServicios" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_servicios) ?>€</dd>
|
<dd id="margenServicios" class="col-3 text-end py-1"></dd>
|
||||||
|
|
||||||
<dt class="col-5 fw-normal text-end">Coste de envío</dt>
|
<dt class="col-5 fw-normal text-end">Coste de envío</dt>
|
||||||
<dd id="totalEnvios"class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_coste_envios) ?>€</dd>
|
<dd id="costeEnvios"class="col-6 text-end py-1"></dd>
|
||||||
|
<dt class="col-5 fw-normal text-end">Precio de envío</dt>
|
||||||
|
<dd id="totalEnvios"class="col-6 text-end py-1"></dd>
|
||||||
<dt class="col-5 fw-normal text-end">Margen envío</dt>
|
<dt class="col-5 fw-normal text-end">Margen envío</dt>
|
||||||
<dd id="margenEnvios" class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_envios) ?>€</dd>
|
<dd id="margenEnvios" class="col-6 text-end py-1"></dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<hr class="mx-n4">
|
<hr class="mx-n4">
|
||||||
|
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-5 fw-normal text-end">Total Costes</dt>
|
<dt class="col-5 fw-normal text-end">Total Costes</dt>
|
||||||
<dd id="totalCostes" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_costes) ?>€</dd>
|
<dd id="totalCostes" class="col-6 text-end"></dd>
|
||||||
<dt class="col-5 fw-normal text-end">Total Margen</dt>
|
<dt class="col-5 fw-normal text-end">Total Margen</dt>
|
||||||
<dd id="porcentajeMargen" class="col-3 text-end py-1"><?= old('0', round(($presupuestoEntity->total_costes+$presupuestoEntity->total_margenes)>0? 100*$presupuestoEntity->total_margenes/($presupuestoEntity->total_costes+$presupuestoEntity->total_margenes) : 0,0)) ?>%</dd>
|
<dd id="porcentajeMargen" class="col-3 text-end py-1"></dd>
|
||||||
<dd id="totalMargenes" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenes) ?>€</dd>
|
<dd id="totalMargenes" class="col-3 text-end py-1"></dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<hr class="mx-n4">
|
<hr class="mx-n4">
|
||||||
|
|
||||||
<dl class="row mb-0">
|
<dl class="row mb-0">
|
||||||
<dt class="col-5 fw-normal text-end">Total</dt>
|
<dt class="col-5 fw-normal text-end">Total</dt>
|
||||||
<dd id="totalAntesDescuento" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_antes_descuento) ?>€</dd>
|
<dd id="totalAntesDescuento" class="col-6 text-end"></dd>
|
||||||
<dt class="col-5 py-1 fw-normal text-end">Descuento</dt>
|
<dt class="col-5 py-1 fw-normal text-end">Descuento (%)</dt>
|
||||||
<dd id="dd" class="col-3 text-end py-1"><input id="total_descuentoPercent" type="number" value="<?= old('0', $presupuestoEntity->total_descuentoPercent) ?>" class="update-totales form-control" style="width:100% !important;"></dd>
|
<dd id="dd" class="col-3 text-end py-1"><input id="total_descuentoPercent" type="number" value="" class="update-totales form-control" style="width:100% !important;"></dd>
|
||||||
<dd id="descuentoTotal" class="col-3 py-1 text-end"><?= old('0', $presupuestoEntity->total_descuento) ?>€</dd>
|
<dd id="descuentoTotal" class="col-3 py-1 text-end"></dd>
|
||||||
<dt class="col-5 text-end">Total presupuesto</dt>
|
<dt class="col-5 text-end">Total presupuesto</dt>
|
||||||
<dd id="totalDespuesDecuento" class="col-6 fw-semibold text-end"><?= old('0', $presupuestoEntity->total_presupuesto) ?>€</dd>
|
<dd id="totalDespuesDecuento" class="col-6 fw-semibold text-end"></dd>
|
||||||
<dt class="col-5 fw-normal text-end">Precio unidad</dt>
|
<dt class="col-5 fw-normal text-end">Precio unidad</dt>
|
||||||
<dd id="precioUnidadPresupuesto" class="col-6 text-end mb-2"><?= old('0', $presupuestoEntity->total_precio_unidad) ?>€</dd>
|
<dd id="precioUnidadPresupuesto" class="col-6 text-end mb-2"></dd>
|
||||||
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor</dt>
|
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor</dt>
|
||||||
<dd id="factor" class="col-6 text-end mb-2" style="font-size: smaller !important;"><?= old('0', is_numeric($presupuestoEntity->total_factor) ? $presupuestoEntity->total_factor : 0) ?></dd>
|
<dd id="factor" class="col-6 text-end mb-2" style="font-size: smaller !important;"></dd>
|
||||||
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor Ponderado</dt>
|
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor Ponderado</dt>
|
||||||
<dd id="factor_ponderado" class="col-6 text-end mb-0" style="font-size: smaller !important;"><?= old('0', is_numeric($presupuestoEntity->total_factor_ponderado) ? $presupuestoEntity->total_factor_ponderado : 0) ?></dd>
|
<dd id="factor_ponderado" class="col-6 text-end mb-0" style="font-size: smaller !important;"></dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-grid float-end mb-4">
|
<div class="d-grid float-end mb-4">
|
||||||
@ -83,7 +85,7 @@
|
|||||||
<label for="paginas" class="form-label">
|
<label for="paginas" class="form-label">
|
||||||
<?= lang('Presupuestos.totalAceptado') ?>
|
<?= lang('Presupuestos.totalAceptado') ?>
|
||||||
</label>
|
</label>
|
||||||
<input disabled type="text" id="totalAceptado" name="totalAceptado" class="form-control" value="<?= old('paginas', $presupuestoEntity->total_aceptado) ?>" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
|
<input disabled type="text" id="totalAceptado" name="totalAceptado" class="form-control" value="" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@ -1,299 +0,0 @@
|
|||||||
function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
|
|
||||||
|
|
||||||
var totalPapel = 0
|
|
||||||
var margenPapel = 0
|
|
||||||
|
|
||||||
var totalImpresion = 0
|
|
||||||
var totalImpresionforMargen = 0
|
|
||||||
var margenImpresion = 0
|
|
||||||
|
|
||||||
var totalServicios = 0
|
|
||||||
var margenServicios = 0
|
|
||||||
|
|
||||||
var totalEnvios = 0
|
|
||||||
var margenEnvios = 0
|
|
||||||
|
|
||||||
var sumForFactor = 0.0
|
|
||||||
var sumForFactorPonderado = 0.0
|
|
||||||
|
|
||||||
|
|
||||||
var margenPorHoras = 0.0;
|
|
||||||
|
|
||||||
if(updateLP){
|
|
||||||
|
|
||||||
if(typeof $("#tableLineasPresupuesto").DataTable() !== 'undefined'){
|
|
||||||
$("#tableLineasPresupuesto").DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
|
|
||||||
if(rowData.check_papel_total){
|
|
||||||
totalPapel += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
|
|
||||||
margenPapel += parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
|
|
||||||
|
|
||||||
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
|
|
||||||
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
|
|
||||||
|
|
||||||
}
|
|
||||||
if(rowData.check_impresion_total){
|
|
||||||
//totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
|
||||||
margenPorHoras += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
|
||||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
|
||||||
|
|
||||||
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
|
||||||
|
|
||||||
if(rowData.maquinaTipo=='inkjet'){
|
|
||||||
totalImpresion += parseFloat(rowData.totalTinta)
|
|
||||||
totalImpresion += parseFloat(rowData.totalCorte)
|
|
||||||
|
|
||||||
sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
|
|
||||||
}
|
|
||||||
//margenImpresion += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
|
||||||
//margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
|
||||||
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
|
||||||
|
|
||||||
|
|
||||||
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
|
||||||
|
|
||||||
if(!isNaN(parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val()))){
|
|
||||||
totalImpresion += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
|
||||||
sumForFactor += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
totalImpresion -= margenImpresion
|
|
||||||
totalPapel -= margenPapel
|
|
||||||
|
|
||||||
margenImpresion += margenPorHoras
|
|
||||||
|
|
||||||
var porcentajeMargenPapel = isNaN(margenPapel/(totalPapel)*100.0)?0:margenPapel/(totalPapel)*100.0
|
|
||||||
$('#porcentajeMargenPapel').text(porcentajeMargenPapel.toFixed(0) + '%')
|
|
||||||
$('#totalCostePapel').text((addSeparatorsNF(totalPapel.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#margenPapel').text((addSeparatorsNF(margenPapel.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#totalCostePapel').attr('val',totalPapel.toFixed(2))
|
|
||||||
$('#margenPapel').attr('val',margenPapel.toFixed(2))
|
|
||||||
|
|
||||||
var porcentajeMargenImpresion = isNaN(margenImpresion/(totalImpresion)*100.0)?0:margenImpresion/(totalImpresion)*100.0
|
|
||||||
$('#porcentajeMargenImpresion').text(porcentajeMargenImpresion.toFixed(0) + '%')
|
|
||||||
$('#totalCosteImpresion').text((addSeparatorsNF(totalImpresion.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#margenImpresion').text((addSeparatorsNF(margenImpresion.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#totalCosteImpresion').attr('val',totalImpresion.toFixed(2))
|
|
||||||
$('#margenImpresion').attr('val',margenImpresion.toFixed(2))
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
totalPapel = parseFloat($('#totalCostePapel').attr('val'))
|
|
||||||
margenPapel = parseFloat($('#margenPapel').attr('val'))
|
|
||||||
totalImpresion = parseFloat($('#totalCosteImpresion').attr('val'))
|
|
||||||
margenImpresion = parseFloat($('#margenImpresion').attr('val'))
|
|
||||||
}
|
|
||||||
|
|
||||||
sumForFactorPonderado = sumForFactor;
|
|
||||||
|
|
||||||
if(updateServicios){
|
|
||||||
|
|
||||||
if ( typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0){
|
|
||||||
$('#tableOfServiciosEncuadernacion tbody tr').each(function(){
|
|
||||||
var currentRow = $(this).closest("tr");
|
|
||||||
var subId = $('#tableOfServiciosEncuadernacion').DataTable().cell(currentRow,0).node().innerHTML;
|
|
||||||
var total = parseFloat($('#precio_total_encuadernado_' + subId)[0].value)
|
|
||||||
totalServicios += total
|
|
||||||
var base = parseFloat($('#precio_total_encuadernado_' + subId)[0].value)/(1+parseFloat($('#enc_margen_' + subId)[0].innerHTML)/100.0);
|
|
||||||
var margen = total - base;
|
|
||||||
margenServicios += margen;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( typeof $("#tableOfServiciosAcabado").DataTable() !== 'undefined' && $("#tableOfServiciosAcabado").DataTable().rows().count() > 0){
|
|
||||||
$('#tableOfServiciosAcabado tbody tr').each(function(){
|
|
||||||
var currentRow = $(this).closest("tr");
|
|
||||||
var subId = $('#tableOfServiciosAcabado').DataTable().cell(currentRow,0).node().innerHTML;
|
|
||||||
var total = parseFloat($('#precio_total_acabado_' + subId)[0].value)
|
|
||||||
totalServicios += total
|
|
||||||
var base = parseFloat($('#precio_total_acabado_' + subId)[0].value)/(1+parseFloat($('#acabado_margen_' + subId)[0].innerHTML)/100.0);
|
|
||||||
var margen = total - base;
|
|
||||||
margenServicios += margen;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( typeof $("#tableOfServiciosPreimpresion").DataTable() !== 'undefined' && $("#tableOfServiciosPreimpresion").DataTable().rows().count() > 0){
|
|
||||||
|
|
||||||
$('#tableOfServiciosPreimpresion tbody tr').each(function(){
|
|
||||||
var currentRow = $(this).closest("tr");
|
|
||||||
var subId = $('#tableOfServiciosPreimpresion').DataTable().cell(currentRow,0).node().innerHTML;
|
|
||||||
var total = parseFloat($('#precio_preimpresion_' + subId)[0].value)
|
|
||||||
totalServicios += total
|
|
||||||
var base = parseFloat($('#precio_preimpresion_' + subId)[0].value)/(1+parseFloat($('#preimpresion_margen_' + subId)[0].innerHTML)/100.0);
|
|
||||||
var margen = total - base;
|
|
||||||
margenServicios += margen;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( typeof $("#tableOfServiciosExtra").DataTable() !== 'undefined' && $("#tableOfServiciosExtra").DataTable().rows().count() > 0){
|
|
||||||
|
|
||||||
$('#tableOfServiciosExtra tbody tr').each(function(){
|
|
||||||
var currentRow = $(this).closest("tr");
|
|
||||||
var subId = $('#tableOfServiciosExtra').DataTable().cell(currentRow,0).node().innerHTML;
|
|
||||||
var total = parseFloat($('#precio_servicioextra_' + subId)[0].value)
|
|
||||||
totalServicios += total
|
|
||||||
var base = parseFloat($('#precio_servicioextra_' + subId)[0].value)/(1+parseFloat($('#servicioextra_margen_' + subId)[0].innerHTML)/100.0);
|
|
||||||
var margen = total - base;
|
|
||||||
margenServicios += margen;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( typeof $("#tableOfServiciosManipulado").DataTable() !== 'undefined' && $("#tableOfServiciosManipulado").DataTable().rows().count() > 0){
|
|
||||||
|
|
||||||
$('#tableOfServiciosManipulado tbody tr').each(function(){
|
|
||||||
var currentRow = $(this).closest("tr");
|
|
||||||
var subId = $('#tableOfServiciosManipulado').DataTable().cell(currentRow,0).node().innerHTML;
|
|
||||||
var total = parseFloat($('#precio_total_manipulado_' + subId)[0].value)
|
|
||||||
totalServicios += total
|
|
||||||
var base = parseFloat($('#precio_total_manipulado_' + subId)[0].value)/(1+parseFloat($('#manipulado_margen_' + subId)[0].innerHTML)/100.0);
|
|
||||||
var margen = total - base;
|
|
||||||
margenServicios += margen;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
totalServicios -= margenServicios;
|
|
||||||
|
|
||||||
sumForFactorPonderado += totalServicios;
|
|
||||||
|
|
||||||
var porcentajeMargenServicios = margenServicios/(totalServicios)*100
|
|
||||||
$('#porcentajeMargenServicios').text(isNaN(porcentajeMargenServicios.toFixed(0))?0:porcentajeMargenServicios.toFixed(0) + '%')
|
|
||||||
$('#totalServicios').text((addSeparatorsNF(totalServicios.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#margenServicios').text((addSeparatorsNF(margenServicios.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#totalServicios').attr('val',totalServicios.toFixed(2) + '€')
|
|
||||||
$('#margenServicios').attr('val',margenServicios.toFixed(2) + '€')
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
totalServicios = parseFloat($('#totalServicios').attr('val'))
|
|
||||||
margenServicios = parseFloat($('#margenServicios').attr('val'))
|
|
||||||
|
|
||||||
sumForFactorPonderado += totalServicios;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(updateEnvio){
|
|
||||||
|
|
||||||
if ( typeof $('#tableOfDireccionesEnvio').DataTable() !== 'undefined' && $('#tableOfDireccionesEnvio').DataTable().rows().count() > 0){
|
|
||||||
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var data = this.data()
|
|
||||||
totalEnvios += parseFloat(data.precio)
|
|
||||||
margenEnvios += parseFloat((data.precio)*data.margen/100)
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
totalEnvios -= margenEnvios
|
|
||||||
$('#totalEnvios').text((addSeparatorsNF(totalEnvios.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#margenEnvios').text((addSeparatorsNF(margenEnvios.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#totalEnvios').attr('val',totalEnvios.toFixed(2) + '€')
|
|
||||||
$('#margenEnvios').attr('val',margenEnvios.toFixed(2) + '€')
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
totalEnvios = parseFloat($('#totalEnvios').attr('val'))
|
|
||||||
margenEnvios = parseFloat($('#margenEnvios').attr('val'))
|
|
||||||
}
|
|
||||||
|
|
||||||
var totalCostes = parseFloat(totalPapel.toFixed(2)) + parseFloat(totalImpresion.toFixed(2)) + parseFloat(totalServicios.toFixed(2)) + parseFloat(totalEnvios.toFixed(2))
|
|
||||||
var totalMargenes = parseFloat(margenPapel.toFixed(2)) + parseFloat(margenImpresion.toFixed(2)) + parseFloat(margenServicios.toFixed(2)) + parseFloat(margenEnvios.toFixed(2))
|
|
||||||
var porcentajeMargen = totalCostes+totalMargenes>0? (100*totalMargenes/(totalCostes+totalMargenes)).toFixed(0) : 0
|
|
||||||
$('#totalCostes').text((addSeparatorsNF(totalCostes.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#totalMargenes').text((addSeparatorsNF(totalMargenes.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#totalCostes').attr('val',(totalCostes).toFixed(2) + '€')
|
|
||||||
$('#totalMargenes').attr('val',(totalMargenes).toFixed(2) + '€')
|
|
||||||
$('#porcentajeMargen').text(porcentajeMargen + '%')
|
|
||||||
$('#porcentajeMargen').attr('val',porcentajeMargen)
|
|
||||||
|
|
||||||
if($('#total_descuentoPercent').val()<0){
|
|
||||||
$('#total_descuentoPercent').val(0)
|
|
||||||
}
|
|
||||||
var totalAntesDescuento = totalCostes + totalMargenes
|
|
||||||
var totalDescuento = totalAntesDescuento * parseInt($('#total_descuentoPercent').val())/100
|
|
||||||
var totalPresupuesto = totalAntesDescuento - totalDescuento
|
|
||||||
var precioUnidad = totalPresupuesto/parseInt($('#tirada').val())
|
|
||||||
|
|
||||||
$('#totalAntesDescuento').text((addSeparatorsNF(totalAntesDescuento.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#descuentoTotal').text((addSeparatorsNF(totalDescuento.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#totalDespuesDecuento').text((addSeparatorsNF(totalPresupuesto.toFixed(2), ".", ",", ".")) + "€")
|
|
||||||
$('#precioUnidadPresupuesto').text((addSeparatorsNF(precioUnidad.toFixed(4), ".", ",", ".")) + "€")
|
|
||||||
$('#totalAntesDescuento').attr('val',(totalAntesDescuento).toFixed(2))
|
|
||||||
$('#descuentoTotal').attr('val',(totalDescuento).toFixed(2))
|
|
||||||
$('#totalDespuesDecuento').attr('val',(totalPresupuesto).toFixed(2))
|
|
||||||
$('#precioUnidadPresupuesto').attr('val',(precioUnidad).toFixed(4))
|
|
||||||
|
|
||||||
|
|
||||||
$('#factor').text(addSeparatorsNF(((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactor).toFixed(2), ".", ",", "."))
|
|
||||||
$('#factor').attr('val', ((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactor).toFixed(2))
|
|
||||||
$('#factor_ponderado').text(addSeparatorsNF(((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactorPonderado).toFixed(2), ".", ",", "."))
|
|
||||||
$('#factor_ponderado').attr('val',((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactorPonderado).toFixed(2))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function addSeparatorsNF(nStr, inD, outD, sep)
|
|
||||||
{
|
|
||||||
nStr += '';
|
|
||||||
var dpos = nStr.indexOf(inD);
|
|
||||||
var nStrEnd = '';
|
|
||||||
if (dpos != -1) {
|
|
||||||
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
|
|
||||||
nStr = nStr.substring(0, dpos);
|
|
||||||
}
|
|
||||||
var rgx = /(\d+)(\d{3})/;
|
|
||||||
while (rgx.test(nStr)) {
|
|
||||||
nStr = nStr.replace(rgx, '$1' + sep + '$2');
|
|
||||||
}
|
|
||||||
return nStr + nStrEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getValuesResumenForm(){
|
|
||||||
var formResumen = "";
|
|
||||||
formResumen += '&total_coste_papel=' + $('#totalCostePapel').attr('val');
|
|
||||||
formResumen += '&total_margen_papel=' + $('#margenPapel').attr('val');
|
|
||||||
formResumen += '&total_margenPercent_papel=' + $('#porcentajeMargenPapel').text().replace('%', '');
|
|
||||||
|
|
||||||
formResumen += '&total_coste_impresion=' + $('#totalCosteImpresion').attr('val');
|
|
||||||
formResumen += '&total_margen_impresion=' + $('#margenImpresion').attr('val');
|
|
||||||
formResumen += '&total_margenPercent_impresion=' + $('#porcentajeMargenImpresion').text().replace('%', '');
|
|
||||||
|
|
||||||
formResumen += '&total_coste_servicios=' + $('#totalServicios').attr('val');
|
|
||||||
formResumen += '&total_margen_servicios=' + $('#margenServicios').attr('val');
|
|
||||||
formResumen += '&total_margenPercent_servicios=' + $('#porcentajeMargenServicios').text().replace('%', '');
|
|
||||||
|
|
||||||
formResumen += '&total_coste_envios=' + $('#totalEnvios').attr('val');
|
|
||||||
formResumen += '&total_margen_envios=' + $('#margenEnvios').attr('val');
|
|
||||||
|
|
||||||
formResumen += '&total_costes=' + $('#totalCostes').attr('val');
|
|
||||||
formResumen += '&total_margenes=' + $('#totalMargenes').attr('val');
|
|
||||||
|
|
||||||
formResumen += '&total_antes_descuento=' + $('#totalAntesDescuento').attr('val');
|
|
||||||
formResumen += '&total_descuento=' + $('#descuentoTotal').attr('val');
|
|
||||||
formResumen += '&total_descuentoPercent=' + $('#total_descuentoPercent').val();
|
|
||||||
formResumen += '&total_presupuesto=' + $('#totalDespuesDecuento').attr('val');
|
|
||||||
formResumen += '&total_precio_unidad=' + $('#precioUnidadPresupuesto').attr('val');
|
|
||||||
|
|
||||||
// replace , for . in the values
|
|
||||||
formResumen += '&total_factor=' + $('#factor').text().replace(/,/g, '.');
|
|
||||||
formResumen += '&total_factor_ponderado=' + $('#factor_ponderado').text().replace(/,/g, '.');
|
|
||||||
|
|
||||||
if($('#confirmar_presupuesto').prop('checked')){
|
|
||||||
formResumen += '&confirmar=1';
|
|
||||||
formResumen += '&total_aceptado=' + $('#totalDespuesDecuento').attr('val');
|
|
||||||
}
|
|
||||||
|
|
||||||
return formResumen
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(".update-totales").on("change", function(){
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: false,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: false
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@ -1,397 +0,0 @@
|
|||||||
// Selección de la última columna de la tabla de tiradas
|
|
||||||
const lastColNr_tiradasAlt = $('#tableTiradas').find("tr:first th").length - 1;
|
|
||||||
|
|
||||||
|
|
||||||
// Función para generar los botones de acción de la tabla de tiradas
|
|
||||||
const actionBtns_tiradasAlt = function (data) {
|
|
||||||
return `
|
|
||||||
<a href="javascript:void(0);"><i class="ti ti-check ti-sm comfirm-tirada-alt mx-2" data-id="${data.row_id}"></i></a>
|
|
||||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-tirada mx-2" data-id="${data.row_id}"></i></a>
|
|
||||||
`;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Inicializaciones de la tabla de tiradas
|
|
||||||
var tableTiradas;
|
|
||||||
|
|
||||||
|
|
||||||
// Espera a que todas las variables necesarias estén definidas
|
|
||||||
(async () => {
|
|
||||||
|
|
||||||
while (!window.hasOwnProperty("datatable_lang_url") && !window.hasOwnProperty("datatable_TA_url"))
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 200));
|
|
||||||
initTableTiradas();
|
|
||||||
fill_tiradas_alternativas();
|
|
||||||
|
|
||||||
/*$('.tiradas-alternativas').each(function() {
|
|
||||||
if ($(this).is('input')) {
|
|
||||||
$(this).bind('change', update_tiradas_alternativas);
|
|
||||||
} else if ($(this).is('button')) {
|
|
||||||
$(this).bind('click', update_tiradas_alternativas);
|
|
||||||
} else if ($(this).is('table')) {
|
|
||||||
$(this).bind('draw.dt', update_tiradas_alternativas);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// para los botones de borrar
|
|
||||||
$(this).bind('click', update_tiradas_alternativas);
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
|
||||||
async function actualizar_tiradas_alternativas(){
|
|
||||||
if(tableTiradas !== undefined && tableTiradas.rows().count() > 0){
|
|
||||||
// se obtiene la primera columna de la tabla de tiradas
|
|
||||||
const data = tableTiradas.rows().data().toArray();
|
|
||||||
// se borra la tabla de tiradas
|
|
||||||
tableTiradas.clear().draw();
|
|
||||||
const tiradas = data.map(row => row.tirada);
|
|
||||||
// por cada tirada, se añade una fila a la tabla de tiradas
|
|
||||||
await tiradas.forEach(async function(tirada){
|
|
||||||
await add_tirada_alternativa(tirada);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Evento de añadir una tirada alternativa
|
|
||||||
$('#add_tirada_alt').on('click', function () {
|
|
||||||
|
|
||||||
const tirada_alt = parseInt($('#tirada_alt').val());
|
|
||||||
add_tirada_alternativa(tirada_alt);
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Funcion para añadir una tirada alternativa
|
|
||||||
async function add_tirada_alternativa(tirada_alt) {
|
|
||||||
|
|
||||||
// se comprueba que la tirada no existe ya en la tabla
|
|
||||||
const exists = tableTiradas.rows().data().toArray().some(row => row.tirada == tirada_alt);
|
|
||||||
const isPOD = parseInt($('#tirada').val())<= parseInt($('#POD').val());
|
|
||||||
|
|
||||||
const typeIsOk = tirada_alt <= parseInt($('#POD').val()) && isPOD || tirada_alt > parseInt($('#POD').val()) && !isPOD;
|
|
||||||
|
|
||||||
if (!exists && typeIsOk) {
|
|
||||||
|
|
||||||
const dimension = getDimensionLibro();
|
|
||||||
|
|
||||||
let datos = {
|
|
||||||
tirada: tirada_alt,
|
|
||||||
merma: get_merma_tirada_alternativa(tirada_alt),
|
|
||||||
tipo_impresion_id: $('#tipo_impresion_id').val(),
|
|
||||||
json_tiradas: generate_json_tiradas(),
|
|
||||||
ancho: dimension.ancho,
|
|
||||||
alto: dimension.alto,
|
|
||||||
cliente_id: $('#clienteId').find(":selected").val(),
|
|
||||||
solapas_cubierta: $('#solapas').is(':checked')?1:0,
|
|
||||||
solapas_cubierta_ancho: $('#solapas').is(':checked')?parseInt($('#solapas_ancho').val()):0,
|
|
||||||
solapas_sobrecubierta: $('#solapas_sobrecubierta').is(':checked')?1:0,
|
|
||||||
solapas_sobrecubierta_ancho: $('#solapas_sobrecubierta').is(':checked')?parseInt($('#solapas_ancho_sobrecubierta').val()):0,
|
|
||||||
lomo: getLomoExterior(),
|
|
||||||
};
|
|
||||||
|
|
||||||
datos = Object.assign(datos, window.token_ajax);
|
|
||||||
|
|
||||||
// Se realiza la petición AJAX
|
|
||||||
await $.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: window.get_tirada_url,
|
|
||||||
data: datos,
|
|
||||||
success: async function (data) {
|
|
||||||
|
|
||||||
var coste_total = 0.0;
|
|
||||||
var margen_total = 0.0;
|
|
||||||
|
|
||||||
var costes_servicios = 0.0;
|
|
||||||
var margen_servicios = 0.0;
|
|
||||||
|
|
||||||
var coste_envio = 0.0;
|
|
||||||
var margen_envio = 0.0;
|
|
||||||
|
|
||||||
if(data.lineas.length >0){
|
|
||||||
// Se cogen los valores de la linea con los datos correspondientes
|
|
||||||
data.lineas.forEach(function(value) {
|
|
||||||
coste_total += value.total_coste;
|
|
||||||
margen_total += value.total_margen;
|
|
||||||
});
|
|
||||||
|
|
||||||
//console.log(datos.tirada);
|
|
||||||
|
|
||||||
// Se obtiene el precio de los servicios
|
|
||||||
const valueAcabados = await get_servAcabados_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
costes_servicios += parseFloat(valueAcabados.coste);
|
|
||||||
margen_servicios += parseFloat(valueAcabados.margen);
|
|
||||||
|
|
||||||
//console.log('coste acabados ('+ datos.tirada +'): ' + valueAcabados.coste);
|
|
||||||
|
|
||||||
const valueEncuadernacion = await get_servEncuadernacion_tiradasAlternativas(
|
|
||||||
parseInt(datos.tirada), parseInt( $('#paginas').val()), parseInt(dimension.ancho), parseInt(dimension.alto));
|
|
||||||
costes_servicios += parseFloat(valueEncuadernacion.coste);
|
|
||||||
margen_servicios += parseFloat(valueEncuadernacion.margen);
|
|
||||||
|
|
||||||
//console.log('coste encuadernacion ('+ datos.tirada +'): ' + valueEncuadernacion.coste);
|
|
||||||
|
|
||||||
const valueManipulado = await get_servManipulado_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
costes_servicios += parseFloat(valueManipulado.coste);
|
|
||||||
margen_servicios += parseFloat(valueManipulado.margen);
|
|
||||||
|
|
||||||
//console.log('coste manipulado ('+ datos.tirada +'): ' + valueManipulado.coste);
|
|
||||||
|
|
||||||
const valuePreimpresion = await get_servPreimpresion_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
costes_servicios += parseFloat(valuePreimpresion.coste);
|
|
||||||
margen_servicios += parseFloat(valuePreimpresion.margen);
|
|
||||||
|
|
||||||
const valueServiciosExtra = await get_servExtra_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
costes_servicios += parseFloat(valueServiciosExtra.coste);
|
|
||||||
margen_servicios += parseFloat(valueServiciosExtra.margen);
|
|
||||||
|
|
||||||
//console.log('coste preimpresion ('+ datos.tirada +'): ' + valuePreimpresion.coste);
|
|
||||||
|
|
||||||
const valueTransporte = await get_coste_envio_tiradasAlternativas(parseInt(datos.tirada));
|
|
||||||
coste_envio = valueTransporte.coste;
|
|
||||||
margen_envio = valueTransporte.margen;
|
|
||||||
|
|
||||||
|
|
||||||
// Se añade la fila a la tabla de tiradas
|
|
||||||
tableTiradas.row.add({
|
|
||||||
tirada: datos.tirada,
|
|
||||||
coste_impresion: coste_total.toFixed(2),
|
|
||||||
coste_envio: coste_envio.toFixed(2),
|
|
||||||
margen: ((margen_total + margen_servicios + margen_envio)/(coste_total+coste_envio)*100.0).toFixed(2),
|
|
||||||
total_pedido: (coste_total + costes_servicios + coste_envio).toFixed(2),
|
|
||||||
precio_unidad: ((coste_total + costes_servicios + coste_envio) / datos.tirada).toFixed(4),
|
|
||||||
|
|
||||||
}).draw(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
yeniden(data[window.csrf_token]);
|
|
||||||
|
|
||||||
},
|
|
||||||
error: function(e){}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var htmlString = '';
|
|
||||||
if(typeIsOk){
|
|
||||||
htmlString = `
|
|
||||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
|
||||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
|
||||||
<i class="ti ti-bell ti-sm"></i>
|
|
||||||
</span>
|
|
||||||
<div class="d-flex flex-column ps-1">
|
|
||||||
<h5 class="alert-heading mb-2">` +
|
|
||||||
window.Presupuestos.errores.tirada_alt_duplicada +
|
|
||||||
`</h5>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
else{
|
|
||||||
htmlString = `
|
|
||||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
|
||||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
|
||||||
<i class="ti ti-bell ti-sm"></i>
|
|
||||||
</span>
|
|
||||||
<div class="d-flex flex-column ps-1">
|
|
||||||
<h5 class="alert-heading mb-2">` +
|
|
||||||
window.Presupuestos.errores.tirada_alt_tipo +
|
|
||||||
`</h5>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
$('#alert-tiradas_alt').hide().empty().html(htmlString).fadeIn("slow", function(){
|
|
||||||
setTimeout(function(){
|
|
||||||
$('#alert-tiradas_alt').fadeOut("slow");
|
|
||||||
}, 5000);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Función para obtener el lomo exterior
|
|
||||||
function getLomoExterior(){
|
|
||||||
let lomoTotal = 0
|
|
||||||
try{
|
|
||||||
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
if(rowData.row_id != 'lp_cubierta' && rowData.tipo != 'lp_sobrecubierta')
|
|
||||||
lomoTotal += parseFloat(rowData.lomo)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
catch(error){
|
|
||||||
lomoTotal = 0
|
|
||||||
}
|
|
||||||
return lomoTotal
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Inicialización de la tabla de tiradas
|
|
||||||
function initTableTiradas() {
|
|
||||||
tableTiradas = $('#tableTiradas').DataTable({
|
|
||||||
"language": {
|
|
||||||
"url": window.datatable_lang_url
|
|
||||||
},
|
|
||||||
"paging": false,
|
|
||||||
"info": false,
|
|
||||||
"searching": false,
|
|
||||||
"ordering": true,
|
|
||||||
"autoWidth": false,
|
|
||||||
"responsive": true,
|
|
||||||
"columnDefs": [
|
|
||||||
{
|
|
||||||
orderable: false,
|
|
||||||
searchable: false,
|
|
||||||
targets: [lastColNr_tiradasAlt]
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"columns": [
|
|
||||||
{ data: "tirada" },
|
|
||||||
{ data: 'coste_impresion' },
|
|
||||||
{ data: 'coste_envio' },
|
|
||||||
{ data: 'margen' ,
|
|
||||||
render: function ( data, type, row ) {
|
|
||||||
return data + '%';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ data: 'total_pedido' },
|
|
||||||
{ data: 'precio_unidad' },
|
|
||||||
{
|
|
||||||
data: actionBtns_tiradasAlt,
|
|
||||||
className: 'row-edit dt-center'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
order: [[0, 'asc']]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Evento de borrado de una fila de la tabla de tiradas
|
|
||||||
$(document).on('click', '.btn-delete-tirada', function (e) {
|
|
||||||
|
|
||||||
const row = $(this).closest('tr');
|
|
||||||
tableTiradas.row(row)
|
|
||||||
.remove()
|
|
||||||
.draw();
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// Función para usar la tirada alternativa como tirada principal
|
|
||||||
$(document).on('click', '.comfirm-tirada-alt', function (e) {
|
|
||||||
|
|
||||||
const row = $(this).closest('tr');
|
|
||||||
const data = tableTiradas.row(row).data();
|
|
||||||
|
|
||||||
updateTablaEnvios($('#tirada').val(), data.tirada).then(function(){
|
|
||||||
$('#tirada').val(data.tirada);
|
|
||||||
$('#tirada').trigger('change', [false]);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// Función para generar el JSON de las lineas de presupuesto para calcular las tiradas
|
|
||||||
function generate_json_tiradas() {
|
|
||||||
|
|
||||||
const data = $('#tableLineasPresupuesto').DataTable().data().toArray();
|
|
||||||
|
|
||||||
//return data; // For debugging purposes
|
|
||||||
json = filterData(data,
|
|
||||||
['paginas',
|
|
||||||
'numPagColor',
|
|
||||||
'paginas_impresion',
|
|
||||||
'papel', // papel generico
|
|
||||||
'papel_impresion_id',
|
|
||||||
'gramaje',
|
|
||||||
'maquina_id',
|
|
||||||
'aFavorFibra',
|
|
||||||
'row_id',
|
|
||||||
'check_papel_total',
|
|
||||||
'check_impresion_total',
|
|
||||||
'cobAmarillo', // tipologia de papel
|
|
||||||
'cobCyan',
|
|
||||||
'cobMagenta',
|
|
||||||
'cobNegro',
|
|
||||||
'cobCG',
|
|
||||||
'gotaColor',
|
|
||||||
'gotaNegro']);
|
|
||||||
|
|
||||||
json.forEach(element => {
|
|
||||||
element['check_papel_total'] = $('#' + element['row_id'] + '_checkPapel').is(':checked') ? 1 : 0;
|
|
||||||
element['check_impresion_total'] = $('#' + element['row_id'] + '_checkClicks').is(':checked') ? 1 : 0;
|
|
||||||
});
|
|
||||||
return JSON.stringify(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Función para filtrar las columnas de la tabla de tiradas
|
|
||||||
function filterData(data, keys) {
|
|
||||||
return data.map(obj => {
|
|
||||||
const newObj = {};
|
|
||||||
keys.forEach(key => {
|
|
||||||
if (obj.hasOwnProperty(key)) {
|
|
||||||
newObj[key] = obj[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return newObj;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Función para obtener la merma de la tirada alternativa
|
|
||||||
function get_merma_tirada_alternativa(tirada){
|
|
||||||
|
|
||||||
var merma = 0
|
|
||||||
|
|
||||||
if(tirada>parseInt($('#POD').val())){
|
|
||||||
|
|
||||||
merma = tirada*0.1<=30 ? tirada*0.1 : 30
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
merma_lineas = []
|
|
||||||
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){
|
|
||||||
const formas_linea = $('#isCosido').val()==0?parseInt(rowData.formas):parseInt(rowData.formas)/2
|
|
||||||
if(formas_linea > tirada)
|
|
||||||
merma_lineas.push(formas_linea-tirada)
|
|
||||||
else
|
|
||||||
merma_lineas.push(tirada%formas_linea)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if(merma_lineas.length>0)
|
|
||||||
merma = Math.max(...merma_lineas)
|
|
||||||
else
|
|
||||||
merma = 0
|
|
||||||
}
|
|
||||||
return merma;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function fill_tiradas_alternativas(){
|
|
||||||
tableTiradas.clear().draw();
|
|
||||||
const text = $('#tirada_alternativa_json_data').val()
|
|
||||||
if(text.length>0){
|
|
||||||
|
|
||||||
const data = JSON.parse(text);
|
|
||||||
if(data.length>0){
|
|
||||||
$.each(data, function(key, value) {
|
|
||||||
tableTiradas.row.add({
|
|
||||||
tirada: value.tirada,
|
|
||||||
coste_impresion: value.coste_impresion,
|
|
||||||
coste_envio: value.coste_envio,
|
|
||||||
margen: value.margen,
|
|
||||||
total_pedido: value.total_pedido,
|
|
||||||
precio_unidad: value.precio_unidad,
|
|
||||||
}).draw(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +30,7 @@
|
|||||||
<th><?= lang('Presupuestos.tiradaMargen') ?></th>
|
<th><?= lang('Presupuestos.tiradaMargen') ?></th>
|
||||||
<th><?= lang('Presupuestos.totalPedido') ?></th>
|
<th><?= lang('Presupuestos.totalPedido') ?></th>
|
||||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||||
<th></th>
|
<th style="min-width: 80px;"></th>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -48,21 +48,6 @@
|
|||||||
</div> <!-- //.accordion-item -->
|
</div> <!-- //.accordion-item -->
|
||||||
</div> <!-- //.accordion -->
|
</div> <!-- //.accordion -->
|
||||||
|
|
||||||
<!------------------------------------------------------->
|
|
||||||
<!-- Código JS comportamiento ?????. -->
|
|
||||||
<!------------------------------------------------------->
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
window.datatable_lang_url = "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json";
|
|
||||||
|
|
||||||
window.datatable_TA_url = "<?= route_to('dataTableOfPresupuestoTiradasAlternativas') ?>";
|
|
||||||
window.get_tirada_url = "<?= route_to('getTiradaData') ?>";
|
|
||||||
|
|
||||||
window.error_lang_tirada_alt_duplicada = "<?= lang('Presupuestos.errores.tirada_alt_duplicada') ?>";
|
|
||||||
window.error_lang_tirada_alt_tipo = "<?= lang('Presupuestos.errores.tirada_alt_tipo') ?>";
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,747 +0,0 @@
|
|||||||
/*******************************
|
|
||||||
* Eventos asociados a elementos HTML
|
|
||||||
*******************************/
|
|
||||||
$('#compPaginasNegro').on("change", function () {
|
|
||||||
var negro = parseInt(document.getElementById('compPaginasNegro').value);
|
|
||||||
const paginas = parseInt(document.getElementById('paginas').value);
|
|
||||||
if (paginas < negro) {
|
|
||||||
document.getElementById('compPaginasNegro').value = paginas;
|
|
||||||
negro = paginas;
|
|
||||||
}
|
|
||||||
var color = parseInt(document.getElementById('compPaginasColor').value);
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
|
||||||
|
|
||||||
var newValue = paginas - negro;
|
|
||||||
if (newValue != color) {
|
|
||||||
document.getElementById('compPaginasColor').value = newValue >= 0 ? newValue : 0;
|
|
||||||
$('#compPaginasColor').change();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#compPaginasColor').on("change", function () {
|
|
||||||
const paginas = parseInt(document.getElementById('paginas').value);
|
|
||||||
var color = parseInt(document.getElementById('compPaginasColor').value);
|
|
||||||
var negro = parseInt(document.getElementById('compPaginasNegro').value);
|
|
||||||
|
|
||||||
if (paginas < color) {
|
|
||||||
document.getElementById('compPaginasColor').value = paginas;
|
|
||||||
color = paginas
|
|
||||||
}
|
|
||||||
var newValue = paginas - color;
|
|
||||||
if (newValue != negro) {
|
|
||||||
document.getElementById('compPaginasNegro').value = newValue >= 0 ? newValue : 0;
|
|
||||||
$('#compPaginasNegro').change();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#compPaginasNegrohq').on("change", function () {
|
|
||||||
|
|
||||||
var negro = parseInt(document.getElementById('compPaginasNegrohq').value);
|
|
||||||
const paginas = parseInt(document.getElementById('paginas').value);
|
|
||||||
if (paginas < negro) {
|
|
||||||
document.getElementById('compPaginasNegrogq').value = paginas;
|
|
||||||
negro = paginas;
|
|
||||||
}
|
|
||||||
var color = parseInt(document.getElementById('compPaginasColorhq').value);
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
|
||||||
|
|
||||||
var newValue = paginas - negro;
|
|
||||||
if (newValue != color) {
|
|
||||||
document.getElementById('compPaginasColorhq').value = newValue >= 0 ? newValue : 0;
|
|
||||||
$('#compPaginasColorhq').change();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#compPaginasColorhq').on("change", function () {
|
|
||||||
const paginas = parseInt(document.getElementById('paginas').value);
|
|
||||||
var color = parseInt(document.getElementById('compPaginasColorhq').value);
|
|
||||||
var negro = parseInt(document.getElementById('compPaginasNegrohq').value);
|
|
||||||
|
|
||||||
if (paginas < color) {
|
|
||||||
document.getElementById('compPaginasColorhq').value = paginas;
|
|
||||||
color = paginas
|
|
||||||
}
|
|
||||||
var newValue = paginas - color;
|
|
||||||
if (newValue != negro) {
|
|
||||||
document.getElementById('compPaginasNegrohq').value = newValue >= 0 ? newValue : 0;
|
|
||||||
$('#compPaginasNegrohq').change();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#prototipo').on("change", function () {
|
|
||||||
$('#ferro').prop('checked', true)
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#compPosPaginasColor').on("keyup", function () {
|
|
||||||
computarPaginasColor(this.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Este evento recoloca los headers de las tablas cuando se pulsa el
|
|
||||||
// boton del acordeon
|
|
||||||
$('.accordion-button').on('click', function (e) {
|
|
||||||
|
|
||||||
if (e.target.id.includes("plana")) {
|
|
||||||
$("#tableCompIntPlana").DataTable().columns.adjust();
|
|
||||||
}
|
|
||||||
else if (e.target.id.includes("rotativa")) {
|
|
||||||
$("#tableCompIntRotativa").DataTable().columns.adjust();
|
|
||||||
}
|
|
||||||
else if (e.target.id.includes("cubierta")) {
|
|
||||||
$("#tableCompCubierta").DataTable().columns.adjust();
|
|
||||||
}
|
|
||||||
else if (e.target.id.includes("guardas")) {
|
|
||||||
$("#tableCompGuardas").DataTable().columns.adjust();
|
|
||||||
}
|
|
||||||
else if (e.target.id.includes("LineasPresupuesto")) {
|
|
||||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************
|
|
||||||
* Metodos
|
|
||||||
*******************************/
|
|
||||||
function getRowFromLineaInt(tipo, linea) {
|
|
||||||
|
|
||||||
$precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido)) ? "" :
|
|
||||||
parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido).toFixed(2);
|
|
||||||
|
|
||||||
|
|
||||||
data = {
|
|
||||||
'tipo': tipo,
|
|
||||||
'paginas': linea.fields.paginas,
|
|
||||||
'papel': linea.fields.papel_generico,
|
|
||||||
'gramaje': linea.fields.gramaje,
|
|
||||||
'marca': linea.fields.papel_impresion,
|
|
||||||
'maquina': linea.fields.maquina,
|
|
||||||
'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2),
|
|
||||||
'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2),
|
|
||||||
'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6),
|
|
||||||
'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2),
|
|
||||||
'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2),
|
|
||||||
'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2),
|
|
||||||
'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2),
|
|
||||||
'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2),
|
|
||||||
'precioImpresion': $precio_impresion,
|
|
||||||
'total': isNaN(parseFloat(linea.fields.total_impresion).toFixed(2)) ? "" : parseFloat(linea.fields.total_impresion).toFixed(2),
|
|
||||||
'maquinaId': linea.fields.maquina_id,
|
|
||||||
'maquinaVelocidad': linea.fields.maquina_velocidad,
|
|
||||||
'tiempoMaquina': linea.fields.tiempo_maquina,
|
|
||||||
'papelGenericoId': linea.fields.papel_generico_id,
|
|
||||||
'papelImpresionId': linea.fields.papel_impresion_id,
|
|
||||||
'tarifa_impresion_id': linea.fields.tarifa_impresion_id,
|
|
||||||
}
|
|
||||||
if(data['tipo']=='guardas')
|
|
||||||
data['paginas_impresion'] = linea.fields.paginas_impresion;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRowFromLineaRot(linea) {
|
|
||||||
|
|
||||||
$precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido)) ? "" :
|
|
||||||
parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido).toFixed(2);
|
|
||||||
|
|
||||||
return {
|
|
||||||
'tipo': 'rotativa',
|
|
||||||
'paginas': linea.fields.paginas,
|
|
||||||
'papel': linea.fields.papel_generico,
|
|
||||||
'gramaje': linea.fields.gramaje,
|
|
||||||
'marca': linea.fields.papel_impresion,
|
|
||||||
'aFavorFibra': linea.fields.a_favor_fibra == 1 ? 'si' : 'no',
|
|
||||||
'maquina': linea.fields.maquina,
|
|
||||||
'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2),
|
|
||||||
'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2),
|
|
||||||
'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6),
|
|
||||||
'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2),
|
|
||||||
'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2),
|
|
||||||
'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2),
|
|
||||||
'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2),
|
|
||||||
'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2),
|
|
||||||
'precioImpresion': $precio_impresion,
|
|
||||||
'precioPagNegro': isNaN(parseFloat(linea.fields.precio_pagina_negro)) ? "" : parseFloat(linea.fields.precio_pagina_negro).toFixed(6),
|
|
||||||
'precioPagColor': isNaN(parseFloat(linea.fields.precio_pagina_color)) ? "" : parseFloat(linea.fields.precio_pagina_color).toFixed(6),
|
|
||||||
'totalTinta': isNaN(parseFloat(linea.fields.precio_tinta)) ? "" : parseFloat(linea.fields.precio_tinta).toFixed(2),
|
|
||||||
'totalCorte': isNaN(parseFloat(linea.fields.total_corte)) ? "" : parseFloat(linea.fields.total_corte).toFixed(2),
|
|
||||||
'total': isNaN(parseFloat(linea.fields.total_impresion)) ? "" : (parseFloat(linea.fields.total_impresion)).toFixed(2),
|
|
||||||
'maquinaId': linea.fields.maquina_id,
|
|
||||||
'maquinaVelocidad': linea.fields.maquina_velocidad,
|
|
||||||
'tiempoMaquina': linea.fields.tiempo_maquina,
|
|
||||||
'papelGenericoId': linea.fields.papel_generico_id,
|
|
||||||
'papelImpresionId': linea.fields.papel_impresion_id,
|
|
||||||
'paginasColor': linea.fields.paginas_color,
|
|
||||||
'tarifa_impresion_id': linea.fields.tarifa_impresion_id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function computarPaginasColor(string) {
|
|
||||||
|
|
||||||
var numbers = [];
|
|
||||||
for (const [, beginStr, endStr] of string.matchAll(/(\d+)(?:-(\d+))?/g)) {
|
|
||||||
const [begin, end] = [beginStr, endStr].map(Number);
|
|
||||||
numbers.push(begin);
|
|
||||||
if (endStr !== undefined) {
|
|
||||||
for (let num = begin + 1; num <= end; num++) {
|
|
||||||
numbers.push(num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var numbers2 = [];
|
|
||||||
numbers.forEach(function (value, i) {
|
|
||||||
// Si es impar y no está el siguiente par hay que añadirlo
|
|
||||||
if (value % 2 != 0 && numbers[i + 1] != value + 1) {
|
|
||||||
numbers2.push(value + 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
numbers = numbers.concat(numbers2);
|
|
||||||
numbers.sort(function (a, b) {
|
|
||||||
return a - b;
|
|
||||||
});
|
|
||||||
calPagesTextarea = document.getElementById('compCalPaginasColor');
|
|
||||||
calPagesTextarea.value = numbers;
|
|
||||||
autosize.update(calPagesTextarea);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function checkRetractiladoComparador(element) {
|
|
||||||
|
|
||||||
switch (element.id) {
|
|
||||||
case 'retractilado':
|
|
||||||
if ($('#' + element.id).prop('checked')) {
|
|
||||||
$('#retractilado5').prop('checked', false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'retractilado5':
|
|
||||||
if ($('#' + element.id).prop('checked')) {
|
|
||||||
$('#retractilado').prop('checked', false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function updatePapelesComparador() {
|
|
||||||
|
|
||||||
var e = document.getElementById("tipoImpresion");
|
|
||||||
elements_negro = document.getElementsByClassName('comp-negro-selected');
|
|
||||||
elements_negrohq = document.getElementsByClassName('comp-negrohq-selected');
|
|
||||||
elements_color = document.getElementsByClassName('comp-color-selected');
|
|
||||||
elements_colorhq = document.getElementsByClassName('comp-colorhq-selected');
|
|
||||||
switch (e.value) {
|
|
||||||
case "negro":
|
|
||||||
Array.from(elements_color).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
});
|
|
||||||
Array.from(elements_negro).forEach(element => {
|
|
||||||
element.style.display = "flex";
|
|
||||||
});
|
|
||||||
Array.from(elements_negrohq).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
});
|
|
||||||
Array.from(elements_colorhq).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "negrohq":
|
|
||||||
Array.from(elements_color).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
|
|
||||||
});
|
|
||||||
Array.from(elements_negro).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
});
|
|
||||||
Array.from(elements_negrohq).forEach(element => {
|
|
||||||
element.style.display = "flex";
|
|
||||||
});
|
|
||||||
Array.from(elements_colorhq).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "color":
|
|
||||||
Array.from(elements_negro).forEach(element => {
|
|
||||||
element.style.display = "flex";
|
|
||||||
});
|
|
||||||
Array.from(elements_negrohq).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
});
|
|
||||||
Array.from(elements_color).forEach(element => {
|
|
||||||
element.style.display = "flex";
|
|
||||||
});
|
|
||||||
Array.from(elements_colorhq).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "colorhq":
|
|
||||||
Array.from(elements_negro).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
});
|
|
||||||
Array.from(elements_negrohq).forEach(element => {
|
|
||||||
element.style.display = "flex";
|
|
||||||
});
|
|
||||||
Array.from(elements_color).forEach(element => {
|
|
||||||
element.style.display = "none";
|
|
||||||
});
|
|
||||||
Array.from(elements_colorhq).forEach(element => {
|
|
||||||
element.style.display = "flex";
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function clearIntLineas(is_color) {
|
|
||||||
//$("#tableCompIntPlana").DataTable().rows( '.selected' ).deselect();
|
|
||||||
var tabla = $('#tableCompIntPlana').DataTable();
|
|
||||||
tabla
|
|
||||||
.rows(function (idx, data, node) {
|
|
||||||
return data['tipo'].includes(is_color ? 'color' : 'bn');
|
|
||||||
})
|
|
||||||
.remove()
|
|
||||||
.draw();
|
|
||||||
//$('#tableCompIntPlana').DataTable().clear().draw();
|
|
||||||
$('#insertarPlanaBtn').css('display', 'none');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function clearCubierta() {
|
|
||||||
|
|
||||||
var tabla = $('#tableCompCubierta').DataTable();
|
|
||||||
tabla
|
|
||||||
.rows(function (idx, data, node) {
|
|
||||||
return data['tipo'] === 'cubierta';
|
|
||||||
})
|
|
||||||
.remove()
|
|
||||||
.draw();
|
|
||||||
if(tabla.rows().count()==0)
|
|
||||||
$('#insertarCubiertaBtn').css('display', 'none');
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearSobrecubierta() {
|
|
||||||
|
|
||||||
|
|
||||||
var tabla = $('#tableCompCubierta').DataTable();
|
|
||||||
tabla
|
|
||||||
.rows(function (idx, data, node) {
|
|
||||||
return data['tipo'] === 'sobrecubierta';
|
|
||||||
})
|
|
||||||
.remove()
|
|
||||||
.draw();
|
|
||||||
if(tabla.rows().count()==0)
|
|
||||||
$('#insertarCubiertaBtn').css('display', 'none');
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearGuardas() {
|
|
||||||
|
|
||||||
$('#tableCompGuardas').DataTable().clear().draw();
|
|
||||||
$('#insertarGuardasBtn').css('display', 'none');
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearIntRot() {
|
|
||||||
|
|
||||||
$('#errorComRot').html('');
|
|
||||||
$('#tableCompIntRotativa').DataTable().clear().draw();
|
|
||||||
$('#insertarRotativaBtn').css('display', 'none');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function selectIntLineas() {
|
|
||||||
var negro_selected = false;
|
|
||||||
var color_selected = false;
|
|
||||||
$("#tableCompIntPlana").DataTable().rows('.selected').deselect();
|
|
||||||
$("#tableCompIntPlana").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
|
||||||
if (!negro_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('bn')) {
|
|
||||||
$("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
|
||||||
negro_selected = true;
|
|
||||||
}
|
|
||||||
if (!color_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('color')) {
|
|
||||||
$("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
|
||||||
color_selected = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var table = $("#tableCompIntPlana").DataTable();
|
|
||||||
var rows = table.rows('.selected').indexes();
|
|
||||||
var data = table.rows(rows).data();
|
|
||||||
|
|
||||||
var value_total = 0.00;
|
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
|
|
||||||
value_total += parseFloat(data[i]['total'])
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#total_comp_plana').html(value_total.toFixed(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectIntRotLineas() {
|
|
||||||
|
|
||||||
$("#tableCompIntRotativa").DataTable().rows('.selected').deselect();
|
|
||||||
|
|
||||||
let value_total = 0.00;
|
|
||||||
|
|
||||||
if ($("#tableCompIntRotativa").DataTable().rows().count() > 0) {
|
|
||||||
|
|
||||||
$("#tableCompIntRotativa").DataTable().row(0).nodes().to$().toggleClass('selected');
|
|
||||||
value_total = parseFloat($("#tableCompIntRotativa").DataTable().rows(0).data()[0]['total'])
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$('#total_comp_rot').html(value_total.toFixed(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectCubiertaLineas() {
|
|
||||||
|
|
||||||
$("#tableCompCubierta").DataTable().rows('.selected').deselect();
|
|
||||||
|
|
||||||
cubierta_selected = false;
|
|
||||||
sobrecubierta_selected = false;
|
|
||||||
|
|
||||||
if ($("#tableCompCubierta").DataTable().rows().count() > 0) {
|
|
||||||
|
|
||||||
$("#tableCompCubierta").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
|
||||||
if (!cubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'cubierta') {
|
|
||||||
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
|
||||||
cubierta_selected = true;
|
|
||||||
}
|
|
||||||
if (!sobrecubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'sobrecubierta') {
|
|
||||||
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
|
||||||
sobrecubierta_selected = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var table = $("#tableCompCubierta").DataTable();
|
|
||||||
var rows = table.rows('.selected').indexes();
|
|
||||||
var data = table.rows(rows).data();
|
|
||||||
|
|
||||||
var value_total = 0.00;
|
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
|
|
||||||
value_total += parseFloat(data[i]['total'])
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$('#total_comp_cubierta').html(value_total.toFixed(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectGuardasLineas() {
|
|
||||||
|
|
||||||
$("#tableCompGuardas").DataTable().rows('.selected').deselect();
|
|
||||||
|
|
||||||
let value_total = 0.00;
|
|
||||||
|
|
||||||
if ($("#tableCompGuardas").DataTable().rows().count() > 0) {
|
|
||||||
|
|
||||||
$("#tableCompGuardas").DataTable().row(0).nodes().to$().toggleClass('selected');
|
|
||||||
value_total = parseFloat($("#tableCompGuardas").DataTable().rows(0).data()[0]['total'])
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$('#total_comp_guardas').html(value_total.toFixed(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIDsComparador(is_color, is_hq) {
|
|
||||||
|
|
||||||
if (!is_color) {
|
|
||||||
if (is_hq) {
|
|
||||||
var papel = '#compPapelNegrohq';
|
|
||||||
var gramaje = '#compGramajeNegrohq';
|
|
||||||
var paginas = '#compPaginasNegrohq';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var papel = '#compPapelNegro';
|
|
||||||
var gramaje = '#compGramajeNegro';
|
|
||||||
var paginas = '#compPaginasNegro';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (is_hq) {
|
|
||||||
var papel = '#compPapelColorhq';
|
|
||||||
var gramaje = '#compGramajeColorhq';
|
|
||||||
var paginas = '#compPaginasColorhq';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var papel = '#compPapelColor';
|
|
||||||
var gramaje = '#compGramajeColor';
|
|
||||||
var paginas = '#compPaginasColor';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
papel: papel,
|
|
||||||
gramaje: gramaje,
|
|
||||||
paginas: paginas,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDimensionLibro() {
|
|
||||||
var ancho = 0;
|
|
||||||
var alto = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if ($('#papelFormatoId').select2('data').length > 0) {
|
|
||||||
if ($('#papelFormatoId').select2('data')[0].id.length > 0) {
|
|
||||||
ancho = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[0]);
|
|
||||||
alto = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[1]);
|
|
||||||
}
|
|
||||||
else if (document.getElementById('papelFormatoPersonalizado').checked) {
|
|
||||||
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
|
|
||||||
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (document.getElementById('papelFormatoPersonalizado').checked) {
|
|
||||||
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
|
|
||||||
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
ancho: ancho,
|
|
||||||
alto: alto
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkInputsForRotativa() {
|
|
||||||
|
|
||||||
// Si es color, el gramaje y el papel tiene que ser el mismo
|
|
||||||
try {
|
|
||||||
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
|
||||||
if ($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id &&
|
|
||||||
$('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim()) {
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ($('#tipoImpresion').select2('data')[0].id == 'negro') {
|
|
||||||
if ($('#compPapelNegro').select2('data')[0].id.length > 0 &&
|
|
||||||
$('#compGramajeNegro').select2('data')[0].text.length > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function fillIntPlana(data, is_color, is_hq) {
|
|
||||||
let sorted = data.lineas.sort(
|
|
||||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
|
||||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
|
||||||
sorted.forEach(function (linea) {
|
|
||||||
if (typeof linea.error == "undefined")
|
|
||||||
$('#tableCompIntPlana').DataTable().row
|
|
||||||
.add(getRowFromLineaInt(is_color ? (is_hq ? 'colorhq' : 'color') : (is_hq ? 'bnhq' : 'bn'), linea))
|
|
||||||
.draw()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillIntRot(data) {
|
|
||||||
let sorted = data.lineas.sort(
|
|
||||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
|
||||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
|
||||||
sorted.forEach(function (linea) {
|
|
||||||
if (typeof linea.error == "undefined") {
|
|
||||||
$('#tableCompIntRotativa').DataTable().row
|
|
||||||
.add(getRowFromLineaRot(linea))
|
|
||||||
.draw()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillCubierta(data) {
|
|
||||||
|
|
||||||
let sorted = data.lineas.sort(
|
|
||||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
|
||||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
|
||||||
sorted.forEach(function (linea) {
|
|
||||||
if (typeof linea.error == "undefined")
|
|
||||||
$('#tableCompCubierta').DataTable().row
|
|
||||||
.add(getRowFromLineaInt('cubierta', linea))
|
|
||||||
.draw()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillSobrecubierta(data) {
|
|
||||||
|
|
||||||
let sorted = data.lineas.sort(
|
|
||||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
|
||||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
|
||||||
sorted.forEach(function (linea) {
|
|
||||||
if (typeof linea.error == "undefined")
|
|
||||||
$('#tableCompCubierta').DataTable().row
|
|
||||||
.add(getRowFromLineaInt('sobrecubierta', linea))
|
|
||||||
.draw()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillGuardas(data) {
|
|
||||||
|
|
||||||
let sorted = data.lineas.sort(
|
|
||||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
|
||||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
|
||||||
sorted.forEach(function (linea) {
|
|
||||||
if (typeof linea.error == "undefined")
|
|
||||||
$('#tableCompGuardas').DataTable().row
|
|
||||||
.add(getRowFromLineaInt('guardas', linea))
|
|
||||||
.draw()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearCompTable() {
|
|
||||||
|
|
||||||
$('#insertarPlanaBtn').addClass('d-none')
|
|
||||||
$('#insertarRotativaBtn').addClass('d-none')
|
|
||||||
$('#total_comp_plana').html('0.00')
|
|
||||||
$('#total_comp_rot').html('0.00')
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateCompJSON() {
|
|
||||||
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') {
|
|
||||||
try {
|
|
||||||
bn_obj = {
|
|
||||||
"bn": {
|
|
||||||
'paginas': $('#compPaginasNegro').val(),
|
|
||||||
'papel_id': $('#compPapelNegro').select2('data')[0].id,
|
|
||||||
'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
bn_obj = {}
|
|
||||||
}
|
|
||||||
$.extend(data, bn_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
|
||||||
try {
|
|
||||||
bnhq_obj = {
|
|
||||||
"bnhq": {
|
|
||||||
'paginas': $('#compPaginasNegrohq').val(),
|
|
||||||
'papel_id': $('#compPapelNegrohq').select2('data')[0].id,
|
|
||||||
'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
bnhq_obj = {}
|
|
||||||
}
|
|
||||||
$.extend(data, bnhq_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
|
||||||
try {
|
|
||||||
color_obj = {
|
|
||||||
"color": {
|
|
||||||
'paginas': $('#compPaginasColor').val(),
|
|
||||||
'papel_id': $('#compPapelColor').select2('data')[0].id,
|
|
||||||
'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
color_obj = {}
|
|
||||||
}
|
|
||||||
$.extend(data, color_obj);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
|
||||||
try {
|
|
||||||
colorhq_obj = {
|
|
||||||
"colorhq": {
|
|
||||||
'paginas': $('#compPaginasColorhq').val(),
|
|
||||||
'papel_id': $('#compPapelColorhq').select2('data')[0].id,
|
|
||||||
'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
colorhq_obj = {}
|
|
||||||
}
|
|
||||||
$.extend(data, colorhq_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
cubierta_obj = {
|
|
||||||
"cubierta": {
|
|
||||||
'paginas': $('#compCarasCubierta option:selected').val(),
|
|
||||||
'papel_id': $('#compPapelCubierta').select2('data')[0].id,
|
|
||||||
'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
cubierta_obj = {}
|
|
||||||
}
|
|
||||||
$.extend(data, cubierta_obj);
|
|
||||||
|
|
||||||
try {
|
|
||||||
sobrecubierta_obj = {
|
|
||||||
"sobrecubierta": {
|
|
||||||
'imprimir': $('#compSobrecubierta option:selected').val(),
|
|
||||||
'papel_id': $('#compPapelSobrecubierta').select2('data')[0].id,
|
|
||||||
'gramaje': $('#compGramajeSobrecubierta').select2('data')[0].text.trim(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
sobrecubierta_obj = {}
|
|
||||||
}
|
|
||||||
$.extend(data, sobrecubierta_obj);
|
|
||||||
|
|
||||||
if($('#compCarasGuardas').length>0){
|
|
||||||
try {
|
|
||||||
guardas_obj = {
|
|
||||||
"guardas": {
|
|
||||||
'paginas_impresion': $('#compCarasGuardas option:selected').val(),
|
|
||||||
'papel_id': $('#compPapelGuardas').select2('data')[0].id,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
guardas_obj = {}
|
|
||||||
}
|
|
||||||
$.extend(data, guardas_obj);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
data_str = JSON.stringify(data)
|
|
||||||
$('#comparador_json_data').val(data_str)
|
|
||||||
}
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -6,25 +6,31 @@
|
|||||||
|
|
||||||
<?= $this->section("content") ?>
|
<?= $this->section("content") ?>
|
||||||
|
|
||||||
<div class="row">
|
<div id="mainContainer" class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||||
<form id="presupuestoForm" class="card-body" method="post" action="<?= $formAction ?>">
|
<form id="presupuestoForm" class="card-body" method="post" action="<?= $formAction ?>">
|
||||||
|
|
||||||
<?= csrf_field() ?>
|
<?= csrf_field() ?>
|
||||||
|
|
||||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||||
|
<?= view("themes/vuexy/form/presupuestos/cliente/loader") ?>
|
||||||
|
|
||||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||||
<input type="hidden" name="presupuesto_id" id="presupuesto_id" class="form-control"
|
|
||||||
value="<?= $presupuestoEntity->id ?>"></input>
|
|
||||||
<input type="hidden" name="tipo_impresion_id" id="tipo_impresion_id" class="form-control"
|
<input type="hidden" name="tipo_impresion_id" id="tipo_impresion_id" class="form-control"
|
||||||
value="<?= $tipo_impresion_id ?>"></input>
|
value="<?= $tipo_impresion_id ?>"></input>
|
||||||
<input type="hidden" name="lomo_cubierta" id="lomo_cubierta" class="form-control"
|
<input type="hidden" name="lomo" id="lomo" class="form-control" value=""></input>
|
||||||
value="<?= is_null($presupuestoEntity->lomo_cubierta)?0:$presupuestoEntity->lomo_cubierta ?>"></input>
|
<input type="hidden" name="lomo_cubierta" id="lomo_cubierta" class="form-control" value=""></input>
|
||||||
<input type="hidden" name="lomo_sobrecubierta" id="lomo_sobrecubierta" class="form-control"
|
<input type="hidden" name="lomo_sobrecubierta" id="lomo_sobrecubierta" class="form-control" value=""></input>
|
||||||
value="<?= is_null($presupuestoEntity->lomo_sobrecubierta)?0:$presupuestoEntity->lomo_sobrecubierta ?>"></input>
|
|
||||||
<input type="hidden" name="isCosido" id="isCosido" class="form-control"
|
<input type="hidden" name="isCosido" id="isCosido" class="form-control"
|
||||||
value="<?= $isCosido ?>"></input>
|
value="<?= $isCosido ?>"></input>
|
||||||
|
|
||||||
|
<input type="hidden" name="presupuesto_id" id="presupuesto_id" class="form-control"
|
||||||
|
value="<?= $presupuestoEntity->id ?>"></input>
|
||||||
|
|
||||||
<input type="hidden" name="POD" id="POD" class="form-control"
|
<input type="hidden" name="POD" id="POD" class="form-control"
|
||||||
value="<?= $POD ?>"></input>
|
value="<?= $POD ?>"></input>
|
||||||
|
|
||||||
<?= view("themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems") ?>
|
<?= view("themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems") ?>
|
||||||
<?= view("themes/vuexy/form/presupuestos/admin/_datosLibroItems") ?>
|
<?= view("themes/vuexy/form/presupuestos/admin/_datosLibroItems") ?>
|
||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
<?php if (str_contains($formAction, 'edit')): ?>
|
||||||
@ -169,103 +175,19 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#clienteId').select2({
|
|
||||||
allowClear: false,
|
|
||||||
ajax: {
|
|
||||||
url: '<?= route_to("menuItemsOfClientes") ?>',
|
|
||||||
type: 'post',
|
|
||||||
dataType: 'json',
|
|
||||||
|
|
||||||
data: function(params) {
|
|
||||||
return {
|
|
||||||
id: 'id',
|
|
||||||
text: 'nombre',
|
|
||||||
searchTerm: params.term,
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
|
||||||
};
|
|
||||||
},
|
|
||||||
delay: 60,
|
|
||||||
processResults: function(response) {
|
|
||||||
yeniden(response.<?= csrf_token() ?>);
|
|
||||||
return {
|
|
||||||
results: response.menu
|
|
||||||
};
|
|
||||||
},
|
|
||||||
cache: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/*******************************
|
|
||||||
* Inicialización de los Select2
|
|
||||||
*******************************/
|
|
||||||
$('#incRei').select2({
|
|
||||||
allowClear: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#paisId').select2({
|
|
||||||
allowClear: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
<!------------------------------------------------------->
|
|
||||||
<!-- Código JS para detectar cambios en el presupuesto -->
|
|
||||||
<!------------------------------------------------------->
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
|
|
||||||
$(window).on('load', function() {
|
|
||||||
|
|
||||||
// Detectar cambios en inputs de texto
|
|
||||||
$('input[type="text"]').on('input', function() {
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Detectar cambios en inputs de texto
|
|
||||||
$('input[type="number"]').on('input', function() {
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Detectar cambios en select
|
|
||||||
$('select').change(function() {
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Detectar cambios en checkboxes
|
|
||||||
$('input[type="checkbox"]').change(function() {
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Detectar cambios en textareas
|
|
||||||
$('textarea').on('input', function() {
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Detectar cambios en otros tipos de input
|
|
||||||
$('input[type="radio"]').change(function() {
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Detectar cambios en otros tipos de input
|
|
||||||
$('input:not([type])').on('input', function() {
|
|
||||||
showBreadCrumbSaveButton(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#bc-save').on( "click", function() {
|
|
||||||
showBreadCrumbSaveButton(false);
|
|
||||||
$('#saveForm').click()
|
|
||||||
} );
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
|
|
||||||
<!------------------------------------------->
|
<!------------------------------------------->
|
||||||
<!-- Acciones antes de submit... -->
|
<!-- Acciones antes de submit... -->
|
||||||
<!------------------------------------------->
|
<!------------------------------------------->
|
||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
<?php if (str_contains($formAction, 'edit')): ?>
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
|
<?php /*
|
||||||
|
|
||||||
var submitButtonClicked; // Variable para almacenar el botón que fue clickeado
|
var submitButtonClicked; // Variable para almacenar el botón que fue clickeado
|
||||||
|
|
||||||
@ -314,7 +236,7 @@ $('#bc-save').on( "click", function() {
|
|||||||
|
|
||||||
return false; //stop the actual form post !important!
|
return false; //stop the actual form post !important!
|
||||||
});
|
});
|
||||||
|
*/ ?>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
@ -350,17 +272,6 @@ $('#bc-save').on( "click", function() {
|
|||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<!------------------------------------------->
|
|
||||||
<!-- Variables generales usadas en los ficheros js -->
|
|
||||||
<!------------------------------------------->
|
|
||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
|
|
||||||
window.token_ajax= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
|
|
||||||
window.csrf_token = '<?= csrf_token() ?>';
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -370,6 +281,7 @@ $('#bc-save').on( "click", function() {
|
|||||||
<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/buttons/buttons.bootstrap5.min.css") ?>">
|
||||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/sk-datatables.css') ?>">
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/sk-datatables.css') ?>">
|
||||||
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/presupuestoCliente.css') ?>">
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
<?= $this->section('additionalExternalJs') ?>
|
<?= $this->section('additionalExternalJs') ?>
|
||||||
@ -380,18 +292,14 @@ $('#bc-save').on( "click", function() {
|
|||||||
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/select/dataTables.select.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/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/autosize/autosize.js') ?>"></script>
|
||||||
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
|
|
||||||
<script src="<?= site_url('js_loader/datosLibro_js') ?>"></script>
|
|
||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
<?php if (str_contains($formAction, 'edit')): ?>
|
||||||
<script src="<?= site_url('js_loader/datosEnvios_js') ?>"></script>
|
|
||||||
<script src="<?= site_url('js_loader/resumenPresupuestos_js') ?>"></script>
|
|
||||||
<script src="<?= site_url('js_loader/presupuestos_js') ?>"></script>
|
|
||||||
<script src="<?= site_url('js_loader/comparadorPresupuestoAdmin_js') ?>"></script>
|
|
||||||
<script src="<?= site_url('js_loader/previsualizador_js') ?>"></script>
|
|
||||||
<script src="<?= site_url('js_loader/lineasPresupuesto_js') ?>"></script>
|
|
||||||
<script src="<?= site_url('js_loader/tiradasAlternativas_js') ?>"></script>
|
|
||||||
<script src="<?= site_url('js_loader/datosServicios_js') ?>"></script>
|
|
||||||
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
|
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
|
||||||
<script src="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') ?>"></script>
|
<script src="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') ?>"></script>
|
||||||
|
|
||||||
|
<script type="module" src="<?= site_url('assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js') ?>"></script>
|
||||||
|
<?php else: ?>
|
||||||
|
<script type="module" src="<?= site_url('assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminAdd.js') ?>"></script>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
<input readonly hidden id="lomo_minimo_fresado_cosido" value="<?= $lomo_minimo_fresado_cosido ?>"></input>
|
<input readonly hidden id="lomo_minimo_fresado_cosido" value="<?= $lomo_minimo_fresado_cosido ?>"></input>
|
||||||
<input readonly hidden id="pod" value="<?= $POD ?>"></input>
|
<input readonly hidden id="pod" value="<?= $POD ?>"></input>
|
||||||
<input readonly hidden id="c" value="<?= $clienteId ?>"></input>
|
<input readonly hidden id="c" value="<?= $clienteId ?>"></input>
|
||||||
|
<input readonly hidden id="eb" value="<?= $eb ?>"></input>
|
||||||
|
|
||||||
<!-- Create Deal Wizard -->
|
<!-- Create Deal Wizard -->
|
||||||
<div id="wizard-presupuesto-cliente" class="bs-stepper vertical mt-2 linear">
|
<div id="wizard-presupuesto-cliente" class="bs-stepper vertical mt-2 linear">
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
class previewFormas {
|
class previewFormas {
|
||||||
|
|
||||||
constructor(container, tipoLibro, tipoTapa, size, datos) {
|
constructor(container, tipoLibro, tipoTapa, size, datos) {
|
||||||
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
@ -10,6 +10,40 @@ class previewFormas {
|
|||||||
this.ancho = datos.ancho;
|
this.ancho = datos.ancho;
|
||||||
this.alto = datos.alto;
|
this.alto = datos.alto;
|
||||||
this.lomo = datos.lomo;
|
this.lomo = datos.lomo;
|
||||||
|
this.lomoSobrecubierta = datos.lomoSobrecubierta;
|
||||||
|
|
||||||
|
if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) {
|
||||||
|
this.solapa = 0;
|
||||||
|
this.offsetSolapa = 0.0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.solapa = datos.solapas;
|
||||||
|
this.offsetSolapa = 3.0;
|
||||||
|
}
|
||||||
|
if (datos.solapas_sobrecubierta == undefined || datos.solapas_sobrecubierta == null || datos.solapas_sobrecubierta == false) {
|
||||||
|
this.solapas_sobrecubierta = 0;
|
||||||
|
this.offsetSolapa_sobrecubierta = 0.0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.solapa_sobrecubierta = datos.solapas_sobrecubierta;
|
||||||
|
this.offsetSolapa_sobrecubierta = 3.0;
|
||||||
|
}
|
||||||
|
this.lomoRedondo = datos.lomoRedondo;
|
||||||
|
|
||||||
|
this.pvObj = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setContainer(container) {
|
||||||
|
this.container = container;
|
||||||
|
}
|
||||||
|
|
||||||
|
setData(datos) {
|
||||||
|
|
||||||
|
this.ancho = datos.ancho;
|
||||||
|
this.alto = datos.alto;
|
||||||
|
this.lomo = datos.lomo;
|
||||||
|
this.lomoSobrecubierta = datos.lomoSobrecubierta;
|
||||||
|
|
||||||
if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) {
|
if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) {
|
||||||
this.solapa = 0;
|
this.solapa = 0;
|
||||||
@ -20,6 +54,384 @@ class previewFormas {
|
|||||||
this.offsetSolapa = 3.0;
|
this.offsetSolapa = 3.0;
|
||||||
}
|
}
|
||||||
this.lomoRedondo = datos.lomoRedondo;
|
this.lomoRedondo = datos.lomoRedondo;
|
||||||
|
}
|
||||||
|
|
||||||
|
getObjetoLP(lpName, _isCosido, _isTapaDura) {
|
||||||
|
|
||||||
|
let rowData = null;
|
||||||
|
|
||||||
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
|
||||||
|
let lineaPresupuestoId = this.data().row_id.replace('lp_', '');
|
||||||
|
|
||||||
|
switch (lpName) {
|
||||||
|
case 'bn':
|
||||||
|
case 'bnhq':
|
||||||
|
case 'color':
|
||||||
|
case 'colorhq':
|
||||||
|
case 'cubierta':
|
||||||
|
case 'rot_bn':
|
||||||
|
case 'rot_color':
|
||||||
|
case 'guardas':
|
||||||
|
case 'sobrecubierta':
|
||||||
|
if (lineaPresupuestoId === lpName) {
|
||||||
|
rowData = this.data();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'ec':
|
||||||
|
if (lineaPresupuestoId === 'cubierta') {
|
||||||
|
rowData = this.data();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//console.log(lineaPresupuestoId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.pvObj = {
|
||||||
|
idIndex: lpName,
|
||||||
|
tipoImpresion: parseInt($('#tipo_impresion_id').val()),
|
||||||
|
gramajeLibro: parseInt(rowData.gramaje),
|
||||||
|
manoLP: parseFloat(rowData.lomo),
|
||||||
|
lomoLibro: this.lomo(),
|
||||||
|
lomoLibroSobrecubierta: this.lomoSobrecubierta(),
|
||||||
|
anchoSolapa: $('#solapas').is(':checked') ? parseFloat($('#solapas_ancho').val()) : parseFloat(0),
|
||||||
|
nFormas: parseInt(rowData.formas),
|
||||||
|
nFormasH: parseInt(rowData.formas_h),
|
||||||
|
nFormasV: parseInt(rowData.formas_v),
|
||||||
|
orientacionFormas: rowData.formas_orientacion,
|
||||||
|
altoMaquina: parseFloat(rowData.maquina_alto),
|
||||||
|
anchoMaquina: parseFloat(rowData.maquina_ancho),
|
||||||
|
altoImpresion: parseFloat(rowData.maquina_impresion_alto),
|
||||||
|
anchoImpresion: parseFloat(rowData.maquina_impresion_ancho),
|
||||||
|
altoLibro: this.alto(),
|
||||||
|
anchoLibro: this.ancho(),
|
||||||
|
offsetSolapa: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
//console.log(pvObj);
|
||||||
|
|
||||||
|
// Printing shape definition
|
||||||
|
this.pvObj.anchoForma = (_isCosido) ? 2 * this.pvObj.anchoLibro : this.pvObj.anchoLibro;
|
||||||
|
this.pvObj.altoForma = this.pvObj.altoLibro;
|
||||||
|
|
||||||
|
|
||||||
|
// Update preview info fields
|
||||||
|
let pvName = '#pv_' + lpName;
|
||||||
|
$(pvName + '_pg').attr("href", $(pvName + '_pg').attr('sk-url') + rowData.papel);
|
||||||
|
$(pvName + '_pi').attr("href", $(pvName + '_pi').attr('sk-url') + rowData.papel_impresion_id);
|
||||||
|
$(pvName + '_mi').attr("href", $(pvName + '_mi').attr('sk-url') + rowData.maquina_id);
|
||||||
|
|
||||||
|
$(pvName + '_gramaje').text(this.pvObj.gramajeLibro);
|
||||||
|
$(pvName + '_mano').text(this.pvObj.manoLP);
|
||||||
|
$(pvName + '_solapas').text(this.pvObj.anchoSolapa);
|
||||||
|
$(pvName + '_maquina').text(this.pvObj.anchoMaquina + "x" + this.pvObj.altoMaquina);
|
||||||
|
$(pvName + '_maquina_impresion').text(this.pvObj.anchoImpresion + "x" + this.pvObj.altoImpresion);
|
||||||
|
$(pvName + '_libro').text(this.pvObj.anchoLibro + "x" + this.pvObj.altoLibro);
|
||||||
|
$(pvName + '_forma').text(this.pvObj.anchoForma + "x" + this.pvObj.altoForma);
|
||||||
|
$(pvName + '_nFormas').text(this.pvObj.nFormas);
|
||||||
|
|
||||||
|
if (this.pvObj.anchoSolapa != 0) {
|
||||||
|
$('.pv-solapas').show();
|
||||||
|
this.pvObj.offsetSolapa = parseFloat(3); // 3mm
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom overwrites
|
||||||
|
switch (this.pvObj.idIndex) {
|
||||||
|
case 'cubierta':
|
||||||
|
// Fresado TD or Cosido TD
|
||||||
|
if (this.pvObj.tipoImpresion === 1 || this.pvObj.tipoImpresion === 3) {
|
||||||
|
let anchoPliegue = parseFloat(7); // mm
|
||||||
|
let altoPliegue = parseFloat(7); // mm
|
||||||
|
let sangre = parseFloat(20); // mm
|
||||||
|
if (this.isTapaDura && (this.ancho() >= 210 || this.alto() >= 297)) {
|
||||||
|
sangre = parseFloat(10); // mm
|
||||||
|
}
|
||||||
|
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * sangre) + this.pvObj.lomoLibro);
|
||||||
|
this.pvObj.altoForma += altoPliegue + (2 * sangre);
|
||||||
|
}
|
||||||
|
// Fresado TB y Cosido TB
|
||||||
|
else if (this.pvObj.tipoImpresion === 2 || this.pvObj.tipoImpresion === 4) {
|
||||||
|
let sangre = parseFloat(5); // mm
|
||||||
|
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * (this.pvObj.anchoSolapa + this.pvObj.offsetSolapa)) + (2 * sangre) + this.pvObj.lomoLibro);
|
||||||
|
this.pvObj.altoForma += (2 * sangre);
|
||||||
|
}
|
||||||
|
// Grapado
|
||||||
|
else if (this.pvObj.tipoImpresion === 21) {
|
||||||
|
let sangre = parseFloat(5); // mm
|
||||||
|
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * (this.pvObj.anchoSolapa + this.pvObj.offsetSolapa)) + (2 * sangre));
|
||||||
|
this.pvObj.altoForma += (2 * sangre);
|
||||||
|
}
|
||||||
|
// Espiral TD y TB, Wire-o TD y TB
|
||||||
|
else if (this.pvObj.tipoImpresion === 5 || this.pvObj.tipoImpresion === 6 ||
|
||||||
|
this.pvObj.tipoImpresion === 7 || this.pvObj.tipoImpresion === 8) {
|
||||||
|
let sangre = parseFloat(20); // mm
|
||||||
|
this.pvObj.anchoForma = this.pvObj.anchoLibro;
|
||||||
|
} else {
|
||||||
|
// ?
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update labels
|
||||||
|
$(pvName + '_forma').text(this.pvObj.anchoForma + "x" + this.pvObj.altoForma);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'sobrecubierta':
|
||||||
|
let sangre = parseFloat(5); // mm
|
||||||
|
let anchoSolapaSobrecubierta = $('#solapas_sobrecubierta').is(':checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : parseFloat(0); // mm
|
||||||
|
if (_isTapaDura) {
|
||||||
|
let anchoPliegue = parseFloat(7); // mm
|
||||||
|
let altoPliegue = parseFloat(7); // mm
|
||||||
|
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * (anchoSolapaSobrecubierta + this.pvObj.offsetSolapa)) + (2 * sangre) + this.pvObj.lomoLibroSobrecubierta);
|
||||||
|
this.pvObj.altoForma += altoPliegue + (2 * sangre);
|
||||||
|
} else {
|
||||||
|
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * (anchoSolapaSobrecubierta + this.pvObj.offsetSolapa)) + (2 * sangre) + this.pvObj.lomoLibroSobrecubierta);
|
||||||
|
this.pvObj.altoForma += (2 * sangre);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update labels
|
||||||
|
$(pvName + '_solapas').text(anchoSolapaSobrecubierta);
|
||||||
|
anchoSolapaSobrecubierta != 0 ? $('.pv-solapas').show() : $('.pv-solapas').hide();
|
||||||
|
$(pvName + '_forma').text(this.pvObj.anchoForma + "x" + this.pvObj.altoForma);
|
||||||
|
break;
|
||||||
|
case 'ec':
|
||||||
|
$(pvName + '_pg').attr("href", $(pvName + '_pg').attr('sk-url') + rowData.papel);
|
||||||
|
$(pvName + '_pi').attr("href", $(pvName + '_pi').attr('sk-url') + rowData.papel_impresion_id);
|
||||||
|
$(pvName + '_mi').attr("href", $(pvName + '_mi').attr('sk-url') + rowData.maquina_id);
|
||||||
|
$('#pv_ec_lomo').text(this.pvObj.lomoLibro);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'rot_bn':
|
||||||
|
case 'rot_color':
|
||||||
|
// Conditional assignements depending on rotation of the printing shape
|
||||||
|
if (this.pvObj.orientacionFormas == 'v') {
|
||||||
|
let auxReg = this.pvObj.altoForma;
|
||||||
|
this.pvObj.altoForma = this.pvObj.anchoForma;
|
||||||
|
this.pvObj.anchoForma = auxReg;
|
||||||
|
}
|
||||||
|
$(pvName + '_forma').text(this.pvObj.anchoForma + "x" + this.pvObj.altoForma);
|
||||||
|
this.pvObj.altoClick = isNaN(parseFloat(rowData.alto_click)) ? 305 : parseFloat(rowData.alto_click);
|
||||||
|
this.pvObj.nFormasH = Math.trunc(this.pvObj.anchoImpresion / this.pvObj.anchoForma);
|
||||||
|
this.pvObj.nFormasV = Math.trunc((this.pvObj.altoImpresion - 3) / (this.pvObj.altoForma + 4));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'bn':
|
||||||
|
case 'bnhq':
|
||||||
|
case 'color':
|
||||||
|
case 'colorhq':
|
||||||
|
// Conditional assignements depending on rotation of the printing shape
|
||||||
|
if (this.pvObj.orientacionFormas == 'v') {
|
||||||
|
let auxReg = this.pvObj.altoForma;
|
||||||
|
this.pvObj.altoForma = this.pvObj.anchoForma;
|
||||||
|
this.pvObj.anchoForma = auxReg;
|
||||||
|
}
|
||||||
|
$(pvName + '_forma').text(this.pvObj.anchoForma + "x" + this.pvObj.altoForma);
|
||||||
|
break;
|
||||||
|
case 'guardas':
|
||||||
|
// Fresado TD y Cosido TD
|
||||||
|
if (this.pvObj.tipoImpresion === 1 || this.pvObj.tipoImpresion === 3) {
|
||||||
|
this.pvObj.anchoForma = 2 * this.pvObj.anchoLibro;
|
||||||
|
}
|
||||||
|
// Fresado TB y Cosido TB
|
||||||
|
else if (this.pvObj.tipoImpresion === 2 || this.pvObj.tipoImpresion === 4) {
|
||||||
|
this.pvObj.anchoForma = this.pvObj.anchoLibro;
|
||||||
|
}
|
||||||
|
// Espiral TD y TB, Wire-o TD y TB
|
||||||
|
else if (this.pvObj.tipoImpresion === 5 || this.pvObj.tipoImpresion === 6 ||
|
||||||
|
this.pvObj.tipoImpresion === 7 || this.pvObj.tipoImpresion === 8) {
|
||||||
|
this.pvObj.anchoForma = this.pvObj.anchoLibro;
|
||||||
|
} else {
|
||||||
|
// ?
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conditional assignements depending on rotation of the printing shape
|
||||||
|
if (this.pvObj.orientacionFormas == 'v') {
|
||||||
|
let auxReg = this.pvObj.altoForma;
|
||||||
|
this.pvObj.altoForma = this.pvObj.anchoForma;
|
||||||
|
this.pvObj.anchoForma = auxReg;
|
||||||
|
}
|
||||||
|
$(pvName + '_forma').text(this.pvObj.anchoForma + "x" + this.pvObj.altoForma);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
previewInteriorPlana(lpTagName, isCosido, isTapaDura) {
|
||||||
|
|
||||||
|
// Local parameters
|
||||||
|
let guardaV = 0;
|
||||||
|
let guardaH = 0;
|
||||||
|
let styleText = { size: 12, family: 'Public Sans' };
|
||||||
|
|
||||||
|
// Get the preview Object parameters
|
||||||
|
this.getObjetoLP(lpTagName, isCosido, isTapaDura);
|
||||||
|
|
||||||
|
// Configuracion de las guardas
|
||||||
|
// Guarda vertical
|
||||||
|
if (this.pvObj.nFormasV > 1) {
|
||||||
|
guardaV = 3;
|
||||||
|
}
|
||||||
|
// Guarda horizontal
|
||||||
|
if (this.pvObj.nFormasH > 1) {
|
||||||
|
guardaH = 3;
|
||||||
|
}
|
||||||
|
// Constantes relativas a las dimnesiones de la forma
|
||||||
|
let LVo = this.pvObj.altoForma / 2;
|
||||||
|
let LHo = this.pvObj.anchoForma / 2;
|
||||||
|
|
||||||
|
// Clear the canvas element
|
||||||
|
$('#pv_' + this.pvObj.idIndex + '_shape').empty();
|
||||||
|
// Get the element for placing the graphical elements
|
||||||
|
var divPlana = document.getElementById('pv_' + this.pvObj.idIndex + '_shape');
|
||||||
|
var _pvPlana = new Two({ fitted: true }).appendTo(divPlana);
|
||||||
|
// Calculate the center of the canvas element
|
||||||
|
var origenPlana = new Two.Vector(_pvPlana.width / 2, _pvPlana.height / 2);
|
||||||
|
|
||||||
|
var areaMaquinaPlana = _pvPlana.makeRectangle(
|
||||||
|
origenPlana.x,
|
||||||
|
origenPlana.y,
|
||||||
|
this.pvObj.anchoMaquina,
|
||||||
|
this.pvObj.altoMaquina);
|
||||||
|
areaMaquinaPlana.stroke = 'black';
|
||||||
|
areaMaquinaPlana.fill = '#E69F6E';
|
||||||
|
areaMaquinaPlana.linewidth = 1;
|
||||||
|
|
||||||
|
var areaImpresionPlana = _pvPlana.makeRectangle(
|
||||||
|
origenPlana.x,
|
||||||
|
origenPlana.y,
|
||||||
|
this.pvObj.anchoImpresion,
|
||||||
|
this.pvObj.altoImpresion);
|
||||||
|
areaImpresionPlana.stroke = 'red';
|
||||||
|
areaImpresionPlana.fill = '#FCEAF1';
|
||||||
|
areaImpresionPlana.linewidth = 1;
|
||||||
|
|
||||||
|
var formas = [];
|
||||||
|
|
||||||
|
for (let iV = 0; iV < this.pvObj.nFormasV; iV++) {
|
||||||
|
|
||||||
|
for (let iH = 0; iH < this.pvObj.nFormasH; iH++) {
|
||||||
|
|
||||||
|
let _offsetX = ((((this.pvObj.nFormasH - 1) - 2 * iH) * LHo) + (((this.pvObj.nFormasH - 1) / 2 - iH) * guardaH));
|
||||||
|
let _offsetY = ((((this.pvObj.nFormasV - 1) - 2 * iV) * LVo) + (((this.pvObj.nFormasV - 1) / 2 - iV) * guardaV));
|
||||||
|
|
||||||
|
formas[iV + iH] = _pvPlana.makeRectangle(
|
||||||
|
origenPlana.x + _offsetX,
|
||||||
|
origenPlana.y + _offsetY,
|
||||||
|
this.pvObj.anchoForma,
|
||||||
|
this.pvObj.altoForma);
|
||||||
|
formas[iV + iH].stroke = 'grey';
|
||||||
|
formas[iV + iH].fill = '#F4F8F2';
|
||||||
|
formas[iV + iH].linewidth = 1;
|
||||||
|
|
||||||
|
// Texts
|
||||||
|
_pvPlana.makeText(this.pvObj.altoForma, (origenPlana.x + _offsetX) + (this.pvObj.anchoForma / 2 - 25), (origenPlana.y + _offsetY), styleText);
|
||||||
|
_pvPlana.makeText(this.pvObj.anchoForma, (origenPlana.x + _offsetX), (origenPlana.y + _offsetY) + (this.pvObj.altoForma / 2 - 15), styleText);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_pvPlana.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
previewRotativa(lpTagName, isCosido, isTapaDura) {
|
||||||
|
|
||||||
|
// Local parameters
|
||||||
|
let styleText = { size: 12, family: 'Public Sans' };
|
||||||
|
let margenTop = 3;
|
||||||
|
let guardaV = 0;
|
||||||
|
let guardaH = 0;
|
||||||
|
|
||||||
|
// Get the preview Object parameters
|
||||||
|
this.getObjetoLP(lpTagName, isCosido, isTapaDura);
|
||||||
|
|
||||||
|
// Calculos
|
||||||
|
// Configuracion de las guardas
|
||||||
|
// Guarda vertical
|
||||||
|
if (this.pvObj.nFormasV > 1) {
|
||||||
|
guardaV = 3;
|
||||||
|
}
|
||||||
|
// Guarda horizontal
|
||||||
|
if (this.pvObj.nFormasH > 1) {
|
||||||
|
guardaH = 3;
|
||||||
|
}
|
||||||
|
// Constantes relativas al libro
|
||||||
|
let LVo = this.pvObj.altoForma / 2;
|
||||||
|
let LHo = this.pvObj.anchoForma / 2;
|
||||||
|
|
||||||
|
// offset Y
|
||||||
|
let nTopForms = (this.pvObj.altoImpresion / 2.0 - margenTop) / (LVo + guardaV);
|
||||||
|
const int_part = Math.trunc(nTopForms);
|
||||||
|
const float_part = Number((nTopForms - int_part).toFixed(2));
|
||||||
|
let yOffset = LVo * float_part;
|
||||||
|
|
||||||
|
//console.log(yOffset);
|
||||||
|
|
||||||
|
// Clear the canvas element
|
||||||
|
$('#pv_' + this.pvObj.idIndex + '_shape').empty();
|
||||||
|
// Get the element for placing the graphical elements
|
||||||
|
var divRotativa = document.getElementById('pv_' + this.pvObj.idIndex + '_shape');
|
||||||
|
var _pvRotativa = new Two({ fitted: true }).appendTo(divRotativa);
|
||||||
|
// Calculate the center of the canvas element
|
||||||
|
var origenRotativa = new Two.Vector(_pvRotativa.width / 2, _pvRotativa.height / 2);
|
||||||
|
|
||||||
|
var areaMaquinaRotativa = _pvRotativa.makeRectangle(
|
||||||
|
origenRotativa.x,
|
||||||
|
origenRotativa.y,
|
||||||
|
this.pvObj.anchoMaquina,
|
||||||
|
this.pvObj.altoMaquina);
|
||||||
|
areaMaquinaRotativa.stroke = 'black';
|
||||||
|
areaMaquinaRotativa.fill = '#E69F6E';
|
||||||
|
areaMaquinaRotativa.linewidth = 1;
|
||||||
|
|
||||||
|
var areaImpresionRotativa = _pvRotativa.makeRectangle(
|
||||||
|
origenRotativa.x,
|
||||||
|
origenRotativa.y,
|
||||||
|
this.pvObj.anchoImpresion,
|
||||||
|
this.pvObj.altoImpresion);
|
||||||
|
areaImpresionRotativa.stroke = 'red';
|
||||||
|
areaImpresionRotativa.fill = '#FCEAF1';
|
||||||
|
areaImpresionRotativa.linewidth = 1;
|
||||||
|
|
||||||
|
var areaClickRotativa = _pvRotativa.makeRectangle(
|
||||||
|
origenRotativa.x,
|
||||||
|
origenRotativa.y - (this.pvObj.altoImpresion / 2 - this.pvObj.altoClick / 2),
|
||||||
|
this.pvObj.anchoImpresion - 10,
|
||||||
|
this.pvObj.altoClick);
|
||||||
|
areaClickRotativa.stroke = 'blue';
|
||||||
|
//areaClickRotativa.fill = '#FCEAF1';
|
||||||
|
areaClickRotativa.linewidth = 2;
|
||||||
|
|
||||||
|
var formas = [];
|
||||||
|
|
||||||
|
for (let iV = 0; iV < this.pvObj.nFormasV; iV++) {
|
||||||
|
|
||||||
|
for (let iH = 0; iH < this.pvObj.nFormasH; iH++) {
|
||||||
|
|
||||||
|
let _offsetX = ((((this.pvObj.nFormasH - 1) - 2 * iH) * LHo) + (((this.pvObj.nFormasH - 1) / 2 - iH) * guardaH));
|
||||||
|
let _offsetY = ((((this.pvObj.nFormasV - 1) - 2 * iV) * LVo) + (((this.pvObj.nFormasV - 1) / 2 - iV) * guardaV));
|
||||||
|
|
||||||
|
formas[iV + iH] = _pvRotativa.makeRectangle(
|
||||||
|
origenRotativa.x + _offsetX,
|
||||||
|
(origenRotativa.y - yOffset) + _offsetY,
|
||||||
|
this.pvObj.anchoForma,
|
||||||
|
this.pvObj.altoForma);
|
||||||
|
formas[iV + iH].stroke = 'grey';
|
||||||
|
formas[iV + iH].fill = '#F4F8F2';
|
||||||
|
formas[iV + iH].linewidth = 1;
|
||||||
|
|
||||||
|
// Texts
|
||||||
|
_pvRotativa.makeText(this.pvObj.altoForma, (origenRotativa.x + _offsetX) + (this.pvObj.anchoForma / 2 - 25), ((origenRotativa.y - yOffset) + _offsetY), styleText);
|
||||||
|
_pvRotativa.makeText(this.pvObj.anchoForma, (origenRotativa.x + _offsetX), ((origenRotativa.y - yOffset) + _offsetY) + (this.pvObj.altoForma / 2 - 15), styleText);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_pvRotativa.update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +461,15 @@ class previewFormas {
|
|||||||
|
|
||||||
// Variables locales
|
// Variables locales
|
||||||
let altoLibro, anchoLibro, lomoLibro, anchoCubierta, altoSangrado, anchoSangrado, anchoSolapa;
|
let altoLibro, anchoLibro, lomoLibro, anchoCubierta, altoSangrado, anchoSangrado, anchoSolapa;
|
||||||
|
|
||||||
|
if(typeof this.lomo === 'function') {
|
||||||
|
this.lomo = this.lomo();
|
||||||
|
this.ancho = this.ancho();
|
||||||
|
this.alto = this.alto();
|
||||||
|
this.lomoRedondo = this.lomoRedondo();
|
||||||
|
this.solapa = this.solapa();
|
||||||
|
}
|
||||||
|
|
||||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
let styleCotas = { size: 12, family: 'Public Sans' };
|
||||||
let sangradoTexto = "Sangrado 5 mm";
|
let sangradoTexto = "Sangrado 5 mm";
|
||||||
let sangradoValor = parseFloat(5); // mm
|
let sangradoValor = parseFloat(5); // mm
|
||||||
@ -60,7 +481,7 @@ class previewFormas {
|
|||||||
anchoSangrado = 350; // px
|
anchoSangrado = 350; // px
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
||||||
} else {
|
} else {
|
||||||
anchoSangrado = 800; // px
|
anchoSangrado = 750; // px
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,12 +638,18 @@ class previewFormas {
|
|||||||
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
||||||
// Cotas
|
// Cotas
|
||||||
previewEC.makeText(this.lomo.toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
|
let lomoTotal = 0;
|
||||||
|
if(typeof this.lomo === 'function') {
|
||||||
|
lomoTotal = this.lomo().toFixed(1);
|
||||||
|
} else {
|
||||||
|
lomoTotal = this.lomo.toFixed(1);
|
||||||
|
}
|
||||||
|
previewEC.makeText(lomoTotal + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText((this.alto + (2 * sangradoValor)).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
previewEC.makeText((this.alto + (2 * sangradoValor)).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText(((2 * this.ancho) + (2 * (this.solapa + this.offsetSolapa)) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm",
|
previewEC.makeText((((2 * this.ancho) + (2 * (this.solapa + this.offsetSolapa)) + parseFloat(lomoTotal) + (2 * sangradoValor)).toFixed(1)) + " mm",
|
||||||
origenEC.x,
|
origenEC.x,
|
||||||
origenEC.y + (altoLibro / 2) + 50,
|
origenEC.y + (altoLibro / 2) + 50,
|
||||||
styleCotas);
|
styleCotas);
|
||||||
@ -238,12 +665,20 @@ class previewFormas {
|
|||||||
|
|
||||||
// Variables locales
|
// Variables locales
|
||||||
let altoLibro, anchoLibro, lomoLibro, anchoCubierta, altoSangrado, anchoSangrado;
|
let altoLibro, anchoLibro, lomoLibro, anchoCubierta, altoSangrado, anchoSangrado;
|
||||||
|
|
||||||
|
if(typeof this.lomo === 'function') {
|
||||||
|
this.lomo = this.lomo();
|
||||||
|
this.ancho = this.ancho();
|
||||||
|
this.alto = this.alto();
|
||||||
|
this.lomoRedondo = this.lomoRedondo();
|
||||||
|
}
|
||||||
|
|
||||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
let styleCotas = { size: 12, family: 'Public Sans' };
|
||||||
let sangradoTexto = "Sangrado 20 mm";
|
let sangradoTexto = "Sangrado 20 mm";
|
||||||
let sangradoValor = parseFloat(20); // mm
|
let sangradoValor = parseFloat(20); // mm
|
||||||
if (this.ancho >= 210 || this.alto >= 297) {
|
if (this.ancho >= 210 || this.alto >= 297) {
|
||||||
sangradoValor = parseFloat(15); // mm
|
sangradoValor = parseFloat(10); // mm
|
||||||
sangradoTexto = "Sangrado 15 mm";
|
sangradoTexto = "Sangrado 10 mm";
|
||||||
}
|
}
|
||||||
let anchoPliegue = parseFloat(7); // mm cajo
|
let anchoPliegue = parseFloat(7); // mm cajo
|
||||||
let altoPliegue = parseFloat(7); // mm
|
let altoPliegue = parseFloat(7); // mm
|
||||||
@ -378,11 +813,19 @@ class previewFormas {
|
|||||||
|
|
||||||
// Variables locales
|
// Variables locales
|
||||||
let altoLibro, anchoLibro, anchoSolapa, anchoCalle, altoSangrado, anchoSangrado, offsetCubierta, anchoCubierta;
|
let altoLibro, anchoLibro, anchoSolapa, anchoCalle, altoSangrado, anchoSangrado, offsetCubierta, anchoCubierta;
|
||||||
|
|
||||||
|
if(typeof this.lomo === 'function') {
|
||||||
|
this.lomo = this.lomo();
|
||||||
|
this.ancho = this.ancho();
|
||||||
|
this.alto = this.alto();
|
||||||
|
this.lomoRedondo = this.lomoRedondo();
|
||||||
|
this.solapa = this.solapa();
|
||||||
|
}
|
||||||
|
|
||||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
let styleCotas = { size: 12, family: 'Public Sans' };
|
||||||
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
|
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
|
||||||
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
|
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
|
||||||
|
|
||||||
|
|
||||||
// Definicion de los parametros del Esquema de Cubierta (EC)
|
// Definicion de los parametros del Esquema de Cubierta (EC)
|
||||||
if ((this.solapa !== 0) && (!isTapaDura)) {
|
if ((this.solapa !== 0) && (!isTapaDura)) {
|
||||||
if (this.size == "thumbnail") {
|
if (this.size == "thumbnail") {
|
||||||
@ -587,6 +1030,15 @@ class previewFormas {
|
|||||||
|
|
||||||
// Variables locales
|
// Variables locales
|
||||||
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
|
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
|
||||||
|
|
||||||
|
if(typeof this.lomo === 'function') {
|
||||||
|
this.lomo = this.lomo();
|
||||||
|
this.ancho = this.ancho();
|
||||||
|
this.alto = this.alto();
|
||||||
|
this.lomoRedondo = this.lomoRedondo();
|
||||||
|
this.solapa = this.solapa();
|
||||||
|
}
|
||||||
|
|
||||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
let styleCotas = { size: 12, family: 'Public Sans' };
|
||||||
let sangradoTexto = "Sangrado 5 mm";
|
let sangradoTexto = "Sangrado 5 mm";
|
||||||
let sangradoValor = parseFloat(5); // mm
|
let sangradoValor = parseFloat(5); // mm
|
||||||
|
|||||||
@ -4,15 +4,16 @@
|
|||||||
* @param {String} url
|
* @param {String} url
|
||||||
* @param {String} placeholder
|
* @param {String} placeholder
|
||||||
*/
|
*/
|
||||||
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}) {
|
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}, dropdownParent = "") {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.item = domItem;
|
this.item = domItem;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
|
this.dropdownParent = dropdownParent;
|
||||||
|
|
||||||
this.config = {
|
this.config = {
|
||||||
placeholder: placeholder,
|
placeholder: placeholder,
|
||||||
allowClear: allowClear,
|
allowClear: allowClear,
|
||||||
dropdownParent: domItem.parent(),
|
dropdownParent: dropdownParent!=""?dropdownParent:domItem.parent(),
|
||||||
language: "es",
|
language: "es",
|
||||||
ajax: {
|
ajax: {
|
||||||
url: () => {
|
url: () => {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ class tarjetaDireccion {
|
|||||||
this.card = this.#generateHTML(id, direccion);
|
this.card = this.#generateHTML(id, direccion);
|
||||||
this.deleteBtn = this.card.find('.direccion-eliminar');
|
this.deleteBtn = this.card.find('.direccion-eliminar');
|
||||||
this.editBtn = this.card.find('.direccion-editar');
|
this.editBtn = this.card.find('.direccion-editar');
|
||||||
|
this.direccion = direccion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,13 +90,21 @@ class tarjetaDireccion {
|
|||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPaisId() {
|
||||||
|
return this.direccion.pais_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDireccion() {
|
||||||
|
return this.direccion;
|
||||||
|
}
|
||||||
|
|
||||||
getDireccionId() {
|
getDireccionId() {
|
||||||
return this.direccionId;
|
return this.direccionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFormData() {
|
getFormData() {
|
||||||
return {
|
return {
|
||||||
id: this.direccionId,
|
direccion: this.direccion,
|
||||||
unidades: this.getUnidades(),
|
unidades: this.getUnidades(),
|
||||||
entregaPalets: this.getEntregaPalets()
|
entregaPalets: this.getEntregaPalets()
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,185 @@
|
|||||||
|
import ClassSelect from '../../components/select2.js';
|
||||||
|
import Ajax from '../../components/ajax.js';
|
||||||
|
|
||||||
|
class PresupuestoAdminAdd {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
this.cosido = $("#isCosido");
|
||||||
|
this.tipo_impresion = $("#tipo_impresion_id");
|
||||||
|
this.POD = $("#POD");
|
||||||
|
|
||||||
|
this.inc_rei = $('#incRei');
|
||||||
|
this.cliente = new ClassSelect($('#clienteId'), '/clientes/cliente/getSelect2', 'Seleccione cliente');
|
||||||
|
this.pais = new ClassSelect($('#paisId'), '/paises/menuitems2', 'Seleccione País');
|
||||||
|
|
||||||
|
this.fecha = $('#updated_at');
|
||||||
|
this.estado = $('#estado_id');
|
||||||
|
this.titulo = $('#titulo');
|
||||||
|
this.autor = $('#autor');
|
||||||
|
this.coleccion = $('#coleccion');
|
||||||
|
this.numeroEdicion = $('#numeroEdicion');
|
||||||
|
this.isbn = $('#isbn');
|
||||||
|
this.referenciaCliente = $('#referenciaCliente');
|
||||||
|
|
||||||
|
this.paginas = $('#paginas');
|
||||||
|
this.tirada = $('#tirada');
|
||||||
|
this.merma = $('#merma');
|
||||||
|
this.mermaCubierta = $('#mermacubierta');
|
||||||
|
|
||||||
|
this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language.Presupuestos.formatoLibro);
|
||||||
|
this.tamanioPersonalizado = $('#papelFormatoPersonalizado');
|
||||||
|
this.anchoPersonalizado = $('#papelFormatoAncho');
|
||||||
|
this.altoPersonalizado = $('#papelFormatoAlto');
|
||||||
|
|
||||||
|
this.guardar = $('#saveForm');
|
||||||
|
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
// Fuerza el foco en el campo de búsqueda de select2
|
||||||
|
$(document).on('select2:open', () => {
|
||||||
|
document.querySelector('.select2-search__field').focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#solapas').addClass('d-none');
|
||||||
|
$('#solapas_sobrecubierta').addClass('d-none');
|
||||||
|
$('#div_solapas_ancho').addClass('d-none');
|
||||||
|
$('#div_solapas_ancho_sobrecubierta').addClass('d-none');
|
||||||
|
$('.solapas-cubierta-div').addClass('d-none');
|
||||||
|
$('.solapas-sobrecubierta-div').addClass('d-none');
|
||||||
|
|
||||||
|
this.cliente.init();
|
||||||
|
this.pais.init();
|
||||||
|
|
||||||
|
this.tamanio.init();
|
||||||
|
|
||||||
|
this.inc_rei.select2({
|
||||||
|
allowClear: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this));
|
||||||
|
this.guardar.on('click', this.guardarPresupuesto.bind(this));
|
||||||
|
this.tirada.on('change', this.calcular_mermas.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
changeTipoTamanio() {
|
||||||
|
|
||||||
|
if (this.tamanioPersonalizado.prop('checked')) {
|
||||||
|
$('.tamanio-personalizado').removeClass('d-none');
|
||||||
|
$('.tamanio-estandar').addClass('d-none');
|
||||||
|
this.tamanio.setVal('');
|
||||||
|
$("#label_papelFormatoId").text(
|
||||||
|
window.language.Presupuestos.papelFormatoId + " (" +
|
||||||
|
window.language.Presupuestos.papelFormatoAncho + " x " + window.language.Presupuestos.papelFormatoAncho + ")*");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.anchoPersonalizado.val("");
|
||||||
|
this.altoPersonalizado.val("");
|
||||||
|
$('.tamanio-personalizado').addClass('d-none');
|
||||||
|
$('.tamanio-estandar').removeClass('d-none');
|
||||||
|
$("#label_papelFormatoId").text(
|
||||||
|
window.language.Presupuestos.papelFormatoId + '*');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async guardarPresupuesto() {
|
||||||
|
|
||||||
|
$('#loader').modal('show');
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
let data = this.getFormData();
|
||||||
|
|
||||||
|
new Ajax('/presupuestoadmin/add/', data, {},
|
||||||
|
function (response) {
|
||||||
|
popSuccessAlert(response.mensaje);
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.error(error);
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getFormData() {
|
||||||
|
|
||||||
|
let datos = {};
|
||||||
|
|
||||||
|
datos.cliente_id = this.cliente.getVal();
|
||||||
|
datos.tipo_impresion_id = this.tipo_impresion.val();
|
||||||
|
datos.cosido = this.cosido.val();
|
||||||
|
|
||||||
|
datos = {
|
||||||
|
...datos, ...{
|
||||||
|
inc_rei: this.inc_rei.select2('data')[0].id,
|
||||||
|
titulo: this.titulo.val(),
|
||||||
|
autor: this.autor.val(),
|
||||||
|
isbn: this.isbn.val(),
|
||||||
|
pais_id: this.pais.getVal(),
|
||||||
|
coleccion: this.coleccion.val(),
|
||||||
|
numero_edicion: this.numeroEdicion.val(),
|
||||||
|
referencia_cliente: this.referenciaCliente.val(),
|
||||||
|
updated_at: new Date().toISOString().slice(0, 19).replace('T', ' '),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
datos = {
|
||||||
|
...datos, ...{
|
||||||
|
paginas: this.paginas.val(),
|
||||||
|
tirada: this.tirada.val(),
|
||||||
|
papel_formato_id: this.tamanio.item.hasClass('d-none') ? 0 : this.tamanio.getVal(),
|
||||||
|
papel_formato_personalizado: this.tamanio.item.hasClass('d-none') ? 1 : 0,
|
||||||
|
merma: this.merma.val(),
|
||||||
|
merma_cubierta: this.mermaCubierta.val(),
|
||||||
|
solapas_ancho: "0",
|
||||||
|
solapas_ancho_sobrecubierta: "0",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (datos.papel_formato_personalizado) {
|
||||||
|
datos.papel_formato_ancho = this.anchoPersonalizado.val(),
|
||||||
|
datos.papel_formato_alto = this.altoPersonalizado.val()
|
||||||
|
}
|
||||||
|
datos.selectedTirada = this.tirada.val();
|
||||||
|
|
||||||
|
return datos;
|
||||||
|
}
|
||||||
|
|
||||||
|
calcular_mermas() {
|
||||||
|
|
||||||
|
const tirada = parseInt($('#tirada').val());
|
||||||
|
const POD = parseInt($('#POD').val());
|
||||||
|
let merma = 0;
|
||||||
|
|
||||||
|
merma = tirada * 0.1 <= POD ? tirada * 0.1 : POD;
|
||||||
|
|
||||||
|
$('#mermacubierta').val(parseInt(merma))
|
||||||
|
$('#merma').val(parseInt(merma))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
|
||||||
|
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||||
|
|
||||||
|
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Presupuestos', 'PresupuestosDirecciones'] }, {},
|
||||||
|
function (translations) {
|
||||||
|
window.language = JSON.parse(translations);
|
||||||
|
new PresupuestoAdminAdd().init();
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.log("Error getting translations:", error);
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
});
|
||||||
@ -0,0 +1,503 @@
|
|||||||
|
import { getToken } from '../../common/common.js';
|
||||||
|
import Ajax from '../../components/ajax.js';
|
||||||
|
|
||||||
|
import DatosGenerales from './sections/datosGenerales.js';
|
||||||
|
import DatosLibro from './sections/datosLibro.js';
|
||||||
|
import Comparador from './sections/comparador.js';
|
||||||
|
import LineasPresupuesto from './sections/lineasPresupuesto.js';
|
||||||
|
import PreviewFormasAdmin from './sections/previewFormasAdmin.js';
|
||||||
|
import Servicios from './sections/servicios.js';
|
||||||
|
import Envios from './sections/envios.js';
|
||||||
|
import TiradasAlernativas from './sections/tiradasAlternativas.js';
|
||||||
|
import Resumen from './sections/resumen.js';
|
||||||
|
|
||||||
|
class PresupuestoAdminEdit {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
this.domItem = $('#presupuestoForm');
|
||||||
|
|
||||||
|
this.csrf_token = getToken();
|
||||||
|
this.csrf_hash = $('#presupuestoForm').find('input[name="' + this.csrf_token + '"]').val();
|
||||||
|
|
||||||
|
this.lc = $("#lomo_cubierta");
|
||||||
|
this.lsc = $("#lomo_sobrecubierta");
|
||||||
|
this.cosido = $("#isCosido");
|
||||||
|
this.tipo_impresion = $("#tipo_impresion_id");
|
||||||
|
this.POD = $("#POD");
|
||||||
|
|
||||||
|
this.tipoTapa = $('.card-title').text().toLowerCase().includes('dura') ? 'dura' : 'blanda';
|
||||||
|
|
||||||
|
this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip'));
|
||||||
|
this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip'),
|
||||||
|
{
|
||||||
|
checkPaginasPresupuesto: this.checkPaginasPresupuesto,
|
||||||
|
});
|
||||||
|
this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip'));
|
||||||
|
this.lineasPresupuesto = new LineasPresupuesto(this.domItem.find('#accordionLineasPresupuestoTip'),
|
||||||
|
{
|
||||||
|
getDimensionLibro: this.getDimensionLibro,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.previewFormasAdmin = null;
|
||||||
|
this.servicios = new Servicios();
|
||||||
|
this.envios = new Envios();
|
||||||
|
this.tiradasAlternativas = new TiradasAlernativas({
|
||||||
|
getDimensionLibro: this.getDimensionLibro,
|
||||||
|
});
|
||||||
|
this.resumen = new Resumen();
|
||||||
|
|
||||||
|
this.guardar = $('#saveForm');
|
||||||
|
|
||||||
|
this.calcularPresupuesto = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
// Fuerza el foco en el campo de búsqueda de select2
|
||||||
|
$(document).on('select2:open', () => {
|
||||||
|
document.querySelector('.select2-search__field').focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
const impresion_id = $('#tipo_impresion_id').val();
|
||||||
|
let tipoLibro = '';
|
||||||
|
if (impresion_id == 1 || impresion_id == 2) {
|
||||||
|
tipoLibro = 'fresado';
|
||||||
|
} else if (impresion_id == 3 || impresion_id == 4) {
|
||||||
|
tipoLibro = 'cosido';
|
||||||
|
} else if (impresion_id == 5 || impresion_id == 6) {
|
||||||
|
tipoLibro = 'espiral';
|
||||||
|
} else if (impresion_id == 7 || impresion_id == 8) {
|
||||||
|
tipoLibro = 'wireo';
|
||||||
|
} else if (impresion_id == 21) {
|
||||||
|
tipoLibro = 'grapado';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.datosGenerales.init();
|
||||||
|
this.datosLibro.init();
|
||||||
|
this.comparador.init();
|
||||||
|
this.lineasPresupuesto.init();
|
||||||
|
|
||||||
|
this.previewFormasAdmin = new PreviewFormasAdmin(tipoLibro, this.tipoTapa,
|
||||||
|
{
|
||||||
|
ancho: () => this.getDimensionLibro().ancho,
|
||||||
|
alto: () => this.getDimensionLibro().alto,
|
||||||
|
lomo: () => $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()),
|
||||||
|
lomoSobrecubierta: () => $('#lomo_sobrecubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_sobrecubierta').val()),
|
||||||
|
solapa: () => $('#solapas').prop('checked') ? parseFloat($('#solapas_ancho').val()) : 0,
|
||||||
|
solapa_sobrecubierta: () => $('#solapas_sobrecubierta').prop('checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : 0,
|
||||||
|
lomoRedondo: () => (this.tipo_impresion == 1 || this.tipo_impresion == 3) ? parseFloat($('#compLomoRedondo').val()) : 0,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.previewFormasAdmin.init();
|
||||||
|
this.servicios.init();
|
||||||
|
this.envios.init();
|
||||||
|
this.tiradasAlternativas.init();
|
||||||
|
this.resumen.init();
|
||||||
|
|
||||||
|
if (window.location.href.includes("edit")) {
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.#cargarPresupuesto();
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
const successMessage = sessionStorage.getItem('message');
|
||||||
|
if (successMessage) {
|
||||||
|
popSuccessAlert(successMessage);
|
||||||
|
sessionStorage.removeItem('message');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.downloadPreviewImage();
|
||||||
|
|
||||||
|
$(document).on('update-presupuesto', this.updatePresupuesto.bind(this));
|
||||||
|
|
||||||
|
this.guardar.on('click', this.guardarPresupuesto.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async guardarPresupuesto() {
|
||||||
|
|
||||||
|
$('#loader').modal('show');
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
const id = window.location.href.split("/").pop();
|
||||||
|
let data = this.getFormData();
|
||||||
|
|
||||||
|
await this.servicios.guardar();
|
||||||
|
await this.envios.guardarEnvios();
|
||||||
|
await this.lineasPresupuesto.guardarLineasPresupuesto();
|
||||||
|
|
||||||
|
new Ajax('/presupuestoadmin/edit/' + id, data, {},
|
||||||
|
function (response) {
|
||||||
|
popSuccessAlert(response.mensaje);
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.error(error);
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getFormData() {
|
||||||
|
|
||||||
|
let datos = {};
|
||||||
|
|
||||||
|
datos.id = window.location.href.split("/").pop();
|
||||||
|
datos.cliente_id = this.datosGenerales.cliente.getVal();
|
||||||
|
datos.tipo_impresion_id = this.tipo_impresion.val();
|
||||||
|
datos.cosido = this.cosido.val();
|
||||||
|
datos.lomo_cubierta = this.lc.val();
|
||||||
|
datos.lomo_sobrecubierta = this.lsc.val();
|
||||||
|
datos.envio_base = $('#envio_base').val();
|
||||||
|
|
||||||
|
datos = {
|
||||||
|
...datos, ...{
|
||||||
|
inc_rei: this.datosGenerales.inc_rei.select2('data')[0].id,
|
||||||
|
titulo: this.datosGenerales.titulo.val(),
|
||||||
|
autor: this.datosGenerales.autor.val(),
|
||||||
|
isbn: this.datosGenerales.isbn.val(),
|
||||||
|
pais_id: this.datosGenerales.pais.getVal(),
|
||||||
|
coleccion: this.datosGenerales.coleccion.val(),
|
||||||
|
numero_edicion: this.datosGenerales.numeroEdicion.val(),
|
||||||
|
referencia_cliente: this.datosGenerales.referenciaCliente.val(),
|
||||||
|
updated_at: new Date().toISOString().slice(0, 19).replace('T', ' '),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
datos = {
|
||||||
|
...datos, ...{
|
||||||
|
paginas: this.datosLibro.paginas.val(),
|
||||||
|
tirada: this.datosLibro.tirada.val(),
|
||||||
|
papel_formato_id: this.datosLibro.tamanio.item.hasClass('d-none') ? 0 : this.datosLibro.tamanio.getVal(),
|
||||||
|
papel_formato_personalizado: this.datosLibro.tamanio.item.hasClass('d-none') ? 1 : 0,
|
||||||
|
merma: this.datosLibro.merma.val(),
|
||||||
|
merma_cubierta: this.datosLibro.mermaCubierta.val()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (datos.papel_formato_personalizado) {
|
||||||
|
datos.papel_formato_ancho = this.datosLibro.anchoPersonalizado.val(),
|
||||||
|
datos.papel_formato_alto = this.datosLibro.altoPersonalizado.val()
|
||||||
|
}
|
||||||
|
datos.selectedTirada = this.datosLibro.tirada.val();
|
||||||
|
datos.acabado_cubierta_id = this.datosLibro.acabadoCubierta.getVal();
|
||||||
|
datos.acabado_sobrecubierta_id = this.datosLibro.acabadoSobrecubierta.getVal();
|
||||||
|
|
||||||
|
datos = {
|
||||||
|
...datos, ...{
|
||||||
|
'prototipo': this.datosLibro.prototipo.is(':checked') ? 1 : 0,
|
||||||
|
'ferro': this.datosLibro.ferro.is(':checked') ? 1 : 0,
|
||||||
|
'ferro_digital': this.datosLibro.ferroDigital.is(':checked') ? 1 : 0,
|
||||||
|
'marcapaginas': this.datosLibro.marcapaginas.is(':checked') ? 1 : 0,
|
||||||
|
'retractilado': this.datosLibro.retractilado.is(':checked') ? 1 : 0,
|
||||||
|
'retractilado5': this.datosLibro.retractilado5.is(':checked') ? 1 : 0,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
datos.comp_tipo_impresion = this.comparador.tipo_impresion.val();
|
||||||
|
datos.comp_pos_paginas_color = this.comparador.posPagColor.val();
|
||||||
|
|
||||||
|
|
||||||
|
if (this.comparador.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) {
|
||||||
|
datos.lomoRedondo = this.comparador.lomoRedondo.select2('data')[0].id;
|
||||||
|
datos.cabezada = this.comparador.cabezada.val();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
datos.lomoRedondo = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($('#tipo_impresion_id').val() != 1 && $('#tipo_impresion_id').val() != 3 &&
|
||||||
|
$('#tipo_impresion_id').val() != 5 && $('#tipo_impresion_id').val() != 7) {
|
||||||
|
datos.solapas = this.datosLibro.solapasCubierta.is(':checked') ? 1 : 0;
|
||||||
|
datos.solapas_ancho = this.datosLibro.anchoSolapasCubierta.val();
|
||||||
|
}
|
||||||
|
|
||||||
|
datos.solapas_sobrecubierta = this.datosLibro.solapasSobrecubierta.is(':checked') ? 1 : 0;
|
||||||
|
datos.solapas_ancho_sobrecubierta = this.datosLibro.anchoSolapasSobrecubierta.val();
|
||||||
|
|
||||||
|
datos.entrega_taller = this.envios.recogerTaller.is(':checked') ? 1 : 0;
|
||||||
|
if (parseInt(this.cosido.val())) {
|
||||||
|
|
||||||
|
let paginas_por_cuadernillo = "";
|
||||||
|
|
||||||
|
this.servicios.ServiciosEncuadernacion.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
if (rowData.paginas_por_cuadernillo != null) {
|
||||||
|
paginas_por_cuadernillo = rowData.paginas_por_cuadernillo;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
datos.paginas_por_cuadernillo = paginas_por_cuadernillo;
|
||||||
|
}
|
||||||
|
|
||||||
|
datos.comentarios_cliente = $('#comentariosCliente').val();
|
||||||
|
datos.comentarios_safekat = $('#comentariosSafekat').val();
|
||||||
|
datos.comentarios_presupuesto = $('#comentariosPdf').val();
|
||||||
|
datos.comentarios_produccion = $('#comentariosProduccion').val();
|
||||||
|
|
||||||
|
datos = { ...datos, ...this.resumen.getData() };
|
||||||
|
|
||||||
|
return datos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async updatePresupuesto(event, {
|
||||||
|
|
||||||
|
update_lineas = true,
|
||||||
|
update_servicios = true,
|
||||||
|
update_envios = true,
|
||||||
|
update_resumen = true,
|
||||||
|
update_tiradas_alternativas = true
|
||||||
|
}) {
|
||||||
|
const waitForEvent = (eventName) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
$(document).one(eventName, () => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Ejecutar los pasos de forma secuencial si están habilitados
|
||||||
|
if (update_lineas) {
|
||||||
|
$(document).trigger('update-lineas-presupuesto');
|
||||||
|
await waitForEvent('update-lineas-presupuesto-completed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update_servicios) {
|
||||||
|
$(document).trigger('update-servicios');
|
||||||
|
await waitForEvent('update-servicios-completed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update_envios) {
|
||||||
|
$(document).trigger('update-envios');
|
||||||
|
await waitForEvent('update-envios-completed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update_resumen) {
|
||||||
|
$(document).trigger('update-totales');
|
||||||
|
await waitForEvent('update-totales-completed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update_tiradas_alternativas) {
|
||||||
|
$(document).trigger('update-tiradas-alternativas');
|
||||||
|
await waitForEvent('update-tiradas-alternativas-completed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#cargarPresupuesto() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
$('#loader').modal('show');
|
||||||
|
let id = window.location.href.split("/").pop()
|
||||||
|
new Ajax('/presupuestoadmin/cargar/' + id,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
(response) => {
|
||||||
|
|
||||||
|
if (response.status === 1) {
|
||||||
|
|
||||||
|
self.lc.val(parseFloat(response.data.lc).toFixed(2));
|
||||||
|
self.lsc.val(parseFloat(response.data.lsc).toFixed(2));
|
||||||
|
self.cosido.val(response.data.cosido ? 1 : 0);
|
||||||
|
self.tipo_impresion.val(response.data.tipo_impresion);
|
||||||
|
self.POD.val(response.data.POD);
|
||||||
|
|
||||||
|
self.calcularPresupuesto = false;
|
||||||
|
|
||||||
|
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||||
|
self.datosLibro.cargarDatos(response.data.datosLibro);
|
||||||
|
self.comparador.cargarDatos(response.data.comparador);
|
||||||
|
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
|
||||||
|
|
||||||
|
self.servicios.cargar(response.data.servicios);
|
||||||
|
self.envios.cargar(response.data.direcciones);
|
||||||
|
|
||||||
|
$('#comentariosCliente').val(response.data.comentarios_cliente);
|
||||||
|
$('#comentariosSafekat').val(response.data.comentarios_safekat);
|
||||||
|
$('#comentariosPdf').val(response.data.comentarios_presupuesto);
|
||||||
|
$('#comentariosProduccion').val(response.data.comentarios_produccion);
|
||||||
|
|
||||||
|
self.tiradasAlternativas.cargar(response.data.tiradasAlternativas);
|
||||||
|
|
||||||
|
self.resumen.cargar(response.data.resumen);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
|
||||||
|
if (response.data.state != 2) {
|
||||||
|
|
||||||
|
self.calcularPresupuesto = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
// Funciones para detectar cambios en el formulario
|
||||||
|
this.#checkChangesPresupuesto();
|
||||||
|
$('#bc-save').on("click", function () {
|
||||||
|
showBreadCrumbSaveButton(false);
|
||||||
|
$('#saveForm').trigger('click');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
this.calcularPresupuesto = true;
|
||||||
|
}
|
||||||
|
).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
checkPaginasPresupuesto() {
|
||||||
|
|
||||||
|
let cantidad_total = 0;
|
||||||
|
|
||||||
|
// TO-DO
|
||||||
|
/*
|
||||||
|
tableLineasPresupuesto.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas')
|
||||||
|
cantidad_total += parseInt(rowData.paginas)
|
||||||
|
})
|
||||||
|
htmlString = ''
|
||||||
|
|
||||||
|
if (cantidad_total != parseInt($('#paginas').val())) {
|
||||||
|
htmlString = `
|
||||||
|
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||||
|
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||||
|
<i class="ti ti-bell ti-sm"></i>
|
||||||
|
</span>
|
||||||
|
<div class="d-flex flex-column ps-1">
|
||||||
|
<h5 class="alert-heading mb-2">` +
|
||||||
|
window.Presupuestos.errores.paginasLP +
|
||||||
|
`</h5>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
$('#divAlarmasLineasPresupuesto').html(htmlString)*/
|
||||||
|
}
|
||||||
|
|
||||||
|
getDimensionLibro() {
|
||||||
|
|
||||||
|
var ancho = 0;
|
||||||
|
var alto = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if ($('#papelFormatoPersonalizado').is(':checked')) {
|
||||||
|
ancho = parseFloat($('#papelFormatoAncho').val());
|
||||||
|
alto = parseFloat($('#papelFormatoAlto').val());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const selectedText = $('#papelFormatoId').find('option:selected').text();
|
||||||
|
if (selectedText.length > 0) {
|
||||||
|
ancho = parseFloat(selectedText.trim().split(" x ")[0]);
|
||||||
|
alto = parseFloat(selectedText.trim().split(" x ")[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
ancho: ancho,
|
||||||
|
alto: alto
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#checkChangesPresupuesto() {
|
||||||
|
// Detectar cambios en inputs de texto
|
||||||
|
$('input[type="text"]').on('change', function () {
|
||||||
|
showBreadCrumbSaveButton(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Detectar cambios en inputs de texto
|
||||||
|
$('input[type="number"]').on('change', function () {
|
||||||
|
showBreadCrumbSaveButton(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Detectar cambios en select
|
||||||
|
$('select').on('change', function () {
|
||||||
|
showBreadCrumbSaveButton(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.select2bs').on('change', function (e) {
|
||||||
|
showBreadCrumbSaveButton(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Detectar cambios en checkboxes
|
||||||
|
$('input[type="checkbox"]').change(function () {
|
||||||
|
showBreadCrumbSaveButton(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Detectar cambios en textareas
|
||||||
|
$('textarea').on('input', function () {
|
||||||
|
showBreadCrumbSaveButton(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Detectar cambios en otros tipos de input
|
||||||
|
$('input[type="radio"]').change(function () {
|
||||||
|
showBreadCrumbSaveButton(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Detectar cambios en otros tipos de input
|
||||||
|
$('input:not([type])').on('input', function () {
|
||||||
|
showBreadCrumbSaveButton(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
downloadPreviewImage() {
|
||||||
|
$(document).on("click", ".download-shape", (event) => {
|
||||||
|
let parentDiv = $(event.currentTarget).parent().parent();
|
||||||
|
let shapeSvgElQuery = $(parentDiv).find("svg");
|
||||||
|
let shapeSvgEl = shapeSvgElQuery[0];
|
||||||
|
const filename = shapeSvgElQuery.parent().attr("id") ?? "image"
|
||||||
|
const serializer = new XMLSerializer();
|
||||||
|
const svgData = serializer.serializeToString(shapeSvgEl);
|
||||||
|
const svgBlob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' });
|
||||||
|
const svgUrl = URL.createObjectURL(svgBlob);
|
||||||
|
const img = new Image();
|
||||||
|
img.onload = () => {
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
canvas.width = img.width;
|
||||||
|
canvas.height = img.height;
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.drawImage(img, 0, 0);
|
||||||
|
const pngUrl = canvas.toDataURL('image/png');
|
||||||
|
const downloadLink = document.createElement('a');
|
||||||
|
downloadLink.href = pngUrl;
|
||||||
|
downloadLink.download = filename ?? '.png';
|
||||||
|
document.body.appendChild(downloadLink);
|
||||||
|
downloadLink.click();
|
||||||
|
document.body.removeChild(downloadLink);
|
||||||
|
|
||||||
|
URL.revokeObjectURL(svgUrl);
|
||||||
|
};
|
||||||
|
|
||||||
|
img.src = svgUrl;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
|
||||||
|
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||||
|
|
||||||
|
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Presupuestos', 'PresupuestosDirecciones'] }, {},
|
||||||
|
function (translations) {
|
||||||
|
window.language = JSON.parse(translations);
|
||||||
|
new PresupuestoAdminEdit().init();
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.log("Error getting translations:", error);
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
});
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,55 @@
|
|||||||
|
import ClassSelect from '../../../components/select2.js';
|
||||||
|
|
||||||
|
class DatosGenerales{
|
||||||
|
|
||||||
|
constructor(domItem){
|
||||||
|
|
||||||
|
this.domItem = domItem;
|
||||||
|
|
||||||
|
this.id = this.domItem.find('#id');
|
||||||
|
this.fecha = this.domItem.find('#updated_at');
|
||||||
|
this.estado = this.domItem.find('#estado_id');
|
||||||
|
this.inc_rei = this.domItem.find('#incRei');
|
||||||
|
this.titulo = this.domItem.find('#titulo');
|
||||||
|
this.autor = this.domItem.find('#autor');
|
||||||
|
this.coleccion = this.domItem.find('#coleccion');
|
||||||
|
this.numeroEdicion = this.domItem.find('#numeroEdicion');
|
||||||
|
this.isbn = this.domItem.find('#isbn');
|
||||||
|
|
||||||
|
|
||||||
|
this.cliente = new ClassSelect($('#clienteId'), '/clientes/cliente/getSelect2', 'Seleccione cliente');
|
||||||
|
this.pais = new ClassSelect($('#paisId'), '/paises/menuitems2', 'Seleccione País');
|
||||||
|
this.referenciaCliente = this.domItem.find('#referenciaCliente');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init(){
|
||||||
|
|
||||||
|
this.cliente.init();
|
||||||
|
this.pais.init();
|
||||||
|
|
||||||
|
this.inc_rei.select2({
|
||||||
|
allowClear: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cargarDatos(datos){
|
||||||
|
|
||||||
|
this.id.val(datos.id);
|
||||||
|
this.fecha.val(datos.updated_at);
|
||||||
|
this.estado.val(datos.state);
|
||||||
|
this.inc_rei.val(datos.inc_rei).trigger('change');
|
||||||
|
this.titulo.val(datos.titulo);
|
||||||
|
this.autor.val(datos.autor);
|
||||||
|
this.coleccion.val(datos.coleccion);
|
||||||
|
this.numeroEdicion.val(datos.numero_edicion);
|
||||||
|
this.isbn.val(datos.isbn);
|
||||||
|
|
||||||
|
|
||||||
|
this.cliente.setOption(datos.cliente.id, datos.cliente.nombre);
|
||||||
|
this.pais.setOption(datos.pais, datos.pais_nombre);
|
||||||
|
this.referenciaCliente.val(datos.referenciaCliente);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DatosGenerales;
|
||||||
@ -0,0 +1,436 @@
|
|||||||
|
import ClassSelect from '../../../components/select2.js';
|
||||||
|
import { getToken } from '../../../common/common.js';
|
||||||
|
|
||||||
|
class DatosLibro {
|
||||||
|
|
||||||
|
constructor(domItem, functions = {}) {
|
||||||
|
|
||||||
|
this.domItem = domItem;
|
||||||
|
|
||||||
|
this.checkPaginasPresupuesto = functions.checkPaginasPresupuesto;
|
||||||
|
|
||||||
|
this.csrf_token = getToken();
|
||||||
|
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||||
|
|
||||||
|
this.paginas = this.domItem.find('#paginas');
|
||||||
|
this.tirada = this.domItem.find('#tirada');
|
||||||
|
this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language.Presupuestos.formatoLibro);
|
||||||
|
this.tamanioPersonalizado = this.domItem.find('#papelFormatoPersonalizado');
|
||||||
|
this.anchoPersonalizado = this.domItem.find('#papelFormatoAncho');
|
||||||
|
this.altoPersonalizado = this.domItem.find('#papelFormatoAlto');
|
||||||
|
this.merma = this.domItem.find('#merma');
|
||||||
|
this.mermaCubierta = this.domItem.find('#mermacubierta');
|
||||||
|
this.solapasCubierta = this.domItem.find('#solapas');
|
||||||
|
this.solapasSobrecubierta = this.domItem.find('#solapas_sobrecubierta');
|
||||||
|
this.anchoSolapasCubierta = this.domItem.find('#solapas_ancho');
|
||||||
|
this.anchoSolapasSobrecubierta = this.domItem.find('#solapas_ancho_sobrecubierta');
|
||||||
|
|
||||||
|
this.divSolapasCubierta = this.domItem.find('#div_solapas_ancho');
|
||||||
|
this.divSolapasSobrecubierta = this.domItem.find('#div_solapas_ancho_sobrecubierta');
|
||||||
|
|
||||||
|
this.acabadoCubierta = new ClassSelect($("#acabado_cubierta_id"),
|
||||||
|
'/serviciosacabados/getacabados',
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
{
|
||||||
|
[this.csrf_token]: this.csrf_hash,
|
||||||
|
"cubierta": 1
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.acabadoSobrecubierta = new ClassSelect($("#acabado_sobrecubierta_id"),
|
||||||
|
'/serviciosacabados/getacabados',
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
{
|
||||||
|
[this.csrf_token]: this.csrf_hash,
|
||||||
|
"sobrecubierta": 1
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.retractilado = this.domItem.find('#retractilado');
|
||||||
|
this.retractilado5 = this.domItem.find('#retractilado5');
|
||||||
|
this.prototipo = this.domItem.find('#prototipo');
|
||||||
|
this.ferro = this.domItem.find('#ferro');
|
||||||
|
this.ferroDigital = this.domItem.find('#ferroDigital');
|
||||||
|
this.marcapaginas = this.domItem.find('#marcapaginas');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
this.tamanio.init();
|
||||||
|
this.acabadoCubierta.init();
|
||||||
|
this.acabadoSobrecubierta.init();
|
||||||
|
|
||||||
|
this.acabadoCubierta.item.on('select2:select', function () {
|
||||||
|
|
||||||
|
$(document).trigger('add-servicio-lineas', 'acabadoCubierta');
|
||||||
|
});
|
||||||
|
this.acabadoSobrecubierta.item.on('select2:select', function () {
|
||||||
|
$(document).trigger('add-servicio-lineas', 'acabadoSobrecubierta');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (window.location.href.includes("edit")) {
|
||||||
|
this.retractilado.on('change', this.checkRetractilado.bind(this));
|
||||||
|
this.retractilado5.on('change', this.checkRetractilado.bind(this));
|
||||||
|
this.ferro.on('change', this.changeFerro.bind(this));
|
||||||
|
this.prototipo.on('change', this.changePrototipo.bind(this));
|
||||||
|
|
||||||
|
this.tamanio.item.on('select2:select', this.changeFormato.bind(this));
|
||||||
|
$('.formato_libro').on('change', this.changeFormato.bind(this));
|
||||||
|
|
||||||
|
if ($('#tipo_impresion_id').val() != 1 && $('#tipo_impresion_id').val() != 3 &&
|
||||||
|
$('#tipo_impresion_id').val() != 5 && $('#tipo_impresion_id').val() != 7) {
|
||||||
|
this.solapasCubierta.on('change', this.changeSolapasCubierta.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.solapasSobrecubierta.on('change', this.changeSolapasSobrecubierta.bind(this));
|
||||||
|
this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this));
|
||||||
|
|
||||||
|
this.paginas.on('change', this.changePaginas.bind(this));
|
||||||
|
this.tirada.on('change', this.changeTirada.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changeFajaColor() {
|
||||||
|
|
||||||
|
if (this.imprimirFajaColor.prop('checked')) {
|
||||||
|
$(document).trigger('add-servicio-lineas', 'facaColor');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(document).trigger('remove-servicio-lineas', 'fajaColor');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changeFerro() {
|
||||||
|
|
||||||
|
if (this.ferro.prop('checked')) {
|
||||||
|
$(document).trigger('add-servicio-lineas', 'ferro');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(document).trigger('remove-servicio-lineas', 'ferro');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changePrototipo() {
|
||||||
|
|
||||||
|
if (this.prototipo.prop('checked')) {
|
||||||
|
|
||||||
|
$(document).trigger('add-servicio-lineas', 'prototipo');
|
||||||
|
this.ferro.prop('checked', true).trigger('change');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(document).trigger('remove-servicio-lineas', 'prototipo');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
checkRetractilado(element) {
|
||||||
|
|
||||||
|
switch (element.id) {
|
||||||
|
case 'retractilado':
|
||||||
|
if ($('#' + element.id).prop('checked')) {
|
||||||
|
$('#retractilado5').prop('checked', false);
|
||||||
|
$(document).trigger('remove-servicio-lineas', 'retractilado5');
|
||||||
|
$(document).trigger('add-servicio-lineas', 'retractilado');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'retractilado5':
|
||||||
|
if ($('#' + element.id).prop('checked')) {
|
||||||
|
$('#retractilado').prop('checked', false);
|
||||||
|
$(document).trigger('remove-servicio-lineas', 'retractilado');
|
||||||
|
$(document).trigger('add-servicio-lineas', 'retractilado5');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
changeFormato() {
|
||||||
|
|
||||||
|
// Si es negro o color
|
||||||
|
if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
|
||||||
|
$('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||||
|
$('#compPaginasNegro').trigger('change')
|
||||||
|
}
|
||||||
|
// Si es negrohq o colorhq
|
||||||
|
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
|
||||||
|
$('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||||
|
$('#compPaginasNegrohq').trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.solapas_cubierta').trigger('change');
|
||||||
|
$('.solapas_sobrecubierta').trigger('change');
|
||||||
|
|
||||||
|
this.checkPaginasPresupuesto();
|
||||||
|
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas : true,
|
||||||
|
update_servicios : true,
|
||||||
|
update_envios: true,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
changeTipoTamanio() {
|
||||||
|
|
||||||
|
if (this.tamanioPersonalizado.prop('checked')) {
|
||||||
|
$('.tamanio-personalizado').removeClass('d-none');
|
||||||
|
$('.tamanio-estandar').addClass('d-none');
|
||||||
|
this.tamanio.setVal('');
|
||||||
|
$("#label_papelFormatoId").text(
|
||||||
|
window.language.Presupuestos.papelFormatoId + " (" +
|
||||||
|
window.language.Presupuestos.papelFormatoAncho + " x " + window.language.Presupuestos.papelFormatoAncho + ")*");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.anchoPersonalizado.val("");
|
||||||
|
this.altoPersonalizado.val("");
|
||||||
|
$('.tamanio-personalizado').addClass('d-none');
|
||||||
|
$('.tamanio-estandar').removeClass('d-none');
|
||||||
|
$("#label_papelFormatoId").text(
|
||||||
|
window.language.Presupuestos.papelFormatoId + '*');
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas : true,
|
||||||
|
update_servicios : false,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: false,
|
||||||
|
update_tiradas_alternativas: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
changeSolapasCubierta() {
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.solapasCubierta.prop('checked')) {
|
||||||
|
$('#div_solapas_ancho').removeClass('d-none');
|
||||||
|
$(document).trigger('add-servicio-lineas', 'solapas');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#div_solapas_ancho').addClass('d-none');
|
||||||
|
this.anchoSolapasCubierta.val(60);
|
||||||
|
$(document).trigger('remove-servicio-lineas', 'solapas');
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas : false,
|
||||||
|
update_servicios : true,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: false,
|
||||||
|
update_tiradas_alternativas: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
changeSolapasSobrecubierta() {
|
||||||
|
|
||||||
|
if (this.solapasSobrecubierta.prop('checked')) {
|
||||||
|
this.divSolapasSobrecubierta.removeClass('d-none');
|
||||||
|
$(document).trigger('remove-servicio-lineas', 'solapas');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.divSolapasSobrecubierta.addClass('d-none');
|
||||||
|
this.anchoSolapasSobrecubierta.val(60);
|
||||||
|
$(document).trigger('add-servicio-lineas', 'solapas');
|
||||||
|
}
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas : false,
|
||||||
|
update_servicios : true,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: false,
|
||||||
|
update_tiradas_alternativas: false
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
changePaginas() {
|
||||||
|
|
||||||
|
if ($('#tipo_impresion_id').val() == 21) {
|
||||||
|
if (parseInt($('#paginas').val()) > 80) {
|
||||||
|
$('#paginas').val(80)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.location.href.includes('edit')) {
|
||||||
|
|
||||||
|
this.checkPaginasPresupuesto();
|
||||||
|
|
||||||
|
// Si es negro o color
|
||||||
|
if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
|
||||||
|
$('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||||
|
$('#compPaginasNegro').val(parseInt($('#paginas').val()) - parseInt($('#compPaginasColor').val()));
|
||||||
|
$('#compPaginasNegro').trigger('change')
|
||||||
|
}
|
||||||
|
// Si es negrohq o colorhq
|
||||||
|
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
|
||||||
|
$('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||||
|
$('#compPaginasNegrohq').val(parseInt($('#paginas').val()) - parseInt($('#compPaginasColorhq').val()));
|
||||||
|
$('#compPaginasNegrohq').trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas : true,
|
||||||
|
update_servicios : true,
|
||||||
|
update_envios: true,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
changeTirada(update_tiradas_alternativas = true) {
|
||||||
|
|
||||||
|
this.calcular_mermas()
|
||||||
|
|
||||||
|
const url2 = window.location.href;
|
||||||
|
const url_parts2 = url2.split('/');
|
||||||
|
|
||||||
|
if (url_parts2[url_parts2.length - 2] == 'edit') {
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas : true,
|
||||||
|
update_servicios : false,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: false,
|
||||||
|
update_tiradas_alternativas: false
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).trigger('ckeck-lineas-envios');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
calcular_mermas() {
|
||||||
|
|
||||||
|
const tirada = parseInt($('#tirada').val());
|
||||||
|
const POD = parseInt($('#POD').val());
|
||||||
|
let merma = 0;
|
||||||
|
let htmlString = '';
|
||||||
|
|
||||||
|
if (tirada > POD) {
|
||||||
|
merma = tirada * 0.1 <= POD ? tirada * 0.1 : POD;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let merma_lineas = []
|
||||||
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
if (rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta') {
|
||||||
|
const formas_linea = parseInt($('#isCosido').val()) == 0 ? parseInt(rowData.formas) : parseInt(rowData.formas) / 2
|
||||||
|
if (formas_linea > tirada)
|
||||||
|
merma_lineas.push(formas_linea - tirada)
|
||||||
|
else
|
||||||
|
merma_lineas.push(tirada % formas_linea)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
if (merma_lineas.length > 0)
|
||||||
|
merma = Math.max(...merma_lineas)
|
||||||
|
else {
|
||||||
|
htmlString = `
|
||||||
|
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||||
|
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||||
|
<i class="ti ti-bell ti-sm"></i>
|
||||||
|
</span>
|
||||||
|
<div class="d-flex flex-column ps-1">
|
||||||
|
<h5 class="alert-heading mb-2">` +
|
||||||
|
window.language.Presupuestos.validation.no_lp_for_merma +
|
||||||
|
`</h5>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
|
||||||
|
merma = 0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$('#mermacubierta').val(parseInt(merma))
|
||||||
|
$('#merma').val(parseInt(merma))
|
||||||
|
$('#alert-datosLibro').html(htmlString)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cargarDatos(datos) {
|
||||||
|
|
||||||
|
this.paginas.val(datos.paginas);
|
||||||
|
this.tirada.val(datos.tirada);
|
||||||
|
this.calcular_mermas();
|
||||||
|
if (datos.papelFormatoPersonalizado) {
|
||||||
|
this.tamanioPersonalizado.prop('checked', true);
|
||||||
|
$(".tamanio-personalizado").removeClass('d-none');
|
||||||
|
$(".tamanio-estandar").addClass('d-none');
|
||||||
|
this.anchoPersonalizado.val(datos.papelFormatoAlto);
|
||||||
|
this.altoPersonalizado.val(datos.papelFormatoAncho);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(".tamanio-personalizado").addClass('d-none');
|
||||||
|
$(".tamanio-estandar").removeClass('d-none');
|
||||||
|
this.tamanio.setOption(datos.papelFormatoId, datos.papelFormatoNombre);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.merma.val(datos.merma);
|
||||||
|
this.mermaCubierta.val(datos.mermaCubierta);
|
||||||
|
|
||||||
|
if ($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3 ||
|
||||||
|
$('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 7) {
|
||||||
|
$(".solapas-cubierta-div").addClass('d-none');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (datos.solapasCubierta) {
|
||||||
|
this.solapasCubierta.prop('checked', true);
|
||||||
|
this.anchoSolapasCubierta.val(datos.solapasCubiertaAncho);
|
||||||
|
this.divSolapasSobrecubierta.removeClass('d-none');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.solapasCubierta.prop('checked', false);
|
||||||
|
this.anchoSolapasCubierta.val(60);
|
||||||
|
this.divSolapasSobrecubierta.addClass('d-none');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (datos.solapasSobrecubierta) {
|
||||||
|
this.solapasSobrecubierta.prop('checked', true);
|
||||||
|
this.anchoSolapasSobrecubierta.val(datos.solapasSobrecubiertaAncho);
|
||||||
|
$('#div_solapas_ancho_sobrecubierta').removeClass('d-none');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.solapasSobrecubierta.prop('checked', false);
|
||||||
|
this.anchoSolapasSobrecubierta.val(60);
|
||||||
|
$('#div_solapas_ancho_sobrecubierta').addClass('d-none');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.acabadoCubierta.setOption(datos.acabadoCubierta.id, datos.acabadoCubierta.text);
|
||||||
|
|
||||||
|
if ($('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 6 ||
|
||||||
|
$('#tipo_impresion_id').val() == 7 || $('#tipo_impresion_id').val() == 8
|
||||||
|
|| $('#tipo_impresion_id').val() == 21) {
|
||||||
|
$(".impresion-con-sobrecubierta").addClass('d-none');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
this.acabadoSobrecubierta.setOption(datos.acabadoSobrecubierta.id, datos.acabadoSobrecubierta.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.retractilado.prop('checked', datos.retractilado);
|
||||||
|
this.retractilado5.prop('checked', datos.retractilado5);
|
||||||
|
this.prototipo.prop('checked', datos.prototipo);
|
||||||
|
this.ferro.prop('checked', datos.ferro);
|
||||||
|
this.ferroDigital.prop('checked', datos.ferroDigital);
|
||||||
|
this.marcapaginas.prop('checked', datos.marcapaginas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default DatosLibro;
|
||||||
@ -0,0 +1,675 @@
|
|||||||
|
import Ajax from "../../../components/ajax.js";
|
||||||
|
import { getToken } from "../../../common/common.js";
|
||||||
|
import ClassSelect from "../../../components/select2.js";
|
||||||
|
import ModalYesNo from "../../../components/modalYesNo.js";
|
||||||
|
|
||||||
|
|
||||||
|
class Envios {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
this.csrf_token = getToken();
|
||||||
|
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||||
|
|
||||||
|
this.recogerTaller = $('#recoger_en_taller');
|
||||||
|
|
||||||
|
this.table = null;
|
||||||
|
this.direccionesClienteForm = new ClassSelect($('#add_clientedAdd'), '/misdirecciones/getSelect2', 'Seleccione una direccion', false, {});
|
||||||
|
this.paisesClienteForm = new ClassSelect($('#add_pais_id'), '/paises/menuitems2', 'Seleccione país', false, {});
|
||||||
|
this.modalYesNo = null;
|
||||||
|
|
||||||
|
this.insertarEnvio = $('#insertar_direccion');
|
||||||
|
|
||||||
|
this.actionBtns_direcciones = function (data) {
|
||||||
|
return `
|
||||||
|
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-add mx-2" data-id="${data.id}"></i></a></span>
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas delete-add-row mx-2"></i></a>
|
||||||
|
`;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
this.paisesClienteForm.init();
|
||||||
|
|
||||||
|
this.table = $('#tableOfDireccionesEnvio').DataTable({
|
||||||
|
draw: 5,
|
||||||
|
serverSide: false,
|
||||||
|
processing: true,
|
||||||
|
autoWidth: true,
|
||||||
|
responsive: true,
|
||||||
|
order: [[0, "asc"]],
|
||||||
|
pageLength: 20,
|
||||||
|
lengthChange: false,
|
||||||
|
searching: false,
|
||||||
|
paging: false,
|
||||||
|
info: false,
|
||||||
|
scrollX: true,
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
{ 'data': 'tarifa_id' },
|
||||||
|
{ 'data': 'cantidad' },
|
||||||
|
{ 'data': 'peso' },
|
||||||
|
{ 'data': 'att' },
|
||||||
|
{ 'data': 'email' },
|
||||||
|
{ 'data': 'direccion' },
|
||||||
|
{ 'data': 'cp' },
|
||||||
|
{ 'data': 'municipio' },
|
||||||
|
{ 'data': 'pais' },
|
||||||
|
{ 'data': 'pais_id', visible: false },
|
||||||
|
{ 'data': 'telefono' },
|
||||||
|
{ 'data': 'proveedor' },
|
||||||
|
{ 'data': 'proveedor_id', visible: false },
|
||||||
|
{ 'data': 'precio' },
|
||||||
|
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
|
||||||
|
{ 'data': 'entregaPieCalle' },
|
||||||
|
{
|
||||||
|
data: function (row, type, set, meta) {
|
||||||
|
return `
|
||||||
|
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-envio mx-2" data-id="${row.id}"></i></a></span>
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
|
||||||
|
`;
|
||||||
|
},
|
||||||
|
className: 'row-edit dt-center'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
columnDefs: [
|
||||||
|
|
||||||
|
{
|
||||||
|
orderable: false,
|
||||||
|
searchable: false,
|
||||||
|
targets: [$('#tableOfDireccionesEnvio').find("tr:first th").length - 1]
|
||||||
|
},
|
||||||
|
{ "orderData": [0], "targets": 0 },
|
||||||
|
|
||||||
|
],
|
||||||
|
language: {
|
||||||
|
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||||
|
},
|
||||||
|
|
||||||
|
drawCallback: function (settings) {
|
||||||
|
|
||||||
|
const boolCols = [15];
|
||||||
|
for (let coln of boolCols) {
|
||||||
|
self.table.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
|
||||||
|
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// obtener la suma del precio de los envios
|
||||||
|
let total = 0;
|
||||||
|
self.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let data = this.data();
|
||||||
|
total += parseFloat(data.precio);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#costeEnvios").text(total.toFixed(2) + "€" || "0€");
|
||||||
|
|
||||||
|
self.check_unidades_enviadas();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-delete-envio', function () {
|
||||||
|
const rowId = $(this).closest('td').parent()[0].sectionRowIndex;
|
||||||
|
self.table.row(rowId).remove().draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-edit-envio', function () {
|
||||||
|
const rowId = $(this).closest('td').parent()[0].sectionRowIndex;
|
||||||
|
const data = $('#tableOfDireccionesEnvio').DataTable().row(rowId).data();
|
||||||
|
|
||||||
|
$("#addressForm").attr('action', 'edit')
|
||||||
|
$("#addressForm").attr('row', rowId)
|
||||||
|
$("#addressForm").attr('presupuestodireccion_id', data.id)
|
||||||
|
let $newAddDialog = $("#addressForm")
|
||||||
|
let maximaCantidad = parseInt($('#tirada').val())
|
||||||
|
$("#add_cantidad").attr("max", maximaCantidad);
|
||||||
|
$("#add_cantidad").val(maximaCantidad);
|
||||||
|
$("#add_cantidad").on('change', function () {
|
||||||
|
$("#add_cantidad").val(parseInt($("#add_cantidad").val()) > maximaCantidad ? maximaCantidad : $("#add_cantidad").val())
|
||||||
|
})
|
||||||
|
|
||||||
|
let cantidad_total = 0
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let data2 = this.data();
|
||||||
|
cantidad_total += parseInt(data2.cantidad)
|
||||||
|
});
|
||||||
|
cantidad_total -= parseInt(data.cantidad) // Si es editar tienes que restar los de la linea actual
|
||||||
|
$('#add_cantidad').attr('max-value', parseInt($('#tirada').val()) - cantidad_total)
|
||||||
|
$('#add_cantidad').val(parseInt($('#tirada').val()) - cantidad_total)
|
||||||
|
|
||||||
|
$('#add_att').val(data.att)
|
||||||
|
$('#add_direccion').val(data.direccion)
|
||||||
|
$('#add_email').val(data.email)
|
||||||
|
$('#add_cp').val(data.cp)
|
||||||
|
$('#add_municipio').val(data.municipio)
|
||||||
|
$('#add_provincia').val(data.provincia)
|
||||||
|
self.paisesClienteForm.setOption(data.pais_id, data.pais);
|
||||||
|
$('#add_telefono').val(data.telefono)
|
||||||
|
$('#add_cantidad').val(data.cantidad)
|
||||||
|
$('#add_entregaPieCalle').prop('checked', data.entregaPieCalle == 1 ? true : false)
|
||||||
|
|
||||||
|
self.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
|
||||||
|
self.direccionesClienteForm.init();
|
||||||
|
|
||||||
|
$newAddDialog.modal('show')
|
||||||
|
});
|
||||||
|
|
||||||
|
this.recogerTaller.on('change', function () {
|
||||||
|
|
||||||
|
const current_value = this.checked;
|
||||||
|
self.recogerTaller.prop('checked', false);
|
||||||
|
|
||||||
|
if (current_value) {
|
||||||
|
self.modalYesNo = new ModalYesNo("Esto borrará todas las direcciones de envío. ¿Está seguro?", "modalYesNoEnvios");
|
||||||
|
self.modalYesNo.init();
|
||||||
|
self.modalYesNo.show(() => {
|
||||||
|
self.table.clear().draw();
|
||||||
|
self.check_unidades_enviadas();
|
||||||
|
self.recogerTaller.prop('checked', true);
|
||||||
|
self.modalYesNo.hide();
|
||||||
|
self.insertarEnvio.addClass('d-none');
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.insertarEnvio.removeClass('d-none');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.insertarEnvio.on('click', this.addEnvio.bind(this));
|
||||||
|
|
||||||
|
this.initFormularioDireccionEnvio();
|
||||||
|
|
||||||
|
$(document).on('update-envios', async function () {
|
||||||
|
|
||||||
|
await self.updateTablaEnvios();
|
||||||
|
|
||||||
|
$(document).trigger('update-envios-completed');
|
||||||
|
|
||||||
|
});
|
||||||
|
$(document).on('ckeck-lineas-envios', this.check_unidades_enviadas.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
addEnvio() {
|
||||||
|
|
||||||
|
$("#addressForm").attr('action', 'create');
|
||||||
|
let newAddDialog = $("#addressForm");
|
||||||
|
this.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
|
||||||
|
this.direccionesClienteForm.init();
|
||||||
|
let maximaCantidad = parseInt($('#tirada').val());
|
||||||
|
$("#add_cantidad").attr("max", maximaCantidad);;
|
||||||
|
$("#add_cantidad").val(maximaCantidad);
|
||||||
|
$("#add_cantidad").on('change', function () {
|
||||||
|
$("#add_cantidad").val(parseInt($("#add_cantidad").val()) > maximaCantidad ? maximaCantidad : $("#add_cantidad").val());
|
||||||
|
})
|
||||||
|
|
||||||
|
let cantidad_total = 0;
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let data = this.data();
|
||||||
|
cantidad_total += parseInt(data.cantidad);
|
||||||
|
});
|
||||||
|
$('#add_cantidad').attr('max-value', parseInt($('#tirada').val()) - cantidad_total);
|
||||||
|
$('#add_cantidad').val(parseInt($('#tirada').val()) - cantidad_total);
|
||||||
|
newAddDialog.modal('show');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
get_peso_libro() {
|
||||||
|
|
||||||
|
var peso_total_libro = 0.0
|
||||||
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
peso_total_libro += parseFloat(rowData.peso)
|
||||||
|
})
|
||||||
|
return peso_total_libro;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async guardarEnvios() {
|
||||||
|
|
||||||
|
var id = window.location.pathname.split('/').pop();
|
||||||
|
|
||||||
|
await $.post('/presupuestodirecciones/datatable',
|
||||||
|
Object.assign({ tipo: "clear_lineas", presupuesto_id: id }, window.token_ajax))
|
||||||
|
.done(function (data) {
|
||||||
|
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var data = this.data();
|
||||||
|
await $.post('/presupuestos/presupuestodirecciones/add',
|
||||||
|
{
|
||||||
|
presupuesto_id: id,
|
||||||
|
tarifa_id: data.tarifa_id,
|
||||||
|
cantidad: data.cantidad,
|
||||||
|
peso: data.peso,
|
||||||
|
att: data.att,
|
||||||
|
email: data.email,
|
||||||
|
direccion: data.direccion,
|
||||||
|
pais_id: data.pais_id,
|
||||||
|
provincia: data.provincia,
|
||||||
|
municipio: data.municipio,
|
||||||
|
cp: data.cp,
|
||||||
|
telefono: data.telefono,
|
||||||
|
precio: data.precio,
|
||||||
|
margen: data.margen,
|
||||||
|
proveedor: data.proveedor,
|
||||||
|
proveedor_id: data.proveedor_id,
|
||||||
|
entregaPieCalle: data.entregaPieCalle
|
||||||
|
})
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async updateTiradaBase() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
var peso_total_libro = this.get_peso_libro();
|
||||||
|
|
||||||
|
const tirada = parseInt($('#tirada').val());
|
||||||
|
const peso_envio = peso_total_libro * tirada / 1000.0;
|
||||||
|
|
||||||
|
let pais = 1;
|
||||||
|
let cp = 18000;
|
||||||
|
let entrega = 'cajas';
|
||||||
|
|
||||||
|
var datos_tarifa = await self.get_precio_envio(peso_envio, pais, cp, entrega);
|
||||||
|
|
||||||
|
if (datos_tarifa.id != null) {
|
||||||
|
|
||||||
|
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
|
||||||
|
else {
|
||||||
|
let m = ((parseFloat(datos_tarifa.precio_max) - parseFloat(datos_tarifa.precio_min)) / (parseFloat(datos_tarifa.peso_max) - parseFloat(datos_tarifa.peso_min)));
|
||||||
|
let b = parseFloat(datos_tarifa.precio_max) - m * parseFloat(datos_tarifa.peso_max);
|
||||||
|
datos_tarifa.precio = parseFloat(m * peso_envio + b);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#envio_base').val(datos_tarifa.precio.toFixed(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateTablaEnvios(event, input_data = {}) {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
var peso_total_libro = this.get_peso_libro();
|
||||||
|
|
||||||
|
await self.updateTiradaBase();
|
||||||
|
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
|
||||||
|
var rowData = this.data();
|
||||||
|
|
||||||
|
if (Object.keys(input_data).length > 0) {
|
||||||
|
const porcentaje = parseInt(rowData.cantidad) / input_data.tirada_inicial * 100.0;
|
||||||
|
const cantidad = Math.floor(input_data.tirada * porcentaje / 100.0);
|
||||||
|
rowData.cantidad = cantidad;
|
||||||
|
}
|
||||||
|
|
||||||
|
const peso_envio = peso_total_libro * parseInt(rowData.cantidad) / 1000.0;
|
||||||
|
const tirada = parseInt($('#tirada').val());
|
||||||
|
var datos_tarifa = await self.get_precio_envio(peso_envio, rowData.pais_id, rowData.cp, parseInt(rowData.entregaPieCalle) == 1 ? 'palets' : 'cajas');
|
||||||
|
|
||||||
|
|
||||||
|
if (datos_tarifa.id != null) {
|
||||||
|
|
||||||
|
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
|
||||||
|
else {
|
||||||
|
let m = ((parseFloat(datos_tarifa.precio_max) - parseFloat(datos_tarifa.precio_min)) / (parseFloat(datos_tarifa.peso_max) - parseFloat(datos_tarifa.peso_min)));
|
||||||
|
let b = parseFloat(datos_tarifa.precio_max) - m * parseFloat(datos_tarifa.peso_max);
|
||||||
|
datos_tarifa.precio = parseFloat(m * peso_envio + b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
datos_tarifa.cantidad = parseInt($('#add_cantidad').val());
|
||||||
|
datos_tarifa.peso = peso_envio;
|
||||||
|
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().row(rowIdx)
|
||||||
|
.data({
|
||||||
|
'tarifa_id': datos_tarifa.id,
|
||||||
|
'cantidad': rowData.cantidad,
|
||||||
|
'peso': datos_tarifa.peso.toFixed(3),
|
||||||
|
'att': rowData.att,
|
||||||
|
'email': rowData.email,
|
||||||
|
'direccion': rowData.direccion,
|
||||||
|
'cp': rowData.cp,
|
||||||
|
'municipio': rowData.municipio,
|
||||||
|
'provincia': rowData.provincia,
|
||||||
|
'pais_id': rowData.pais_id,
|
||||||
|
'pais': datos_tarifa.pais,
|
||||||
|
'telefono': rowData.telefono,
|
||||||
|
'proveedor': datos_tarifa.proveedor,
|
||||||
|
'proveedor_id': datos_tarifa.proveedor_id,
|
||||||
|
'precio': datos_tarifa.precio.toFixed(2),
|
||||||
|
'margen': datos_tarifa.margen,
|
||||||
|
'entregaPieCalle': rowData.entregaPieCalle,
|
||||||
|
'actionBtns_direcciones': self.actionBtns_direcciones,
|
||||||
|
})
|
||||||
|
.draw();
|
||||||
|
|
||||||
|
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas: false,
|
||||||
|
update_servicios: false,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
popErrorAlert(window.error_no_tarifa_envio, 'error-tarifa')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (Object.keys(input_data).length > 0) {
|
||||||
|
|
||||||
|
$('#tirada').val(input_data.tirada);
|
||||||
|
$('#tirada').trigger('change', [false]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async get_precio_envio(peso, paisId, cp, tipo_envio) {
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
tipo: 'get_tarifa',
|
||||||
|
peso: peso,
|
||||||
|
paisId: paisId,
|
||||||
|
cp: cp,
|
||||||
|
tipo_envio: tipo_envio,
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch('/presupuestodirecciones/datatable_2', {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const values = await response.json();
|
||||||
|
return values.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormularioDireccionEnvio() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
this.direccionesClienteForm.item.on('select2:select', function (e) {
|
||||||
|
|
||||||
|
$('.save-alias').css('display', 'none');
|
||||||
|
$('#add_alias').val('');
|
||||||
|
$('#add_saveDirection').attr("disabled", true);
|
||||||
|
|
||||||
|
let data = e.params.data;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: '/clientedirecciones/datatable',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
tipo: 'direccion',
|
||||||
|
id: data.id,
|
||||||
|
[self.csrf_token]: self.csrf_hash
|
||||||
|
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
if (data.length > 0) {
|
||||||
|
$('#add_att').val(data[0].att);
|
||||||
|
$('#add_direccion').val(data[0].direccion);
|
||||||
|
$('#add_cp').val(data[0].cp);
|
||||||
|
$('#add_municipio').val(data[0].municipio);
|
||||||
|
$('#add_provincia').val(data[0].provincia);
|
||||||
|
$('#add_telefono').val(data[0].telefono);
|
||||||
|
$('#add_email').val(data[0].email);
|
||||||
|
self.paisesClienteForm.empty();
|
||||||
|
self.paisesClienteForm.setOption(data[0].pais_id, data[0].pais);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#addressForm').on('hidden.bs.modal', function () {
|
||||||
|
$('#add_alias').val("");
|
||||||
|
$('#add_att').val("");
|
||||||
|
$('#add_email').val("");
|
||||||
|
$('#add_direccion').val("");
|
||||||
|
self.paisesClienteForm.empty();
|
||||||
|
self.direccionesClienteForm.empty();
|
||||||
|
$('#add_municipio').val("");
|
||||||
|
$('#add_provincia').val("");
|
||||||
|
$('#add_cp').val("");
|
||||||
|
$('#add_telefono').val("");
|
||||||
|
$('#add_saveDirection').prop('checked', false)
|
||||||
|
$('#add_entregaPieCalle').prop('checked', false)
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#cancelAdd').on('click', function () {
|
||||||
|
$('#addressForm').modal("hide");
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#add_cantidad').on('change', function () {
|
||||||
|
if (parseInt($('#add_cantidad').val()) > $('#add_cantidad').attr('max-value'))
|
||||||
|
$('#add_cantidad').val($('#add_cantidad').attr('max-value'))
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#saveDireccionEnvio').on('click', function () {
|
||||||
|
|
||||||
|
if (self.validate_fields()) {
|
||||||
|
|
||||||
|
if ($('#addressForm').attr('action') == 'edit') {
|
||||||
|
self.table.row($("#addressForm").attr('row'))
|
||||||
|
.remove()
|
||||||
|
.draw();
|
||||||
|
}
|
||||||
|
let peso_total_libro = 0
|
||||||
|
|
||||||
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
peso_total_libro += parseFloat(rowData.peso)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
const peso_envio = peso_total_libro * parseInt($('#add_cantidad').val()) / 1000.0
|
||||||
|
|
||||||
|
|
||||||
|
$.post('/presupuestodirecciones/datatable',
|
||||||
|
{
|
||||||
|
tipo: "get_tarifa",
|
||||||
|
peso: peso_envio,
|
||||||
|
paisId: $("#add_pais_id").val(),
|
||||||
|
cp: $('#add_cp').val(),
|
||||||
|
tipo_envio: $('#add_entregaPieCalle').is(":checked") ? 'palets' : 'cajas',
|
||||||
|
[self.csrf_token]: self.csrf_hash
|
||||||
|
})
|
||||||
|
.done(function (data) {
|
||||||
|
if (data.length > 0) {
|
||||||
|
|
||||||
|
let precios = []
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
let m = ((data[i].precio_max - data[i].precio_min) / (data[i].peso_max - data[i].peso_min))
|
||||||
|
let b = data[i].precio_max - m * data[i].peso_max
|
||||||
|
data[i].precio = parseFloat(m * peso_envio + b).toFixed(2);
|
||||||
|
}
|
||||||
|
data[i].margen = data[i].margen
|
||||||
|
}
|
||||||
|
|
||||||
|
let tarifa_final = data.reduce((previous, current) => {
|
||||||
|
return current.precio < previous.precio ? current : previous;
|
||||||
|
});
|
||||||
|
tarifa_final.cantidad = parseInt($('#add_cantidad').val())
|
||||||
|
tarifa_final.peso = peso_envio
|
||||||
|
|
||||||
|
|
||||||
|
self.table.row
|
||||||
|
.add({
|
||||||
|
'tarifa_id': tarifa_final.id,
|
||||||
|
'cantidad': tarifa_final.cantidad,
|
||||||
|
'peso': tarifa_final.peso.toFixed(3),
|
||||||
|
'att': $('#add_att').val(),
|
||||||
|
'email': $('#add_email').val(),
|
||||||
|
'direccion': $('#add_direccion').val(),
|
||||||
|
'cp': $('#add_cp').val(),
|
||||||
|
'municipio': $('#add_municipio').val(),
|
||||||
|
'provincia': $('#add_provincia').val(),
|
||||||
|
'pais_id': $('#add_pais_id').select2('data')[0].id,
|
||||||
|
'pais': $('#add_pais_id').select2('data')[0].text,
|
||||||
|
'telefono': $('#add_telefono').val(),
|
||||||
|
'proveedor': tarifa_final.proveedor,
|
||||||
|
'proveedor_id': tarifa_final.proveedor_id,
|
||||||
|
'precio': tarifa_final.precio,
|
||||||
|
'margen': tarifa_final.margen,
|
||||||
|
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked") ? 1 : 0,
|
||||||
|
'actionBtns_direcciones': `
|
||||||
|
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-envio mx-2"></i></a></span>
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
.draw();
|
||||||
|
|
||||||
|
|
||||||
|
// Se guarda la dirección
|
||||||
|
if ($('#add_saveDirection').is(":checked") &&
|
||||||
|
$('#add_alias').val().length > 0) {
|
||||||
|
$.post('/clientes/clientedirecciones/add',
|
||||||
|
{
|
||||||
|
cliente_id: $('#clienteId').val(),
|
||||||
|
'att': $('#add_att').val(),
|
||||||
|
'email': $('#add_email').val(),
|
||||||
|
'direccion': $('#add_direccion').val(),
|
||||||
|
'cp': $('#add_cp').val(),
|
||||||
|
'municipio': $('#add_municipio').val(),
|
||||||
|
'provincia': $('#add_provincia').val(),
|
||||||
|
'paisId': $('#add_pais_id').val(),
|
||||||
|
'telefono': $('#add_telefono').val(),
|
||||||
|
'alias': $('#add_alias').val(),
|
||||||
|
[self.csrf_token]: self.csrf_hash
|
||||||
|
})
|
||||||
|
.done(function (data) {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).trigger('ckeck-lineas-envios');
|
||||||
|
|
||||||
|
$(document).trigger('update-presupuesto', {
|
||||||
|
update_lineas : false,
|
||||||
|
update_servicios : true,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#addressForm').modal("hide");
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
popErrorAlert(window.language.PresupuestosDirecciones.validation.no_tarifa, 'error-tarifa')
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#add_saveDirection').on('change', function () {
|
||||||
|
if (this.checked) {
|
||||||
|
$('.save-alias').css('display', 'inline')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.save-alias').css('display', 'none')
|
||||||
|
}
|
||||||
|
$('#add_saveDirection').val(this.checked);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('.new-address').on('change', function (e) {
|
||||||
|
if (e.originalEvent) {
|
||||||
|
// user-triggered event
|
||||||
|
$('#add_clientedAdd').val(null).trigger('change');
|
||||||
|
$('#add_saveDirection').removeAttr("disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_fields() {
|
||||||
|
|
||||||
|
$(".error-text-form").remove();
|
||||||
|
|
||||||
|
let returnValue = false
|
||||||
|
|
||||||
|
$("input.new-address").each(function () {
|
||||||
|
if ($('#' + this.id).val().length == 0 && $('#' + this.id).css('display') != 'none') {
|
||||||
|
$('#' + this.id).after(
|
||||||
|
"<p style='font-size: 11px !important;" +
|
||||||
|
"padding: 0 !important; " +
|
||||||
|
"color: #b11f1f !important;' " +
|
||||||
|
"class='error-text-form'>" + window.language.PresupuestosDirecciones.validation.required + '</p>')
|
||||||
|
}
|
||||||
|
returnValue = true
|
||||||
|
})
|
||||||
|
return returnValue
|
||||||
|
}
|
||||||
|
|
||||||
|
cargar(datos) {
|
||||||
|
if (datos.entrega_taller) {
|
||||||
|
this.recogerTaller.prop('checked', true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.table.rows.add(datos).draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
check_unidades_enviadas() {
|
||||||
|
|
||||||
|
let cantidad_total = 0
|
||||||
|
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
cantidad_total += parseInt(this.data().cantidad)
|
||||||
|
});
|
||||||
|
|
||||||
|
const tirada = parseInt($('#tirada').val());
|
||||||
|
let htmlString = '';
|
||||||
|
if (cantidad_total < tirada && this.recogerTaller.prop('checked') === false) {
|
||||||
|
htmlString = `
|
||||||
|
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||||
|
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||||
|
<i class="ti ti-bell ti-sm"></i>
|
||||||
|
</span>
|
||||||
|
<div class="d-flex flex-column ps-1">
|
||||||
|
<h5 class="alert-heading mb-2">` +
|
||||||
|
window.language.Presupuestos.validation.ejemplares_envio +
|
||||||
|
`</h5>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
$('#alert-envios').html(htmlString);
|
||||||
|
this.insertarEnvio.removeClass('d-none');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.insertarEnvio.addClass('d-none');
|
||||||
|
$('#alert-envios').html(htmlString);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Envios;
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,86 @@
|
|||||||
|
import preview from '../../../components/preview.js';
|
||||||
|
|
||||||
|
class PreviewFormasAdmin{
|
||||||
|
|
||||||
|
constructor(tipoLibro, tipoTapa, data){
|
||||||
|
|
||||||
|
this.data = data;
|
||||||
|
this.isCosido = $("#isCosido").val();
|
||||||
|
this.tipoTapa = tipoTapa;
|
||||||
|
|
||||||
|
// Container para el esquema de cubierta
|
||||||
|
this.preview = new preview($('#pv_ec_shape'), tipoLibro, tipoTapa, "fullImage", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
setData(data){
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
init(){
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
$('#tab-pv-bn').on( "click", function() {
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.previewInteriorPlana('bn', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
} );
|
||||||
|
|
||||||
|
$('#tab-pv-bnhq').on( "click", function() {
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.previewInteriorPlana('bnhq', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
} );
|
||||||
|
|
||||||
|
$('#tab-pv-color').on( "click", function() {
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.previewInteriorPlana('color', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
} );
|
||||||
|
|
||||||
|
$('#tab-pv-colorhq').on( "click", function() {
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.previewInteriorPlana('colorhq', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
} );
|
||||||
|
|
||||||
|
$('#tab-pv-rot-bn').on( "click", function() {
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.previewRotativa('rot_bn', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
$('#tab-pv-rot-color').on( "click", function() {
|
||||||
|
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.previewRotativa('rot_color', self.isCosido, self.tipoTapa.constains("dura")?1:0);
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
$('#tab-pv-guardas').on( "click", function() {
|
||||||
|
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.previewInteriorPlana('guardas', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
} );
|
||||||
|
|
||||||
|
$('#tab-pv-cubierta').on( "click", function() {
|
||||||
|
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.previewInteriorPlana('cubierta', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
$('#tab-pv-esquema-cubierta').on( "click", function() {
|
||||||
|
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.getObjetoLP('ec', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
self.preview.previewEsquemaCubierta('ec', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
$('#tab-pv-sobrecubierta').on( "click", function() {
|
||||||
|
|
||||||
|
self.preview.setData(self.data);
|
||||||
|
self.preview.previewInteriorPlana('sobrecubierta', self.isCosido, self.tipoTapa.includes("dura")?1:0);
|
||||||
|
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PreviewFormasAdmin;
|
||||||
@ -0,0 +1,351 @@
|
|||||||
|
class Resumen {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
$(".update-totales").on("change", function () {
|
||||||
|
self.updateTotales(true, true, true)
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('update-totales', async function () {
|
||||||
|
await self.updateTotales();
|
||||||
|
$(document).trigger('update-totales-completed');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cargar(resumen) {
|
||||||
|
|
||||||
|
// Mapear los valores a los elementos HTML por ID
|
||||||
|
$("#totalCostePapel").text(resumen.total_coste_papel + "€" || "0€");
|
||||||
|
$("#porcentajeMargenPapel").text(resumen.total_margenPercent_papel ? resumen.total_margenPercent_papel + "%" : "0%");
|
||||||
|
$("#margenPapel").text(resumen.total_margen_papel + "€" || "0€");
|
||||||
|
|
||||||
|
$("#totalCosteImpresion").text(resumen.total_coste_impresion + "€" || "0€");
|
||||||
|
$("#porcentajeMargenImpresion").text(resumen.total_margenPercent_impresion ? resumen.total_margenPercent_impresion + "%" : "0%");
|
||||||
|
$("#margenImpresion").text(resumen.total_margen_impresion + "€" || "0€");
|
||||||
|
|
||||||
|
$("#totalServicios").text(resumen.total_coste_servicios + "€" || "0€");
|
||||||
|
$("#porcentajeMargenServicios").text(resumen.total_margenPercent_servicios ? resumen.total_margenPercent_servicios + "%" : "0%");
|
||||||
|
$("#margenServicios").text(resumen.total_margen_servicios + "€" || "0€");
|
||||||
|
|
||||||
|
//$("#costeEnvios").text(resumen.total_coste_envios + "€" || "0€");
|
||||||
|
$("#totalEnvios").text(resumen.total_coste_envios + "€" || "0€");
|
||||||
|
$("#margenEnvios").text(resumen.total_margen_envios + "€" || "0€");
|
||||||
|
|
||||||
|
$("#totalCostes").text(resumen.total_costes + "€" || "0€");
|
||||||
|
$("#porcentajeMargen").text(resumen.porcentajeMargen ? resumen.porcentajeMargen + "%" : "0%");
|
||||||
|
$("#totalMargenes").text(resumen.total_margenes + "€" || "0€");
|
||||||
|
|
||||||
|
$("#totalAntesDescuento").text(resumen.total_antes_descuento + "€" || "0€");
|
||||||
|
$("#total_descuentoPercent").val(resumen.total_descuentoPercent || "0");
|
||||||
|
$("#descuentoTotal").text(resumen.total_descuento + "€" || "0€");
|
||||||
|
$("#totalDespuesDecuento").text(resumen.total_presupuesto + "€" || "0€");
|
||||||
|
$("#precioUnidadPresupuesto").text(resumen.total_precio_unidad + "€" || "0€");
|
||||||
|
$("#factor").text(resumen.total_factor || "0");
|
||||||
|
$("#factor_ponderado").text(resumen.total_factor_ponderado || "0");
|
||||||
|
|
||||||
|
if (resumen.total_aceptado !== undefined) {
|
||||||
|
$("#totalAceptado").val(resumen.total_aceptado + "€" || "0€");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formatear agregando separadores de miles
|
||||||
|
addSeparatorsNF(nStr, inD, outD, sep) {
|
||||||
|
nStr += '';
|
||||||
|
let dpos = nStr.indexOf(inD);
|
||||||
|
let nStrEnd = '';
|
||||||
|
if (dpos != -1) {
|
||||||
|
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
|
||||||
|
nStr = nStr.substring(0, dpos);
|
||||||
|
}
|
||||||
|
let rgx = /(\d+)(\d{3})/;
|
||||||
|
while (rgx.test(nStr)) {
|
||||||
|
nStr = nStr.replace(rgx, '$1' + sep + '$2');
|
||||||
|
}
|
||||||
|
return nStr + nStrEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async updateTotales(event, data = {}) {
|
||||||
|
|
||||||
|
let updateLP = data.updateLP || true;
|
||||||
|
let updateServicios = data.updateServicios || true;
|
||||||
|
let updateEnvio = data.updateEnvio || true;
|
||||||
|
let totalPapel = 0;
|
||||||
|
let margenPapel = 0;
|
||||||
|
|
||||||
|
let totalImpresion = 0;
|
||||||
|
let totalImpresionforMargen = 0;
|
||||||
|
let margenImpresion = 0;
|
||||||
|
|
||||||
|
let totalServicios = 0;
|
||||||
|
let margenServicios = 0;
|
||||||
|
|
||||||
|
let totalEnvios = 0;
|
||||||
|
let margenEnvios = 0;
|
||||||
|
|
||||||
|
let sumForFactor = 0.0;
|
||||||
|
let sumForFactorPonderado = 0.0;
|
||||||
|
|
||||||
|
|
||||||
|
let margenPorHoras = 0.0;
|
||||||
|
|
||||||
|
if (updateLP) {
|
||||||
|
|
||||||
|
if (typeof $("#tableLineasPresupuesto").DataTable() !== 'undefined') {
|
||||||
|
$("#tableLineasPresupuesto").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
|
||||||
|
if (rowData.check_papel_total) {
|
||||||
|
totalPapel += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
|
||||||
|
margenPapel += parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
|
||||||
|
|
||||||
|
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
|
||||||
|
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
|
||||||
|
|
||||||
|
}
|
||||||
|
if (rowData.check_impresion_total) {
|
||||||
|
//totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||||
|
margenPorHoras += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||||
|
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||||
|
|
||||||
|
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||||
|
|
||||||
|
if (rowData.maquinaTipo == 'inkjet') {
|
||||||
|
totalImpresion += parseFloat(rowData.totalTinta)
|
||||||
|
totalImpresion += parseFloat(rowData.totalCorte)
|
||||||
|
|
||||||
|
sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
|
||||||
|
}
|
||||||
|
//margenImpresion += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||||
|
//margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||||
|
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||||
|
|
||||||
|
|
||||||
|
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||||
|
|
||||||
|
if (!isNaN(parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val()))) {
|
||||||
|
totalImpresion += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||||
|
sumForFactor += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
totalImpresion -= parseFloat(margenImpresion);
|
||||||
|
totalPapel -= parseFloat(margenPapel);
|
||||||
|
|
||||||
|
margenImpresion += parseFloat(margenPorHoras);
|
||||||
|
|
||||||
|
let porcentajeMargenPapel = isNaN(margenPapel / (totalPapel) * 100.0) ? 0 : margenPapel / (totalPapel) * 100.0
|
||||||
|
$('#porcentajeMargenPapel').text(porcentajeMargenPapel.toFixed(0) + '%')
|
||||||
|
$('#totalCostePapel').text((this.addSeparatorsNF(totalPapel.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#margenPapel').text((this.addSeparatorsNF(margenPapel.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalCostePapel').attr('val', totalPapel.toFixed(2))
|
||||||
|
$('#margenPapel').attr('val', margenPapel.toFixed(2))
|
||||||
|
|
||||||
|
let porcentajeMargenImpresion = isNaN(margenImpresion / (totalImpresion) * 100.0) ? 0 : margenImpresion / (totalImpresion) * 100.0
|
||||||
|
$('#porcentajeMargenImpresion').text(porcentajeMargenImpresion.toFixed(0) + '%')
|
||||||
|
$('#totalCosteImpresion').text((this.addSeparatorsNF(totalImpresion.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#margenImpresion').text((this.addSeparatorsNF(margenImpresion.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalCosteImpresion').attr('val', totalImpresion.toFixed(2))
|
||||||
|
$('#margenImpresion').attr('val', margenImpresion.toFixed(2))
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
totalPapel = parseFloat($('#totalCostePapel').attr('val'))
|
||||||
|
margenPapel = parseFloat($('#margenPapel').attr('val'))
|
||||||
|
totalImpresion = parseFloat($('#totalCosteImpresion').attr('val'))
|
||||||
|
margenImpresion = parseFloat($('#margenImpresion').attr('val'))
|
||||||
|
}
|
||||||
|
|
||||||
|
sumForFactorPonderado = sumForFactor;
|
||||||
|
|
||||||
|
if (updateServicios) {
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosEncuadernacion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = parseFloat(rowData.precio_total);
|
||||||
|
let margen_servicio = parseFloat(rowData.margen);
|
||||||
|
totalServicios += total_servicio
|
||||||
|
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||||
|
margenServicios = total_servicio - base;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosAcabado").DataTable() !== 'undefined' && $("#tableOfServiciosAcabado").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosAcabado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = parseFloat(rowData.precio_total);
|
||||||
|
let margen_servicio = parseFloat(rowData.margen);
|
||||||
|
totalServicios += total_servicio
|
||||||
|
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||||
|
margenServicios = total_servicio - base;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosPreimpresion").DataTable() !== 'undefined' && $("#tableOfServiciosPreimpresion").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosPreimpresion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = parseFloat(rowData.precio);
|
||||||
|
let coste_servicio = parseFloat(rowData.coste);
|
||||||
|
totalServicios += total_servicio
|
||||||
|
margenServicios = total_servicio - coste_servicio;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosExtra").DataTable() !== 'undefined' && $("#tableOfServiciosExtra").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosExtra').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = parseFloat(rowData.precio);
|
||||||
|
let coste_servicio = parseFloat(rowData.coste);
|
||||||
|
totalServicios += total_servicio
|
||||||
|
margenServicios = total_servicio - coste_servicio;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof $("#tableOfServiciosManipulado").DataTable() !== 'undefined' && $("#tableOfServiciosManipulado").DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfServiciosManipulado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
let rowData = this.data();
|
||||||
|
let total_servicio = parseFloat(rowData.precio_total);
|
||||||
|
let margen_servicio = parseFloat(rowData.margen);
|
||||||
|
totalServicios += total_servicio
|
||||||
|
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||||
|
margenServicios = total_servicio - base;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
totalServicios -= margenServicios;
|
||||||
|
|
||||||
|
sumForFactorPonderado += totalServicios;
|
||||||
|
|
||||||
|
let porcentajeMargenServicios = margenServicios / (totalServicios) * 100
|
||||||
|
$('#porcentajeMargenServicios').text(isNaN(porcentajeMargenServicios.toFixed(0)) ? 0 : porcentajeMargenServicios.toFixed(0) + '%')
|
||||||
|
$('#totalServicios').text((this.addSeparatorsNF(totalServicios.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#margenServicios').text((this.addSeparatorsNF(margenServicios.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalServicios').attr('val', totalServicios.toFixed(2) + '€')
|
||||||
|
$('#margenServicios').attr('val', margenServicios.toFixed(2) + '€')
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
totalServicios = parseFloat($('#totalServicios').attr('val'))
|
||||||
|
margenServicios = parseFloat($('#margenServicios').attr('val'))
|
||||||
|
|
||||||
|
sumForFactorPonderado += totalServicios;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateEnvio) {
|
||||||
|
|
||||||
|
totalEnvios = parseFloat($('#envio_base').val());
|
||||||
|
if (typeof $('#tableOfDireccionesEnvio').DataTable() !== 'undefined' && $('#tableOfDireccionesEnvio').DataTable().rows().count() > 0) {
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
if (rowIdx == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let data = this.data()
|
||||||
|
totalEnvios += parseFloat(data.precio)
|
||||||
|
margenEnvios += parseFloat((data.precio) * data.margen / 100)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
totalEnvios -= margenEnvios
|
||||||
|
$('#totalEnvios').text((this.addSeparatorsNF(totalEnvios.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#margenEnvios').text((this.addSeparatorsNF(margenEnvios.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalEnvios').attr('val', totalEnvios.toFixed(2) + '€')
|
||||||
|
$('#margenEnvios').attr('val', margenEnvios.toFixed(2) + '€')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
totalEnvios = parseFloat($('#totalEnvios').attr('val'))
|
||||||
|
margenEnvios = parseFloat($('#margenEnvios').attr('val'))
|
||||||
|
}
|
||||||
|
|
||||||
|
let totalCostes = parseFloat(totalPapel.toFixed(2)) + parseFloat(totalImpresion.toFixed(2)) + parseFloat(totalServicios.toFixed(2)) + parseFloat(totalEnvios.toFixed(2))
|
||||||
|
let totalMargenes = parseFloat(margenPapel.toFixed(2)) + parseFloat(margenImpresion.toFixed(2)) + parseFloat(margenServicios.toFixed(2)) + parseFloat(margenEnvios.toFixed(2))
|
||||||
|
let porcentajeMargen = totalCostes + totalMargenes > 0 ? (100 * totalMargenes / (totalCostes + totalMargenes)).toFixed(0) : 0
|
||||||
|
$('#totalCostes').text((this.addSeparatorsNF(totalCostes.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalMargenes').text((this.addSeparatorsNF(totalMargenes.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalCostes').attr('val', (totalCostes).toFixed(2) + '€')
|
||||||
|
$('#totalMargenes').attr('val', (totalMargenes).toFixed(2) + '€')
|
||||||
|
$('#porcentajeMargen').text(porcentajeMargen + '%')
|
||||||
|
$('#porcentajeMargen').attr('val', porcentajeMargen)
|
||||||
|
|
||||||
|
if ($('#total_descuentoPercent').val() < 0) {
|
||||||
|
$('#total_descuentoPercent').val(0)
|
||||||
|
}
|
||||||
|
let totalAntesDescuento = totalCostes + totalMargenes
|
||||||
|
let totalDescuento = totalAntesDescuento * parseInt($('#total_descuentoPercent').val() || 0) / 100
|
||||||
|
let totalPresupuesto = totalAntesDescuento - totalDescuento
|
||||||
|
let precioUnidad = totalPresupuesto / parseInt($('#tirada').val())
|
||||||
|
|
||||||
|
$('#totalAntesDescuento').text((this.addSeparatorsNF(totalAntesDescuento.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#descuentoTotal').text((this.addSeparatorsNF(totalDescuento.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#totalDespuesDecuento').text((this.addSeparatorsNF(totalPresupuesto.toFixed(2), ".", ",", ".")) + "€")
|
||||||
|
$('#precioUnidadPresupuesto').text((this.addSeparatorsNF(precioUnidad.toFixed(4), ".", ",", ".")) + "€")
|
||||||
|
$('#totalAntesDescuento').attr('val', (totalAntesDescuento).toFixed(2))
|
||||||
|
$('#descuentoTotal').attr('val', (totalDescuento).toFixed(2))
|
||||||
|
$('#totalDespuesDecuento').attr('val', (totalPresupuesto).toFixed(2))
|
||||||
|
$('#precioUnidadPresupuesto').attr('val', (precioUnidad).toFixed(4))
|
||||||
|
|
||||||
|
|
||||||
|
$('#factor').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactor).toFixed(2), ".", ",", "."))
|
||||||
|
$('#factor').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactor).toFixed(2))
|
||||||
|
$('#factor_ponderado').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2), ".", ",", "."))
|
||||||
|
$('#factor_ponderado').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getData(){
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
'total_coste_papel': $('#totalCostePapel').attr('val').replace('€', ''),
|
||||||
|
'total_margen_papel': $('#margenPapel').attr('val').replace('€', ''),
|
||||||
|
'total_margenPercent_papel': $('#porcentajeMargenPapel').text().replace('%', ''),
|
||||||
|
|
||||||
|
'total_coste_impresion': $('#totalCosteImpresion').attr('val').replace('€', ''),
|
||||||
|
'total_margen_impresion': $('#margenImpresion').attr('val').replace('€', ''),
|
||||||
|
'total_margenPercent_impresion': $('#porcentajeMargenImpresion').text().replace('%', ''),
|
||||||
|
|
||||||
|
'total_coste_servicios': $('#totalServicios').attr('val').replace('€', ''),
|
||||||
|
'total_margen_servicios': $('#margenServicios').attr('val').replace('€', ''),
|
||||||
|
'total_margenPercent_servicios': $('#porcentajeMargenServicios').text().replace('%', ''),
|
||||||
|
|
||||||
|
'total_coste_envios': $('#totalEnvios').attr('val').replace('€', ''),
|
||||||
|
'total_margen_envios': $('#margenEnvios').attr('val').replace('€', ''),
|
||||||
|
|
||||||
|
'total_costes': $('#totalCostes').attr('val').replace('€', ''),
|
||||||
|
'total_margenes': $('#totalMargenes').attr('val').replace('€', ''),
|
||||||
|
|
||||||
|
'total_antes_descuento': $('#totalAntesDescuento').attr('val').replace('€', ''),
|
||||||
|
'total_descuento': $('#descuentoTotal').attr('val').replace('€', ''),
|
||||||
|
'total_descuentoPercent': $('#total_descuentoPercent').val().replace('€', ''),
|
||||||
|
'total_presupuesto': $('#totalDespuesDecuento').attr('val').replace('€', ''),
|
||||||
|
'total_precio_unidad': $('#precioUnidadPresupuesto').attr('val').replace('€', ''),
|
||||||
|
|
||||||
|
'total_factor': $('#factor').text().replace(/,/g, '.'),
|
||||||
|
'total_factor_ponderado': $('#factor_ponderado').text().replace(/,/g, '.'),
|
||||||
|
};
|
||||||
|
|
||||||
|
if($('#confirmar_presupuesto').prop('checked')){
|
||||||
|
data.confirmar = '1';
|
||||||
|
data.total_aceptado = $('#totalDespuesDecuento').attr('val').replace('€', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Resumen;
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,382 @@
|
|||||||
|
import { getToken } from "../../../common/common.js";
|
||||||
|
|
||||||
|
class TiradasAlernativas {
|
||||||
|
|
||||||
|
constructor(functions = {}) {
|
||||||
|
|
||||||
|
this.getDimensionLibro = functions.getDimensionLibro;
|
||||||
|
|
||||||
|
this.csrf_token = getToken();
|
||||||
|
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||||
|
|
||||||
|
this.addTirada = $('#add_tirada_alt');
|
||||||
|
this.tirada = $('#tirada_alt');
|
||||||
|
|
||||||
|
this.table = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
this.addTirada.on('click', this.addTiradaAlt.bind(this));
|
||||||
|
|
||||||
|
this.table = $('#tableTiradas').DataTable({
|
||||||
|
|
||||||
|
"language": {
|
||||||
|
"url": "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||||
|
},
|
||||||
|
"paging": false,
|
||||||
|
"info": false,
|
||||||
|
"searching": false,
|
||||||
|
"ordering": true,
|
||||||
|
"autoWidth": false,
|
||||||
|
"responsive": true,
|
||||||
|
"columnDefs": [
|
||||||
|
{
|
||||||
|
orderable: false,
|
||||||
|
searchable: false,
|
||||||
|
targets: [$('#tableTiradas').find("tr:first th").length - 1]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"columns": [
|
||||||
|
{ data: "tirada" },
|
||||||
|
{ data: 'coste_impresion' },
|
||||||
|
{
|
||||||
|
data: 'coste_envio',
|
||||||
|
render: function (data, type, row) {
|
||||||
|
return parseFloat(data).toFixed(2);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'margen',
|
||||||
|
render: function (data, type, row) {
|
||||||
|
return data + '%';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'total_pedido',
|
||||||
|
render: function (data, type, row) {
|
||||||
|
return parseFloat(data).toFixed(2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'precio_unidad',
|
||||||
|
render: function (data, type, row) {
|
||||||
|
return parseFloat(data).toFixed(4);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: function (row, type, set, meta) {
|
||||||
|
return `
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-check ti-sm comfirm-tirada-alt mx-2" ></i></a>
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-tirada mx-2" F></i></a>
|
||||||
|
`;
|
||||||
|
},
|
||||||
|
className: 'row-edit dt-center'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
order: [[0, 'asc']]
|
||||||
|
});
|
||||||
|
|
||||||
|
// Evento de borrado de una fila de la tabla de tiradas
|
||||||
|
$(document).on('click', '.btn-delete-tirada', function (e) {
|
||||||
|
|
||||||
|
const row = $(this).closest('tr');
|
||||||
|
$('#tableTiradas').DataTable().row(row)
|
||||||
|
.remove()
|
||||||
|
.draw();
|
||||||
|
showBreadCrumbSaveButton(true);
|
||||||
|
})
|
||||||
|
|
||||||
|
$(document).on('click', '.comfirm-tirada-alt', function (e) {
|
||||||
|
|
||||||
|
const row = $(this).closest('tr');
|
||||||
|
const data = self.table.row(row).data();
|
||||||
|
|
||||||
|
self.table.row(row).remove().draw();
|
||||||
|
|
||||||
|
$(document).trigger('update-envios', { tirada_inicial: $('#tirada').val(), tirada: data.tirada });
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('update-tiradas-alternativas', async function () {
|
||||||
|
|
||||||
|
await self.updateTiradasAlternativas();
|
||||||
|
|
||||||
|
$(document).trigger('update-tiradas-alternativas-completed');
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateTiradasAlternativas() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
if ($('#tableTiradas').DataTable().rows().count() > 0) {
|
||||||
|
// se obtiene la primera columna de la tabla de tiradas
|
||||||
|
const data = $('#tableTiradas').DataTable().rows().data().toArray();
|
||||||
|
// se borra la tabla de tiradas
|
||||||
|
$('#tableTiradas').DataTable().clear().draw();
|
||||||
|
const tiradas = data.map(row => row.tirada);
|
||||||
|
// por cada tirada, se añade una fila a la tabla de tiradas
|
||||||
|
tiradas.forEach(function (tirada) {
|
||||||
|
self.addTiradaAlt(tirada);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cargar(datos) {
|
||||||
|
|
||||||
|
if (datos != null && datos != undefined && datos.length > 0) {
|
||||||
|
this.table.clear().draw();
|
||||||
|
this.table.rows.add(datos).draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_json_tiradas() {
|
||||||
|
|
||||||
|
const data = this.table.rows().data().toArray();
|
||||||
|
return JSON.stringify(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addTiradaAlt(tiradaExterna = null) {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
const id = window.location.href.split('/').pop();
|
||||||
|
|
||||||
|
const tirada = tiradaExterna === null ? parseInt(this.tirada.val()) : tiradaExterna;
|
||||||
|
const tirada_ejemplo = parseInt($('#tirada').val());
|
||||||
|
const POD = parseInt($('#POD').val());
|
||||||
|
|
||||||
|
if ((tirada_ejemplo > POD && tirada <= POD) ||
|
||||||
|
(tirada_ejemplo <= POD && tirada > POD)) {
|
||||||
|
popErrorAlert('No se pueden mezclar tiradas POD y no POD', 'alert-tiradas_alt');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.table.rows().count() > 0) {
|
||||||
|
let tiradas = this.table.rows().data().toArray();
|
||||||
|
if (tiradas.find(t => parseInt(t.tirada) == tirada)) {
|
||||||
|
popErrorAlert('La tirada ya existe', 'alert-tiradas_alt');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const dimension = this.getDimensionLibro();
|
||||||
|
|
||||||
|
const envios = JSON.stringify($('#tableOfDireccionesEnvio').DataTable().rows().data().toArray());
|
||||||
|
|
||||||
|
let datos = {
|
||||||
|
id: id,
|
||||||
|
tirada: this.tirada.val(),
|
||||||
|
peso_libro: this.get_peso_libro(),
|
||||||
|
tirada_base: $('#tirada').val(),
|
||||||
|
paginas: $('#paginas').val(),
|
||||||
|
merma: this.getMerma(tirada),
|
||||||
|
tipo_impresion_id: $('#tipo_impresion_id').val(),
|
||||||
|
json_tiradas: this.generate_json_lp(),
|
||||||
|
json_acabados: this.generate_json_servicios('acabados'),
|
||||||
|
json_encuadernaciones: this.generate_json_servicios('encuadernaciones'),
|
||||||
|
json_manipulado: this.generate_json_servicios('manipulado'),
|
||||||
|
json_envios: envios,
|
||||||
|
ancho: dimension.ancho,
|
||||||
|
alto: dimension.alto,
|
||||||
|
cliente_id: $('#clienteId').find(":selected").val(),
|
||||||
|
solapas_cubierta: $('#solapas').is(':checked') ? 1 : 0,
|
||||||
|
solapas_cubierta_ancho: $('#solapas').is(':checked') ? parseInt($('#solapas_ancho').val()) : 0,
|
||||||
|
solapas_sobrecubierta: $('#solapas_sobrecubierta').is(':checked') ? 1 : 0,
|
||||||
|
solapas_sobrecubierta_ancho: $('#solapas_sobrecubierta').is(':checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0,
|
||||||
|
lomo: $('#lomo_cubierta').val(),
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: '/presupuestotiradasalternativas/datatable_2',
|
||||||
|
data: datos,
|
||||||
|
success: async function (data) {
|
||||||
|
|
||||||
|
var coste_total = 0.0;
|
||||||
|
var margen_total = 0.0;
|
||||||
|
|
||||||
|
var costes_servicios = 0.0;
|
||||||
|
var margen_servicios = 0.0;
|
||||||
|
|
||||||
|
var coste_envio = 0.0;
|
||||||
|
var margen_envio = 0.0;
|
||||||
|
|
||||||
|
if (data.lineas.length > 0) {
|
||||||
|
// Se cogen los valores de la linea con los datos correspondientes
|
||||||
|
data.lineas.forEach(function (value) {
|
||||||
|
coste_total += value.total_coste;
|
||||||
|
margen_total += value.total_margen;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data.servicios) {
|
||||||
|
costes_servicios += data.servicios.coste;
|
||||||
|
margen_servicios += data.servicios.margen;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#tableOfServiciosPreimpresion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
costes_servicios += parseFloat(rowData.coste);
|
||||||
|
margen_servicios += parseFloat(rowData.precio) - parseFloat(rowData.coste);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#tableOfServiciosExtra').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
costes_servicios += parseFloat(rowData.coste);
|
||||||
|
margen_servicios += parseFloat(rowData.precio) - parseFloat(rowData.coste);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data.envios) {
|
||||||
|
coste_envio += data.envios.coste;
|
||||||
|
margen_envio += data.envios.margen;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Se añade la fila a la tabla de tiradas
|
||||||
|
self.table.row.add({
|
||||||
|
tirada: datos.tirada,
|
||||||
|
coste_impresion: coste_total.toFixed(2),
|
||||||
|
coste_envio: coste_envio.toFixed(2),
|
||||||
|
margen: ((margen_total + margen_servicios + margen_envio) / (coste_total + coste_envio) * 100.0).toFixed(2),
|
||||||
|
total_pedido: (coste_total + costes_servicios + coste_envio).toFixed(2),
|
||||||
|
precio_unidad: ((coste_total + costes_servicios + coste_envio) / datos.tirada).toFixed(4),
|
||||||
|
|
||||||
|
}).draw(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function (e) { }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_json_lp() {
|
||||||
|
|
||||||
|
const data = $('#tableLineasPresupuesto').DataTable().data().toArray();
|
||||||
|
|
||||||
|
let json = this.filterData(data,
|
||||||
|
['paginas',
|
||||||
|
'numPagColor',
|
||||||
|
'paginas_impresion',
|
||||||
|
'papel', // papel generico
|
||||||
|
'papel_impresion_id',
|
||||||
|
'gramaje',
|
||||||
|
'maquina_id',
|
||||||
|
'aFavorFibra',
|
||||||
|
'row_id',
|
||||||
|
'check_papel_total',
|
||||||
|
'check_impresion_total',
|
||||||
|
'cobAmarillo', // tipologia de papel
|
||||||
|
'cobCyan',
|
||||||
|
'cobMagenta',
|
||||||
|
'cobNegro',
|
||||||
|
'cobCG',
|
||||||
|
'gotaColor',
|
||||||
|
'gotaNegro']);
|
||||||
|
|
||||||
|
json.forEach(element => {
|
||||||
|
element['check_papel_total'] = $('#' + element['row_id'] + '_checkPapel').is(':checked') ? 1 : 0;
|
||||||
|
element['check_impresion_total'] = $('#' + element['row_id'] + '_checkClicks').is(':checked') ? 1 : 0;
|
||||||
|
});
|
||||||
|
return JSON.stringify(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_json_servicios(servicios) {
|
||||||
|
|
||||||
|
let json = [];
|
||||||
|
switch (servicios) {
|
||||||
|
case 'acabados':
|
||||||
|
$('#tableOfServiciosAcabado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
json.push(rowData);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'encuadernaciones':
|
||||||
|
$('#tableOfServiciosEncuadernacion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
json.push(rowData);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'presimpresion':
|
||||||
|
$('#tableOfServiciosPreimpresion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
json.push(rowData);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'manipulado':
|
||||||
|
$('#tableOfServiciosManipulado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
json.push(rowData);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'extra':
|
||||||
|
$('#tableOfServiciosExtra').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
json.push(rowData);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return JSON.stringify(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
get_peso_libro() {
|
||||||
|
|
||||||
|
var peso_total_libro = 0.0
|
||||||
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
peso_total_libro += parseFloat(rowData.peso)
|
||||||
|
})
|
||||||
|
return peso_total_libro;
|
||||||
|
}
|
||||||
|
|
||||||
|
getMerma(tirada) {
|
||||||
|
|
||||||
|
let merma = 0;
|
||||||
|
|
||||||
|
if (tirada > parseInt($('#POD').val())) {
|
||||||
|
|
||||||
|
merma = tirada * 0.1 <= 30 ? tirada * 0.1 : 30
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let merma_lineas = []
|
||||||
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
if (rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta') {
|
||||||
|
const formas_linea = $('#isCosido').val() == 0 ? parseInt(rowData.formas) : parseInt(rowData.formas) / 2
|
||||||
|
if (formas_linea > tirada)
|
||||||
|
merma_lineas.push(formas_linea - tirada)
|
||||||
|
else
|
||||||
|
merma_lineas.push(tirada % formas_linea)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (merma_lineas.length > 0)
|
||||||
|
merma = Math.max(...merma_lineas)
|
||||||
|
else
|
||||||
|
merma = 0
|
||||||
|
}
|
||||||
|
return merma;
|
||||||
|
}
|
||||||
|
|
||||||
|
filterData(data, keys) {
|
||||||
|
|
||||||
|
return data.map(obj => {
|
||||||
|
|
||||||
|
const newObj = {};
|
||||||
|
keys.forEach(key => {
|
||||||
|
if (obj.hasOwnProperty(key)) {
|
||||||
|
newObj[key] = obj[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return newObj;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TiradasAlernativas;
|
||||||
@ -88,6 +88,9 @@ class Direcciones {
|
|||||||
});
|
});
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
|
||||||
|
$('#tiradaEnvios-' + datosGenerales.selectedTirada).trigger('click');
|
||||||
|
|
||||||
if (datos.entrega_taller == 1) {
|
if (datos.entrega_taller == 1) {
|
||||||
this.recogidaTaller.prop('checked', true);
|
this.recogidaTaller.prop('checked', true);
|
||||||
this.recogidaTaller.trigger('change');
|
this.recogidaTaller.trigger('change');
|
||||||
@ -104,7 +107,7 @@ class Direcciones {
|
|||||||
for (let i = 0; i < datos.length; i++) {
|
for (let i = 0; i < datos.length; i++) {
|
||||||
|
|
||||||
let id = datos[i].id;
|
let id = datos[i].id;
|
||||||
let unidades = datos[i].unidades;
|
let unidades = datos[i].cantidad;
|
||||||
let entregaPalets = datos[i].palets;
|
let entregaPalets = datos[i].palets;
|
||||||
|
|
||||||
|
|
||||||
@ -113,7 +116,22 @@ class Direcciones {
|
|||||||
if (unidades == null || unidades <= 0 || unidades == undefined)
|
if (unidades == null || unidades <= 0 || unidades == undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {},
|
let divId = "dirEnvio-1";
|
||||||
|
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
|
||||||
|
if (direccionesActuales.length > 0) {
|
||||||
|
// the the lass item
|
||||||
|
let last = direccionesActuales[direccionesActuales.length - 1];
|
||||||
|
divId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1);
|
||||||
|
}
|
||||||
|
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, datos[i]);
|
||||||
|
tarjeta.setUnidades(unidades);
|
||||||
|
tarjeta.setEntregaPalets(entregaPalets);
|
||||||
|
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self));
|
||||||
|
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self));
|
||||||
|
this.divDirecciones.append(tarjeta.card);
|
||||||
|
this.direcciones.push(tarjeta);
|
||||||
|
|
||||||
|
/*let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {},
|
||||||
(response) => {
|
(response) => {
|
||||||
let divId = "dirEnvio-1";
|
let divId = "dirEnvio-1";
|
||||||
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
|
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
|
||||||
@ -134,7 +152,7 @@ class Direcciones {
|
|||||||
console.error('Error getting address');
|
console.error('Error getting address');
|
||||||
});
|
});
|
||||||
|
|
||||||
peticion.get();
|
peticion.get();*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -226,7 +244,7 @@ class Direcciones {
|
|||||||
let direcciones = [];
|
let direcciones = [];
|
||||||
this.direcciones.forEach(direccion => {
|
this.direcciones.forEach(direccion => {
|
||||||
let dir = {
|
let dir = {
|
||||||
id: direccion.getId(),
|
direccion: direccion.getDireccion(),
|
||||||
unidades: direccion.getUnidades(),
|
unidades: direccion.getUnidades(),
|
||||||
entregaPalets: direccion.getEntregaPalets()
|
entregaPalets: direccion.getEntregaPalets()
|
||||||
};
|
};
|
||||||
@ -306,12 +324,23 @@ class Direcciones {
|
|||||||
total_unidades += parseInt(this.direcciones[i].getUnidades());
|
total_unidades += parseInt(this.direcciones[i].getUnidades());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (this.getSelectedTirada() == null) {
|
||||||
|
popErrorAlert("Tiene que seleccionar una tirada para insertar una dirección");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (total_unidades + parseInt(unidades) > this.getSelectedTirada()) {
|
if (total_unidades + parseInt(unidades) > this.getSelectedTirada()) {
|
||||||
popErrorAlert("El total de unidades enviadas tiene que ser menor que " + this.getSelectedTirada());
|
popErrorAlert("El total de unidades enviadas tiene que ser menor que " + this.getSelectedTirada());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (this.getSelectedTirada() == null) {
|
||||||
|
popErrorAlert("Tiene que seleccionar una tirada para insertar una dirección");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (unidades > this.getSelectedTirada()) {
|
if (unidades > this.getSelectedTirada()) {
|
||||||
popErrorAlert("El total de unidades enviadas tiene que ser menor que " + this.getSelectedTirada());
|
popErrorAlert("El total de unidades enviadas tiene que ser menor que " + this.getSelectedTirada());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -194,10 +194,10 @@ class PresupuestoCliente {
|
|||||||
console.log("Error en el calculo del lomo interior.");
|
console.log("Error en el calculo del lomo interior.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(response.errors.status == 1){
|
if (response.errors.status == 1) {
|
||||||
popErrorAlert('' + response.errors.value, "sk-alert", false);
|
popErrorAlert('' + response.errors.value, "sk-alert", false);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
popAlert2Hide('sk-alert');
|
popAlert2Hide('sk-alert');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -477,6 +477,13 @@ class PresupuestoCliente {
|
|||||||
try {
|
try {
|
||||||
$('#loader').modal('show');
|
$('#loader').modal('show');
|
||||||
|
|
||||||
|
if (this.direcciones.tiradaSeleccionada == null || this.direcciones.tiradaSeleccionada == undefined
|
||||||
|
|| this.direcciones.tiradaSeleccionada == "" || this.direcciones.tiradaSeleccionada == 0) {
|
||||||
|
popErrorAlert("Seleccione una tirada en la pestaña direcciones para guardar el presupuesto.");
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.#getDatos();
|
this.#getDatos();
|
||||||
|
|
||||||
let datos_to_check = this.#prepareData();
|
let datos_to_check = this.#prepareData();
|
||||||
@ -561,17 +568,23 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
popAlert2Hide();
|
popAlert2Hide();
|
||||||
|
|
||||||
for (let i = 0; i < tiradas.length; i++) {
|
for (let i = 0; i < response.tiradas.length; i++) {
|
||||||
|
if(i==0){
|
||||||
|
$('#eb').val(response.eb[i]);
|
||||||
|
}
|
||||||
new tarjetaTiradasPrecio(
|
new tarjetaTiradasPrecio(
|
||||||
this.divTiradasPrecios,
|
this.divTiradasPrecios,
|
||||||
('precio-tiradas-' + response.tiradas[i]),
|
('precio-tiradas-' + response.tiradas[i]),
|
||||||
tiradas[i],
|
response.tiradas[i],
|
||||||
(parseFloat(response.precio_u[i]) * parseInt(tiradas[i])).toFixed(2),
|
(parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2),
|
||||||
response.precio_u[i]
|
response.precio_u[i]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.actualizarTiradasEnvio) {
|
if (this.actualizarTiradasEnvio) {
|
||||||
this.direcciones.insertTirada(tiradas[i]);
|
this.direcciones.insertTirada(response.tiradas[i]);
|
||||||
|
if(i==0){
|
||||||
|
$('#tiradaEnvios-' + response.tiradas[i]).trigger('click');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -670,6 +683,12 @@ class PresupuestoCliente {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.direcciones.getSelectedTirada() != null && this.direcciones.getSelectedTirada() != undefined && this.direcciones.getSelectedTirada() > 0){
|
||||||
|
this.datos.selectedTirada = this.direcciones.getSelectedTirada();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.datos.guardas = this.disenioCubierta.getGuardas();
|
||||||
|
|
||||||
if (calcularSolapas) {
|
if (calcularSolapas) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -683,6 +702,7 @@ class PresupuestoCliente {
|
|||||||
this.datos.retractilado = this.datosGenerales.retractilado.is(':checked') ? 1 : 0;
|
this.datos.retractilado = this.datosGenerales.retractilado.is(':checked') ? 1 : 0;
|
||||||
this.datos.retractilado5 = this.datosGenerales.retractilado5.is(':checked') ? 1 : 0;
|
this.datos.retractilado5 = this.datosGenerales.retractilado5.is(':checked') ? 1 : 0;
|
||||||
|
|
||||||
|
this.datos.eb = $('#eb').val();
|
||||||
|
|
||||||
this.datos.cubierta = {
|
this.datos.cubierta = {
|
||||||
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
||||||
@ -693,7 +713,7 @@ class PresupuestoCliente {
|
|||||||
carasImpresion: this.disenioCubierta.carasCubierta.val(),
|
carasImpresion: this.disenioCubierta.carasCubierta.val(),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.datos.guardas = this.disenioCubierta.getGuardas();
|
|
||||||
this.datos.sobrecubierta = this.disenioCubierta.getSobrecubierta();
|
this.datos.sobrecubierta = this.disenioCubierta.getSobrecubierta();
|
||||||
this.datos.faja = this.disenioCubierta.getFaja();
|
this.datos.faja = this.disenioCubierta.getFaja();
|
||||||
|
|
||||||
@ -780,8 +800,18 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||||
|
|
||||||
|
try {
|
||||||
self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log("Error al cargar diseño interior: " + e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log("Error al cargar diseño cubierta: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -811,7 +841,7 @@ class PresupuestoCliente {
|
|||||||
$('#menu_resumen_button').trigger('click');
|
$('#menu_resumen_button').trigger('click');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
self.resumen.init_dropzone();
|
self.resumen.init_dropzone();
|
||||||
self.resumen.generate_total(response.data.resumen.base, response.data.resumen.precio_unidad);
|
self.resumen.generate_total(response.data.resumen.base, response.data.resumen.precio_unidad, response.data.datosGenerales.ivaReducido);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|||||||
@ -322,7 +322,7 @@ class Resumen {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_total(base, precio_u) {
|
generate_total(base, precio_u, iva_reducido) {
|
||||||
|
|
||||||
let precio_u_text = String(precio_u);
|
let precio_u_text = String(precio_u);
|
||||||
precio_u_text = precio_u_text.replace('€/u', '');
|
precio_u_text = precio_u_text.replace('€/u', '');
|
||||||
@ -330,7 +330,7 @@ class Resumen {
|
|||||||
|
|
||||||
let base_text = this.#changeDecimalFormat(String(base));
|
let base_text = this.#changeDecimalFormat(String(base));
|
||||||
|
|
||||||
const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04;
|
const iva_porcentaje = !iva_reducido? 0.21 : 0.04;
|
||||||
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
|
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
|
||||||
let iva_text = this.#changeDecimalFormat(iva);
|
let iva_text = this.#changeDecimalFormat(iva);
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ class Resumen {
|
|||||||
|
|
||||||
this.precio_unidad.text(precio_u_text);
|
this.precio_unidad.text(precio_u_text);
|
||||||
this.total_base.text(base_text);
|
this.total_base.text(base_text);
|
||||||
this.iva_porcentaje.text(this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? '21' : '4');
|
this.iva_porcentaje.text(!iva_reducido? '21' : '4');
|
||||||
this.iva.text(iva_text);
|
this.iva.text(iva_text);
|
||||||
this.total.text(total_text);
|
this.total.text(total_text);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,11 +38,16 @@ table.dataTable.table-hover>tbody>tr.selected:hover>* {
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#tableOfDireccionesEnvio.comparator-table td {
|
||||||
|
text-align: center !important;
|
||||||
|
}
|
||||||
|
|
||||||
.comparator-table td.dt-result-value {
|
.comparator-table td.dt-result-value {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.lp-cell {
|
.lp-cell {
|
||||||
padding-left: 1px;
|
padding-left: 1px;
|
||||||
padding-right: 1px;
|
padding-right: 1px;
|
||||||
|
|||||||
Reference in New Issue
Block a user