diff --git a/.gitignore b/.gitignore index 2740fefd..0af4bfd9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ ci4/.env .vscode/ -xdebug.log \ No newline at end of file +xdebug.log +xdebug.* diff --git a/README.md b/README.md deleted file mode 100755 index e5e6f95b..00000000 --- a/README.md +++ /dev/null @@ -1,92 +0,0 @@ -# safekat - - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://git.imnavajas.es/jjimenez/safekat.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://git.imnavajas.es/jjimenez/safekat/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. diff --git a/acciones.txt b/acciones.txt deleted file mode 100755 index 8106b1fd..00000000 --- a/acciones.txt +++ /dev/null @@ -1,133 +0,0 @@ -Quitar Oauth ---------------------------------------------- -Quitar packete con composer que se usa en la Oauth - composer remove hybridauth/hybridauth -Tablas en la BBDD. - wg_user_oauth - wg_settings_oauth - Se hace migración (hay que añadir el controlador Migrate a whiteListController) -Modelos - UserOauthModel.php - SettingsOauthModel.php -Controllers - Oauth.php -Realizar busqueda de UserOauthModel que está en varios Controllers - Buscar la variable que crea en cada controlador y ver para que la usa -Igual que la acción anterior pero con SettingsOauthModel - Está en el controlador Settings.php. Buscar la variable que crea y borrarla -Eliminar Views\themes\backend\focus2\form\settings\oauth.php -En Views\themes\backend\focus2\main\menu. - Quitar la línea php que invoca a la configuración de Oauth (site_url("settings/oauth")) -En Views\themes\frontend\tivo\main\menu.php - Quitar la línea php que invoca a la configuración de Oauth (site_url("settings/oauth")) -En en controlador Settings.php - Quitar las funciones oauth() y oauth_store() -En los idiomas quitar la key dashboard_chart_auth -En la vista quitar la carta de Solcial autenthification -
-
-
-

-
-
-
-
-
-
-
-
-
-
-
- - -Quitar los SMS --------------------------------------------- -Quitar packete con composer que se usa en la Oauth - twilio/sdk -Dentro de Controllers\Integration.php - Eliminar sendSMS (public y private) -Se hace migración de la BBDD -Del controlador Cron.php se elimina - la accion // Cron Notification SMS - la función test() -Del controlador Ajax.php - linea 368, quitar is_send_sms de la lista - linea 399, eliminar "is_send_sms"=>$record['is_send_sms'], -Del controlador Login.php eliminar - //Notification SMS User Welcome - //SMS Account Confirmation - Dentro de //Notification New Register, las dos líneas is_send_sms y send_sms_notification - linea 455 if($settings['send_sms_register']??false){ quitar if completo -Del controlador Notification.php - linea 117 , 148, 150 -Del controlador Settings.php - linea 106, 109 -De los idiomas, quitar los registros - settings_field_send_sms_register - notification_field_send_sms -Del modelo NotificationModel.php - Quitar los fields is_send_sms y send_sms_notification -Del modelo SettingsModel.php - Quitar los fields send_sms_register y send_sms_welcome - sms_gateway, sms_account_id, ,sms_auth_token, sms_info_add, sms_confirmation -De la vista Views\themes\backend\focus2\form\notification\form quitar -
-
- -
- > - -
-
-
-De la vista Views\themes\backend\focus2\form\notification\index.php quitar de la linea 129 { data: 'is_send_sms' }, -De la vista Views\themes\backend\focus2\form\settings\index.php quitar los siguientes bloques -
-
- -
- > - -
-
-
- y -
-
- -
- > - -
-
-
-En el controlador Ajax.php quitar if($records[$key]['sms_confirmed'] == 1) -En el controlador Login.php quitar - bloque // Check sms confirmed - if($confirmation['type'] == 'sms') -En el controlador Settings.php quitar - linea 104 - case 'sms; -En el controlador User.php quitar linea 217 y 236 -Del modelo UserModel.php quitar el campo sms_confirmed -En los idiomas buscar la key sms -En la vista Views\themes\backend\focus2\form\notification\index.php quitar linea 49 -En la vista Views\themes\backend\focus2\form\settings\index.php quitar - linea 37 - bloque en linea 298 - linea 355 - bloque en linea 679 - linea 1033 -En la vista Views\themes\backend\focus2\form\settings\template.php - bloque linea 87 hasta 131 -En la vista Views\themes\backend\focus2\form\user\form.php - bloque linea 104 hasta 113 - linea 210 - - -Renombrar tablas a auth_ en lugar de wg_ -------------------------------------------------- -La tabla wg_migrations hay que modificarla a mano. -En .env quitar el prefijo: database.default.DBPrefix = -En todos los modelos añadir auth_ al principio del nombre de la tabla \ No newline at end of file diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index e0329474..a9baa5bc 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -1,6 +1,7 @@ routes($routes, ['except' => ['login', 'register']]); service('auth')->routes($routes); + //WEB ROUTER ------------------------------------------------------ //------------------------------------------------------------------ $routes->get('/', 'Home::index', ['as' => 'home']); @@ -50,7 +52,6 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function ( $routes->get('delete/(:num)', 'TarifaAcabadosLineas::delete/$1', ['as' => 'tarifaAcabadoLineasDelete']); }); }); - }); /* Rutas para configuraciones */ @@ -64,7 +65,6 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $routes->match(['get', 'post'], 'edit/(:num)', 'Ubicaciones::edit/$1', ['as' => 'ubicacionesEdit']); $routes->get('delete/(:num)', 'Ubicaciones::delete/$1', ['as' => 'ubicacionesDelete']); $routes->post('datatable', 'Ubicaciones::datatable', ['as' => 'ubicacionesDT']); - }); /* Series Factura */ @@ -85,14 +85,20 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $routes->get('delete/(:num)', 'FormasPago::delete/$1', ['as' => 'formasPagoDelete']); $routes->post('datatable', 'FormasPago::datatable', ['as' => 'formasPagoDT']); }); - $routes->group("variables",["namespace" => 'App\Controllers\Configuracion'],function($routes){ + $routes->group("variables", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'ConfigVariables::index', ['as' => 'variablesIndex']); $routes->get('find/(:num)', 'ConfigVariables::get/$1', ['as' => 'variablesFind']); $routes->post('edit/(:num)', 'ConfigVariables::updateVariable/$1', ['as' => 'updateVariable']); $routes->delete('delete/(:num)', 'ConfigVariables::delete/$1', ['as' => 'deleteVariable']); $routes->get('datatable', 'ConfigVariables::datatable', ['as' => 'datatableVariables']); }); - + $routes->group("errores-presupuesto", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'ConfigErrores::index', ['as' => 'erroresPresupuestoIndex']); + $routes->get('edit/(:num)', 'ConfigErrores::viewForm/$1', ['as' => 'erroresPresupuestoViewForm']); + $routes->get('get/(:num)', 'ConfigErrores::get_error_presupuesto/$1', ['as' => 'erroresPresupuestoGetErrorPresupuesto']); + $routes->get('datatable', 'ConfigErrores::datatable', ['as' => 'erroresPresupuestoDatatable']); + $routes->post('edit/(:num)', 'ConfigErrores::update_error_presupuesto/$1', ['as' => 'erroresPresupuestoUpdate']); + }); }); @@ -370,8 +376,8 @@ $routes->group('clientes', ['namespace' => 'App\Controllers\Clientes'], function $routes->get('delete/(:num)', 'Cliente::delete/$1', ['as' => 'clienteDelete']); $routes->post('datatable', 'Cliente::datatable', ['as' => 'clienteDT']); $routes->post('menuitems', 'Cliente::menuItems', ['as' => 'menuItemsOfClientes']); + $routes->get('getSelect2', 'Cliente::getSelect2', ['as' => 'getListaSelect2']); }); - }); @@ -407,6 +413,10 @@ $routes->group('clienteusuarios', ['namespace' => 'App\Controllers\Clientes'], f $routes->group('misdirecciones', ['namespace' => 'App\Controllers\Clientes'], function ($routes) { $routes->get('', 'Clientedirecciones::index', ['as' => 'clientedireccionesIndex']); + $routes->get('get/(:num)', 'Clientedirecciones::get/$1', ['as' => 'get']); + $routes->get('getDireccionPresupuesto/(:num)', 'Clientedirecciones::getDireccionPresupuesto/$1', ['as' => 'getDireccionPresupuesto']); + $routes->post('add', 'Clientedirecciones::add', ['as' => 'newClientedirecciones']); + $routes->get('getSelect2', 'Clientedirecciones::getSelect2', ['as' => 'listaClientedirecciones']); }); @@ -562,7 +572,7 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos $routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']); $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { - $routes->get('list', 'Presupuestocliente::list', ['as' => 'listaPresupuestos']); + $routes->get('list', 'Presupuestocliente::list', ['as' => 'listaPresupuestos']); $routes->post('datatable', 'Presupuestocliente::datatable', ['as' => 'datatableOfPresupuestos']); $routes->get('add', 'Presupuestocliente::add', ['as' => 'nuevoPresupuestoCliente']); $routes->post('add', 'Presupuestocliente::add', ['as' => 'crearPresupuestoCliente']); @@ -571,10 +581,11 @@ $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuest $routes->post('getgramaje', 'Presupuestocliente::getGramaje', ['as' => 'obtenerGramaje']); $routes->post('presupuesto', 'Presupuestocliente::presupuesto', ['as' => 'presupuestoCliente']); $routes->post('getDireccionesCliente', 'Presupuestocliente::getDireccionesCliente', ['as' => 'getDirecciones']); - $routes->post('getDatosDireccion', 'Presupuestocliente::getDatosDireccion', ['as' => 'getDatosDireccion']); $routes->post('getNuevaDireccion', 'Presupuestocliente::getNuevaDireccion', ['as' => 'nuevaDireccion']); - $routes->post('guardarPresupuesto', 'Presupuestocliente::guardarPresupuesto', ['as' => 'guardarPresupuesto']); + $routes->post('guardar', 'Presupuestocliente::guardar', ['as' => 'guardar']); + $routes->get('cargar/(:num)', 'Presupuestocliente::cargar/$1', ['as' => 'cargarPresupuesto']); $routes->post('duplicarPresupuesto', 'Presupuestocliente::duplicarPresupuesto', ['as' => 'duplicarPresupuesto']); + $routes->post('calcular', 'Presupuestocliente::calcular', ['as' => 'calcularPresupuesto']); }); $routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']); @@ -589,7 +600,6 @@ $routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Pre $routes->post('menuitems', 'Presupuestoencuadernaciones::menuItems', ['as' => 'menuItemsOfPresupuestoEncuadernaciones']); $routes->get('delete/(:num)', 'Presupuestoencuadernaciones::delete/$1', ['as' => 'deletePresupuestoencuadernaciones']); $routes->post('edit/(:num)', 'Presupuestoencuadernaciones::edit/$1', ['as' => 'updatePresupuestoencuadernaciones']); - }); $routes->group('serviciosmanipulados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { @@ -615,13 +625,13 @@ $routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presup $routes->group('presupuestotiradasalternativas', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { $routes->post('datatable', 'Presupuestotiradasalternativas::datatable', ['as' => 'dataTableOfPresupuestoTiradasAlternativas']); $routes->post('datatable_2', 'Presupuestotiradasalternativas::datatable_2', ['as' => 'getTiradaData']); -}); +}); $routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) { $routes->get('list', 'Pedido::todos', ['as' => 'listaPresupuestos']); - $routes->get('listActivos', 'Pedido::activos', ['as' => 'listaPresupuestosActivos']); - $routes->get('listFinalizados', 'Pedido::finalizados', ['as' => 'listaFinalizados']); - $routes->get('listCancelados', 'Pedido::cancelados', ['as' => 'listaCancelados']); + $routes->get('listActivos', 'Pedido::activos', ['as' => 'listaPresupuestosActivos']); + $routes->get('listFinalizados', 'Pedido::finalizados', ['as' => 'listaFinalizados']); + $routes->get('listCancelados', 'Pedido::cancelados', ['as' => 'listaCancelados']); $routes->post('datatable', 'Pedido::datatable', ['as' => 'dataTableOfPedidos']); $routes->get('add', 'Pedido::add', ['as' => 'nuevoPedido']); $routes->post('add', 'Pedido::add', ['as' => 'crearPedido']); @@ -629,9 +639,7 @@ $routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function ( $routes->post('getlineas', 'Pedido::getLineas', ['as' => 'tablaLineasPedido']); $routes->post('cambiarestado', 'Pedido::cambiarEstado', ['as' => 'cambiarEstadoPedido']); $routes->post('update/(:any)', 'Pedido::update/$1', ['as' => 'actualizarPedido']); - $routes->get('xml/(:num)', 'Pedido::get_xml_pedido/$1',['as' => 'getXMLPedido']); - - + $routes->get('xml/(:num)', 'Pedido::get_xml_pedido/$1', ['as' => 'getXMLPedido']); }); $routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']); @@ -728,6 +736,19 @@ $routes->group( ); $routes->resource('buscadorpresupuestos', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Buscador', 'except' => 'show,new,create,update']); + +$routes->group( + 'papel-formato', + ['namespace' => 'App\Controllers\Configuracion'], + function ($routes) { + $routes->post('menuitems', 'Papelformato::menuitems', ['as' => 'menuitems']); + $routes->get('getSelect2', 'Papelformato::getSelect2', ['as' => 'getSelect2']); + } +); +$routes->resource('papel-formato', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelformato', 'except' => 'show,new,create,update']); + + + /* Rutas para mensajeria */ $routes->group('mensajes', ['namespace' => 'App\Controllers\Mensajeria'], function ($routes) { @@ -740,9 +761,7 @@ $routes->group('mensajes', ['namespace' => 'App\Controllers\Mensajeria'], functi $routes->match(['get', 'post'], 'edit/(:num)', 'TarifaAcabados::edit/$1', ['as' => 'tarifaAcabadoEdit']); $routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']); $routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']);*/ - }); - }); $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($routes) { $routes->get('departments', 'ChatController::get_chat_departments', ['as' => 'getChatDepartments']); @@ -766,14 +785,9 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route $routes->post('hebra/pedido', 'ChatController::store_hebra_pedido', ['as' => 'storeHebraPedido']); $routes->post('hebra/factura', 'ChatController::store_hebra_factura', ['as' => 'storeHebraFactura']); $routes->post('hebra/(:num)', 'ChatController::update_hebra/$1', ['as' => 'updateHebra']); - $routes->get('hebra/presupuesto/(:num)',"ChatController::get_hebra_presupuesto/$1",["as" => "getHebraPresupuesto"]); - $routes->get('hebra/pedido/(:num)',"ChatController::get_hebra_pedido/$1",["as" => "getHebraPedido"]); - $routes->get('hebra/factura/(:num)',"ChatController::get_hebra_factura/$1",["as" => "getHebraFactura"]); - - - - - + $routes->get('hebra/presupuesto/(:num)', "ChatController::get_hebra_presupuesto/$1", ["as" => "getHebraPresupuesto"]); + $routes->get('hebra/pedido/(:num)', "ChatController::get_hebra_pedido/$1", ["as" => "getHebraPedido"]); + $routes->get('hebra/factura/(:num)', "ChatController::get_hebra_factura/$1", ["as" => "getHebraFactura"]); }); @@ -789,6 +803,15 @@ $routes->group('api', ['filter' => 'jwt'], static function ($routes) { // ... }); +/* + * -------------------------------------------------------------------- + * Translation + * -------------------------------------------------------------------- + */ +$routes->group('translate', ['namespace' => 'App\Controllers'], function ($routes) { + $routes->post('getTranslation', 'Language::getTranslation', ['as' => 'getKeys']); +}); +$routes->resource('translate', ['namespace' => 'App\Controllers', 'controller' => 'Language', 'except' => '']); /* @@ -806,4 +829,4 @@ $routes->group('api', ['filter' => 'jwt'], static function ($routes) { */ if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'; -} +} \ No newline at end of file diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index 678532c9..f388ec1f 100755 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -1,4 +1,6 @@ -redirect2listView('sweet-error', $message); endif; - + if ($this->request->getPost()) : @@ -310,10 +312,9 @@ class Cliente extends \App\Controllers\BaseResourceController $onlyActiveOnes = false; $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; $onlyActiveOnes = false; - try{ + try { $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); - } - catch(Exception $e){ + } catch (Exception $e) { $menu = []; } @@ -330,6 +331,28 @@ class Cliente extends \App\Controllers\BaseResourceController } + 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("clientes.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + protected function getPaisListItems($selId = null) { $paisModel = model('App\Models\Configuracion\PaisModel'); @@ -423,24 +446,23 @@ class Cliente extends \App\Controllers\BaseResourceController } - protected function getPrecioTemplate($cliente_id){ + protected function getPrecioTemplate($cliente_id) + { $modelPreciosCliente = model('App\Models\Clientes\ClientePreciosModel'); $plantilla_id = $modelPreciosCliente->get_plantilla_precios($cliente_id); - if (is_null($plantilla_id)){ + if (is_null($plantilla_id)) { return null; } $modelPlantillaPreciosCliente = model('App\Models\Clientes\ClientePlantillaPreciosModel'); $plantilla = $modelPlantillaPreciosCliente->where("id", $plantilla_id)->where("is_deleted", 0)->first(); - if ($plantilla == false){ + if ($plantilla == false) { return null; - } - else{ + } else { return (object)array( "value" => $plantilla_id, "label" => $plantilla->nombre ); } - } } diff --git a/ci4/app/Controllers/Clientes/Clientedirecciones.php b/ci4/app/Controllers/Clientes/Clientedirecciones.php index d37d665f..872eeeca 100755 --- a/ci4/app/Controllers/Clientes/Clientedirecciones.php +++ b/ci4/app/Controllers/Clientes/Clientedirecciones.php @@ -1,4 +1,6 @@ -viewData['breadcrumb'] = [ ['title' => lang("Clientes.direccionesEnvio"), 'route' => "javascript:void(0);", 'active' => false], - + ]; $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null); @@ -71,21 +73,22 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController return view(static::$viewPath . 'viewClienteDireccionesList', $viewData); } - public function add(){ + public function add() + { if ($this->request->isAJAX()) { - + $reqData = $this->request->getPost(); $cliente_id = $reqData['cliente_id'] ?? -1; $att = $reqData['att'] ?? ""; $email = $reqData['email'] ?? ""; $direccion = $reqData['direccion'] ?? ""; - $pais_id = $reqData['paisId'] ?? -1; + $pais_id = $reqData['pais_id'] ?? -1; $provincia = $reqData['provincia'] ?? ""; $municipio = $reqData['municipio'] ?? ""; $cp = $reqData['cp'] ?? ""; $telefono = $reqData['telefono'] ?? ""; $alias = $reqData['alias'] ?? ""; - + $data = [ "cliente_id" => $cliente_id, "att" => $att, @@ -99,15 +102,11 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController "alias" => $alias, ]; $response = $this->model->insert($data); - - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); + $data_ret = [ 'data' => $response, - $csrfTokenName => $newTokenHash ]; return $this->respond($data_ret); - } else { return $this->failUnauthorized('Invalid request', 403); } @@ -117,14 +116,14 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController public function menuItems() { if ($this->request->isAJAX()) { - + $reqData = $this->request->getPost(); $cliente_id = $reqData['cliente_id'] ?? -1; - + $clienteDireccionesModel = model('App\Models\Clientes\ClienteDireccionesModel'); $menu = $clienteDireccionesModel->getMenuDirecciones($cliente_id); //$menu = $this->model->getMenuItems($cliente_id); - + $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); $data = [ @@ -138,6 +137,34 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController } + public function getSelect2() + { + if ($this->request->isAJAX()) { + + $cliente_id = $this->request->getGet('cliente_id'); + + + $query = $this->model->builder()->select( + [ + "id", + "alias as name" + ] + ) + ->where("cliente_id", $cliente_id) + ->orderBy("alias", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("clientes.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function datatable() { if ($this->request->isAJAX()) { @@ -145,7 +172,7 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController $tipo = $reqData['tipo'] ?? null; - if(is_null($tipo)){ + if (is_null($tipo)) { if (!isset($reqData['draw']) || !isset($reqData['columns'])) { $errstr = 'No data available in response to this specific request.'; $response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); @@ -160,22 +187,21 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController $id_C = $reqData['cliente_id'] ?? -1; - + $resourceData = $this->model->getResource($search, $id_C)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); - + return $this->respond(Collection::datatable( $resourceData, $this->model->getResource()->countAllResults(), $this->model->getResource("", $id_C)->countAllResults() )); - } - else{ + } else { $id = $reqData['id'] ?? -1; $resourceData = $this->model->getDireccion($id); - + return $this->respond($resourceData); } @@ -184,6 +210,44 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController } } + + public function get($id) + { + try { + $resourceData = $this->model->getDireccion($id); + $response = (object)[ + 'error' => false, + 'data' => $resourceData + ]; + return $this->respond($response); + } catch (\Exception $e) { + $response = (object)[ + 'error' => true, + 'message' => $e->getMessage() + ]; + return $this->fail($response); + } + } + + public function getDireccionPresupuesto($id) + { + try { + $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); + $resourceData = $model->getDireccion($id); + $response = (object)[ + 'error' => false, + 'data' => $resourceData + ]; + return $this->respond($response); + } catch (\Exception $e) { + $response = (object)[ + 'error' => true, + 'message' => $e->getMessage() + ]; + return $this->fail($response); + } + } + public function datatable_editor() { if ($this->request->isAJAX()) { @@ -194,72 +258,116 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController $response = Editor::inst($db, 'cliente_direcciones') ->fields( Field::inst('att') - ->validator('Validate::notEmpty', array( - 'message' => lang('ClienteDirecciones.validation.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('ClienteDirecciones.validation.required') + ) ) - ->validator( Validate::maxLen( 100 ) , array( - 'message' => lang('ClienteDirecciones.validation.max_length')) - ), + ->validator( + Validate::maxLen(100), + array( + 'message' => lang('ClienteDirecciones.validation.max_length') + ) + ), Field::inst('alias') - ->validator('Validate::notEmpty', array( - 'message' => lang('ClienteDirecciones.validation.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('ClienteDirecciones.validation.required') + ) ) - ->validator( Validate::maxLen( 100 ) , array( - 'message' => lang('ClienteDirecciones.validation.max_length')) - ), + ->validator( + Validate::maxLen(100), + array( + 'message' => lang('ClienteDirecciones.validation.max_length') + ) + ), Field::inst('email') - ->validator('Validate::notEmpty', array( - 'message' => lang('ClienteDirecciones.validation.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('ClienteDirecciones.validation.required') + ) ) - ->validator( Validate::maxLen( 100 ) , array( - 'message' => lang('ClienteDirecciones.validation.max_length')) - ), + ->validator( + Validate::maxLen(100), + array( + 'message' => lang('ClienteDirecciones.validation.max_length') + ) + ), Field::inst('direccion') - ->validator('Validate::notEmpty', array( - 'message' => lang('ClienteDirecciones.validation.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('ClienteDirecciones.validation.required') + ) ) - ->validator( Validate::maxLen( 255 ) , array( - 'message' => lang('ClienteDirecciones.validation.max_length')) - ), + ->validator( + Validate::maxLen(255), + array( + 'message' => lang('ClienteDirecciones.validation.max_length') + ) + ), Field::inst('municipio') - ->validator('Validate::notEmpty', array( - 'message' => lang('ClienteDirecciones.validation.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('ClienteDirecciones.validation.required') + ) ) - ->validator( Validate::maxLen( 100 ) , array( - 'message' => lang('ClienteDirecciones.validation.max_length')) - ), + ->validator( + Validate::maxLen(100), + array( + 'message' => lang('ClienteDirecciones.validation.max_length') + ) + ), Field::inst('cp') - ->validator('Validate::notEmpty', array( - 'message' => lang('ClienteDirecciones.validation.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('ClienteDirecciones.validation.required') + ) ) - ->validator( Validate::maxLen( 20 ) , array( - 'message' => lang('ClienteDirecciones.validation.max_length')) - ), + ->validator( + Validate::maxLen(20), + array( + 'message' => lang('ClienteDirecciones.validation.max_length') + ) + ), Field::inst('telefono') - ->validator('Validate::notEmpty', array( - 'message' => lang('ClienteDirecciones.validation.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('ClienteDirecciones.validation.required') + ) ) - ->validator( Validate::maxLen( 40 ) , array( - 'message' => lang('ClienteDirecciones.validation.max_length')) - ), + ->validator( + Validate::maxLen(40), + array( + 'message' => lang('ClienteDirecciones.validation.max_length') + ) + ), Field::inst('provincia') - ->validator( function ( $val, $data, $field, $host ) { - if ($data['pais_id'] == 1) { // Si es españa provincia y CCAA es obligatorio - if (strlen( $val ) > 100) - return lang('ClienteDirecciones.validation.max_length'); - else if (strlen( $val ) == 0) - lang('ClienteDirecciones.validation.required'); - else - return true; + ->validator( + function ($val, $data, $field, $host) { + if ($data['pais_id'] == 1) { // Si es españa provincia y CCAA es obligatorio + if (strlen($val) > 100) + return lang('ClienteDirecciones.validation.max_length'); + else if (strlen($val) == 0) + lang('ClienteDirecciones.validation.required'); + else + return true; + } + return true; } - return true; - } - ), + ), Field::inst('pais_id')->validator('Validate::notEmpty', array( - 'message' => lang('ClienteDirecciones.validation.required'))), + 'message' => lang('ClienteDirecciones.validation.required') + )), Field::inst('cliente_id'), ) - + ->debug(true) ->process($_POST) ->data(); @@ -270,7 +378,6 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController $response[$csrfTokenName] = $newTokenHash; echo json_encode($response); - } else { return $this->failUnauthorized('Invalid request', 403); } diff --git a/ci4/app/Controllers/Configuracion/ConfigErrores.php b/ci4/app/Controllers/Configuracion/ConfigErrores.php new file mode 100644 index 00000000..fcaade48 --- /dev/null +++ b/ci4/app/Controllers/Configuracion/ConfigErrores.php @@ -0,0 +1,81 @@ +errorPresupuestoModel = model(ErrorPresupuestoModel::class); + } + + + public function index() + { + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_error_presupuesto"), 'route' => site_url('configuracion/errores-presupuesto'), 'active' => true] + ]; + return view(static::$viewPath . $this->indexRoute, $this->viewData); + } + public function viewForm(int $error_presupuesto_id) + { + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_error_presupuesto"), 'route' => site_url('configuracion/errores-presupuesto'), 'active' => true] + ]; + $this->viewData["error_presupuesto_id"] = $error_presupuesto_id; + $this->errorPresupuestoModel->update($error_presupuesto_id, [ + "last_user_id" => auth()->user()->id, + "visto" => true, + ]); + return view(static::$viewPath . 'viewErrorPresupuestoForm', $this->viewData); + } + public function store() + { + $data = []; + $variableCreated = $this->errorPresupuestoModel->store($data); + return $this->response->setJSON($variableCreated); + } + public function get_error_presupuesto(int $error_presupuesto_id) + { + $data = $this->errorPresupuestoModel->getErrorPresupuestoForm($error_presupuesto_id); + if(isset($data[0])){ + return $this->response->setJSON(["data" => $data[0]]); + }else{ + return $this->response->setJSON(["data" => []]); + } + } + public function update_error_presupuesto(int $error_presupuesto_id) + { + $bodyData = $this->request->getPost(); + $this->errorPresupuestoModel->updateComment($error_presupuesto_id, $bodyData["comments"]); + return $this->response->setJSON(["message" => "Comentario actualizado", "status" => true]); + } + + public function datatable() + { + $query = $this->errorPresupuestoModel->getQueryDatatable(); + return DataTable::of($query) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } +} diff --git a/ci4/app/Controllers/Configuracion/ConfigVariables.php b/ci4/app/Controllers/Configuracion/ConfigVariables.php index 23c8c96d..1455c93c 100644 --- a/ci4/app/Controllers/Configuracion/ConfigVariables.php +++ b/ci4/app/Controllers/Configuracion/ConfigVariables.php @@ -33,7 +33,6 @@ class ConfigVariables extends BaseResourceController parent::initController($request, $response, $logger); $this->configVariableModel = model(ConfigVariableModel::class); - } @@ -48,45 +47,46 @@ class ConfigVariables extends BaseResourceController return view(static::$viewPath . $this->indexRoute, $viewData); } - public function store(){ + public function store() + { $data = []; $variableCreated = $this->configVariableModel->store($data); return $this->response->setJSON($variableCreated); } - public function get(int $config_variable_id){ + public function get(int $config_variable_id) + { $data = $this->configVariableModel->find($config_variable_id); return $this->response->setJSON($data); } - public function updateVariable(int $config_variable_id){ + public function updateVariable(int $config_variable_id) + { $reqData = []; if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); - $status = $this->configVariableModel->update($config_variable_id,$reqData); + $status = $this->configVariableModel->update($config_variable_id, $reqData); return $this->response->setJSON([ "message" => "Variable actualizada correctamente", "status" => $status ]); - } - else { + } else { return $this->failUnauthorized('Invalid request', 403); } } public function deleteVariable(int $config_variable_id): Response { return $this->response->setJSON([]); - } - public function datatable(){ + public function datatable() + { $query = $this->configVariableModel->builder()->select([ "id", "name", "value", - "description"])->orderBy("name","asc"); + "description" + ])->orderBy("name", "asc"); return DataTable::of($query) - ->add("action",fn($q) => $q->id) - ->toJson(true); + ->add("action", fn($q) => $q->id) + ->toJson(true); } - - } \ No newline at end of file diff --git a/ci4/app/Controllers/Configuracion/Papelformato.php b/ci4/app/Controllers/Configuracion/Papelformato.php index 4c55dff7..b2b23276 100755 --- a/ci4/app/Controllers/Configuracion/Papelformato.php +++ b/ci4/app/Controllers/Configuracion/Papelformato.php @@ -244,23 +244,15 @@ class Papelformato extends \App\Controllers\BaseResourceController { public function menuItems() { if ($this->request->isAJAX()) { - $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; - $reqId = goSanitize($this->request->getPost('id'))[0]; - $reqText = goSanitize($this->request->getPost('text'))[0]; - $onlyActiveOnes = false; - $columns2select = [$reqId ?? 'id', $reqText ?? 'ancho']; - $onlyActiveOnes = false; - $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); - $nonItem = new \stdClass; - $nonItem->id = ''; - $nonItem->text = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); - - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); + $papelFormatoModel = model('App\Models\Configuracion\PapelFormatoModel'); + $searchStr = goSanitize($this->request->getPfgost('searchTerm'))[0]; + $menu = $papelFormatoModel->getElementsForMenu2($searchStr); + if(empty(($searchStr))) + array_shift($menu); + $data = [ 'menu' => $menu, - $csrfTokenName => $newTokenHash + ]; return $this->respond($data); } else { @@ -268,4 +260,15 @@ class Papelformato extends \App\Controllers\BaseResourceController { } } + + public function getSelect2() + { + if ($this->request->isAJAX()) { + $data = $this->model->getElementsForMenu2($this->request->getGet("q")); + + return $this->response->setJSON($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } } diff --git a/ci4/app/Controllers/Language.php b/ci4/app/Controllers/Language.php index cd2b062e..437f18eb 100755 --- a/ci4/app/Controllers/Language.php +++ b/ci4/app/Controllers/Language.php @@ -15,4 +15,15 @@ class Language extends BaseController $url = previous_url(); return redirect()->to($url); } + + + // Function to get the translation of the language file from a AJAX request + public function getTranslation() + { + $translationFile = $this->request->getPost('translationFile'); + $locale = $this->request->getPost('locale'); + $path = "Language/{$locale}/$translationFile.php"; + $lang = require APPPATH.$path; + return json_encode($lang); + } } diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 0be955ff..72d4370f 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -5,6 +5,8 @@ namespace App\Controllers\Presupuestos; use App\Entities\Presupuestos\PresupuestoEntity; use App\Libraries\SafekatFtpClient; use App\Models\Collection; +use App\Models\Clientes\ClienteModel; +use App\Models\Configuracion\PapelFormatoModel; use App\Models\Configuracion\PapelGenericoModel; use App\Models\Configuracion\TipoPresupuestoModel; use App\Models\Presupuestos\PresupuestoAcabadosModel; @@ -15,6 +17,7 @@ use App\Models\Presupuestos\PresupuestoManipuladosModel; use App\Models\Presupuestos\PresupuestoModel; use App\Models\Presupuestos\PresupuestoPreimpresionesModel; use App\Models\Presupuestos\PresupuestoServiciosExtraModel; +use App\Models\Presupuestos\ErrorPresupuesto; use App\Services\PresupuestoClienteService; use App\Services\PresupuestoService; use Exception; @@ -89,47 +92,28 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController public function add() { + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_presupuestos"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => "Listado", 'route' => site_url('presupuestocliente/list'), 'active' => true] + ]; + // Se obtiene el cliente ID a partir del usuario de la sesion $model_user = model('App\Models\Usuarios\UserModel'); $user = $model_user->find(auth()->user()->id); $clienteId = $user->cliente_id; - - $presupuestoEntity = isset($sanitizedData) ? new PresupuestoEntity($sanitizedData) : new PresupuestoEntity(); - $presupuestoEntity->clienteId = $clienteId; - $datosPresupuesto = (object)array(); - $datosPresupuesto->POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); - $datosPresupuesto->paisList = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true); - $datosPresupuesto->papelFormatoList = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); + $POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); - $datosPresupuesto->papelInteriorNegro = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negro', false, false, false, false, true); - $datosPresupuesto->papelInteriorNegroHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negrohq', false, false, false, false, true); - $datosPresupuesto->papelInteriorColor = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('color', false, false, false, false, true); - $datosPresupuesto->papelInteriorColorHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, false, false, false, true); - - $datosPresupuesto->papelCubierta = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', true, false, false, false, true); - $datosPresupuesto->papelSobrecubierta = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, true, false, false, true); - $datosPresupuesto->papelGuardas = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, false, false, true, false); - - $datosPresupuesto->acabadosCubierta = $this->getAcabadosCubierta(); - $datosPresupuesto->acabadosSobrecubierta = $this->getAcabadosSobrecubierta(); - - $datosPresupuesto->tipo_libro = ""; - $datosPresupuesto->color_impresion = 'negro'; - $datosPresupuesto->tapa = 'blanda'; - - $datosPresupuesto->clienteList = $this->getClienteListItems($clienteId ?? null); - $datosPresupuesto->paginasCuadernillo = [32, 28, 24, 20 , 16]; - $presupuestoEntity->estado_id = 1; - $presupuestoEntity->paginas_por_cuadernillo = 32; + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_presupuestos"), 'route' => site_url('presupuestocliente/list'), 'active' => false], + ['title' => "Añadir Presupuesto", 'route' => "javascript:void(0);", 'active' => true] + ]; $this->viewData['formAction'] = 'add'; - $this->viewData['paisList'] = $this->getPaisListItems(); - - $this->viewData['presupuestoEntity'] = $presupuestoEntity; - $this->viewData['datosPresupuesto'] = $datosPresupuesto; + $this->viewData['paisList'] = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true); $this->viewData['clienteId'] = $clienteId; + $this->viewData['POD'] = $POD; $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.addNewSuffix'); @@ -139,13 +123,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController public function edit($requestedId = null) { - if ($requestedId == null) : + if ($requestedId == null): return $this->redirect2listView(); endif; $id = filter_var($requestedId, FILTER_SANITIZE_URL); $presupuestoEntity = $this->model->find($id); - - if ($presupuestoEntity == false) : + + if ($presupuestoEntity == false): $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]); return $this->redirect2listView('sweet-error', $message); endif; @@ -153,60 +137,26 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // Se obtiene el cliente ID a partir del usuario de la sesion $model_user = model('App\Models\Usuarios\UserModel'); $user = $model_user->find(auth()->user()->id); - $clienteId = $user->cliente_id; - - $datosPresupuesto = (object)array(); - $datosPresupuesto->POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); - $datosPresupuesto->paisList = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true); - $datosPresupuesto->papelFormatoList = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); - - $datosPresupuesto->papelInteriorNegro = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negro', false, false, false, false, true); - $datosPresupuesto->papelInteriorNegroHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negrohq', false, false, false, false, true); - $datosPresupuesto->papelInteriorColor = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('color', false, false, false, false, true); - $datosPresupuesto->papelInteriorColorHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, false, false, false, true); - - $datosPresupuesto->papelCubierta = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', true, false, false, false, true); - $datosPresupuesto->papelSobrecubierta = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, true, false, false, true); - $datosPresupuesto->papelGuardas = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, false, false, true, false); - - $datosPresupuesto->acabadosCubierta = $this->getAcabadosCubierta(); - $datosPresupuesto->acabadosSobrecubierta = $this->getAcabadosSobrecubierta(); - - $datosPresupuesto->tipo_libro = $this->getTipoLibro($presupuestoEntity->tipo_impresion_id ?? null); - $datosPresupuesto->color_impresion = - $this->getTipoInterior($presupuestoEntity->id ?? null); - $datosPresupuesto->tapa = $this->getTapa($presupuestoEntity->tipo_impresion_id ?? null); - - $datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); - - $this->obtenerTiradas($presupuestoEntity); - $this->obtenerDatosPapel($presupuestoEntity); - $this->obtenerPaginasColor($presupuestoEntity); - $this->obtenerDireccionesEnvio($presupuestoEntity); - - // Si el presupuesto está confirmado, se generan los datos del resumen - if($presupuestoEntity->estado_id == 2){ - $this->generarResumen($presupuestoEntity); + if(auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')){ + $clienteId = $user->cliente_id; + } + else{ + $clienteId = $presupuestoEntity->cliente_id; } - - $datosPresupuesto->paginasCuadernillo = [32, 28, 24, 20 , 16]; - $presupuestoEntity->paginas_por_cuadernillo = $this->obtenerPaginasCuadernillo($presupuestoEntity); $this->viewData['formAction'] = 'edit'; $this->viewData['paisList'] = $this->getPaisListItems(); - $this->viewData['presupuestoEntity'] = $presupuestoEntity; - $this->viewData['datosPresupuesto'] = $datosPresupuesto; - $this->viewData['clienteId'] = $presupuestoEntity->cliente_id; // En el caso del edit, se mantiene el clienteId del presupuesto - + $this->viewData['clienteId'] = $clienteId; + $this->viewData['POD'] = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); // 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 if ($presupuestoEntity->is_duplicado) { $this->model->removeIsDuplicado($presupuestoEntity->id); } - + $this->viewData['presupuestoId'] = $presupuestoEntity->id; $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.edit3'); return $this->displayForm(__METHOD__, $id); @@ -237,7 +187,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $datetime = (new \CodeIgniter\I18n\Time("now")); $rawResult = $this->model->where('id', $id) ->set([ - 'deleted_at' => $datetime->format('Y-m-d H:i:s'), + 'deleted_at' => $datetime->format('Y-m-d H:i:s'), 'is_deleted' => $this->delete_flag ]) ->update(); @@ -255,40 +205,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } - public function getGramaje() - { - if ($this->request->isAJAX()) { - $reqData = $this->request->getPost(); - - try { - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - - $tirada = $reqData['tirada'] ?? 0; - $merma = $reqData['merma'] ?? 0; - $papel = $reqData['papel'] ?? ""; - $uso = $reqData['uso'] ?? ""; - - $model = new PapelGenericoModel(); - $menu = $model->getGramajeComparador($papel, $uso, intval($tirada + $merma)); - - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - } catch (Exception $e) { - $data = [ - 'error' => $e, - $csrfTokenName => $newTokenHash - ]; - } finally { - return $this->respond($data); - } - } else { - return $this->failUnauthorized('Invalid request', 403); - } - } public function datatable() { @@ -334,83 +251,212 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController - public function presupuesto() + public function calcular() { if ($this->request->isAJAX()) { - $reqData = $this->request->getPost(); - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); + try { - $tirada = $reqData['tirada'] ?? 0; - $tamanio = $reqData['tamanio']; - $tipo_impresion_id = $this->getTipoImpresion($reqData['tipo'], $reqData['tapa']); - $cliente_id = $reqData['clienteId'] ?? -1; - $isColor = intval($reqData['isColor']) ?? 0; - $isHq = intval($reqData['isHq']) ?? 0; + $reqData = $this->request->getPost(); + $modelPapelGenerico = new PapelGenericoModel(); - // Interior - $papel_generico = [ - 'id' => $reqData['papelInterior'] ?? 0, - 'nombre' => $reqData['papelInteriorNombre'] ?? "", - ]; - $gramaje = $reqData['gramajeInterior'] ?? 0; - $excluirRotativa = $reqData['excluirRotativa'] ?? 0; - $paginas = intval($reqData['paginas']) ?? 0; - $paginas_color = intval($reqData['paginasColor']) ?? 0; - // Cubierta - $papel_generico_cubierta = [ - 'id' => $reqData['papelCubierta'] ?? 0, - 'nombre' => $reqData['papelCubiertaNombre'] ?? "", - ]; - $gramajeCubierta = $reqData['gramajeCubierta'] ?? 0; - $carasCubierta = intval($reqData['carasCubierta'] ?? 0); - $solapasCubierta = intval($reqData['solapasCubierta'] ?? 0); - $acabadoCubierta = $reqData['acabadoCubierta'] ?? 0; + $id = $reqData['id'] ?? 0; - // Sobrecubierta - $sobreCubierta = $reqData["sobrecubierta"] ?? null; + $cliente_id = $reqData['clienteId'] ?? -1; - // Guardas - $datos_guardas = $reqData['guardas'] ?? []; + $tirada = $reqData['tirada'] ?? 0; + $tamanio = $reqData['tamanio']; + $paginas = $reqData['paginas'] ?? 0; + $paginas_color = $reqData['paginasColor'] ?? 0; + $tipo = $reqData['tipo']; - $servicios = $reqData['servicios'] ?? []; + $paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null; + $papelInteriorDiferente = intval($reqData['papelInteriorDiferente']) ?? null; - $paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null; + $isColor = intval($reqData['isColor']) ?? 0; + $isHq = intval($reqData['isHq']) ?? 0; - $datos_presupuesto = array( - 'tirada' => $tirada, - 'tamanio' => $tamanio, - 'tipo_impresion_id' => $tipo_impresion_id, - 'clienteId' => $cliente_id, - 'isColor' => $isColor, - 'isHq' => $isHq, - 'paginasCuadernillo' => $paginasCuadernillo, + $interior = $reqData['interior'] ?? []; + $cubierta = $reqData['cubierta'] ?? []; + $sobrecubierta = $reqData['sobrecubierta'] ?? []; + $guardas = $reqData['guardas'] ?? []; + $faja = $reqData['faja'] ?? []; + $excluirRotativa = $reqData['excluirRotativa'] ?? 0; + $excluirRotativa = intval($excluirRotativa); + $ivaReducido = intval($reqData['ivaReducido']) ?? 0; - 'interior' => array( - 'papel_generico' => $papel_generico, + $direcciones = $reqData['direcciones'] ?? []; + + $tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']); + $lomoRedondo = $cubierta['lomoRedondo'] ?? 0; + + if ($papelInteriorDiferente) { + $papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']); + $papel['color'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['color']); + $gramaje['negro'] = intval($interior['gramajeInterior']['negro']); + $gramaje['color'] = intval($interior['gramajeInterior']['color']); + } else { + $papel = $modelPapelGenerico->getIdFromCode($interior['papelInterior']); + $gramaje = intval($interior['gramajeInterior']); + } + // Interior + $interior = [ + 'papel_generico' => $papel, 'gramaje' => $gramaje, 'excluirRotativa' => $excluirRotativa, 'paginas' => $paginas, 'paginas_color' => $paginas_color, - ), - 'cubierta' => array( - 'papel_generico_cubierta' => $papel_generico_cubierta, - 'gramajeCubierta' => $gramajeCubierta, - 'carasCubierta' => $carasCubierta, - 'solapasCubierta' => $solapasCubierta, - ), - 'acabadoCubierta' => $acabadoCubierta, - 'sobrecubierta' => $sobreCubierta, - 'datos_guardas' => $datos_guardas, - 'servicios' => $servicios, - ); + 'papelInteriorDiferente' => $papelInteriorDiferente + ]; - $return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG - array_merge($return_data, [$csrfTokenName => $newTokenHash]); - return $this->respond($return_data); + // Cubierta + $cubierta = [ + 'papel_generico_cubierta' => $modelPapelGenerico->getIdFromCode($cubierta['papelCubierta']), + 'gramajeCubierta' => intval($cubierta['gramajeCubierta']), + 'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0), + 'solapasCubierta' => intval($cubierta['solapas'] ?? 0), + 'acabadosCubierta' => $cubierta['acabados'] ?? 0, + 'lomoRedondo' => $lomoRedondo, + ]; + + // Sobrecubierta + if ($sobrecubierta != "false" && $sobrecubierta != null) { + $sobrecubierta = [ + 'papel' => $modelPapelGenerico->getIdFromCode($sobrecubierta['papel']), + 'gramaje' => intval($sobrecubierta['gramaje']), + 'solapas' => intval($sobrecubierta['solapas'] ?? 0), + 'acabados' => $sobrecubierta['plastificado'] ?? 0, + ]; + } else + $sobrecubierta = false; + + // Guardas + if ($guardas != "false" && $guardas != null) { + $datos_guardas = [ + 'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']), + 'gramaje' => intval($guardas['gramaje']), + 'caras' => intval($guardas['caras']), + ]; + } else + $datos_guardas = false; + + $datos_presupuesto = array( + 'id' => $id, + 'tirada' => $tirada, + 'tamanio' => $tamanio, + 'tipo_impresion_id' => $tipo_impresion_id, + 'clienteId' => $cliente_id, + 'isColor' => $isColor, + 'isHq' => $isHq, + 'paginasCuadernillo' => $paginasCuadernillo, + + 'interior' => $interior, + 'cubierta' => $cubierta, + 'sobrecubierta' => $sobrecubierta, + 'datos_guardas' => $datos_guardas, + + 'servicios' => $reqData['servicios'] ?? [], + ); + + $return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG + if(array_key_exists('errors', $return_data)){ + if($return_data['errors']->status == 1){ + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } + + } + + if (array_key_exists('exception', $return_data)) { + return $this->failServerError( + $return_data['exception'] . ' - ' . + $return_data['file'] . ' - ' . $return_data['line'] + ); + } + + if (count($direcciones) > 1) { + + for ($i = 0; $i < count($tirada); $i++) { + + $coste_envio = 0.0; + foreach ($direcciones as $direccion) { + $coste_direccion = $this->getCosteEnvio( + $direccion['id'], + $return_data['peso'][$i], + $direccion['unidades'], + $direccion['entregaPalets'] == 'true' ? 1 : 0 + )[0]; + + + if (!property_exists($coste_direccion, 'coste')) { + + $errorModel = new ErrorPresupuesto(); + $data['direccion'] = $direccion; + $data['peso'] = $return_data['peso'][$i]; + $data['palets'] = $direccion['entregaPalets'] == 'true' ? 1 : 0; + $errorModel->insertError( + $id, + auth()->user()->id, + 'No se ha podido calcular el coste de envío', + $data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + + } else { + $coste_envio += $coste_direccion->coste; + } + } + $return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio / $tirada[$i], 4); + } + } else { + + for ($i = 0; $i < count($tirada); $i++) { + + $coste_envio = 0.0; + $coste_direccion = $this->getCosteEnvio(null, $return_data['peso'][$i], $tirada[$i], false)[0]; + + 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); + } + + + } + + return $this->respond($return_data); + } catch (Exception $e) { + return $this->failServerError($e->getMessage()); + } } else { return $this->failUnauthorized('Invalid request', 403); } @@ -438,30 +484,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } - public function getDatosDireccion() - { - if ($this->request->isAJAX()) { - - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - - $reqData = $this->request->getPost(); - $direccionId = $reqData['id'] ?? 0; - $peso = $reqData['peso'] ?? 0; - $unidades = $reqData['unidades'] ?? 0; - $entregaPieCalle = $reqData['entregaPieCalle'] ?? 0; - - $data = $this->calcular_coste_envio($direccionId, $peso, $unidades, $entregaPieCalle); - - return $this->respond([ - 'data' => $data, - $csrfTokenName => $newTokenHash - ]); - } else { - return $this->failUnauthorized('Invalid request', 403); - } - } public function getNuevaDireccion() { @@ -500,7 +523,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } - public function duplicarPresupuesto(){ + public function duplicarPresupuesto() + { if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); @@ -510,61 +534,60 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $id = $reqData['id'] ?? 0; - if($id > 0){ - try{ - + if ($id > 0) { + try { + $presupuesto = $this->model->find($id); - $presupuesto->titulo = $presupuesto->titulo .' - ' . lang('Presupuestos.duplicado'); + $presupuesto->titulo = $presupuesto->titulo . ' - ' . lang('Presupuestos.duplicado'); $presupuesto->is_duplicado = 1; $presupuesto->estado_id = 1; $new_id = $this->model->insert($presupuesto); - + $presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); foreach ($presupuestoAcabadosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $acabado) { $acabado->presupuesto_id = $new_id; $presupuestoAcabadosModel->insert($acabado); } - + $presupuestoEncuadernacionesModel = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel'); foreach ($presupuestoEncuadernacionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $encuadernacion) { $encuadernacion->presupuesto_id = $new_id; $presupuestoEncuadernacionesModel->insert($encuadernacion); } - + $presupuestoManipuladosModel = model('App\Models\Presupuestos\PresupuestoManipuladosModel'); foreach ($presupuestoManipuladosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $manipulado) { $manipulado->presupuesto_id = $new_id; $presupuestoManipuladosModel->insert($manipulado); } - + $presupuestoPreimpresionesModel = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel'); foreach ($presupuestoPreimpresionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $preimpresion) { $preimpresion->presupuesto_id = $new_id; $presupuestoPreimpresionesModel->insert($preimpresion); } - + $presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel'); foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) { $servicioExtra->presupuesto_id = $new_id; $presupuestoServiciosExtraModel->insert($preimpresion); } - + $presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) { $direccion->presupuesto_id = $new_id; $presupuestoDireccionesModel->insert($direccion); } - + $presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel'); $presupuestoLineaModel->duplicateLineasPresupuesto($presupuesto->id, $new_id); - + return $this->respond([ 'success' => true, 'id' => $new_id, $csrfTokenName => $newTokenHash ]); - - }catch(\Exception $e){ + } catch (\Exception $e) { return $this->respond([ 'success' => false, 'message' => $e->getMessage(), @@ -577,68 +600,116 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'success' => false, 'message' => "No existe el presupuesto", $csrfTokenName => $newTokenHash - + ]); - } else { return $this->failUnauthorized('Invalid request', 403); } } - public function guardarPresupuesto() + public function guardar() { if ($this->request->isAJAX()) { + $modelPapelGenerico = new PapelGenericoModel(); + $reqData = $this->request->getPost(); - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - - $confirmar = $reqData['confirmar'] ?? 0; - $id = $reqData['id'] ?? 0; $id = intval($id); - $datosCabecera = $reqData['datos_cabecera'] ?? []; + $datosCabecera = $reqData['datosCabecera'] ?? []; - $tirada = $reqData['datos_libro']['tirada'] ?? 0; - $selected_tirada = $reqData['tirada'] ?? 0; - $peso_libro = $reqData['peso'] ?? 0; - $tamanio = $reqData['datos_libro']['tamanio']; - $tipo_impresion_id = $this->getTipoImpresion($reqData['datos_libro']['tipo'], $reqData['datos_libro']['tapa']); - $cliente_id = $reqData['datos_libro']['clienteId'] ?? -1; - $isColor = intval($reqData['datos_libro']['isColor']) ?? 0; - $isHq = intval($reqData['datos_libro']['isHq']) ?? 0; - $paginasCuadernillo = $reqData['datos_libro']['paginasCuadernillo'] ?? null; + $confirmar = $reqData['confirmar'] ?? 0; + $cliente_id = $reqData['clienteId'] ?? -1; + + $tirada = $reqData['tirada'] ?? 0; + $selected_tirada = $reqData['selectedTirada'] ?? 0; + $tamanio = $reqData['tamanio']; + $paginas = $reqData['paginas'] ?? 0; + $paginas_color = $reqData['paginasColor'] ?? 0; + + $posPaginasColor = $reqData['posPaginasColor'] ?? ""; + $paginasColorConsecutivas = $reqData['pagColorConsecutivas'] ?? 0; + $papelInteriorDiferente = $reqData['papelInteriorDiferente'] ?? 0; + + $tipo = $reqData['tipo']; + + $paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null; + $papelInteriorDiferente = intval($reqData['papelInteriorDiferente']) ?? null; + + $isColor = intval($reqData['isColor']) ?? 0; + $isHq = intval($reqData['isHq']) ?? 0; + + $prototipo = intval($reqData['prototipo']) ?? 0; + + $interior = $reqData['interior'] ?? []; + $cubierta = $reqData['cubierta'] ?? []; + $sobrecubierta = $reqData['sobrecubierta'] ?? []; + $guardas = $reqData['guardas'] ?? []; + $faja = $reqData['faja'] ?? []; + $excluirRotativa = $reqData['excluirRotativa'] ?? 0; + $excluirRotativa = intval($excluirRotativa); + $ivaReducido = intval($reqData['ivaReducido']) ?? 0; + + $direcciones = $reqData['direcciones'] ?? []; + + $tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']); + + if ($papelInteriorDiferente) { + $papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']); + $papel['color'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['color']); + $gramaje['negro'] = intval($interior['gramajeInterior']['negro']); + $gramaje['color'] = intval($interior['gramajeInterior']['color']); + } else { + $papel = $modelPapelGenerico->getIdFromCode($interior['papelInterior']); + $gramaje = intval($interior['gramajeInterior']); + } // Interior - $papel_generico = [ - 'id' => $reqData['datos_libro']['papelInterior'] ?? 0, - 'nombre' => $reqData['datos_libro']['papelInteriorNombre'] ?? "", + $interior = [ + 'papel_generico' => $papel, + 'gramaje' => $gramaje, + 'excluirRotativa' => $excluirRotativa, + 'paginas' => $paginas, + 'paginas_color' => $paginas_color, + 'pos_paginas_color' => $posPaginasColor, + 'paginas_color_consecutivas' => $paginasColorConsecutivas, + 'papelInteriorDiferente' => $papelInteriorDiferente ]; - $gramaje = $reqData['datos_libro']['gramajeInterior'] ?? 0; - $excluirRotativa = $reqData['datos_libro']['excluirRotativa'] ?? 0; - $paginas = intval($reqData['datos_libro']['paginas']) ?? 0; - $paginas_color = intval($reqData['datos_libro']['paginasColor']) ?? 0; + // Cubierta - $papel_generico_cubierta = [ - 'id' => $reqData['datos_libro']['papelCubierta'] ?? 0, - 'nombre' => $reqData['datos_libro']['papelCubiertaNombre'] ?? "", + $cubierta = [ + 'papel_generico_cubierta' => $modelPapelGenerico->getIdFromCode($cubierta['papelCubierta']), + 'gramajeCubierta' => intval($cubierta['gramajeCubierta']), + 'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0), + 'solapasCubierta' => intval($cubierta['solapas'] ?? 0), + 'acabadosCubierta' => $cubierta['acabados'] ?? 0, + 'lomoRedondo' => $cubierta['lomoRedondo'] ?? 0, + 'cabezada' => $cubierta['cabezada'] ?? 'WHI', ]; - $gramajeCubierta = $reqData['datos_libro']['gramajeCubierta'] ?? 0; - $carasCubierta = intval($reqData['datos_libro']['carasCubierta'] ?? 0); - $solapasCubierta = intval($reqData['datos_libro']['solapasCubierta'] ?? 0); - $acabadoCubierta = $reqData['datos_libro']['acabadoCubierta'] ?? 0; // Sobrecubierta - $sobreCubierta = $reqData['datos_libro']["sobrecubierta"] ?? null; + if ($sobrecubierta != "false" && $sobrecubierta != null) { + $sobrecubierta = [ + 'papel' => $modelPapelGenerico->getIdFromCode($sobrecubierta['papel']), + 'gramaje' => intval($sobrecubierta['gramaje']), + 'solapas' => intval($sobrecubierta['solapas'] ?? 0), + 'acabados' => $sobrecubierta['plastificado'] ?? 0, + ]; + } else + $sobrecubierta = false; // Guardas - $datos_guardas = $reqData['datos_libro']['guardas'] ?? 0; - - $servicios = $reqData['datos_libro']['servicios'] ?? []; - $iva_reducido = $reqData['iva_reducido']; + if ($guardas != "false" && $guardas != null) { + $datos_guardas = [ + 'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']), + 'gramaje' => intval($guardas['gramaje']), + 'caras' => intval($guardas['caras']), + ]; + } else + $datos_guardas = false; $datos_presupuesto = array( 'tirada' => $tirada, @@ -648,24 +719,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'isColor' => $isColor, 'isHq' => $isHq, 'paginasCuadernillo' => $paginasCuadernillo, - - 'interior' => array( - 'papel_generico' => $papel_generico, - 'gramaje' => $gramaje, - 'excluirRotativa' => $excluirRotativa, - 'paginas' => $paginas, - 'paginas_color' => $paginas_color, - ), - 'cubierta' => array( - 'papel_generico_cubierta' => $papel_generico_cubierta, - 'gramajeCubierta' => $gramajeCubierta, - 'carasCubierta' => $carasCubierta, - 'solapasCubierta' => $solapasCubierta, - ), - 'acabadoCubierta' => $acabadoCubierta, - 'sobrecubierta' => $sobreCubierta, + + 'interior' => $interior, + 'cubierta' => $cubierta, + 'sobrecubierta' => $sobrecubierta, 'datos_guardas' => $datos_guardas, - 'servicios' => $servicios, + + 'servicios' => $reqData['servicios'] ?? [], ); $resultado_presupuesto = $this->calcular_presupuesto($datos_presupuesto, $selected_tirada, true); @@ -676,57 +736,65 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if (!empty($error)) { return $this->respond([ 'error' => $error, - $csrfTokenName => $newTokenHash ]); } } } else if (isset($resultado_presupuesto['exception'])) { return $this->respond([ 'error' => $resultado_presupuesto['exception'], - $csrfTokenName => $newTokenHash + 'file' => $resultado_presupuesto['file'], + 'line' => $resultado_presupuesto['line'], ]); } + // seleccionamos el peso de la tirada seleccionada + $peso_libro = $resultado_presupuesto['peso'][array_search($selected_tirada, $tirada)]; - for ($i = 0; $i < count($tirada); $i++) { - $resultado_presupuesto['info']['totales'][$i]['coste_envio'] = 0.0; - $resultado_presupuesto['info']['totales'][$i]['margen_envio'] = 0.0; + if (count($direcciones) > 1) { - foreach ($reqData['direcciones'] as $direccion) { + for ($i = 0; $i < count($tirada); $i++) { - $proporcion = intval($direccion['unidades']) / $selected_tirada * 100.0; - $unidades_calculo = floor($tirada[$i] * $proporcion / 100.0); - try{ - $coste_envio = $this->calcular_coste_envio( + $resultado_presupuesto['info']['totales'][$i]['coste_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'], - $peso_libro, - $unidades_calculo, - $direccion['tipo'] == 'cajas' ? 0 : 1 - ); - - if (count($coste_envio) > 0) { - $coste = floatval($coste_envio[0]->coste); - $margen = ($coste * floatval($coste_envio[0]->margen)) / 100.0; - $coste -= $margen; - $resultado_presupuesto['info']['totales'][$i]['coste_envio'] += $coste; - $resultado_presupuesto['info']['totales'][$i]['margen_envio'] += $margen; - } - } - catch(Exception $e){ - return $this->respond([ - 'status' => -1, - 'message' => "Error al calcular el coste de envío (¿las direcciones están guardadas?)", - $csrfTokenName => $newTokenHash - ]); + $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); } + } else { + + 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; + $resultado_presupuesto['info']['totales'][$i]['margen_envio'] = $margen_envio; + } + + } $model_presupuesto = new PresupuestoModel(); $tiradas_alternativas = []; $resumen_totales = []; + for ($i = 0; $i < count($tirada); $i++) { + if ($tirada[$i] != $selected_tirada) { $coste_total = $resultado_presupuesto['info']['totales'][$i]['totalImpresion'] + $resultado_presupuesto['info']['totales'][$i]['totalPapel'] + @@ -736,9 +804,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $resultado_presupuesto['info']['totales'][$i]['margenPapel'] + $resultado_presupuesto['info']['totales'][$i]['margen_envio']) / ($coste_total + $coste_envio) * 100.0, 2); $total_pedido = round(($coste_total + $resultado_presupuesto['info']['totales'][$i]['totalServicios'] + $resultado_presupuesto['info']['totales'][$i]['margenServicios'] + $coste_envio), 2); - $precio_u = round(($coste_total + $resultado_presupuesto['info']['totales'][$i]['totalServicios'] + $resultado_presupuesto['info']['totales'][$i]['margenServicios'] + $coste_envio) / $tirada[$i], 4); + $precio_u = round(($coste_total + $resultado_presupuesto['info']['totales'][$i]['totalServicios'] + $resultado_presupuesto['info']['totales'][$i]['margenServicios'] + $coste_envio) / $tirada[$i], 4); - array_push($tiradas_alternativas, (object)array( + array_push($tiradas_alternativas, (object) array( 'tirada' => $tirada[$i], 'coste_impresion' => round($coste_total, 2), 'coste_envio' => $coste_envio, @@ -756,6 +824,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $borrar_antes = true; } + if ($datos_presupuesto['sobrecubierta']) { + $acabado_id = $this->obtenerTarifasAcabado(['plastificado' => $datos_presupuesto['sobrecubierta']['acabados']]); + if (count($acabado_id) > 0) { + $datos_presupuesto['sobrecubierta']['acabados'] = $acabado_id[0]; + } + } + $acabado_id = $this->obtenerTarifasAcabado($datos_presupuesto['cubierta']['acabadosCubierta']); + if (count($acabado_id) > 0) { + $datos_presupuesto['cubierta']['acabadosCubierta']['plastificado'] = $acabado_id[0]; + $datos_presupuesto['cubierta']['acabadosCubierta']['barniz'] = $acabado_id[1]; + $datos_presupuesto['cubierta']['acabadosCubierta']['estampado'] = $acabado_id[2]; + } else { + $datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0; + } + + $datos_presupuesto['prototipo'] = $prototipo; + $id = $model_presupuesto->insertarPresupuestoCliente( $id, $selected_tirada, @@ -763,7 +848,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $datosCabecera, $resultado_presupuesto['info'], $resumen_totales, - $iva_reducido, + $ivaReducido, $excluirRotativa, $tiradas_alternativas ); @@ -793,14 +878,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) { // Servicios acabado $this->guardarServicio($id, $servicio, 'acabado'); - } else if ($servicio->tarifa_id == 24 ) { + } else if ($servicio->tarifa_id == 24) { // Servicios preimpresion $this->guardarServicio($id, $servicio, 'preimpresion'); } else if ($servicio->tarifa_id == 9) { // Servicios extra $this->guardarServicio($id, $servicio, 'extra'); - } - else if ($servicio->tarifa_id == 62) { + } else if ($servicio->tarifa_id == 62) { // Servicios manipulado $this->guardarServicio($id, $servicio, 'manipulado'); } @@ -819,14 +903,106 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'status' => $id, 'url' => site_url('presupuestos/presupuestocliente/edit'), 'message' => lang('Basic.global.saveSuccess', [lang('Basic.global.record')]), - $csrfTokenName => $newTokenHash ]); } else { return $this->failUnauthorized('Invalid request', 403); } } - public function get_files(){ + + public function cargar($id) + { + if ($this->request->isAJAX()) { + + $modelPapelGenerico = new PapelGenericoModel(); + $modelPapelFormato = new PapelFormatoModel(); + $modelCliente = new ClienteModel(); + + $reqData = $this->request->getPost(); + + $presupuesto = $this->model->find($id); + $data = []; + if ($presupuesto) { + $data['lc'] = $presupuesto->lomo_cubierta; + $data['lsc'] = $presupuesto->lomo_sobrecubierta; + $data['datosGenerales']['titulo'] = $presupuesto->titulo; + $data['datosGenerales']['autor'] = $presupuesto->autor; + $data['datosGenerales']['isbn'] = $presupuesto->isbn; + $data['datosGenerales']['coleccion'] = $presupuesto->coleccion; + $data['datosGenerales']['referenciaCliente'] = $presupuesto->referencia_cliente; + $data['datosGenerales']['paginas'] = $presupuesto->paginas; + $data['datosGenerales']['paginasCuadernillo'] = $presupuesto->paginasCuadernillo; + $data['datosGenerales']['tirada'] = $presupuesto->tirada; + $data['datosGenerales']['ivaReducido'] = $presupuesto->iva_reducido; + $data['datosGenerales']['excluirRotativa'] = $presupuesto->excluir_rotativa; + $data['datosGenerales']['clienteId'] = $presupuesto->cliente_id; + $data['datosGenerales']['clienteNombre'] = $modelCliente->getNombre($presupuesto->cliente_id); + model('App\Models\Clientes\ClienteModel') + ->find($presupuesto->cliente_id)->nombre; + $data['datosGenerales']['papelFormatoId'] = $presupuesto->papel_formato_id; + $data['datosGenerales']['papelFormatoNombre'] = $modelPapelFormato->getNombre($presupuesto->papel_formato_id); + $data['datosGenerales']['papelFormatoPersonalizado'] = $presupuesto->papel_formato_personalizado; + $data['datosGenerales']['papelFormatoAncho'] = $presupuesto->papel_formato_ancho; + $data['datosGenerales']['papelFormatoAlto'] = $presupuesto->papel_formato_alto; + + $data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color; + $data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente; + $data['datosGenerales']['paginasColorConsecutivas'] = $presupuesto->paginas_color_consecutivas; + + $data['datosGenerales']['tipo'] = $this->getTipoLibro($presupuesto->tipo_impresion_id ?? null); + $data['datosGenerales']['prototipo'] = $presupuesto->prototipo; + + $datos_papel = $this->obtenerDatosPapel($presupuesto->id); + $data['interior'] = $datos_papel['interior'] ? $datos_papel['interior'] : []; + + $data['cubierta'] = $datos_papel['cubierta'] ? $datos_papel['cubierta'] : []; + $data['cubierta']['tapa'] = $this->obtenerTipoTapa($presupuesto->tipo_impresion_id ?? null); + $data['cubierta']['lomoRedondo'] = $presupuesto->lomo_redondo ? 1 : 0; + $data['cubierta']['solapas'] = $presupuesto->solapas ? 1 : 0; + $data['cubierta']['solapas_ancho'] = $presupuesto->solapas_ancho; + $data['cubierta']['cabezada'] = $presupuesto->cabezada; + $modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel"); + $data['cubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_cubierta_id); + $data['cubierta']['barniz'] = $modelAcabado->getCodeFromId($presupuesto->barniz_cubierta_id); + $data['cubierta']['estampado'] = $modelAcabado->getCodeFromId($presupuesto->estampado_cubierta_id); + $data['cubierta']['retractilado'] = $presupuesto->retractilado ? 1 : 0; + + $data['sobrecubierta'] = array_key_exists('sobrecubierta', $datos_papel) ? $datos_papel['sobrecubierta'] : []; + $data['sobrecubierta']['solapas'] = $presupuesto->solapas_sobrecubierta ? 1 : 0; + $data['sobrecubierta']['solapas_ancho'] = $presupuesto->solapas_ancho_sobrecubierta; + $data['sobrecubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_sobrecubierta_id); + + $data['guardas'] = array_key_exists('guardas', $datos_papel) ? $datos_papel['guardas'] : []; + + $modelLinea = new PresupuestoLineaModel(); + $lineas = $modelLinea->where('presupuesto_id', $id)->findAll(); + + [$data['datosGenerales']['paginasNegro'], $data['datosGenerales']['paginasColor']] = + $this->getPaginas($lineas); + + $data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id); + + $tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data); + for ($i = 0; $i < count($tiradas_alternativas); $i++) { + $tirada = $tiradas_alternativas[$i]; + $data['datosGenerales']['tirada' . ($i + 2)] = $tirada->tirada; + + } + + return $this->respond([ + 'status' => 1, + 'data' => $data + ]); + } + + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function get_files() + { // Check if the request is a POST request if ($_SERVER['REQUEST_METHOD'] == 'POST') { @@ -842,14 +1018,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $size = filesize($file->file_path); $splitPath = explode("presupuestos/", $file->file_path); - + // se crea un objeto con el nombre del fichero y el tamaño $obj = (object) array( 'name' => $file->nombre, 'size' => $size, - 'hash' => $splitPath[1] ?? $file->file_path); + 'hash' => $splitPath[1] ?? $file->file_path + ); + - // se añade el objeto al array array_push($result, $obj); } @@ -858,23 +1035,24 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } - public function upload_files(){ + public function upload_files() + { $model = model('App\Models\Presupuestos\PresupuestoFicheroModel'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $presupuesto_id = $_POST['presupuesto_id']; - $old_files = json_decode($_POST['oldFiles']); - + $old_files = json_decode($_POST['oldFiles']); + // Comprobar si se han subido archivos if (!empty($_FILES['file']) || !empty($old_files)) { - - + + // Borrar los archivos existentes del presupuesto $model->deleteFiles($presupuesto_id, $old_files); - if (!empty($_FILES['file'])){ + if (!empty($_FILES['file'])) { $files = $_FILES['file']; // Iterar sobre los archivos @@ -885,23 +1063,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $tmp_name = $files['tmp_name'][$i]; $new_name = $model->saveFileInBBDD($presupuesto_id, $name, $extension, auth()->id()); - + // Se sube el fichero // Pero primero se comprueba que la carpeta presupuestos exista if (!is_dir(WRITEPATH . 'uploads/presupuestos')) { mkdir(WRITEPATH . 'uploads/presupuestos', 0777, true); } - if(!is_null($new_name)){ + if (!is_null($new_name)) { $path = WRITEPATH . 'uploads/presupuestos/' . $new_name; - move_uploaded_file($tmp_name,$path); + move_uploaded_file($tmp_name, $path); $ftp = new SafekatFtpClient(); $ftp->uploadFilePresupuesto($presupuesto_id); } } } - } - else{ + } else { // Borrar los archivos existentes del presupuesto $model->deleteFiles($presupuesto_id); } @@ -910,7 +1087,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } - + /*********************** @@ -963,7 +1140,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $unidades = intval($direccion['unidades']); $peso_envio = $peso_libro * $unidades / 1000.0; - $data = $this->calcular_coste_envio($direccion['id'], $peso_libro, $direccion['unidades'], $direccion['tipo'] == 'cajas' ? 0 : 1); + $data = $this->getCosteEnvio( + $direccion['id'], + $peso_libro, + $direccion['unidades'], + $direccion['entregaPalets'] == 'false' ? 0 : 1 + ); + if (count($data) > 0) { $data[0]->presupuesto_id = $presupuestoId; @@ -971,7 +1154,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController unset($data[0]->id); $data[0]->precio = $data[0]->coste; unset($data[0]->coste); - $data[0]->entregaPieCalle = $direccion['tipo'] == 'cajas' ? 0 : 1; + $data[0]->entregaPieCalle = $direccion['entregaPalets'] == 'false' ? 0 : 1; unset($data[0]->tipo); $data[0]->peso = $peso_envio; $data[0]->cantidad = $unidades; @@ -1002,7 +1185,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if (isset($servicio->paginas_por_cuadernillo)) { $data['paginas_por_cuadernillo'] = $servicio->paginas_por_cuadernillo; } - + $model->insert($data); } else if ($tipo == 'extra') { $model = new PresupuestoServiciosExtraModel(); @@ -1010,8 +1193,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data = [ 'presupuesto_id' => $presupuestoId, 'tarifa_extra_id' => $servicio->tarifa_id, - 'precio_total' => $servicio->total, - 'precio_unidad' => $servicio->precio_unidad, + 'precio' => $servicio->precio, 'margen' => $servicio->margen, ]; $model->insert($data); @@ -1041,18 +1223,27 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } - protected function calcular_coste_envio($direccionId, $peso, $unidades, $entregaPieCalle) + protected function getCosteEnvio($direccionId = null, $peso, $unidades, $entregaPieCalle) { - $model = model('App\Models\Clientes\ClienteDireccionesModel'); - $data = $model->getDireccion($direccionId); + if ($direccionId != null) { + $model = model('App\Models\Clientes\ClienteDireccionesModel'); + $data = $model->getDireccion($direccionId); + } else { + $data = []; + array_push($data, (object) [ + 'pais_id' => 1, // españa + 'cp' => 18000, // envio nacional + ]); + } + $modelTarifaEnvio = model('App\Models\Tarifas\TarifaEnvioModel'); $coste = 0; $margen = 0; if ($data > 0) { - $peso_envio = $peso * $unidades / 1000.0; // peso libro * unidades y se pasa a kilogramos + $peso_envio = round(floatval($peso * $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'); for ($i = 0; $i < count($tarifas_envio); $i++) { if ($peso_envio > $tarifas_envio[$i]->peso_max || floatval($tarifas_envio[$i]->precio_max) == 0) { @@ -1077,7 +1268,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $coste = $tarifas_envio[0]->precio; } } - if (count($data) > 0 && count($tarifas_envio) > 0){ + if (count($data) > 0 && count($tarifas_envio) > 0) { $data[0]->coste = $coste; $data[0]->tipo = $entregaPieCalle ? 'palets' : 'cajas'; $data[0]->margen = $margen; @@ -1108,18 +1299,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $isHq = $datos_entrada['isHq']; $paginasCuadernillo = $datos_entrada['paginasCuadernillo'] ?? null; + // Interior + $papelInteriorDiferente = $datos_entrada['interior']['papelInteriorDiferente'] ?? false; $papel_generico = $datos_entrada['interior']['papel_generico']; $gramaje = $datos_entrada['interior']['gramaje']; $excluirRotativa = $datos_entrada['interior']['excluirRotativa']; $paginas = $datos_entrada['interior']['paginas']; $paginas_color = $datos_entrada['interior']['paginas_color']; + // Cubierta $papel_generico_cubierta = $datos_entrada['cubierta']['papel_generico_cubierta']; $gramajeCubierta = $datos_entrada['cubierta']['gramajeCubierta']; $carasCubierta = $datos_entrada['cubierta']['carasCubierta']; $solapasCubierta = $datos_entrada['cubierta']['solapasCubierta']; + $acabadosCubierta = $datos_entrada['cubierta']['acabadosCubierta'] ?? []; + $lomoRedondo = $datos_entrada['cubierta']['lomoRedondo']; // Sobrecubierta $sobreCubierta = $datos_entrada["sobrecubierta"] ?? null; @@ -1130,14 +1326,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // Servicios $servicios = $datos_entrada['servicios'] ?? []; - $error = (object)[ - 'interior' => "", - 'cubierta' => "", - 'sobrecubierta' => "", - 'guardas' => "", - 'servicios' => "", - 'serviciosDefecto' => "", - ]; $coste_servicios = 0.0; $POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); @@ -1167,7 +1355,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $is_cosido = (new TipoPresupuestoModel())->get_isCosido($tipo_impresion_id); - $datosPedido = (object)array( + $datosPedido = (object) array( 'paginas' => $paginas, 'tirada' => $tirada[$t], 'merma' => $tirada[$t] > $POD ? $this->calcular_merma($tirada[$t], $POD) : 0, @@ -1191,10 +1379,28 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'cliente_id' => $cliente_id, 'paginas_color' => $paginas_color, 'excluirRotativa' => $excluirRotativa, + 'papelInteriorDiferente' => $papelInteriorDiferente ); $interior = PresupuestoClienteService::obtenerInterior($input_data); + if ($interior == -1) { + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + ' + No se puede obtener el interior', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } + $costeInterior = 0.0; $peso_interior = 0.0; foreach ($interior as $linea) { @@ -1215,10 +1421,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } - if ($costeInterior <= 0) { - $error->interior = lang('Presupuestos.errores.noInterior'); - } - // Si es POD hay que volver a calcular para incluir la merma correcta if ($tirada[$t] <= $POD) { $num_formas = []; @@ -1233,6 +1435,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $info['merma'] = max($info['merma'], $input_data['datosPedido']->merma); } $interior = PresupuestoClienteService::obtenerInterior($input_data); + if ($interior == -1) { + + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener el interior', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } $costeInterior = 0.0; $peso_interior = 0.0; @@ -1264,11 +1482,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } - if ($costeInterior <= 0) - $error->interior = lang('Presupuestos.errores.noInterior'); - else - $error->interior = ""; + if ($costeInterior <= 0) { + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener el interior', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } // Cubierta $input_data['papel_generico'] = $papel_generico_cubierta; @@ -1281,6 +1510,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $input_data['isColor'] = 1; $input_data['isHq'] = 1; $input_data['uso'] = 'cubierta'; + $input_data['lomoRedondo'] = $lomoRedondo; $cubierta = PresupuestoClienteService::obtenerCubierta($input_data); $coste_cubierta = 0.0; @@ -1301,41 +1531,69 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController ); } } - if ($coste_cubierta <= 0) - $error->cubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta'); - else - $error->cubierta = ""; + if ($coste_cubierta <= 0) { - $tarifaAcabadoCubierta = intval($datos_entrada['acabadoCubierta'] ?? 0); + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener la cubierta', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } + // Acabados Cubierta + $tarifaAcabadoCubierta = $this->obtenerTarifasAcabado($acabadosCubierta); $acabadoCubierta = []; - if ($tarifaAcabadoCubierta > 0) { + foreach ($tarifaAcabadoCubierta as $tarifa) { + + if ($tarifa == 0) + continue; $model = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); - $acabadoCubierta = $model->getPrecioTarifa($tarifaAcabadoCubierta, $datosPedido->tirada, -1, $POD); - } - if (count($acabadoCubierta) > 0) { - if ($acabadoCubierta[0]->total <= 0) - $error->servicios = lang('Presupuestos.errores.errorPresupuesto'); - $coste_servicios += floatval($acabadoCubierta[0]->total); + $acabadoCubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD); + + if (count($acabadoCubierta) > 0) { + if ($acabadoCubierta[0]->total <= 0) { + + $input_data['tarifas_acabado_cubierta'] = $tarifaAcabadoCubierta; + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener acabados de cubierta', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } + $coste_servicios += floatval($acabadoCubierta[0]->total); + } } + // Sobrecubierta $coste_sobrecubierta = 0.0; $peso_sobrecubierta = 0.0; $linea_sobrecubierta = []; $acabadoSobrecubierta = []; $lomo_sobrecubierta = 0.0; - if (!is_null($sobreCubierta)) { + if (!is_null($sobreCubierta) && $sobreCubierta) { - $papel_generico_sobrecubierta = [ - 'id' => $sobreCubierta['papel'] ?? 0, - 'nombre' => $sobreCubierta['papel_nombre'] ?? "", - ]; - $input_data['papel_generico'] = $papel_generico_sobrecubierta; + $input_data['papel_generico'] = $sobreCubierta['papel'] ?? 0; $input_data['gramaje'] = $sobreCubierta['gramaje'] ?? 0; $input_data['datosPedido']->paginas = 4; $input_data['paginas_color'] = 4; $input_data['datosPedido']->solapas_ancho = intval($sobreCubierta['solapas'] ?? 0); - $input_data['datosPedido']->solapas = $input_data['datosPedido']->solapas_ancho > 0 ? 1 : 0; + $input_data['datosPedido']->solapas = $sobreCubierta['solapas'] > 0 ? 1 : 0; $input_data['datosPedido']->lomo = $this->calcular_lomo([$cubierta], $input_data['datosPedido']->lomo); $input_data['isColor'] = 1; $input_data['isHq'] = 1; @@ -1358,23 +1616,56 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController ); } } - if ($coste_sobrecubierta <= 0) - $error->sobrecubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta'); - else - $error->sobrecubierta = ""; + if ($coste_sobrecubierta <= 0) { + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener la sobrecubierta', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } $lomo_sobrecubierta = $lomo + floatval($linea_sobrecubierta['mano']); - $tarifaAcabadoSobrecubierta = intval(strlen($sobreCubierta['acabado']) == 0 ? 0 : $sobreCubierta['acabado']); + $tarifaAcabadoSobrecubierta = $this->obtenerTarifasAcabado(['plastificado' => $sobreCubierta['acabados']]); $acabadoSobrecubierta = []; - if ($tarifaAcabadoSobrecubierta > 0) { + foreach ($tarifaAcabadoSobrecubierta as $tarifa) { + + // NONE + if ($tarifaAcabadoSobrecubierta[0] == 0) + continue; $model = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); - $acabadoSobrecubierta = $model->getPrecioTarifa($tarifaAcabadoSobrecubierta, $datosPedido->tirada, $POD); - } - if (count($acabadoSobrecubierta) > 0) { - if ($acabadoSobrecubierta[0]->total <= 0) - $error->servicios = lang('Presupuestos.errores.errorPresupuesto'); - $coste_servicios += floatval($acabadoSobrecubierta[0]->total); + $acabadoSobrecubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD); + + if (count($acabadoSobrecubierta) > 0) { + + if ($acabadoSobrecubierta[0]->total <= 0) { + + $input_data['tarifas_acabado_sobrecubierta'] = $tarifaAcabadoSobrecubierta; + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener acabados de sobrecubierta', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } + + $coste_servicios += floatval($acabadoSobrecubierta[0]->total); + } } } @@ -1382,15 +1673,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $guardas = []; $peso_guardas = 0.0; $coste_guardas = 0.0; - if($datos_guardas != 0){ - if (count($datos_guardas) != 0) { + if ($datos_guardas != 0) { + if (count($datos_guardas) != 0 && $datos_guardas) { $guardas = $datos_guardas; - $papel_generico_guardas = [ - 'id' => $datos_guardas['papel'] ?? 0, - 'nombre' => $datos_guardas['nombre'] ?? "", - ]; - $input_data['papel_generico'] = $papel_generico_guardas; + $input_data['papel_generico'] = $datos_guardas['papel'] ?? 0; $input_data['gramaje'] = $datos_guardas['gramaje'] ?? 0; $input_data['datosPedido']->paginas = 8; $input_data['paginas_color'] = 8; @@ -1427,10 +1714,21 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController ); } } - if ($coste_guardas <= 0) - $error->guardas = lang('Presupuestos.errores.noGuardas'); - else - $error->guardas = ""; + if ($coste_guardas <= 0) { + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener las guardas', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } } } if ($extra_info) { @@ -1454,8 +1752,24 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController ]); $costeServiciosDefecto = 0.0; foreach ($servDefecto as $servicio) { - if ($servicio->total <= 0) - $error->serviciosDefecto = lang('Presupuestos.errores.errorPresupuesto'); + if ($servicio->total <= 0) { + + $input_data['servicios'] = $servDefecto; + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener servicios', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } + $costeServiciosDefecto += floatval($servicio->total); if ($extra_info) { @@ -1470,29 +1784,29 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // Servicios // se comprueba si $datos guardas es un array - if(is_array($datos_guardas)){ - if(count($datos_guardas) > 0){ + if (is_array($datos_guardas)) { + if (count($datos_guardas) > 0) { array_push($servicios, 62); // Plegado de guardas } - } - else{ + } else { if ($datos_guardas > 0) { array_push($servicios, 62); // Plegado de guardas } } - + /* 'retractilado' => 3, - 'retractilado5' => 5, - 'ferro' => 24, 'prototipo' => 9, - 'fajaColor' => 16, - 'plegadoGuardas' => 62, */ $serviciosAutomaticos = []; - + $servicios = []; + if ($datos_entrada['cubierta']['acabadosCubierta']['retractilado'] === 'true') + array_push($servicios, 3); + if ($datos_entrada['servicios']['prototipo']) + array_push($servicios, 9); foreach ($servicios as $servicio) { - if (intval($servicio) == 3 || intval($servicio) == 5 || intval($servicio) == 16) { + + if (intval($servicio) == 3) { // Servicios acabado $resultado = PresupuestoCLienteService::getServiciosAcabados([ 'tarifa_id' => $servicio, @@ -1500,68 +1814,63 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'POD' => $POD, ]); array_push($serviciosAutomaticos, $resultado[0]); - if ($resultado[0]->total <= 0) - $error->servicios = lang('Presupuestos.errores.errorPresupuesto'); + + if ($resultado[0]->total <= 0) { + + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener servicio con id 3', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } $coste_servicios += floatval($resultado[0]->total); if ($extra_info) { $totalServicios += floatval($resultado[0]->total); $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; } - } else if (intval($servicio) == 24) { - // Servicios preimpresion (Ferro) - $resultado = PresupuestoCLienteService::getServiciosPreimpresion([ - 'tarifa_id' => $servicio, - ]); - array_push($serviciosAutomaticos, $resultado[0]); - if ($resultado[0]->precio <= 0) - $error->servicios = lang('Presupuestos.errores.errorPresupuesto'); - - $coste_servicios += floatval($resultado[0]->precio); - if ($extra_info) { - $totalServicios += floatval($resultado[0]->precio); - $margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0; - } - } - if(intval($servicio) == 9) { - // Servicios preimpresion + } else if (intval($servicio) == 9) { + // Prototipo $resultado = PresupuestoCLienteService::getServiciosExtra([ 'tarifa_id' => $servicio, ]); array_push($serviciosAutomaticos, $resultado[0]); - if ($resultado[0]->precio <= 0) - $error->servicios = lang('Presupuestos.errores.errorPresupuesto'); + if ($resultado[0]->precio <= 0) { + + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener servicio con id 9', + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } + $coste_servicios += floatval($resultado[0]->precio); if ($extra_info) { $totalServicios += floatval($resultado[0]->precio); $margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0; } - } else if (intval($servicio) == 62) { - // Servicios manipulado - $resultado = PresupuestoCLienteService::getServiciosManipulado([ - 'tarifa_id' => $servicio, - 'tirada' => $datosPedido->tirada, - 'POD' => $POD, - ]); - array_push($serviciosAutomaticos, $resultado[0]); - if ($resultado[0]->total <= 0) - $error->servicios = lang('Presupuestos.errores.errorPresupuesto'); - - $coste_servicios += floatval($resultado[0]->total); - if ($extra_info) { - $totalServicios += floatval($resultado[0]->total); - $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; - } } } array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios) / $tirada[$t], 4)); array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2)); - foreach ($error as $err) { - if ($err != "") - break; - } if ($extra_info) { $totalServicios -= $margenServicios; @@ -1588,10 +1897,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController )); } - $info['lomo_cubierta'] = $lomo; - $info['lomo_sobrecubierta'] = $lomo_sobrecubierta; + $info['lomo_cubierta'] = round(floatval($lomo), 2); + $info['lomo_sobrecubierta'] = round(floatval($lomo_sobrecubierta), 2); $return_data['info'] = $info; - + if ($extra_info) { // && $tirada[$t] == $selected_tirada) { @@ -1604,13 +1913,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } - $return_data += [ - 'errors' => $error, - 'total_lp' => $costeInterior + $coste_cubierta + $coste_sobrecubierta, - 'acabadoCubierta' => $acabadoCubierta, - 'acabadoSobrecubierta' => $acabadoSobrecubierta, - 'total_servicios_defecto' => $costeServiciosDefecto, - 'total_servicios_automaticos' => $coste_servicios, + $return_data += [ + 'errors' => (object) ([ + 'status' => 0, + ]), + //'total_lp' => $costeInterior + $coste_cubierta + $coste_sobrecubierta, + //'acabadoCubierta' => $acabadoCubierta, + //'acabadoSobrecubierta' => $acabadoSobrecubierta, + //'total_servicios_defecto' => $costeServiciosDefecto, + //'total_servicios_automaticos' => $coste_servicios, 'tiradas' => $tirada, 'precio_u' => $precio_u, 'peso' => $peso, @@ -1621,8 +1932,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } return $return_data; + } catch (Exception $e) { - return ['exception' => $e->getMessage()]; + return [ + 'exception' => $e->getMessage(), + "line" => $e->getLine(), + "file" => $e->getFile() + ]; } } @@ -1665,37 +1981,41 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController protected function getTipoImpresion($tipo, $tapa) { - $tipo_impresion_id = 0; + $tipo_impresion_id = -1; - if ($tipo == 'fresado') { + try { + if ($tipo == 'fresado') { - if ($tapa == 'blanda') - $tipo_impresion_id = 2; - else - $tipo_impresion_id = 1; - } else if ($tipo == 'cosido') { + if (strpos(strtolower($tapa), 'blanda') !== false) + $tipo_impresion_id = 2; + else + $tipo_impresion_id = 1; + } else if ($tipo == 'cosido') { - if ($tapa == 'blanda') - $tipo_impresion_id = 4; - else - $tipo_impresion_id = 3; - } else if ($tipo == 'espiral') { + if (strpos(strtolower($tapa), 'blanda') !== false) + $tipo_impresion_id = 4; + else + $tipo_impresion_id = 3; + } else if ($tipo == 'espiral') { - if ($tapa == 'blanda') - $tipo_impresion_id = 6; - else - $tipo_impresion_id = 5; - } else if ($tipo == 'wireo') { + if (strpos(strtolower($tapa), 'blanda') !== false) + $tipo_impresion_id = 6; + else + $tipo_impresion_id = 5; + } else if ($tipo == 'wireo') { - if ($tapa == 'blanda') - $tipo_impresion_id = 8; - else - $tipo_impresion_id = 7; - } else if ($tipo == 'grapado') { - $tipo_impresion_id = 21; + if (strpos(strtolower($tapa), 'blanda') !== false) + $tipo_impresion_id = 8; + else + $tipo_impresion_id = 7; + } else if ($tipo == 'grapado') { + $tipo_impresion_id = 21; + } + + return $tipo_impresion_id; + } catch (Exception $e) { + return -1; } - - return $tipo_impresion_id; } @@ -1735,7 +2055,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController { $model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel'); $data = $model->getServiciosAcabadoCubierta(); - array_unshift($data, (object)['id' => '', 'label' => lang('Basic.global.None')]); + array_unshift($data, (object) ['id' => '', 'label' => lang('Basic.global.None')]); return $data; } @@ -1743,18 +2063,18 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController { $model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel'); $data = $model->getServiciosAcabadoSobrecubierta(); - array_unshift($data, (object)['id' => '', 'label' => lang('Basic.global.None')]); + array_unshift($data, (object) ['id' => '', 'label' => lang('Basic.global.None')]); return $data; } protected function getClienteListItems($selId = null) { $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])]; - if (!empty($selId)) : + if (!empty($selId)): $clienteModel = model('App\Models\Clientes\ClienteModel'); $selOption = $clienteModel->where('id', $selId)->findColumn('nombre'); - if (!empty($selOption)) : + if (!empty($selOption)): $data[$selId] = $selOption[0]; endif; endif; @@ -1785,6 +2105,19 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } else return ''; } + + protected function obtenerTipoTapa($tipo_impresion_id) + { + $model = model('App\Models\Configuracion\TipoPresupuestoModel'); + $data = $model->get_isTapaDura($tipo_impresion_id); + if ($data) { + return 'dura'; + } else { + return 'blanda'; + } + } + + protected function getTipoInterior($presupuestoId) { @@ -1792,7 +2125,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $color = 'negro'; $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); - $data = $model->where('presupuesto_id', $presupuestoId)->findAll();; + $data = $model->where('presupuesto_id', $presupuestoId)->findAll(); + ; foreach ($data as $linea) { if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq" @@ -1805,11 +2139,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $tipo = "negro"; - if($calidad == 'premium' && $color=='negro') + if ($calidad == 'premium' && $color == 'negro') $tipo = "negroHq"; - else if ($calidad == 'estandar' && $color=='color') + else if ($calidad == 'estandar' && $color == 'color') $tipo = "color"; - else if ($calidad == 'premium' && $color=='color') + else if ($calidad == 'premium' && $color == 'color') $tipo = "colorHq"; return $tipo; @@ -1832,7 +2166,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController protected function obtenerPaginasColor($presupuestoEntity) { $comparador_data = json_decode($presupuestoEntity->comparador_json_data); - if(!is_null($comparador_data)){ + if (!is_null($comparador_data)) { if (property_exists($comparador_data, 'color')) { $presupuestoEntity->paginasColor = $comparador_data->color->paginas; } @@ -1841,8 +2175,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } else { $presupuestoEntity->paginasColor = 0; } - } - else + } else $presupuestoEntity->paginasColor = 0; } @@ -1867,111 +2200,122 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } - protected function obtenerDireccionesEnvio($presupuestoEntity) + protected function obtenerDireccionesEnvio($id, $cliente_id) { $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); $model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel'); $model_pais = model('App\Models\Configuracion\PaisModel'); - $direcciones = $model->where('presupuesto_id', $presupuestoEntity->id)->findAll(); + $direcciones = $model->where('presupuesto_id', $id)->findAll(); $result = []; $temp = []; - for ($i=0; $igetIdForPresupuestoCliente( - $presupuestoEntity->cliente_id, + $cliente_id, $direcciones[$i]->att, $direcciones[$i]->email, $direcciones[$i]->direccion, $direcciones[$i]->cp, $direcciones[$i]->pais_id, - $direcciones[$i]->telefono); - if(count($direccion_id) > 0) { + $direcciones[$i]->telefono + ); + if (count($direccion_id) > 0) { $temp = $direcciones[$i]->toArray(); - $temp['pais'] = $model_pais->where('id', $direcciones[$i]->pais_id)->first()->nombre; - $temp['direccion_id'] = $direccion_id[0]->id; - array_push($result, $temp); + array_push($result, [ + 'id' => $temp['id'], + 'unidades' => $temp['cantidad'], + 'palets' => $temp['entregaPieCalle'], + ]); } } - if(count($result) > 0) - $presupuestoEntity->direcciones_envio = $result; + if (count($result) > 0) + return $result; + else + return []; } - protected function obtenerDatosPapel($presupuestoEntity) + protected function obtenerDatosPapel($presupuesto_id) { - $id = $presupuestoEntity->id; + $return_data = []; $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); - $data = $model->where('presupuesto_id', $id)->findAll(); + $data = $model->where('presupuesto_id', $presupuesto_id)->findAll(); + + $modelPapelGenerico = model('App\Models\Configuracion\PapelGenericoModel'); + if (count($data) > 0) { foreach ($data as $linea) { - // Se coje el primer papel que se encuentre para el interior - // para presupuestos del cliente sólo se escoje un papel para el interior - if (strpos($linea->tipo, "bn") !== false || strpos($linea->tipo, "color") !== false) { - $presupuestoEntity->papel_interior = $linea->papel_id; - $presupuestoEntity->gramaje_interior = $linea->gramaje; - } - // Si es cubierta - else if (strpos($linea->tipo, "cubierta") !== false && strpos($linea->tipo, "sobrecubierta") === false) { - $presupuestoEntity->papel_cubierta = $linea->papel_id; - $presupuestoEntity->gramaje_cubierta = $linea->gramaje; - $presupuestoEntity->paginas_cubierta = $linea->paginas; - } - // Si es sobrecubierta - else if (strpos($linea->tipo, "sobrecubierta") !== false) { - $presupuestoEntity->papel_sobrecubierta = $linea->papel_id; - $presupuestoEntity->gramaje_sobrecubierta = $linea->gramaje; - $presupuestoEntity->paginas_sobrecubierta = $linea->paginas; - } - // Si es guardas - else if (strpos($linea->tipo, "guardas") !== false) { - $presupuestoEntity->papel_guardas = $linea->papel_id; - $presupuestoEntity->paginas_guardas = $linea->paginas; + if ($linea->tipo == 'lp_bn' || $linea->tipo == 'lp_bnhq' || $linea->tipo == 'lp_rot_bn') { + $return_data['interior']['negro']['tipo'] = $linea->tipo == 'lp_bn' || $linea->tipo == 'lp_rot_bn' ? 'negroEstandar' : 'negroPremium'; + $return_data['interior']['negro']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id); + $return_data['interior']['negro']['gramaje'] = $linea->gramaje; + } else if ($linea->tipo == 'lp_color' || $linea->tipo == 'lp_colorhq' || $linea->tipo == 'lp_rot_color') { + $return_data['interior']['color']['tipo'] = $linea->tipo == 'lp_color' || $linea->tipo == 'lp_rot_color' ? 'colorEstandar' : 'colorPremium'; + $return_data['interior']['color']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id); + $return_data['interior']['color']['gramaje'] = $linea->gramaje; + } else if ($linea->tipo == 'lp_cubierta') { + $return_data['cubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id); + $return_data['cubierta']['gramaje'] = $linea->gramaje; + $return_data['cubierta']['paginas'] = $linea->paginas; + } else if ($linea->tipo == 'lp_sobrecubierta') { + $return_data['sobrecubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id); + $return_data['sobrecubierta']['gramaje'] = $linea->gramaje; + $return_data['sobrecubierta']['paginas'] = $linea->paginas; + } else if ($linea->tipo == 'lp_guardas') { + $return_data['guardas']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id); + $return_data['guardas']['gramaje'] = $linea->gramaje; + $return_data['guardas']['paginas'] = $linea->paginas; } } } + + return $return_data; } - protected function generarResumen($presupuestoEntity){ - - $presupuestoEntity->resumen = (object)[ + protected function generarResumen($presupuestoEntity) + { + + $presupuestoEntity->resumen = (object) [ 'titulo' => $this->generarTitulo($presupuestoEntity), 'tamanio' => $this->obtenerTamanio($presupuestoEntity), 'tipo_impresion' => $this->obtenerTipoImpresion($presupuestoEntity) ]; $model_papelGenerico = model('App\Models\Configuracion\PapelGenericoModel'); - if(!is_null($presupuestoEntity->papel_interior)){ + if (!is_null($presupuestoEntity->papel_interior)) { $nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_interior)->first()->nombre; - if($nombre != null) + if ($nombre != null) $presupuestoEntity->papel_interior_nombre = $nombre; } - if(!is_null($presupuestoEntity->papel_cubierta)){ + if (!is_null($presupuestoEntity->papel_cubierta)) { $nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_interior)->first()->nombre; - if($nombre != null) + if ($nombre != null) $presupuestoEntity->papel_cubierta_nombre = $nombre; } - if(!is_null($presupuestoEntity->papel_sobrecubierta)){ + if (!is_null($presupuestoEntity->papel_sobrecubierta)) { $nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_sobrecubierta)->first()->nombre; - if($nombre != null) + if ($nombre != null) $presupuestoEntity->papel_sobrecubierta_nombre = $nombre; } - if(!is_null($presupuestoEntity->papel_guardas)){ + if (!is_null($presupuestoEntity->papel_guardas)) { $nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_guardas)->first()->nombre; - if($nombre != null) + if ($nombre != null) $presupuestoEntity->papel_guardas_nombre = $nombre; } } - protected function generarTitulo($presupuestoEntity){ + protected function generarTitulo($presupuestoEntity) + { $model = model('App\Models\Configuracion\TipoPresupuestoModel'); $codigo = $model->where('id', $presupuestoEntity->tipo_impresion_id)->first()->codigo; - $titulo = lang('Presupuestos.titulos.'.$codigo); + $titulo = lang('Presupuestos.titulos.' . $codigo); return $titulo; } - protected function obtenerTamanio($presupuestoEntity){ + protected function obtenerTamanio($presupuestoEntity) + { $ancho = 0; $alto = 0; @@ -1979,15 +2323,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $model = model('App\Models\Presupuestos\PresupuestoModel'); $data = $model->where('id', $presupuestoEntity->id)->first(); - if($data != null){ - if($data->papel_formato_personalizado == 0){ + if ($data != null) { + if ($data->papel_formato_personalizado == 0) { $model_papel_formato = model('App\Models\Configuracion\PapelFormatoModel'); $data_papel_formato = $model_papel_formato->where('id', $data->papel_formato_id)->first(); $ancho = $data_papel_formato->ancho; $alto = $data_papel_formato->alto; - } - else{ + } else { $ancho = $data->papel_formato_ancho; $alto = $data->papel_formato_alto; } @@ -1996,7 +2339,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController return $ancho . "x" . $alto; } - protected function obtenerTipoImpresion($presupuestoEntity){ + protected function obtenerTipoImpresion($presupuestoEntity) + { $id = $presupuestoEntity->id; @@ -2019,16 +2363,68 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController return $tipo; } - protected function obtenerPaginasCuadernillo($presupuestoEntity){ + protected function obtenerPaginasCuadernillo($presupuestoEntity) + { $model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel'); $lineas = $model->getResource($presupuestoEntity->id)->get()->getResultObject(); - - foreach ($lineas as $linea){ + + foreach ($lineas as $linea) { // check if exist - if($linea->paginas_por_cuadernillo != null) + if ($linea->paginas_por_cuadernillo != null) return $linea->paginas_por_cuadernillo; } return 32; // valor por defecto } + + protected function obtenerTarifasAcabado($acabados) + { + $tarifas = []; + + $model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel'); + + + foreach ($acabados as $acabado => $value) { + + if ($value != 'NONE') { + $data = $model->where('code', $value)->first(); + $data = $data->id; + array_push($tarifas, $data); + } else { + array_push($tarifas, 0); + } + } + + return $tarifas; + } + + + private function getPaginas($lineas) + { + + $paginasNegro = 0; + $paginasColor = 0; + + foreach ($lineas as $linea) { + if (strpos($linea->tipo, "lp_bn") !== false || strpos($linea->tipo, "lp_bnhq") !== false) { + $paginasNegro = $linea->paginas; + } + + if (strpos($linea->tipo, "lp_color") !== false || strpos($linea->tipo, "lp_colorhq") !== false) { + $paginasColor = $linea->paginas; + } + + if (strpos($linea->tipo, "lp_rot_bn") !== false) { + $paginasNegro = $linea->paginas; + } + + if (strpos($linea->tipo, "lp_rot_color") !== false) { + $paginasColor = $linea->rotativa_pag_color; + $paginasNegro = $linea->paginas - $linea->rotativa_pag_color; + } + } + + return [$paginasNegro, $paginasColor]; + } + } diff --git a/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php b/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php index eb9e47eb..85920898 100644 --- a/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php +++ b/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php @@ -39,10 +39,10 @@ class TarifaAcabados extends BaseResourceController $this->viewData = ['usingServerSideDataTable' => true]; - // Breadcrumbs + // Breadcrumbs $this->viewData['breadcrumb'] = [ ['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false], - ['title' => lang("App.menu_tarifaacabado"), 'route' => site_url('tarifas/tarifaacabado'), 'active' => true] + ['title' => lang("App.menu_tarifaacabado"), 'route' => site_url('tarifas/acabados'), 'active' => true] ]; parent::initController($request, $response, $logger); @@ -133,6 +133,8 @@ class TarifaAcabados extends BaseResourceController endif; // ($requestMethod === 'post') + $this->viewData['proveedores'] = $this->getProveedores(); + $this->viewData['tarifaacabadoEntity'] = isset($sanitizedData) ? new TarifaAcabadoEntity($sanitizedData) : new TarifaAcabadoEntity(); $this->viewData['formAction'] = route_to('tarifaAcabadoAdd'); $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaacabado.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index d8ade0a6..3969835e 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -64,7 +64,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "created_at" => null, "updated_at" => null, "comp_tipo_impresion" => null, - "comp_pos_paginas_color" => null, + "pos_paginas_color" => null, "total_coste_papel" => null, "total_margen_papel" => null, "total_margenPercent_papel" => null, @@ -90,6 +90,11 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "acabado_cubierta_id" => null, "acabado_sobrecubierta_id" => null, "is_duplicado" => false, + 'paginas_color_consecutivas' => null, + 'papel_interior_diferente' => null, + 'paginasCuadernillo' => null, + 'lomo_redondo' => null, + 'cabezada' => null, ]; protected $casts = [ "cliente_id" => "int", @@ -155,5 +160,9 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "acabado_cubierta_id" => "int", "acabado_sobrecubierta_id" => "int", "is_duplicado" => "boolean", + 'paginas_color_consecutivas' => "boolean", + 'papel_interior_diferente' => "boolean", + 'paginasCuadernillo' => "int", + 'lomo_redondo' => "boolean", ]; } diff --git a/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php b/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php index 0d5852a1..37554c8d 100644 --- a/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php +++ b/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php @@ -8,6 +8,8 @@ class TarifaAcabadoEntity extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "nombre" => null, + "code" => null, + "comment" => null, "precio_min" => 0, "importe_fijo" => 0, "mostrar_en_presupuesto" => 1, @@ -22,6 +24,8 @@ class TarifaAcabadoEntity extends \CodeIgniter\Entity\Entity ]; protected $casts = [ "precio_min" => "float", + "comment" => "string", + "code" => "string", "importe_fijo" => "float", "user_created_id" => "int", "user_updated_id" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php index 87d18ebe..03d68989 100755 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php @@ -9,6 +9,7 @@ class TarifaEncuadernacionEntity extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "nombre" => null, + "code" => null, "mostrar_en_presupuesto" => 1, "tipo_encuadernacion" => 0, "servicio_encuadernacion" => 0, @@ -22,6 +23,7 @@ class TarifaEncuadernacionEntity extends \CodeIgniter\Entity\Entity ]; protected $casts = [ "mostrar_en_presupuesto" => "int", + "code" => "string", "tipo_encuadernacion" => "int", "servicio_encuadernacion" => "int", "por_horas" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaEnvioEntity.php b/ci4/app/Entities/Tarifas/TarifaEnvioEntity.php index 0becbc9d..acc68f37 100755 --- a/ci4/app/Entities/Tarifas/TarifaEnvioEntity.php +++ b/ci4/app/Entities/Tarifas/TarifaEnvioEntity.php @@ -9,6 +9,8 @@ class TarifaEnvioEntity extends \CodeIgniter\Entity\Entity "id" => null, "pais_id" => null, "nombre" => null, + "code" => null, + "comment" => null, "user_created_id" => 0, "user_updated_id" => 0, "is_deleted" => 0, @@ -17,6 +19,8 @@ class TarifaEnvioEntity extends \CodeIgniter\Entity\Entity ]; protected $casts = [ "pais_id" => "?int", + "code" => "string", + "comment" => "string", "user_created_id" => "int", "user_updated_id" => "int", "is_deleted" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaManipuladoEntity.php b/ci4/app/Entities/Tarifas/TarifaManipuladoEntity.php index aac261a4..d9f3c2f7 100755 --- a/ci4/app/Entities/Tarifas/TarifaManipuladoEntity.php +++ b/ci4/app/Entities/Tarifas/TarifaManipuladoEntity.php @@ -9,6 +9,8 @@ class TarifaManipuladoEntity extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "nombre" => null, + "code" => null, + "comment" => null, "precio_min" => 0, "importe_fijo" => 0, "mostrar_en_presupuesto" => 1, @@ -22,6 +24,8 @@ class TarifaManipuladoEntity extends \CodeIgniter\Entity\Entity protected $casts = [ "precio_min" => "float", "importe_fijo" => "float", + "code" => "string", + "comment" => "string", "mostrar_en_presupuesto" => "int", "user_created_id" => "int", "user_updated_id" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaextraEntity.php b/ci4/app/Entities/Tarifas/TarifaextraEntity.php index ac6b35eb..db2b0594 100755 --- a/ci4/app/Entities/Tarifas/TarifaextraEntity.php +++ b/ci4/app/Entities/Tarifas/TarifaextraEntity.php @@ -8,6 +8,8 @@ class TarifaextraEntity extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "nombre" => null, + "code" => null, + "comment" => null, "precio" => null, "margen" => 0, "mostrar_en_presupuesto" => 1, @@ -20,6 +22,8 @@ class TarifaextraEntity extends \CodeIgniter\Entity\Entity ]; protected $casts = [ "precio" => "float", + "code" => "string", + "comment" => "string", "margen" => "float", "mostrar_en_presupuesto" => "int", "user_created_id" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php b/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php index a6ea7177..b1873597 100755 --- a/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php +++ b/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php @@ -8,6 +8,8 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "nombre" => null, + "code" => null, + "comment" => null, "precio" => null, "margen" => 0, "mostrar_en_presupuesto" => 1, @@ -21,6 +23,8 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity protected $casts = [ "precio" => "float", "margen" => "float", + "code" => "string", + "comment" => "string", "mostrar_en_presupuesto" => "int", "user_created_id" => "int", "user_update_id" => "int", diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index 4d514cfa..cce0c828 100755 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -31,12 +31,12 @@ return [ 'presupuestoEstadoAceptado' => 'Acepted', 'incidencia' => 'Incident', 'reimpresion' => 'Reprint', - 'reimpresion' => 'Free of charge', 'autor' => 'Author', 'coleccion' => 'Collection', 'numeroEdicion' => 'Edition number', 'isbn' => 'ISBN', 'referenciaCliente' => 'Customer reference', + 'formatoLibro' => "Book format", 'papelFormatoId' => "Size", 'papelFormatoPersonalizado' => 'Custom size', 'papelFormatoAncho' => 'Width', diff --git a/ci4/app/Language/en/Tarifaacabado.php b/ci4/app/Language/en/Tarifaacabado.php index e9413fab..e527a403 100755 --- a/ci4/app/Language/en/Tarifaacabado.php +++ b/ci4/app/Language/en/Tarifaacabado.php @@ -10,6 +10,9 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Finishing Rates', 'nombre' => 'Name', + 'code' => 'Código', + 'comment' => 'Comentario', + 'comment_placeholder' => 'Inserte un comentario', 'precioMax' => 'Price Max', 'precioMin' => 'Price Min', 'precioMin' => 'Min Price', diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index 50c00a2c..80a35a45 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -26,8 +26,12 @@ return [ "global_inactive" => "Inactivo", "global_copy" => "Dupdo", "global_print" => "Impresión", + "global_print2" => "Imprimir", + "global_confirm" => "Confirmar", "global_excel" => "Excel", "global_pdf" => "PDF", + "global_prev" => "Anterior", + "global_next" => "Siguiente", // LOGIN - Index "login_title" => "Iniciar sesión en su cuenta", @@ -680,6 +684,7 @@ return [ "menu_configuration" => "Configuración", "menu_variables" => "Variables sistema", + "menu_error_presupuesto" => "Errores presupuesto", "menu_calendario" => "Calendario", "menu_paises" => "Paises", "menu_correo" => "Correo", diff --git a/ci4/app/Language/es/Chat.php b/ci4/app/Language/es/Chat.php index 1e649965..3bc975c8 100644 --- a/ci4/app/Language/es/Chat.php +++ b/ci4/app/Language/es/Chat.php @@ -2,6 +2,7 @@ return [ "chat" => "Mensajería", + "messages" => "Mensajes", "modal" => [ "new_hebra" => "Nueva hebra", "title" => "Título", diff --git a/ci4/app/Language/es/ErrorPresupuesto.php b/ci4/app/Language/es/ErrorPresupuesto.php new file mode 100644 index 00000000..d2b8d972 --- /dev/null +++ b/ci4/app/Language/es/ErrorPresupuesto.php @@ -0,0 +1,21 @@ + "Errores presupuesto", + + "datatable" => + [ + "columns" => [ + "usuario" => "Usuario presupuesto", + "last_user_id" => "Último accesso", + "visto" => "Visto", + "created_at" => "Creado" + ] + ], + "form" => + [ + "name" => "Nombre", + "value" => "Valor", + "description" => "Descripción", + ] +]; \ No newline at end of file diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 4904fd8d..d9217b5f 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -44,7 +44,10 @@ return [ 'titulo' => 'Título', 'paisId' => 'País', 'incRei' => 'Incidencia \ Reimpresión', - 'paginas' => 'Paginas', + 'paginas' => 'Páginas', + 'paginasNegro' => 'Páginas Negro', + 'paginasColor' => 'Páginas Color', + 'totalPaginas' => 'Total páginas', 'tirada' => 'Tirada', 'totalPedido' => 'Total Pedido', 'totalPresupuesto' => 'Total Presupuesto', @@ -79,6 +82,8 @@ return [ 'tipoImpresion' => 'Tipo de impresión', 'papelesComparadorCosidoTapaBlanda' => 'Papeles interior y cubierta', 'posicionPagColor' => 'Posición páginas a color', + 'papelDiferente' => 'Papel color y negro diferente', + 'paginasColorConsecutivas' => 'Páginas color consecutivas', 'colorPageInstructions' => 'Introduzca la posición de las páginas a color dentro del libro. Ej: 3,5,7 ó 4-10,20,155', 'numeroPaginas' => 'Nº Páginas', 'papel' => 'Papel', @@ -87,7 +92,43 @@ return [ 'retractilado' => 'Retractilado individual', 'retractilado5' => 'Retractilado de 5', 'Guardas' => 'Guardas', + 'papelGuardas' => 'Papel de guardas', + 'offsetBlancoGuardas' => 'Offset blanco 170 gr', + 'offsetAhuesadoGuardas' => 'Offset ahuesado 170 gr', + 'guardasImpresas' => "Guardas impresas", 'imprimir_guardas' => 'Imprimir guardas', + 'cabezada' => 'Cabezada', + 'blanca' => 'Blanca', + 'verde' => 'Verde', + 'azul' => 'Azul', + 'rojaAmarilla' => 'Roja-Amarilla', + 'plastificado' => 'Plastificado', + 'brillo' => 'Brillo', + 'mate' => 'Mate', + 'antirrayado' => 'Anti-rayado', + 'rugoso' => 'Sandy (rugoso)', + 'sinPlastificar' => 'Sin plastificar', + 'barniz' => 'Barniz UVI', + 'relieve2D' => 'Relieve 2D', + 'relieve3D' => 'Relieve 3D', + 'barnizDescription' => 'Barnizado selectivo en zonas de la cubierta', + 'estampado' => 'Estampado', + 'oro' => 'Oro', + 'plata' => 'Plata', + 'cobre' => 'Cobre', + 'bronce' => 'Bronce', + 'retractiladoTitle' => 'Retractilado', + 'papelSobrecubierta' => 'Papel sobrecubierta', + 'tamanioSolapasSobrecubierta' => 'Tamaño solapas sobrecubierta', + 'plastificadoSobrecubierta' => 'Plastificado sobrecubierta', + 'faja' => 'Faja', + 'altoFaja' => 'Alto faja', + 'papelFaja' => 'Papel faja', + 'tamanioSolapasFaja' => 'Tamaño solapas faja', + 'plastificadoFaja' => 'Plastificado faja', + 'estucadoMate170gr' => 'Estucado mate 170 gr', + 'estucadoMate200gr' => 'Estucado mate 200 gr', + 'fajaColor' => 'Imprimir faja a color', 'compInteriorPlana' => 'Interior en plana', 'compInteriorRotativa' => 'Interior en rotativa', @@ -212,6 +253,11 @@ return [ 'totalAceptado' => 'Total aceptado', + // Placeholders + 'formatoLibro' => "Formato libro", + 'selectCliente' => "Seleccione cliente", + + // Preview 'preview' => 'Previsualización de configuraciones', 'preview-conf-bn' => 'Configuración Blanco y Negro', @@ -302,10 +348,19 @@ return [ 'no_lp_for_merma' => 'Inserte líneas de presupuesto para calcular la merma', 'ejemplares_envio' => 'El número de ejemplares enviados no coincide con la tirada', 'cliente' => 'Debe seleccionar un cliente', + 'papelFormato' => 'Seleccione un formato', + 'tipo_libro' => 'Seleccione un tipo de libro', + 'disenio_interior' => 'Seleccione el diseño del interior', + 'papel_interior' => 'Seleccione el tipo de papel', + 'gramaje_interior' => 'Seleccione el gramaje', 'pais' => 'Debe seleccionar un país', 'integer_greatherThan_0' => 'Número entero > 0 requerido', 'tirada_no_valida' => "Tirada no valida", 'sin_gramaje' => "Seleccione gramaje", + 'tipo_cubierta' => 'Seleccione tipo de cubierta', + 'opcion_solapas' => 'Seleccione la opción para las solapas', + 'paginas_cosido' => 'El número de páginas para cosido debe ser múltiplo de 4', + 'paginas_pares' => 'El número de páginas debe ser par', ], 'errores' => [ diff --git a/ci4/app/Language/es/Tarifaencuadernacion.php b/ci4/app/Language/es/Tarifaencuadernacion.php index 34c01087..fbc59ef5 100755 --- a/ci4/app/Language/es/Tarifaencuadernacion.php +++ b/ci4/app/Language/es/Tarifaencuadernacion.php @@ -10,6 +10,9 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Tarifas Encuadernación', 'nombre' => 'Nombre', + 'code' => 'Código', + 'comment' => 'Comentario', + 'comment_placeholder' => 'Inserte un comentario', 'precioMax' => 'Precio T. Mín', 'precioMin' => 'Precio T. Máx', 'importeFijo' => 'Importe Fijo', diff --git a/ci4/app/Language/es/Tarifaextra.php b/ci4/app/Language/es/Tarifaextra.php index 3d640b2b..ea711c63 100755 --- a/ci4/app/Language/es/Tarifaextra.php +++ b/ci4/app/Language/es/Tarifaextra.php @@ -7,6 +7,9 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Tarifas Servicios Extra', 'nombre' => 'Nombre', + 'code' => 'Código', + 'comment' => 'Comentario', + 'comment_placeholder' => 'Inserte un comentario', 'precio' => 'Precio', 'precioMin' => 'Precio Mínimo', 'importeFijo' => 'Importe Fijo', diff --git a/ci4/app/Language/es/Tarifamanipulado.php b/ci4/app/Language/es/Tarifamanipulado.php index 20079ddb..80afab6a 100755 --- a/ci4/app/Language/es/Tarifamanipulado.php +++ b/ci4/app/Language/es/Tarifamanipulado.php @@ -10,6 +10,9 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Tarifas Manipulado', 'nombre' => 'Nombre', + 'code' => 'Código', + 'comment' => 'Comentario', + 'comment_placeholder' => 'Inserte un comentario', 'importeMinimo' => 'Importe mínimo', 'precioMax' => 'Precio T. Mín', 'precioMin' => 'Precio T. Máx', diff --git a/ci4/app/Language/es/Tarifapreimpresion.php b/ci4/app/Language/es/Tarifapreimpresion.php index 80a0562a..f98cd490 100755 --- a/ci4/app/Language/es/Tarifapreimpresion.php +++ b/ci4/app/Language/es/Tarifapreimpresion.php @@ -7,6 +7,9 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Tarifas Preimpresión', 'nombre' => 'Nombre', + 'code' => 'Código', + 'comment' => 'Comentario', + 'comment_placeholder' => 'Inserte un comentario', 'precio' => 'Precio', 'precioMin' => 'Precio Mínimo', 'importeFijo' => 'Importe Fijo', @@ -25,7 +28,16 @@ return [ 'required' => 'El campo {field} es obligatorio.', ], + 'code' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + ], + 'comment' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], 'precio' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'El campo {field} es obligatorio.', diff --git a/ci4/app/Language/es/TarifasEnvios.php b/ci4/app/Language/es/TarifasEnvios.php index 5591a894..db669784 100755 --- a/ci4/app/Language/es/TarifasEnvios.php +++ b/ci4/app/Language/es/TarifasEnvios.php @@ -9,6 +9,9 @@ return [ 'isDeleted' => 'Is Deleted', 'moduleTitle' => 'Tarifas Envíos', 'nombre' => 'Nombre', + 'code' => 'Código', + 'comment' => 'Comentario', + 'comment_placeholder' => 'Inserte un comentario', 'paisId' => 'Pais', 'tarifaEnvio' => 'Tarifa Envío', 'tarifaEnvioList' => 'Lista Tarifas Envío', diff --git a/ci4/app/Models/Chat/ChatModel.php b/ci4/app/Models/Chat/ChatModel.php index 161b8115..7405f3b9 100644 --- a/ci4/app/Models/Chat/ChatModel.php +++ b/ci4/app/Models/Chat/ChatModel.php @@ -210,6 +210,7 @@ class ChatModel extends Model ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") ->join("pedidos","pedidos.id = chats.pedido_id","left") ->whereIn("pedidos.id",$pedidos) + ->where("chats.chat_department_id is NOT NULL",NULL,FALSE) ->get()->getResultObject(); $chatMessageModel = model(ChatMessageModel::class); $count = 0; @@ -237,6 +238,7 @@ class ChatModel extends Model ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") ->join("facturas","facturas.id = chats.factura_id","left") ->whereIn("facturas.id",$facturas) + ->where("chats.chat_department_id is NOT NULL",NULL,FALSE) ->get()->getResultObject(); $chatMessageModel = model(ChatMessageModel::class); $count = 0; @@ -264,6 +266,7 @@ class ChatModel extends Model ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") ->join("presupuestos","presupuestos.id = chats.presupuesto_id","left") ->whereIn("presupuestos.id",$presupuestos) + ->where("chats.chat_department_id is NOT NULL",NULL,FALSE) ->get()->getResultObject(); $chatMessageModel = model(ChatMessageModel::class); $count = 0; diff --git a/ci4/app/Models/Clientes/ClienteDireccionesModel.php b/ci4/app/Models/Clientes/ClienteDireccionesModel.php index 5ea8db63..e60eab05 100755 --- a/ci4/app/Models/Clientes/ClienteDireccionesModel.php +++ b/ci4/app/Models/Clientes/ClienteDireccionesModel.php @@ -54,7 +54,7 @@ class ClienteDireccionesModel extends \App\Models\BaseModel ], "email" => [ "label" => "ClienteDirecciones.email", - "rules" => "trim|max_length[100]|valid_email", + "rules" => "trim|max_length[100]", ], "cp" => [ "label" => "ClienteDirecciones.cp", diff --git a/ci4/app/Models/Clientes/ClienteModel.php b/ci4/app/Models/Clientes/ClienteModel.php index 8563eef1..a1193860 100755 --- a/ci4/app/Models/Clientes/ClienteModel.php +++ b/ci4/app/Models/Clientes/ClienteModel.php @@ -1,4 +1,5 @@ groupStart() - ->like("t1.nombre", $search) - ->orLike("t1.alias", $search) - ->orLike("t1.cif", $search) - ->orLike("t1.email", $search) - ->orLike("t1.soporte_id", $search) - ->orLike("t1.forma_pago_id", $search) - ->orLike("t1.vencimiento", $search) - ->orLike("t5.id", $search) - ->orLike("t5.first_name", $search) - ->orLike("t5.last_name", $search) - ->orLike("t7.id", $search) - ->orLike("t7.nombre", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.nombre", $search) + ->orLike("t1.alias", $search) + ->orLike("t1.cif", $search) + ->orLike("t1.email", $search) + ->orLike("t1.soporte_id", $search) + ->orLike("t1.forma_pago_id", $search) + ->orLike("t1.vencimiento", $search) + ->orLike("t5.id", $search) + ->orLike("t5.first_name", $search) + ->orLike("t5.last_name", $search) + ->orLike("t7.id", $search) + ->orLike("t7.nombre", $search) + ->groupEnd(); } /* TO-DO: Implementar la lógica de negocio para el crédito disponible */ - public function creditoDisponible($cliente_id){ + public function creditoDisponible($cliente_id) + { return true; } - public function getClienteDataFacturas($cliente_id){ + public function getClienteDataFacturas($cliente_id) + { $builder = $this->db ->table($this->table . " t1") ->select( @@ -329,27 +332,27 @@ class ClienteModel extends \App\Models\BaseModel ->where("t1.id", $cliente_id); $builder->join("lg_paises t2", "t1.pais_id = t2.id", "left"); $builder->join("lg_provincias t3", "t1.provincia_id = t3.id", "left"); - + return $builder->get()->getResultArray(); } - public function getClienteDataPresupuestoPedidoFactura(int $cliente_id) : array + public function getClienteDataPresupuestoPedidoFactura(int $cliente_id): array { $query = $this->db - ->table($this->table." t1") - ->select([ - "t1.id as clienteId", - "presupuestos.id as presupuestoId", - "pedidos.id as pedidoId", - "presupuesto_estados.estado as presupuestoEstado", - "facturas_pedidos_lineas.factura_id as facturaId", + ->table($this->table . " t1") + ->select([ + "t1.id as clienteId", + "presupuestos.id as presupuestoId", + "pedidos.id as pedidoId", + "presupuesto_estados.estado as presupuestoEstado", + "facturas_pedidos_lineas.factura_id as facturaId", ]) - ->join("presupuestos","t1.id = presupuestos.cliente_id","left") - ->join("presupuesto_estados","presupuestos.estado_id = presupuesto_estados.id","left") - ->join("pedidos_linea","presupuestos.id = pedidos_linea.presupuesto_id","left") - ->join("pedidos","pedidos.id = pedidos_linea.pedido_id","left") - ->join("facturas_pedidos_lineas","facturas_pedidos_lineas.pedido_linea_id = pedidos_linea.id","left") - ->where("t1.id",$cliente_id); + ->join("presupuestos", "t1.id = presupuestos.cliente_id", "left") + ->join("presupuesto_estados", "presupuestos.estado_id = presupuesto_estados.id", "left") + ->join("pedidos_linea", "presupuestos.id = pedidos_linea.presupuesto_id", "left") + ->join("pedidos", "pedidos.id = pedidos_linea.pedido_id", "left") + ->join("facturas_pedidos_lineas", "facturas_pedidos_lineas.pedido_linea_id = pedidos_linea.id", "left") + ->where("t1.id", $cliente_id); $data = $query->get()->getResultObject(); $facturas = []; $presupuestos = []; @@ -367,4 +370,23 @@ class ClienteModel extends \App\Models\BaseModel return $result; } + + public function getNombre($id = -1) + { + + try { + + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.nombre AS nombre" + ) + ->where("id", $id) + ->where("is_deleted", 0); + + return $builder->get()->getResultObject()[0]->nombre; + } catch (\Exception $e) { + return null; + } + } } diff --git a/ci4/app/Models/Configuracion/PapelFormatoModel.php b/ci4/app/Models/Configuracion/PapelFormatoModel.php index 6d682a71..03391b5b 100755 --- a/ci4/app/Models/Configuracion/PapelFormatoModel.php +++ b/ci4/app/Models/Configuracion/PapelFormatoModel.php @@ -1,4 +1,5 @@ groupStart() - ->like("t1.id", $search) - ->orLike("t1.ancho", $search) - ->orLike("t1.alto", $search) - ->orLike("t1.created_at", $search) - ->orLike("t1.updated_at", $search) - ->orLike("t1.id", $search) - ->orLike("t1.ancho", $search) - ->orLike("t1.alto", $search) - ->orLike("t1.created_at", $search) - ->orLike("t1.updated_at", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.ancho", $search) + ->orLike("t1.alto", $search) + ->orLike("t1.created_at", $search) + ->orLike("t1.updated_at", $search) + ->orLike("t1.id", $search) + ->orLike("t1.ancho", $search) + ->orLike("t1.alto", $search) + ->orLike("t1.created_at", $search) + ->orLike("t1.updated_at", $search) + ->groupEnd(); } - public function getElementsForMenu(){ + public function getElementsForMenu() + { return $this->db ->table($this->table . " t1") ->select( "t1.id AS id, CONCAT(t1.ancho, ' x ', t1.alto) AS tamanio" )->where('is_deleted', 0)->orderBy('orden_select', 'asc')->get()->getResultObject(); } + + public function getElementsForMenu2($search = "") + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, CONCAT(t1.ancho, ' x ', t1.alto) AS name" + ) + ->where('is_deleted', 0) + ->where('id>', 0) + ->orderBy('orden_select', 'asc'); + + + return empty($search) + ? $builder->get()->getResultObject() + : $builder + ->groupStart() + ->like('t1.ancho', $search) + ->orLike('t1.alto', $search) + ->groupEnd()->get()->getResultObject(); + } + + + public function getNombre($id = -1) + { + try { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "CONCAT(t1.ancho, ' x ', t1.alto) AS name" + ) + ->where('t1.id', $id); + + return $builder->get()->getResultObject()[0]->name; + } catch (\Exception $e) { + return null; + } + } } diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index 6b55a382..49f4a7a1 100755 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -61,6 +61,37 @@ class PapelGenericoModel extends \App\Models\BaseModel ], ]; + + public function getIdFromCode(string $code=""){ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.nombre AS nombre" + ) + ->where("t1.code", $code) + ->where("t1.is_deleted", 0); + $data = $builder->get()->getFirstRow(); + // se convierte a de stdClass a array + $data = json_decode(json_encode($data), true); + return $data; + } + + + public function getCodeFromId($id=0){ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.code AS code" + ) + ->where("t1.id", $id) + ->where("t1.is_deleted", 0); + $data = $builder->get()->getFirstRow(); + // se convierte a de stdClass a array + $data = json_decode(json_encode($data), true); + return $data; + } + + /** * Get resource data. * diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php index c5da113b..eac4807c 100755 --- a/ci4/app/Models/Configuracion/PapelImpresionModel.php +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -322,4 +322,22 @@ class PapelImpresionModel extends \App\Models\BaseModel return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } + + public function getPapelGenericoCode($papel_id = 0){ + $builder = $this->db + ->table($this->table . " t1") + ->select("t2.code AS code") + ->join("lg_papel_generico t2", "t1.papel_generico_id = t2.id", "left") + ->where("t1.id", $papel_id) + ->where("t1.is_deleted", 0) + ->where("t1.isActivo", 1) + ->where("t2.is_deleted", 0); + + $result = $builder->get()->getResultObject(); + if(count($result) > 0){ + return $result[0]->code; + } + else + return ""; + } } diff --git a/ci4/app/Models/Presupuestos/BuscadorModel.php b/ci4/app/Models/Presupuestos/BuscadorModel.php index 99caa4f5..e1df2343 100644 --- a/ci4/app/Models/Presupuestos/BuscadorModel.php +++ b/ci4/app/Models/Presupuestos/BuscadorModel.php @@ -80,7 +80,7 @@ class BuscadorModel extends \App\Models\BaseModel "comparador_json_data", "is_deleted", "comp_tipo_impresion", - "comp_pos_paginas_color", + "pos_paginas_color", "total_coste_papel", "total_margen_papel", "total_margenPercent_papel", diff --git a/ci4/app/Models/Presupuestos/ErrorPresupuesto.php b/ci4/app/Models/Presupuestos/ErrorPresupuesto.php new file mode 100644 index 00000000..add5a233 --- /dev/null +++ b/ci4/app/Models/Presupuestos/ErrorPresupuesto.php @@ -0,0 +1,115 @@ +insert([ + "presupuesto_id" => $presupuesto_id, + "presupuesto_user_id" => $presupuesto_user_id, + "error" => $error, + "datos_presupuesto" => json_encode($datos) + ]); + } + public function updateComment(int $error_presupuesto_id, string $comment): bool + { + $updated = $this->update($error_presupuesto_id, [ + "comment" => $comment + ]); + return $updated; + } + public function getErrorPresupuestoForm(int $error_presupuesto_id) : array + { + $query = $this->builder() + ->select([ + "presupuesto_errores.id", + "CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser", + "CONCAT(t2.first_name,' ',t2.last_name) as lastUser", + "presupuesto_errores.created_at", + "presupuesto_errores.datos_presupuesto", + "presupuesto_errores.error", + "presupuesto_errores.visto", + "presupuesto_errores.comment" + ]) + ->join("users t1", "t1.id = presupuesto_errores.presupuesto_user_id", "left") + ->join("users t2", "t2.id = presupuesto_errores.last_user_id", "left") + ->where("presupuesto_errores.deleted_at", null) + ->where("presupuesto_errores.id",$error_presupuesto_id); + return $query->get()->getResultObject(); + } + public function getQueryDatatable(): BaseBuilder + { + $query = $this->builder() + ->select([ + "presupuesto_errores.id", + "presupuestos.id as presupuestoId", + "CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser", + "CONCAT(t2.first_name,' ',t2.last_name) as lastUser", + "presupuesto_errores.created_at", + "presupuesto_errores.datos_presupuesto", + "presupuesto_errores.error", + "presupuesto_errores.visto", + "presupuesto_errores.comment", + + ]) + ->join("users t1", "t1.id = presupuesto_errores.presupuesto_user_id", "left") + ->join("users t2", "t2.id = presupuesto_errores.last_user_id", "left") + ->join("presupuestos", "presupuestos.id = presupuesto_errores.presupuesto_id", "left") + ->where("presupuesto_errores.deleted_at", null); + return $query; + } +} \ No newline at end of file diff --git a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php index f89ddfd3..90da4d00 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php @@ -123,4 +123,21 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel return $builder; } + public function getDireccion($id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.att AS att, + t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t3.nombre AS pais, + t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono" + ); + + $builder->where('t1.id', $id); + $builder->join("lg_paises t3", "t1.pais_id = t3.id", "left"); + + + return $builder->get()->getResultObject(); + } + } diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index 0150f6af..f242d25e 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -96,7 +96,9 @@ class PresupuestoModel extends \App\Models\BaseModel "comparador_json_data", "is_deleted", "comp_tipo_impresion", - "comp_pos_paginas_color", + "pos_paginas_color", + "paginas_color_consecutivas", + "papel_interior_diferente", "total_coste_papel", "total_margen_papel", "total_margenPercent_papel", @@ -121,8 +123,15 @@ class PresupuestoModel extends \App\Models\BaseModel 'iva_reducido', 'excluir_rotativa', "acabado_cubierta_id", + "barniz_cubierta_id", + "estampado_cubierta_id", "acabado_sobrecubierta_id", - "is_duplicado" + "is_duplicado", + 'paginas_color_consecutivas', + 'papel_interior_diferente', + 'paginasCuadernillo', + 'lomo_redondo', + 'cabezada', ]; protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity"; @@ -395,35 +404,47 @@ class PresupuestoModel extends \App\Models\BaseModel 'cliente_id' => $data['clienteId'], 'tipo_impresion_id' => $data['tipo_impresion_id'], 'pais_id' => 1, - 'retractilado' => in_array(3, $data['servicios']) ? 1 : 0, + 'retractilado' => in_array("RETR", $data['cubierta']['acabadosCubierta']) ? 1 : 0, 'retractilado5' => in_array(5, $data['servicios']) ? 1 : 0, 'guardas' => in_array(62, $data['servicios']) ? 1 : 0, 'faja_color' => in_array(16, $data['servicios']) ? 1 : 0, 'ferro' => in_array(24, $data['servicios']) ? 1 : 0, - 'prototipo' => in_array(9, $data['servicios']) ? 1 : 0, + 'prototipo' => $data['prototipo'] ? 1 : 0, 'papel_formato_id' => is_null($papel_formato_id) ? 0 : $papel_formato_id->id, 'papel_formato_personalizado' => !$papel_formato_id ? 1 : 0, 'papel_formato_ancho' => !$papel_formato_id ? $data['tamanio']['ancho'] : null, 'papel_formato_alto' => !$papel_formato_id ? $data['tamanio']['alto'] : null, 'titulo' => $data_cabecera['titulo'], + 'autor' => $data_cabecera['autor'], + 'ISBN' => $data_cabecera['isbn'], + 'coleccion' => $data_cabecera['coleccion'], 'referencia_cliente' => $data_cabecera['referenciaCliente'], 'paginas' => $data['interior']['paginas'], 'tirada' => $tirada, - 'solapas' => $data['cubierta']['solapasCubierta'] > 0 ? 1 : 0, - 'solapas_ancho' => $data['cubierta']['solapasCubierta'] > 0 ? $data['cubierta']['solapasCubierta'] : 0, - 'solapas_sobrecubierta' => is_null($data['sobrecubierta']) ? 0 : 1, - 'solapas_ancho_sobrecubierta' => is_null($data['sobrecubierta']) ? 0 : $data['sobrecubierta']['solapas'], + 'solapas' => $data['cubierta']['solapasCubierta'] == 0 ? 0 : 1, + 'lomo_redondo' => $data['cubierta']['lomoRedondo'] == 0 ? 0 : 1, + 'cabezada' => $data['cubierta']['cabezada'] == 0 ? 0 : 1, + 'solapas_ancho' => $data['cubierta']['solapasCubierta'] == 0 ? $data['cubierta']['solapasCubierta'] : 0, + 'solapas_sobrecubierta' => !$data['sobrecubierta'] ? 0 : 1, + 'solapas_ancho_sobrecubierta' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['solapas'], 'cosido' => $is_cosido, 'merma' => $extra_info['merma'], 'merma_cubierta' => $extra_info['merma'], + 'paginasCuadernillo' => $data['paginasCuadernillo'], + + 'comp_pos_paginas_color' => $data['interior']['pos_paginas_color'], + 'paginas_color_consecutivas' => $data['interior']['paginas_color_consecutivas'], + 'papel_interior_diferente' => $data['interior']['papelInteriorDiferente'], 'lomo_cubierta' => $extra_info['lomo_cubierta'], 'lomo_sobrecubierta' => $extra_info['lomo_sobrecubierta'], 'comparador_json_data' => $this->generateJson($data), - 'acabado_cubierta_id' => $data['acabadoCubierta'], - 'acabado_sobrecubierta_id' => is_null($data['sobrecubierta']) ? 0 : $data['sobrecubierta']['acabado'], + 'acabado_cubierta_id' => $data['cubierta']['acabadosCubierta']['plastificado'], + 'barniz_cubierta_id' => $data['cubierta']['acabadosCubierta']['barniz'], + 'estampado_cubierta_id' => $data['cubierta']['acabadosCubierta']['estampado'], + 'acabado_sobrecubierta_id' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['acabados'], 'comp_tipo_impresion' => $data['isHq'] ? ($data['isColor'] ? 'colorhq' : 'negrohq') : ($data['isColor'] ? 'color' : 'negro'), @@ -444,7 +465,7 @@ class PresupuestoModel extends \App\Models\BaseModel 'total_margenPercent_servicios' => round($resumen_totales['porcentajeMargenServicios'], 2), 'total_coste_envios' => round($resumen_totales['coste_envio'], 2), 'total_margen_envios' => round($resumen_totales['margen_envio'], 2), - 'total_costes' => round($totalCostes, 2), + 'total_costes' => round($totalCostes, 2), 'total_margenes' => round($totalMargenes, 2), 'total_antes_descuento' => round($totalCostes + $totalMargenes, 2), @@ -482,29 +503,45 @@ class PresupuestoModel extends \App\Models\BaseModel if (is_array($data)) { // -- INTERIOR -- // Si hay negro - if ($data['interior']['paginas'] > $data['interior']['paginas_color']) { + if (intval($data['interior']['paginas']) > intval($data['interior']['paginas_color'])) { if ($data['isHq']) $key = 'bnhq'; else $key = 'bn'; + if (array_key_exists('id', $data['interior']['papel_generico'])) { + $papel_id = intval($data['interior']['papel_generico']['id']); + $gramaje = intval($data['interior']['gramaje']); + } else { + $papel_id = intval($data['interior']['papel_generico']['negro']['id']); + $gramaje = intval($data['interior']['gramaje']['negro']); + } + + $values[$key] = array( - 'paginas' => intval($data['interior']['paginas']) - intval($data['interior']['paginas_color']), - 'papel_id' => intval($data['interior']['papel_generico']['id']), - 'gramaje' => intval($data['interior']['gramaje']), + 'paginas' => intval($data['interior']['paginas']) - intval(intval($data['interior']['paginas_color'])), + 'papel_id' => $papel_id, + 'gramaje' => $gramaje, ); } // Si hay color - if ($data['interior']['paginas_color'] > 0) { + if (intval($data['interior']['paginas_color']) > 0) { if ($data['isHq']) $key = 'colorhq'; else $key = 'color'; + if (array_key_exists('id', $data['interior']['papel_generico'])) { + $papel_id = intval($data['interior']['papel_generico']['id']); + $gramaje = intval($data['interior']['gramaje']); + } else { + $papel_id = intval($data['interior']['papel_generico']['color']['id']); + $gramaje = intval($data['interior']['gramaje']['color']); + } $values[$key] = array( - 'paginas' => intval($data['interior']['paginas_color']), - 'papel_id' => intval($data['interior']['papel_generico']['id']), - 'gramaje' => intval($data['interior']['gramaje']), + 'paginas' => intval(intval($data['interior']['paginas_color'])), + 'papel_id' => $papel_id, + 'gramaje' => $gramaje, ); } @@ -516,7 +553,7 @@ class PresupuestoModel extends \App\Models\BaseModel ); // -- SOBRECUBIERTA -- - if (!is_null($data['sobrecubierta'])) { + if ($data['sobrecubierta']) { $values['sobrecubierta'] = array( 'papel_id' => intval($data['sobrecubierta']['papel']), 'gramaje' => intval($data['sobrecubierta']['gramaje']), @@ -542,7 +579,7 @@ class PresupuestoModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS numero, t1.tipo_impresion_id as tipo, t1.tirada AS unidades, t1.total_aceptado as total, t1.paginas AS paginas, + "t1.id AS numero, t1.tipo_impresion_id as tipo, t1.tirada AS unidades, t1.total_aceptado as total, t1.paginas AS paginas, t1.titulo AS titulo, t1.autor AS autor, t1.isbn AS isbn, t1.papel_formato_id AS papel_formato_id, t1.papel_formato_personalizado AS papel_formato_personalizado, t1.papel_formato_ancho AS papel_formato_ancho, t1.papel_formato_alto AS papel_formato_alto, @@ -550,7 +587,7 @@ class PresupuestoModel extends \App\Models\BaseModel t3.codigo AS codigo_encuadernacion, t1.solapas AS solapas_cubierta, CAST(t1.solapas_ancho AS INT) AS solapas_ancho_cubierta, t1.solapas_sobrecubierta AS solapas_sobrecubierta, CAST(t1.solapas_ancho_sobrecubierta AS INT) AS solapas_ancho_sobrecubierta," - ); + ); $builder->join("lg_papel_formato t2", "t1.papel_formato_id = t2.id", "left"); $builder->join("tipos_presupuestos t3", "t1.tipo_impresion_id = t3.id", "left"); $builder->where("t1.is_deleted", 0); @@ -585,7 +622,7 @@ class PresupuestoModel extends \App\Models\BaseModel ); $presupuesto->concepto .= $this->generarConceptoLineasPresupuestoLibro($lineas, $presupuesto); - $presupuesto = (object)[ + $presupuesto = (object) [ 'numero' => $presupuesto->numero, 'unidades' => $presupuesto->unidades, 'total' => $presupuesto->total, @@ -634,8 +671,8 @@ class PresupuestoModel extends \App\Models\BaseModel ->join('presupuesto_manipulados', 'presupuesto_manipulados.presupuesto_id = presupuestos.id', 'left') ->join('lg_tarifa_manipulado', 'lg_tarifa_manipulado.id = presupuesto_manipulados.tarifa_manipulado_id', 'left') ->where('presupuestos.id', $presupuesto_id); - - $queryExtras = $this->db->table($this->table) + + $queryExtras = $this->db->table($this->table) ->select( [ 'lg_tarifa_preimpresion.id', @@ -645,7 +682,7 @@ class PresupuestoModel extends \App\Models\BaseModel ) ->join('presupuesto_serviciosExtra', 'presupuesto_serviciosExtra.presupuesto_id = presupuestos.id', 'left') ->join('lg_tarifa_preimpresion', 'lg_tarifa_preimpresion.id = presupuesto_serviciosExtra.tarifa_extra_id', 'left') - ->where('presupuestos.id', $presupuesto_id); + ->where('presupuestos.id', $presupuesto_id); $servicios['acabado'] = $queryAcabado->get()->getResultObject(); $servicios['manipulado'] = $queryManipulado->get()->getResultObject(); @@ -783,5 +820,5 @@ class PresupuestoModel extends \App\Models\BaseModel } - + } diff --git a/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php b/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php index 60927b0e..75e9b1ef 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php @@ -15,11 +15,10 @@ class PresupuestoServiciosExtraModel extends \App\Models\BaseModel const SORTABLE = [ 0 => "t2.nombre", - 1 => "t1.precio_unidad", - 2 => "t1.precio_total" + 1 => "t1.precio", ]; - protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "precio_total", "precio_unidad", "margen"]; + protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "precio", "margen"]; protected $returnType = "App\Entities\Presupuestos\PresupuestoServiciosExtraEntity"; protected $useTimestamps = true; diff --git a/ci4/app/Models/Tarifas/Acabados/TarifaAcabadoModel.php b/ci4/app/Models/Tarifas/Acabados/TarifaAcabadoModel.php index 4ae2b09f..9c9227d0 100644 --- a/ci4/app/Models/Tarifas/Acabados/TarifaAcabadoModel.php +++ b/ci4/app/Models/Tarifas/Acabados/TarifaAcabadoModel.php @@ -21,6 +21,8 @@ class TarifaAcabadoModel extends \App\Models\BaseModel protected $allowedFields = [ "nombre", + "code", + "comment", "precio_min", "importe_fijo", "mostrar_en_presupuesto", @@ -83,13 +85,13 @@ class TarifaAcabadoModel extends \App\Models\BaseModel public function getResource(string $search = "") { $builder = $this->db->table($this->table . " t1")->select( - "t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo, + "t1.id AS id, t1.nombre AS nombre,t1.code AS code, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo, t1.mostrar_en_presupuesto AS mostrar_en_presupuesto, t1.acabado_cubierta AS acabado_cubierta, t1.acabado_sobrecubierta AS acabado_sobrecubierta" ); //JJO $builder->where("t1.is_deleted", 0); - + return empty($search) ? $builder : $builder @@ -114,8 +116,9 @@ class TarifaAcabadoModel extends \App\Models\BaseModel return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); } - public function getTarifaPresupuestoAcabado($tarifa_id, $tirada, $proveedor_id = -1){ - + public function getTarifaPresupuestoAcabado($tarifa_id, $tirada, $proveedor_id = -1) + { + $builder = $this->db ->table($this->table . " t1") ->select( @@ -128,18 +131,18 @@ class TarifaAcabadoModel extends \App\Models\BaseModel ->where("t1.is_deleted", 0) //->where("t1.mostrar_en_presupuesto", 1) ->where("t2.is_deleted", 0); - + $builder->where('t1.id =', $tarifa_id); $builder->where('t2.tirada_min <=', $tirada); $builder->where('t2.tirada_max >=', $tirada); - - if($proveedor_id != -1){ + + if ($proveedor_id != -1) { $builder->where('t2.proveedor_id', $proveedor_id); } return $builder->get()->getResultObject(); } - public function getNombreTarifaAcabado($id=-1) + public function getNombreTarifaAcabado($id = -1) { /* Todos los servicios de encuadernacion activas que se pueden usar en presupuestos @@ -184,4 +187,23 @@ class TarifaAcabadoModel extends \App\Models\BaseModel return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } + + public function getCodeFromId($id = 0) + { + + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.code AS code" + ) + ->where("t1.id", $id) + ->where("t1.is_deleted", 0); + + $data = $builder->get()->getResultObject(); + if (count($data) > 0) { + return $data[0]->code; + } else { + return ""; + } + } } diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php index f0c50663..b014f83d 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php @@ -22,6 +22,8 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel protected $allowedFields = [ "nombre", + "code", + "comment", "mostrar_en_presupuesto", "tipo_encuadernacion", "servicio_encuadernacion", @@ -65,7 +67,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel */ public function getResource(string $search = "") { - $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre, + $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre, t1.code AS code, t1.mostrar_en_presupuesto AS mostrar_en_presupuesto, t1.tipo_encuadernacion AS tipo_encuadernacion, t1.servicio_encuadernacion AS servicio_encuadernacion, t1.por_horas AS por_horas"); diff --git a/ci4/app/Models/Tarifas/TarifaEnvioModel.php b/ci4/app/Models/Tarifas/TarifaEnvioModel.php index 9583d4df..c5348c6e 100755 --- a/ci4/app/Models/Tarifas/TarifaEnvioModel.php +++ b/ci4/app/Models/Tarifas/TarifaEnvioModel.php @@ -1,4 +1,5 @@ "t2.nombre", ]; - protected $allowedFields = ["pais_id", "nombre","deleted_at","is_deleted"]; + protected $allowedFields = ["pais_id", "nombre", "code", "comment", "deleted_at", "is_deleted"]; protected $returnType = "App\Entities\Tarifas\TarifaEnvioEntity"; protected $useTimestamps = true; @@ -73,7 +74,7 @@ class TarifaEnvioModel extends \App\Models\BaseModel */ public function getResource(string $search = "") { - $builder = $this->db->table($this->table . " t1")->select("t1.id as id, t1.nombre AS nombre, t2.nombre AS pais_id"); + $builder = $this->db->table($this->table . " t1")->select("t1.id as id, t1.nombre AS nombre,t1.code AS code, t2.nombre AS pais_id"); $builder->join("lg_paises t2", "t1.pais_id = t2.id", "left"); //JJO @@ -82,43 +83,44 @@ class TarifaEnvioModel extends \App\Models\BaseModel return empty($search) ? $builder : $builder - ->groupStart() - ->like("t1.nombre", $search) - ->orLike("t2.id", $search) - ->orLike("t1.pais_id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t2.nombre", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.nombre", $search) + ->orLike("t2.code", $search) + ->orLike("t2.id", $search) + ->orLike("t1.pais_id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t2.nombre", $search) + ->groupEnd(); } - public function getTarifaEnvio($paisId, string $cp, $peso, $tipo_envio){ + public function getTarifaEnvio($paisId, string $cp, $peso, $tipo_envio) + { // Si el pais es españa se tienen que tener en cuenta los postales // Se busca primero la tarifa a la que corresponde $builder = $this->db->table($this->table . " t1") - ->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo") - ->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id") - ->where("t1.pais_id", $paisId) - ->where("t1.is_deleted", 0) - ->where("t2.is_deleted", 0); - - if($paisId == 1) {// España + ->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo") + ->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id") + ->where("t1.pais_id", $paisId) + ->where("t1.is_deleted", 0) + ->where("t2.is_deleted", 0); + + if ($paisId == 1) { // España $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)); } $tarifas = $builder->get()->getResultObject(); $resultado = []; - + $model = model('App\Models\Tarifas\TarifaEnvioPrecioModel'); - foreach($tarifas as $tarifa){ + foreach ($tarifas as $tarifa) { $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; array_push($resultado, $precio_tarifa); } } return $resultado; - } } diff --git a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php index 9a4aefd4..7783d480 100755 --- a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php +++ b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php @@ -22,6 +22,8 @@ class TarifaManipuladoModel extends \App\Models\BaseModel protected $allowedFields = [ "nombre", "precio_min", + "code", + "comment", "importe_fijo", "mostrar_en_presupuesto", "deleted_at", @@ -80,7 +82,7 @@ class TarifaManipuladoModel extends \App\Models\BaseModel */ public function getResource(string $search = "") { - $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo + $builder = $this->db->table($this->table . " t1")->select("t1.id AS id,t1.code AS code, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo ,t1.mostrar_en_presupuesto AS mostrar_en_presupuesto"); //JJO diff --git a/ci4/app/Models/Tarifas/TarifaextraModel.php b/ci4/app/Models/Tarifas/TarifaextraModel.php index 10ec5dd8..8b1001a1 100755 --- a/ci4/app/Models/Tarifas/TarifaextraModel.php +++ b/ci4/app/Models/Tarifas/TarifaextraModel.php @@ -13,7 +13,9 @@ class TarifaextraModel extends \App\Models\BaseModel protected $useAutoIncrement = true; protected $allowedFields = [ - "nombre", + "nombre", + "code", + "comment", "precio", "margen", "mostrar_en_presupuesto", diff --git a/ci4/app/Models/Tarifas/TarifapreimpresionModel.php b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php index 6bb1391f..56ed6999 100755 --- a/ci4/app/Models/Tarifas/TarifapreimpresionModel.php +++ b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php @@ -13,7 +13,9 @@ class TarifapreimpresionModel extends \App\Models\BaseModel protected $useAutoIncrement = true; protected $allowedFields = [ - "nombre", + "nombre", + "code", + "comment", "precio", "margen", "mostrar_en_presupuesto", @@ -37,6 +39,14 @@ class TarifapreimpresionModel extends \App\Models\BaseModel "label" => "Tarifapreimpresion.nombre", "rules" => "trim|required|max_length[255]", ], + "code" => [ + "label" => "Tarifapreimpresion.code", + "rules" => "trim|required|max_length[5]", + ], + "comment" => [ + "label" => "Tarifapreimpresion.comment", + "rules" => "trim|max_length[255]", + ], "precio" => [ "label" => "Tarifapreimpresion.precio", "rules" => "required|decimal", @@ -52,6 +62,14 @@ class TarifapreimpresionModel extends \App\Models\BaseModel "max_length" => "Tarifapreimpresion.validation.nombre.max_length", "required" => "Tarifapreimpresion.validation.nombre.required", ], + "code" => [ + "max_length" => "Tarifapreimpresion.validation.code.max_length", + "required" => "Tarifapreimpresion.validation.code.required", + ], + "comment" => [ + "max_length" => "Tarifapreimpresion.validation.comment.max_length", + "required" => "Tarifapreimpresion.validation.comment.required", + ], "precio" => [ "decimal" => "Tarifapreimpresion.validation.precio.decimal", "required" => "Tarifapreimpresion.validation.precio.required", diff --git a/ci4/app/Services/PresupuestoClienteService.php b/ci4/app/Services/PresupuestoClienteService.php index bf6c6408..25a3a42c 100644 --- a/ci4/app/Services/PresupuestoClienteService.php +++ b/ci4/app/Services/PresupuestoClienteService.php @@ -15,37 +15,44 @@ class PresupuestoClienteService extends BaseService { $rotativa = []; - $plana = PresupuestoClienteService::obtenerPresupuestoClienteInterior($data); + $plana = []; + // no se busca en plana cuando es estándar (no Premium) + if ($data['isHq']) + $plana = PresupuestoClienteService::obtenerPresupuestoClienteInterior($data); if (!$data['excluirRotativa'] && !$data['isHq']) $rotativa = PresupuestoClienteService::obtenerPresupuestoClienteInteriorRotativa($data); $total_plana = -1; $hay_plana = false; - if($data['isColor']){ - if ($data['datosPedido']->paginas == $data['paginas_color']) - $total_plana += floatval($plana[1]['total_impresion']); - - elseif(count($plana[0]) > 2 && count($plana[1]) > 2) { - $total_plana = 0.0; - foreach ($plana as $linea) { - if (count($linea) > 0) - $total_plana += floatval($linea['total_impresion']); + if ($data['isColor']) { + if ($data['datosPedido']->paginas == $data['paginas_color']){ + if(count($plana[1]) > 2) + $total_plana += floatval($plana[1]['total_impresion']); + else + return -1; + } + + elseif (count($plana) > 0) { + if (count($plana[0]) > 2 && count($plana[1]) > 2) { + $total_plana = 0.0; + foreach ($plana as $linea) { + if (count($linea) > 0) + $total_plana += floatval($linea['total_impresion']); + } } } - } - else{ + } else { foreach ($plana as $linea) { if (count($linea) > 0) - if($linea['tipo_linea'] == 'lp_bn' || $linea['tipo_linea'] == 'lp_bnhq'){ + if ($linea['tipo_linea'] == 'lp_bn' || $linea['tipo_linea'] == 'lp_bnhq') { $total_plana = 0.0; $total_plana = floatval($linea['total_impresion']); } - } } $total_rotativa = -1; - if (!$data['excluirRotativa'] && count($rotativa) > 0 && $rotativa['num_formas']['posicion_formas'] != 'n/a') { + if (!$data['excluirRotativa'] && count($rotativa) > 0 && $rotativa['num_formas']['posicion_formas'] != 'n/a') { $total_rotativa = floatval($rotativa['total_impresion']); } if ($total_plana < 0 && $total_rotativa < 0) @@ -70,9 +77,10 @@ class PresupuestoClienteService extends BaseService $isHq = $data['isHq']; $cliente_id = $data['cliente_id']; $paginas_color = $data['paginas_color']; + $lomoRedondo = $data['lomoRedondo']; $lineas_cubierta = []; - + for ($i = 0; $i < 2; $i++) { $lineas = PresupuestoService::obtenerComparadorPlana([ @@ -84,7 +92,8 @@ class PresupuestoClienteService extends BaseService 'isColor' => $isColor, 'isHq' => $isHq, 'cliente_id' => $cliente_id, - 'a_favor_fibra' => $i + 'a_favor_fibra' => $i, + 'lomoRedondo' => $lomoRedondo ]); if (count($lineas) > 0) { @@ -124,7 +133,7 @@ class PresupuestoClienteService extends BaseService $paginas_color = $data['paginas_color']; $lineas_sobrecubierta = []; - + for ($i = 0; $i < 2; $i++) { $lineas = PresupuestoService::obtenerComparadorPlana([ @@ -175,7 +184,7 @@ class PresupuestoClienteService extends BaseService $cliente_id = $data['cliente_id']; $lineas_guardas = []; - + for ($i = 0; $i < 2; $i++) { $lineas = PresupuestoService::obtenerComparadorPlana([ @@ -238,11 +247,21 @@ class PresupuestoClienteService extends BaseService $uso = $data['uso']; $tipo_impresion_id = $data['tipo_impresion_id']; $datosPedido = $data['datosPedido']; - $papel_generico = $data['papel_generico']; - $gramaje = $data['gramaje']; + if ($data['papelInteriorDiferente'] == false) + $papel_generico = $data['papel_generico']; + else { + $papel_generico = $data['papel_generico']['negro']; + $papel_generico_color = $data['papel_generico']['color']; + } + if ($data['papelInteriorDiferente'] == false) + $gramaje = $data['gramaje']; + else { + $gramaje = $data['gramaje']['negro']; + $gramaje_color = $data['gramaje']['color']; + } $isColor = $data['isColor']; $isHq = $data['isHq']; - $cliente_id = $data['cliente_id']; + $cliente_id = $data['cliente_id']; $paginas_color = $data['paginas_color']; $paginas_negro = $datosPedido->paginas - $paginas_color; @@ -285,8 +304,6 @@ class PresupuestoClienteService extends BaseService return $result; } ); - $linea_negro_plana = $linea_negro_plana[0]['fields']; - $linea_negro_plana['tipo_linea'] = $isHq ? 'lp_bnhq' : 'lp_bn'; } } @@ -296,6 +313,10 @@ class PresupuestoClienteService extends BaseService $datosPedido->paginas = $paginas_color; for ($i = 0; $i < 2; $i++) { + if ($data['papelInteriorDiferente'] == true) { + $papel_generico = $papel_generico_color; + $gramaje = $gramaje_color; + } $lineas = PresupuestoService::obtenerComparadorPlana([ 'uso' => $uso, 'tipo_impresion_id' => $tipo_impresion_id, @@ -325,14 +346,61 @@ class PresupuestoClienteService extends BaseService return $result; } ); + } + } + + // 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 + if ( + $paginas_negro > 0 && $paginas_color > 0 && $data['papelInteriorDiferente'] == 0 && + count($linea_negro_plana) > 0 && count($linea_color_plana) > 0 + ) { + $mejor_combinacion = null; + $coste_menor = PHP_INT_MAX; + // Iteramos ambos arrays + foreach ($linea_color_plana as $color_item) { + foreach ($linea_negro_plana as $negro_item) { + // Comparar si tienen el mismo 'maquina_id' + if ($color_item['fields']['maquina_id'] == $negro_item['fields']['maquina_id']) { + // Sumar los 'total_impresion' de ambas líneas + $costo_total = $color_item['fields']['total_impresion'] + $negro_item['fields']['total_impresion']; + + // Verificar si es la combinación más barata hasta ahora + if ($costo_total < $coste_menor) { + $coste_menor = $costo_total; + $mejor_combinacion = [ + 'maquina_id' => $color_item['fields']['maquina_id'], + 'costo_total' => $costo_total, + 'color_item' => $color_item, + 'negro_item' => $negro_item, + ]; + } + } + } + + // Retornar la mejor combinación encontrada + if ($mejor_combinacion !== null) { + return [$mejor_combinacion['negro_item']['fields'], $mejor_combinacion['color_item']['fields']]; + } else { + return []; + } + } + } else { + if (count($linea_negro_plana) > 0) { + $linea_negro_plana = $linea_negro_plana[0]['fields']; + $linea_negro_plana['tipo_linea'] = $isHq ? 'lp_bnhq' : 'lp_bn'; + } + if (count($linea_color_plana) > 0) { $linea_color_plana = $linea_color_plana[0]['fields']; $linea_color_plana['tipo_linea'] = $isHq ? 'lp_colorhq' : 'lp_color'; } } + return [$linea_negro_plana, $linea_color_plana]; } - public static function getServiciosEncuadernacionDefault($data){ + public static function getServiciosEncuadernacionDefault($data) + { $tipo_impresion_id = $data['tipo_impresion_id'] ?? -1; $tirada = $data['tirada'] ?? -1; @@ -348,42 +416,46 @@ class PresupuestoClienteService extends BaseService return $values; } - public static function getServiciosManipulado($data){ + public static function getServiciosManipulado($data) + { $tarifa_id = $data['tarifa_id'] ?? -1; $tirada = $data['tirada'] ?? -1; $POD = $data['POD'] ?? -1; - + $model = model('App\Models\Presupuestos\PresupuestoManipuladosModel'); $values = $model->getPrecioTarifa($tarifa_id, $tirada, $POD); return $values; } - public static function getServiciosPreimpresion($data){ + public static function getServiciosPreimpresion($data) + { $tarifa_id = $data['tarifa_id'] ?? -1; - + $model = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel'); $values = $model->getPrecioTarifa($tarifa_id); return $values; } - public static function getServiciosExtra($data){ + public static function getServiciosExtra($data) + { $tarifa_id = $data['tarifa_id'] ?? -1; - + $model = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel'); $values = $model->getPrecioTarifa($tarifa_id); return $values; } - public static function getServiciosAcabados($data){ + public static function getServiciosAcabados($data) + { $tarifa_id = $data['tarifa_id'] ?? -1; $tirada = $data['tirada'] ?? -1; $POD = $data['POD'] ?? -1; - + $model = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); $values = $model->getPrecioTarifa($tarifa_id, $tirada, -1, $POD); // proveedor más barato return $values; diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index 781b8127..dcf1fa87 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -838,9 +838,13 @@ class PresupuestoService extends BaseService * Devuelve el ancho de la cubierta/sobrecubierta, incluido el lomo. * El $uso tiene que ser "cubierta" o "sobrecubierta" */ - public static function getAnchoTotalExteriores($uso = "cubierta", $tipo_impresion_id = 1, $datosPedido = null, $maquina_id = -1) + public static function getAnchoTotalExteriores($uso = "cubierta", $tipo_impresion_id = 1, $datosPedido = null, $maquina_id = -1, $lomoRedondo = 0) { $ancho_total = 0; + $sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA; + if($datosPedido->ancho > 210 || $datosPedido->alto > 297){ + $sangre_cubierta = 15; + } if ($datosPedido) { // Tapa blanda (cosido y fresado) @@ -861,8 +865,13 @@ class PresupuestoService extends BaseService // si es cubierta // se añade 7mm del ancho del cartón (2*3.5mm) por cada lado del lomo // más 7mm de vuelo+cajo por cada lado. Por último, 20mm de sangre por cada lado - if ($uso == "cubierta") - $ancho_total += (2 * 7 + 2 * self::SANGRE_FORMAS_CUBIERTA + 7); + if ($uso == "cubierta"){ + $ancho_total += (2 * 7 + 2 * $sangre_cubierta + 6); + if($lomoRedondo){ + $ancho_total += 6; + } + } + // si es sobrecubierta // Se añaden 5mm de sangre por cada lado + 2 * 7mm de vuelo portada y contraportada -> total 52 else @@ -893,7 +902,7 @@ class PresupuestoService extends BaseService // Tapa dura else{ // Se le suma 20mm de sangre por cada lado. Como son 2 hojas independientes, se multiplica por 4 - $ancho_total += (4 * self::SANGRE_FORMAS_CUBIERTA); + $ancho_total += (4 * $sangre_cubierta); } } else { @@ -1716,6 +1725,7 @@ class PresupuestoService extends BaseService $cliente_id = $input_data['cliente_id']; $datosTipolog = $input_data['datosTipolog'] ?? null; $a_favor_fibra = $datosPedido->a_favor_fibra ?? false; + $lomoRedondo = $input_data['lomoRedondo'] ?? 0; $tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro'); @@ -1747,7 +1757,7 @@ class PresupuestoService extends BaseService if ($uso == 'cubierta' || $uso == 'sobrecubierta') { - $datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso, $tipo_impresion_id, $datosPedido, $maquina->maquina_id); + $datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso, $tipo_impresion_id, $datosPedido, $maquina->maquina_id, $lomoRedondo); $datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso, $tipo_impresion_id, $datosPedido); } diff --git a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php index 6f0ddc22..e5019405 100755 --- a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php +++ b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php @@ -21,10 +21,13 @@ if (session()->has('error')) {
+
+
+ section('globalJsFunctions') ?> -function popAlert(message, alertClass, alertIcon, containerId = 'sk-alert'){ +function popAlert(message, alertClass, alertIcon, containerId = 'sk-alert', fade = true){ var htmlString = ` diff --git a/ci4/app/Views/themes/vuexy/components/chat_internal_pedido.php b/ci4/app/Views/themes/vuexy/components/chat_internal_pedido.php index 800229f2..bc6f8813 100644 --- a/ci4/app/Views/themes/vuexy/components/chat_internal_pedido.php +++ b/ci4/app/Views/themes/vuexy/components/chat_internal_pedido.php @@ -15,17 +15,21 @@ + user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?> +
- + user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?> + +
diff --git a/ci4/app/Views/themes/vuexy/components/chat_internal_presupuesto.php b/ci4/app/Views/themes/vuexy/components/chat_internal_presupuesto.php index e8775dde..d8509da1 100644 --- a/ci4/app/Views/themes/vuexy/components/chat_internal_presupuesto.php +++ b/ci4/app/Views/themes/vuexy/components/chat_internal_presupuesto.php @@ -15,17 +15,21 @@ + user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?> +
- + user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?> + +
diff --git a/ci4/app/Views/themes/vuexy/components/chat_pedido.php b/ci4/app/Views/themes/vuexy/components/chat_pedido.php index 44e17de6..03768365 100644 --- a/ci4/app/Views/themes/vuexy/components/chat_pedido.php +++ b/ci4/app/Views/themes/vuexy/components/chat_pedido.php @@ -37,16 +37,6 @@ - - diff --git a/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php b/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php index cf791d27..5a9bb075 100644 --- a/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php +++ b/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php @@ -1,4 +1,4 @@ -
+
diff --git a/ci4/app/Views/themes/vuexy/components/modals/modalDireccion.php b/ci4/app/Views/themes/vuexy/components/modals/modalDireccion.php new file mode 100644 index 00000000..b85c7ef7 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/modals/modalDireccion.php @@ -0,0 +1,114 @@ + diff --git a/ci4/app/Views/themes/vuexy/components/modals/modalNewInternalMessage.php b/ci4/app/Views/themes/vuexy/components/modals/modalNewInternalMessage.php index 462725e6..bad4ce3a 100644 --- a/ci4/app/Views/themes/vuexy/components/modals/modalNewInternalMessage.php +++ b/ci4/app/Views/themes/vuexy/components/modals/modalNewInternalMessage.php @@ -31,7 +31,7 @@
diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoForm.php b/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoForm.php new file mode 100644 index 00000000..dfb2abfc --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoForm.php @@ -0,0 +1,89 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + +section('content'); ?> +
+
+ +
+
+

Error presupuesto

+
+ +
+ + +
+ +
+
+ + +
+
+ +
+
+
+
+ + +
+
+ + +
+
+ + + +
+ +
+
+ +
+ +
+ + + +
+ +
+ + +endSection() ?> +section("additionalExternalJs") ?> + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoList.php b/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoList.php new file mode 100644 index 00000000..08069a3b --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoList.php @@ -0,0 +1,50 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + +section('content'); ?> +
+
+ +
+
+

+
+ +
+ + + + + + + + + + + + + + + + + +
ID Presupuesto
+
+ + + +
+ +
+ +
+ +endSection() ?> +section("additionalExternalJs") ?> + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_datosLibroItems.php deleted file mode 100644 index d0d58e27..00000000 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_datosLibroItems.php +++ /dev/null @@ -1,94 +0,0 @@ -
- - - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- - -
- - -
- -
- - -
- -
- - -
- -
- - -
- - -
- - -
- - -
- -
- -
- - diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_direccionesItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_direccionesItems.php deleted file mode 100644 index eb4fe1d7..00000000 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_direccionesItems.php +++ /dev/null @@ -1,48 +0,0 @@ -
- -
-
- -
- -
- - -
-
- - -
-
- -
- -
-
-
-
- - -
-
-
- -
- -
-
- -section("additionalInlineJs") ?> - -window.direcciones = direcciones_envio) ?>; -window.direcciones_sel_tirada = selected_tirada) ?>; -window.routes_direcciones = { - direcciones: "", - getDatos: "", - nuevaDireccion: "", -} -endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_disenioLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_disenioLibroItems.php deleted file mode 100644 index 0516df66..00000000 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_disenioLibroItems.php +++ /dev/null @@ -1,665 +0,0 @@ -
- - - -
- -

Fresado

- -
-
- - -
-
- -
-
user()->inGroup('admin') || auth()->user()->inGroup('beta')) ?' style="display:none;"':''?>> - - -
- - -
- - -
-
- -
- -
-
> - -
-
-
-
> - -
-
- -
- -
-
-
Datos presupuesto
-
-
- -
- - - -
-
- - -
- -
- - -
- -
- - -
- -
- - -
-
- -
- - -
- -
- - -
- -
- - -
- -
- -
- -
papel_formato_personalizado == false ? '' : 'style="display: none"'; ?>> - - - -
- -
papel_formato_personalizado == true ? '' : 'style="display: none"'; ?>> -
- - -
-
- -
papel_formato_personalizado == true ? '' : 'style="display: none"'; ?>> -
- - -
-
- -
-
- papel_formato_personalizado == true ? 'checked' : ''; ?>> - -
-
- -
- -
-
-
Interior
-
-
- - - -
Color del interior
- -
- -
- -
-
- - color_impresion == 'negro' ? ' checked=""': ''); ?> > -
- -
-
Blanco y Negro Estándar
-
-
- - -
-
- - color_impresion == 'negroHq' ? ' checked=""': ''); ?> > -
- -
-
Blanco y Negro Premium
-
-
-
- - -
- -
-
- - color_impresion == 'color' ? ' checked=""': ''); ?> > -
- -
-
Color Estándar
-
-
- - -
-
- - color_impresion == 'colorHq' ? ' checked=""': ''); ?> > -
- -
-
Color Premium
-
-
-
-
- -
-
- - -
-
- -
Papel
-
- -
- - -
- -
- - -
- -
- - -
Opciones extra
- - - -
-
-
Cubierta
-
-
- - - -
Papel
-
- -
- - -
- -
- - -
- -
- -
- -
- - -
- -
- - -
Opciones extra
- -
- -
-
- solapas == true ? 'checked' : ''; ?>> - -
-
- -
solapas == true ? '' : 'style="display: none;"'; ?>> - - -
- -
- -
- -
- - -
- -
- - - -
-
-
Sobrecubierta
-
-
- - - -
-
-
- papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) : - echo 'checked'; - endif; ?> - > - -
-
-
- -
papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) : - echo ''; - else: - echo 'style="display: none;"'; - endif; ?> - > Papel
-
- -
- - -
- -
- - -
- -
- -
papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) : - echo ''; - else: - echo 'style="display: none;"'; - endif; ?> - > Opciones extra
- -
papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) : - echo ''; - else: - echo 'style="display: none;"'; - endif; ?> - > - -
- - -
- -
- -
papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) : - echo ''; - else: - echo 'style="display: none;"'; - endif; ?> - > - -
- - -
- -
- - - -
-
-
Guardas
-
-
- - - -
-
- - -
-
- -
-
- - -
-
- - - -
-
-
Servicios Extra
-
-
- -
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- - -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
- -
-
-
- -
-
-
- -
- - -
-
-
Otras opciones
-
-
- -
-
- - -
- -

Se verificará que el pedido cumpla con los requisitos establecidos en el Artículo 91 de la Ley 37/1992, sobre inserción de publicidad, antes de proceder con su producción, lo que garantiza la aplicación del IVA reducido del 4%.

-
- -
-
- - -section("additionalInlineJs") ?> - - -window.datosDisenioLibro = { - papel_interior: papel_interior ? $presupuestoEntity->papel_interior : 'null'; ?>, - gramaje_interior: gramaje_interior ? $presupuestoEntity->gramaje_interior : 'null'; ?>, - papel_cubierta: papel_cubierta ? $presupuestoEntity->papel_cubierta : 'null'; ?>, - gramaje_cubierta: gramaje_cubierta ? $presupuestoEntity->gramaje_cubierta : 'null'; ?>, - papel_sobrecubierta: papel_sobrecubierta ? $presupuestoEntity->papel_sobrecubierta : 'null'; ?>, - gramaje_sobrecubierta: gramaje_sobrecubierta ? $presupuestoEntity->gramaje_sobrecubierta : 'null'; ?>, -} -window.routes_disenio_libro = { - obtenerGramaje: "", - presupuestoCliente: "", -} -endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_resumenItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_resumenItems.php deleted file mode 100644 index f9cf2d07..00000000 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_resumenItems.php +++ /dev/null @@ -1,316 +0,0 @@ -
-
- estado_id==2): ?> -

PRESUPUESTO ACEPTADO

- lomo_cubierta ?>> -
- -

Resumen

-
-
Libro
-

resumen->titulo)?$presupuestoEntity->resumen->titulo:'') ?>

-

Tamaño: resumen->tamanio)?$presupuestoEntity->resumen->tamanio:'') ?>

-

Número de páginas: paginas ?>

-

Tirada: tirada ?>

-

Prototipo: prototipo?'SI':'NO') ?>

-

Ferro: ferro?'SI':'NO') ?>

- -
Interior
-

Impresion: - resumen->tipo_impresion)?$presupuestoEntity->resumen->tipo_impresion:'') ?> -

-

paginasColor==0?'style="display:none"':'')?>> - Páginas a color: paginasColor?>

-

Papel: - papel_interior_nombre)?$presupuestoEntity->papel_interior_nombre:'') ?> - gramaje_interior)?$presupuestoEntity->gramaje_interior:'') ?>gr/m²

- -
Cubierta
-

Papel: - papel_cubierta_nombre)?$presupuestoEntity->papel_cubierta_nombre:''); ?> - gramaje_cubierta)?$presupuestoEntity->gramaje_cubierta:''); ?>gr/m²

-

Impresión: paginas_cubierta==2?"1 cara":"2 caras");?>

- solapas_ancho>0 || $presupuestoEntity->estado_id==1): ?> -

Solapas: solapas_ancho;?>mm

- - acabado_cubierta_id>0 || $presupuestoEntity->estado_id==1): ?> -

Acabado: - acabadosCubierta) && is_array($datosPresupuesto->acabadosCubierta) && !empty($datosPresupuesto->acabadosCubierta)) : - foreach ($datosPresupuesto->acabadosCubierta as $acabado) : - if ($acabado->id == $presupuestoEntity->acabado_cubierta_id): - echo $acabado->label; - endif; - endforeach; - endif; ?> -

- - - papel_sobrecubierta || $presupuestoEntity->estado_id==1): ?> -
Sobrecubierta
-

Papel: - papel_sobrecubierta_nombre)?$presupuestoEntity->papel_sobrecubierta_nombre:'') ?> - gramaje_sobrecubierta)?$presupuestoEntity->gramaje_sobrecubierta:'') ?>gr/m²

- solapas_ancho_sobrecubierta>0 || $presupuestoEntity->estado_id==1): ?> -

Ancho solapas: solapas_ancho_sobrecubierta;?>mm

- -

Acabado: - acabadosSobrecubierta) && is_array($datosPresupuesto->acabadosSobrecubierta) && !empty($datosPresupuesto->acabadosSobrecubierta)) : - foreach ($datosPresupuesto->acabadosSobrecubierta as $acabado) : - if ($acabado->id == $presupuestoEntity->acabado_sobrecubierta_id): - echo $acabado->label; - endif; - endforeach; - endif; ?> -

- - - papel_guardas || $presupuestoEntity->estado_id==1): ?> -
Guardas
-

Papel: - papel_guardas_nombre)?$presupuestoEntity->papel_guardas_nombre:''); ?> - 170gr/m²

-

Impresión: - paginas_guardas) || $presupuestoEntity->paginas_guardas==0): - echo "Sin impresion"; - elseif($presupuestoEntity->paginas_guardas==4): - echo "1 cara"; - else: - echo "2 caras"; - endif; ?>

- - - retractiladol || $presupuestoEntity->retractilado5 || $presupuestoEntity->faja_color || $presupuestoEntity->estado_id==1): ?> -
Extras
- - retractiladol): ?> -

Retractilado individual

- retractilado5): ?> -

Retractilado de 5

- faja_color): ?> -

Imprimir faja a color

- -
- -
- - estado_id==2): - $total = $presupuestoEntity->total_aceptado; - $iva = $presupuestoEntity->iva_reducido?1.04:1.21; - $total *= $iva; - $total_unidad = $presupuestoEntity->total_precio_unidad * $iva;; - echo '

Total: ' . round($total, 2) . '€

'; - echo '
' . round($total_unidad, 4) . '€/ud
' - ?> - -

Total: 100€

-
10.4€/ud
- -
-
-
- -
-
-
-
- estado_id==2): - echo '
'; - echo '

Direcciones de envío

'; - echo '
'; - if(isset($presupuestoEntity->direcciones_envio)): - foreach ($presupuestoEntity->direcciones_envio as $direccion): - echo '
'; - echo '
'; - echo ''; - echo '
'; - echo '
'; - endforeach; - endif; - echo '
'; - echo '
'; - endif; ?> - - estado_id==2): ?> -
-

Ficheros

-
-
-
- Arrastre aquí los ficheros o haga click -
-
- -
-
-
- -
- -
- - - - - -section("additionalInlineJs") ?> -window.estado = estado_id ?? 1?>; -window.tirada = selected_tirada ?? 0?>; -window.total = total_aceptado ?? 0?>; -window.total_unidad = total_precio_unidad ?? 0 ?>; -window.routes_resumen = { - guardarPresupuesto: "", - duplicarPresupuesto: "", -} - -estado_id===2): ?> - previewEsquemaCubierta(true); - - const previewTemplate = `
-
-
- -
-
-
-
-
-
-
-
-
-
-
`; - - Dropzone.autoDiscover = false; - - var dropzoneMulti = new Dropzone('#dropzone-multi', { - url: "", - addRemoveLinks: true, - previewTemplate: previewTemplate, - paramName: "file", - uploadMultiple: true, - parallelUploads: 4, // Ajusta este número al máximo número de archivos que esperas subir a la vez - maxFiles: 5, // Ajusta este número al máximo número de archivos que esperas subir a la vez - autoProcessQueue: true, - dictRemoveFile: "Eliminar", - acceptedFiles: 'image/*, application/pdf', - maxFilesize: 5e+7, // Bytes - init: function() { - thisDropzone = this; - $('#loader').show(); - - $.ajax({ - url: "", - type: 'POST', - data: { presupuesto_id: id ?> }, - - }).done(function(response) { - if(response == null || response == ""){ - return; - } - values = JSON.parse(response); - for(var i = 0; i < values.length; i++){ - var mockFile = { name: values[i].name, size: values[i].size, hash: values[i].hash}; - - thisDropzone.files.push(mockFile); // add to files array - thisDropzone.emit("addedfile", mockFile); - thisDropzone.emit("thumbnail", mockFile, window.location.host + "/sistema/intranet/presupuestos/"+values[i].hash); - thisDropzone.emit("complete", mockFile); - thisDropzone.options.success.call(thisDropzone, mockFile); - }; - }).always(function() { - $('#loader').hide(); - }); - - this.on("addedfile", function (file) { - if(file.hash){ - var viewButton = Dropzone.createElement("Ver"); - file.previewElement.appendChild(viewButton); - // Listen to the view button click event - viewButton.addEventListener("click", function (e) { - - window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/presupuestos/"+file.hash, '_blank'); - }); - } - }); - } - }); - - $('#presupuesto-cliente-form').submit(function(e){ - e.preventDefault(); - var files = dropzoneMulti.files; - $('#loader').show(); - - var formData = new FormData(); - var oldFiles = []; - var counter = 0; - for (var i = 0; i < files.length; i++) { - - if(files[i].upload){ - var file = files[i]; - formData.append('file[' + counter + ']', file); - counter += 1; - } - else{ - oldFiles.push(files[i].name); - } - } - formData.append('oldFiles', JSON.stringify(oldFiles)); - - formData.append('presupuesto_id', id ?>); - - $.ajax({ - url: "", - type: 'POST', - data: formData, - processData: false, // Indicar a jQuery que no procese los datos - contentType: false // Indicar a jQuery que no establezca el tipo de contenido - }).done(function(response) { - // Aquí puedes manejar la respuesta del servidor - }).always(function() { - $('#loader').hide(); - }) - - return false; - }); - -endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_tipoLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_tipoLibroItems.php deleted file mode 100644 index 54cf1280..00000000 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_tipoLibroItems.php +++ /dev/null @@ -1,122 +0,0 @@ -
-
- - lomo_cubierta ?>> - -
- -
-
-
- > - - tipo_libro == 'cosido' || $datosPresupuesto->tipo_libro == ''){ - echo 'checked=""'; - } - ?> - > -
-

Rústica cosido

-
-
- -
-
-
> - - tipo_libro)=='fresado'? 'checked=""':''); ?> > -
-

Rústica fresado

-
-
- -
-
-
> - - tipo_libro)=='grapado'? 'checked=""':''); ?> > -
-

Cosido con grapas

-
-
-
- -
-
-
-
> - - tipo_libro)=='espiral'? 'checked=""':''); ?> > -
-

Espiral

-
-
- -
-
-
> - - tipo_libro)=='wireo'? 'checked=""':''); ?> > -
-

Wire-o

-
-
- -
-
-
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/direcciones.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/direcciones.js deleted file mode 100644 index 5a264add..00000000 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/direcciones.js +++ /dev/null @@ -1,387 +0,0 @@ -function initDirecciones() { - data = { - id: $('#clienteId').val() - }, - data = Object.assign(data, window.token_ajax); - $('#errorDirecciones').hide(); - - $.ajax({ - url: window.routes_direcciones.direcciones, - type: 'POST', - data: data, - success: function(response) { - $("#direcciones").empty(); - $.each(response.menu, function(index, value) { - $("#direcciones").append(''); - }); - $("#direcciones").val(''); - }, - error: function() { - $("#direcciones").empty(); - }, - }); -} - -function initTiradasDirecciones() { - const _this = this - let sel_index = 1; - - $('#containerTiradasEnvios').empty(); - - for (i = 1; i <= 4; i++) { - let id = "tiradaPrecio" + i; - if ($('#' + id).length > 0) { - - let tirada_id = "ud_tiradaPrecio" + i; - let total_id = "tot_tiradaPrecio" + i; - let precio_u_id = "pu_tiradaPrecio" + i; - let peso = $('#' + id).attr('peso'); - - let html = ''; - html += '
'; - html += '
'; - html += ''; - html += '
'; - html += '
'; - - $('#containerTiradasEnvios').append(html); - - if(parseInt($('#' + tirada_id).text().split(' ')[0]) == window.direcciones_sel_tirada){ - sel_index = i; - } - - $('#' + id).hide(); - } - } - $(('#env_tiradaPrecio' + sel_index)).trigger('click'); - - cargarDirecciones(); - - const tiradasDireccionesList = [].slice.call(document.querySelectorAll('.custom-option-tiradasDirecciones .form-check-input')) - tiradasDireccionesList.map(function (customOptionEL) { - // Update custom options check on page load - _this.updateTiradasDireccionesCheck(customOptionEL) - - // Update custom options check on click - customOptionEL.addEventListener('click', e => { - _this.updateTiradasDireccionesCheck(customOptionEL) - }) - }) -} - -function cargarDirecciones(){ - $('#loader').show(); - $('#divDirecciones').empty(); - - if(window.direcciones == null){ - $('#loader').hide(); - return; - } - for(let i=0; i'; - html += '
'; - html += ''; - html += '
'; - html += '
'; - - $('#divDirecciones').append(html); - $('#errorDirecciones').hide(); - $('#loader').hide(); - } -} - -function updateTiradasDireccionesCheck(el) { - if (el.checked) { - // If custom option element is radio, remove checked from the siblings (closest `.row`) - if (el.type === 'radio') { - const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-tiradasDirecciones')) - customRadioOptionList.map(function (customRadioOptionEL) { - customRadioOptionEL.closest('.custom-option-tiradasDirecciones').classList.remove('checked') - let id_temp = customRadioOptionEL.id.split('-')[1]; - $('#' + id_temp).prop('checked', false); - }) - } - const element = el.closest('.custom-option-tiradasDirecciones'); - element.classList.add('checked'); - - let id = element.id.split('-')[1]; - $('#' + id).prop('checked', true); - - } else { - el.closest('.custom-option-tiradasDirecciones').classList.remove('checked') - } -} - - -function obtenerUnidadesEnvio(){ - - const elements = $('#divDirecciones').find('.row.mb-3'); - let total = 0; - - if(elements.length > 0) { - for (let index=0; index 0 ) { - - let unidades = $('#unidadesEnvio').val(); - if(unidades == '' || isNaN(unidades) || parseInt(unidades) <= 0){ - return false; - } - unidades = parseInt(unidades); - - const seleccion = $('.custom-option-tiradasDirecciones.checked'); - if(seleccion.length == 0) { - return false; - } - - const element_tirada =($(seleccion[0]).find('label input')[0]); - const number = element_tirada.id.match(/\d+$/); - if (number.length == 0) { - return false; - } - let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text()); - - let total = obtenerUnidadesEnvio(); - - if($('#prototipo').is(':checked')) { - tirada += 1; - } - - if(total + unidades <= tirada) { - - data = { - id: $('#direcciones').val(), - peso: $('#env_tiradaPrecio' + number[0]).attr('peso'), - unidades: unidades, - entregaPieCalle: $('#entregaPieCalle').is(':checked')?1:0, - }, - data = Object.assign(data, window.token_ajax) - - $('#loader').show(); - - $.ajax({ - url: window.routes_direcciones.getDatos, - type: 'POST', - data: data, - success: function(response) { - if(response.data.length > 0) { - let html = ''; - html += '
'; - html += '
'; - html += ''; - html += '
'; - html += '
'; - - $('#divDirecciones').append(html); - $('#errorDirecciones').hide(); - $('#loader').hide(); - } - }, - error: function() { - $("#direcciones").empty(); - $('#loader').hide(); - }, - }); - } - else{ - $('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.'); - $('#errorDirecciones').show(); - } - } - return false; -}) - - - -$(document).on('click', '.eliminar-direccion', function(e) { - - $(this).closest('.row.mb-3').remove(); - - const seleccion = $('.custom-option-tiradasDirecciones.checked'); - if(seleccion.length == 0) { - return false; - } - - const element_tirada =($(seleccion[0]).find('label input')[0]); - const number = element_tirada.id.match(/\d+$/); - if (number.length == 0) { - return false; - } - - let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text()); - - const elements = $('#divDirecciones').find('.row.mb-3'); - - let total = 0; - if(elements.length > 0) { - for (let index=0; index' + value.text + ''); - }); - $("#direcciones").val(''); - $('#addressForm').modal('hide'); - }, - error: function() { - $('#addressForm').modal('hide'); - }, - }); - - } -} - -function validarEnvio(){ - - const seleccion = $('.custom-option-tiradasDirecciones.checked'); - if(seleccion.length == 0) { - return false; - } - - const element_tirada =($(seleccion[0]).find('label input')[0]); - - const number = element_tirada.id.match(/\d+$/); - if (number.length == 0) { - return false; - } - let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text()); - - let total = obtenerUnidadesEnvio(); - - if($('#prototipo').is(':checked')) { - tirada += 1; - } - - if(total != tirada){ - return false; - } - return true; -} - -function getDireccionesEnvio(){ - - const elements = $('#divDirecciones').find('.row.mb-3'); - - let direcciones = []; - - if(elements.length > 0) { - for (let index=0; index { - _this.updateTapaCheck(customOptionEL) - }) - }) -} - -function updateTapaCheck(el) { - if (el.checked) { - // If custom option element is radio, remove checked from the siblings (closest `.row`) - if (el.type === 'radio') { - const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-tapa')) - customRadioOptionList.map(function (customRadioOptionEL) { - customRadioOptionEL.closest('.custom-option-tapa').classList.remove('checked') - }) - } - el.closest('.custom-option-tapa').classList.add('checked') - if (el.closest('.custom-option-tapa').id == 'tapaBlandaInnerDiv') { - $('#tapaBlanda').prop('checked', true); - $('#tapaDura').prop('checked', false); - } - else { - $('#tapaBlanda').prop('checked', false); - $('#tapaDura').prop('checked', true); - } - } else { - el.closest('.custom-option-tapa').classList.remove('checked') - } -} - - -function initColorCheck() { - const _this = this - - const custopOptionList = [].slice.call(document.querySelectorAll('.custom-option-color .form-check-input')) - custopOptionList.map(function (customOptionEL) { - // Update custom options check on page load - _this.updateColorCheck(customOptionEL) - - // Update custom options check on click - customOptionEL.addEventListener('click', e => { - _this.updateColorCheck(customOptionEL) - }) - }) -} - -function updateColorCheck(el) { - if (el.checked) { - // If custom option element is radio, remove checked from the siblings (closest `.row`) - if (el.type === 'radio') { - const customRadioOptionList = [].slice.call(el.closest('.row-color').querySelectorAll('.custom-option-color')) - customRadioOptionList.map(function (customRadioOptionEL) { - customRadioOptionEL.closest('.custom-option-color').classList.remove('checked') - }) - } - el.closest('.custom-option-color').classList.add('checked') - if (el.closest('.custom-option-color').id == 'colorNegroDiv') { - $('#colorNegro').prop('checked', true); - $('#colorNegroHq').prop('checked', false); - $('#colorColor').prop('checked', false); - $('#colorColorHq').prop('checked', false); - } - else if (el.closest('.custom-option-color').id == 'colorNegroHqDiv') { - $('#colorNegro').prop('checked', false); - $('#colorNegroHq').prop('checked', true); - $('#colorColor').prop('checked', false); - $('#colorColorHq').prop('checked', false); - } - else if (el.closest('.custom-option-color').id == 'colorColorDiv') { - $('#colorNegro').prop('checked', false); - $('#colorNegroHq').prop('checked', false); - $('#colorColor').prop('checked', true); - $('#colorColorHq').prop('checked', false); - } - else { - $('#colorNegro').prop('checked', false); - $('#colorNegroHq').prop('checked', false); - $('#colorColor').prop('checked', false); - $('#colorColorHq').prop('checked', true); - } - - } else { - el.closest('.custom-option-color').classList.remove('checked') - } -} - - -$('#enableSobrecubierta').on('change', function () { - if ($(this).is(":checked")) { - $('.enable-sobrecubierta').show(); - } else { - $('#gramajeSobrecubierta').val('').trigger('change'); - $('#paperSobrecubierta').val('').trigger('change'); - $('#acabadosSobrecubierta').val('').trigger('change'); - $('#tamanioSolapasSobrecubierta').val(); - $('.enable-sobrecubierta').hide(); - - } -}); - - -function initDisenioLibro() { - initTapaCheck(); - initColorCheck(); - - $('.elementos-libro').trigger('change'); - $('.change-tipo-impresion').trigger('change'); - - $('#papelInterior').trigger('change'); - $('#papelInterior').val(window.datosDisenioLibro.papel_interior); - $('#gramajeInterior').append($(''); - - } -} - - -$('.calcular-presupuesto').on('change', function () { - - // se obtiene el id del elemento que ha disparado el evento - if($(this).hasClass('input-sobrecubierta')){ - if($('#papelSobrecubierta option:selected').val() == '' || $('#gramajeSobrecubierta option:selected').val() == ''){ - return; - } - } - calcularPresupuesto(); -}); - -function comprobarTiradasPOD(){ - const tiradas = getTiradas(); - - //Comprobar que todos los elementos del array tiradas estan por encima de 30 o por debajo - const tiradasPOD = tiradas.every(tirada => tirada <= 30); - const tiradasNoPOD = tiradas.every(tirada => tirada > 30); - if (tiradasPOD == !tiradasNoPOD) { - return true; - } - return false; -} - -$('#clienteId').on('select2:change', function () { - calcularPresupuesto(); -}); - - -async function calcularPresupuesto() { - - let isColor = false; - if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked')) - isColor = true; - let isHq = false; - if($('#colorNegroHqDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked')) - isHq = true; - - if(!comprobarTiradasPOD()){ - $('#errorTiradas').show(); - return; - } - $('#errorTiradas').hide(); - - // se obtiene la propiedad serv_id de los checkboxes seleccionados de la clase .servicio-extra - if (!checkValues()) { - return; - } - - let servicios = []; - $('.servicio-extra:checked').each(function () { - servicios.push($(this).attr('serv_id')); - }) - - let datos = { - tamanio: getDimensionLibro(), - tirada: getTiradas(), - paginas: $('#paginas').val(), - paginasColor: $('#paginasColor').val(), - tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''), - tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda', - isColor: isColor ? 1 : 0, - isHq: isHq ? 1 : 0, - papelInterior: $('#papelInterior option:selected').val(), - papelInteriorNombre: $('#papelInterior option:selected').text().trim(), - gramajeInterior: $('#gramajeInterior option:selected').text(), - excluirRotativa: $('#excluirRotativa').is(':checked')? 1 : 0, - papelCubierta: $('#papelCubierta option:selected').val(), - papelCubiertaNombre: $('#papelCubierta option:selected').text().trim(), - gramajeCubierta: $('#gramajeCubierta option:selected').text(), - carasCubierta: $('#carasCubierta').val(), - acabadoCubierta: $('#acabadosCubierta').val(), - clienteId: $('#clienteId').val(), - servicios: servicios, - } - - // Si es cosido, se añade el número de páginas del cuadernillo - if ($('#cosidoDiv').hasClass('checked')) { - datos.paginasCuadernillo = $('#paginasCuadernillo').val(); - } - // Si hay solapas de cubierta - if ($('#solapasCubierta').is(':checked')) { - datos.solapasCubierta = $('#anchoSolapasCubierta').val() - } - - - - // Si hay sobrecubierta - if ($('#enableSobrecubierta').is(':checked')) { - if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){ - - datos.sobrecubierta = { - papel: $('#papelSobrecubierta option:selected').val(), - papel_nombre: $('#papelSobrecubierta option:selected').text().trim(), - gramaje: $('#gramajeSobrecubierta option:selected').text(), - acabado: $('#acabadosSobrecubierta').val() - } - - datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val() - } - } - - if ($('#divGuardas').is(':visible')) { - datos.guardas = { - papel: $('#papelGuardas option:selected').val(), - papel_nombre: $('#papelGuardas option:selected').text().trim(), - gramaje: 170, - caras: $('#impresionGuardas option:selected').val() - } - } - - datos = Object.assign(datos, window.token_ajax) - - $('#divTiradasPrecio').empty(); - $('#loader').show(); - - $.ajax({ - url: window.routes_disenio_libro.presupuestoCliente, - type: 'POST', - data: datos, - success: function (response) { - error = false; - $('#errorGeneral').hide(); - try{ - - - if(response.errors.interior.length > 0){ - $('#errorInterior').show(); - error = true; - } - else - $('#errorInterior').hide(); - if(response.errors.cubierta.length > 0){ - $('#errorCubierta').show(); - error = true; - } - else - $('#errorCubierta').hide(); - - if(response.errors.sobrecubierta.length > 0){ - $('#errorSobrecubierta').show(); - error = true; - } - else - $('#errorSobrecubierta').hide(); - - - if(response.errors.guardas.length > 0){ - $('#errorGuardas').show(); - error = true; - } - else - $('#errorGuardas').hide(); - - if(response.errors.servicios.length > 0 || response.errors.serviciosDefecto.length > 0){ - error = true; - $('#errorGeneral').show(); - } - else{ - $('#errorGeneral').hide(); - } - } - catch(error){ - } - - //For debug only - //console.log(response); - - $('#loader').hide(); - - $('#divTiradasPrecio').empty(); - - if(!error){ - - $('#lomo_cubierta').val(response.info.lomo_cubierta); - - $('#precios').show(); - - if(response.tiradas){ - for (i = 0; i < response.tiradas.length; i++) { - const total = (parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2) ; - const label = "tiradaPrecio" + parseInt(i+1); - - let html = ''; - - html += ''; - - $('#divTiradasPrecio').append(html); - } - } - - if($('#resumen-libro').hasClass('active')) { - initDirecciones(); - initTiradasDirecciones(); - generarResumen(); - previewEsquemaCubierta(true); - } - - } - }, - error: function (error) { - $('#loader').hide(); - $('#divTiradasPrecio').empty(); - } - }); -} \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php new file mode 100644 index 00000000..a2ab40c9 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php @@ -0,0 +1,30 @@ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php new file mode 100644 index 00000000..4640397b --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php @@ -0,0 +1,296 @@ +
+ +
+

Datos del libro

+
+ +
+ + +
+ +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+ + +
+
+ +
+ + +
+ +
+
+ + + +
+ Siempre deben ser pares +
+ +
+ +
+ + + +
+ Siempre deben ser pares +
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+ +
+ + +
+ Intruzca la posición separada por comas. Ej: 3,5,7 ó 4-10,20,155 +
+
+ +
+ +
+
+ + +
+
+
+ + + +
+ +
+ " + alt="Fresado"> +
+ Fresado (a partir de 32 páginas) +
+
+
+ " + alt="Grapado"> +
+ Grapado (entre 12 y 40 páginas) +
+
+
+ " + alt="Espiral"> +
+ Espiral +
+
+
+ " + alt="Cosido"> +
+ Cosido (a partir de 32 páginas) +
+
+
+ +
+

Servicios extra

+
+ +
+
+ + +
+
+ + +
+

Otros

+
+ +
+ +
+ + +
+ +

Se verificará que el pedido cumpla con los requisitos establecidos en el Artículo 91 de la Ley + 37/1992, sobre inserción de publicidad, antes de proceder con su producción, lo que garantiza la aplicación + del IVA reducido del 4%.

+
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php new file mode 100644 index 00000000..67af53db --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php @@ -0,0 +1,64 @@ +
+ +
+
+
+ +
+

Direcciones de envío

+
+ +
+ +
+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ +
+
+
+ + +
+
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php new file mode 100644 index 00000000..2205844d --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php @@ -0,0 +1,419 @@ +
+ +
+
+
+ +
+

Diseño cubierta

+
+ +
+
Recuerde que la cubierta es el conjunto formado por la portada, contraportada, + lomo y solapas, en caso de que las lleve.
+
+ +
+ +
+ " + alt="TapaBlanda"> + +
+ +
+ " alt="TapaDura"> + +
+ +
+ " + alt="TapaDuraLomoRedondo"> + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ " + alt="Sin solapas"> + +
+ +
+ " + alt="Con solapas"> + +
+ +
+ + +
+ Entre 60 y 120 mm +
+
+ +
+ +
+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ +
+

Papel cubierta

+
+ +
+ +
+ " + alt="Cartulina estucada"> + +
+ +
+ " alt="Estucado mate"> + +
+
+ + +
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ Recomendado +
+
+ +
+
+ +
+
+ +
+ + +
+ +
+

Acabados

+
+ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+ " + alt="Retractilado"> + +
+ +
+
+ + +
+ +
+

Extras

+
+ +
+ +
+ +
+
+ + +
+
+ +
+ + +
+ +
+ + +
+ Entre 60 y 120 mm +
+
+ +
+ + +
+ +
+
+ +
+ +
+ +
+
+ + +
+
+ +
+ + +
+ Mayor 60 mm +
+
+ +
+ + +
+ +
+ + +
+ Entre 60 y 120 mm +
+
+ +
+ + +
+ +
+
+ + +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioInterior.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioInterior.php new file mode 100644 index 00000000..8d68314e --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioInterior.php @@ -0,0 +1,351 @@ +
+ +
+
+
+ +
+

Impresión interior

+
+ + +
+ +
+ " alt="Negro"> + +
+ +
+ " alt="NegroPremium"> + +
+ +
+ " alt="Color"> + +
+ +
+ " alt="ColorPremium"> + +
+ +
+ + +
+

Papel interior

+
+ + +
+ +
+ " alt="offsetBlanco"> + +
+ +
+ " alt="offsetAhuesado"> + +
+ +
+ " alt="offsetAhuesadoVolumen"> + +
+ +
+ " alt="estucadoMate"> + +
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + + +
+

Impresión interior color

+
+ + +
+ +
+ " alt="Color"> + +
+ +
+ " alt="ColorPremium"> + +
+ +
+ + +
+

Papel interior color

+
+ + +
+ +
+ " alt="offsetBlanco"> + +
+ +
+ " alt="offsetAhuesado"> + +
+ +
+ " alt="offsetAhuesadoVolumen"> + +
+ +
+ " alt="estucadoMate"> + +
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_interior.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_interior.php new file mode 100644 index 00000000..43a5f685 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_interior.php @@ -0,0 +1,6 @@ +
+ + + + +
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_presupuestoDireccionesForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_presupuestoDireccionesForm.php new file mode 100644 index 00000000..475222d1 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_presupuestoDireccionesForm.php @@ -0,0 +1,143 @@ + + + + + +section("additionalExternalJs") ?> + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php new file mode 100644 index 00000000..1083ef86 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php @@ -0,0 +1,185 @@ +
+ +

Resumen del presupuesto

+
+ +
+
Precio unidad:
+

Total base: € +

Iva (%): € +

Total: € +

+ +
+
+
+ Mostrar desarrollo cubierta + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Datos generales
TituloAlbert Cook
Tipo libro
Formato
Páginas negro
Páginas color
Páginas en total
Tirada
Prototipo
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Interior
Impresion
Papel
Gramaje
Papel B&N
Gramaje B&N
Papel Color
Gramaje Color
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Cubierta
Tipo
Caras impresas
Papel
Gramaje
Solapas
Papel de guardas
Guardas impresas
Cabezada
Acabados
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Sobrecubierta
PapelEstucado Mate
Gramaje
Tamaño solapas
Plastificado
+
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/loader.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/loader.php index 85f03b08..a0ef0448 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/loader.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/loader.php @@ -1,5 +1,18 @@ -