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 a30c3860..bda1e487 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -582,6 +582,7 @@ $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuest $routes->post('getDireccionesCliente', 'Presupuestocliente::getDireccionesCliente', ['as' => 'getDirecciones']); $routes->post('getNuevaDireccion', 'Presupuestocliente::getNuevaDireccion', ['as' => 'nuevaDireccion']); $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']); }); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 4d537282..58a75515 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; @@ -93,13 +95,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController ['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; $POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); - + $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] @@ -107,7 +109,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $this->viewData['formAction'] = 'add'; - + $this->viewData['paisList'] = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true); $this->viewData['clienteId'] = $clienteId; $this->viewData['POD'] = $POD; @@ -178,7 +180,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $this->viewData['presupuestoEntity'] = $presupuestoEntity; $this->viewData['datosPresupuesto'] = $datosPresupuesto; - + $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 @@ -312,6 +314,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $guardas = $reqData['guardas'] ?? []; $faja = $reqData['faja'] ?? []; $excluirRotativa = $reqData['excluirRotativa'] ?? 0; + $excluirRotativa = intval($excluirRotativa); $ivaReducido = intval($reqData['ivaReducido']) ?? 0; $direcciones = $reqData['direcciones'] ?? []; @@ -331,7 +334,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $interior = [ 'papel_generico' => $papel, 'gramaje' => $gramaje, - 'excluirRotativa' => $excluirRotativa == "false" ? false : true, + 'excluirRotativa' => $excluirRotativa, 'paginas' => $paginas, 'paginas_color' => $paginas_color, 'papelInteriorDiferente' => $papelInteriorDiferente @@ -399,20 +402,35 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $coste_envio = 0.0; foreach ($direcciones as $direccion) { - $coste_envio += $this->getCosteEnvio( + $coste_direccion = $this->getCosteEnvio( $direccion['id'], $return_data['peso'][$i], $direccion['unidades'], $direccion['entregaPalets'] == 'true' ? 1 : 0 - )[0]->coste; + )[0]; + + + if (!property_exists($coste_direccion, 'coste')) { + $return_data['errors']->envios = "No se ha podido calcular el coste de envío"; + }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_envio += $this->getCosteEnvio(null, $return_data['peso'][$i], $tirada[$i], false)[0]->coste; + $coste_direccion = $this->getCosteEnvio(null, $return_data['peso'][$i], $tirada[$i], false)[0]; + + if (!property_exists($coste_direccion, 'coste')) { + $return_data['errors']->envios = "No se ha podido calcular el coste de envío"; + }else{ + $coste_envio += $coste_direccion->coste; + } + $return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio / $tirada[$i], 4); } @@ -421,7 +439,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController return $this->respond($return_data); } catch (Exception $e) { - return $this->failServerError($e->getMessage() ); + return $this->failServerError($e->getMessage()); } } else { return $this->failUnauthorized('Invalid request', 403); @@ -595,6 +613,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $tamanio = $reqData['tamanio']; $paginas = $reqData['paginas'] ?? 0; $paginas_color = $reqData['paginasColor'] ?? 0; + $posPaginasColor = $reqData['posPaginasColor'] ?? ""; + $papelInteriorDiferente = $reqData['papelInteriorDiferente'] ?? 0; + $paginasColorConsecutivas = $reqData['paginasColorConsecutivas'] ?? 0; + $prototipo = $reqData['prototipo'] ?? 0; + $tipo = $reqData['tipo']; $paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null; @@ -609,6 +632,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $guardas = $reqData['guardas'] ?? []; $faja = $reqData['faja'] ?? []; $excluirRotativa = $reqData['excluirRotativa'] ?? 0; + $excluirRotativa = intval($excluirRotativa); $ivaReducido = intval($reqData['ivaReducido']) ?? 0; $direcciones = $reqData['direcciones'] ?? []; @@ -628,7 +652,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $interior = [ 'papel_generico' => $papel, 'gramaje' => $gramaje, - 'excluirRotativa' => $excluirRotativa == "false" ? false : true, + 'excluirRotativa' => $excluirRotativa, 'paginas' => $paginas, 'paginas_color' => $paginas_color, 'papelInteriorDiferente' => $papelInteriorDiferente @@ -703,8 +727,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // seleccionamos el peso de la tirada seleccionada $peso_libro = $resultado_presupuesto['peso'][array_search($selected_tirada, $tirada)]; - - + + if (count($direcciones) > 1) { for ($i = 0; $i < count($tirada); $i++) { @@ -746,9 +770,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $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'] + @@ -778,19 +802,18 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $borrar_antes = true; } - if($datos_presupuesto['sobrecubierta']){ + if ($datos_presupuesto['sobrecubierta']) { $acabado_id = $this->obtenerTarifasAcabado(['plastificado' => $datos_presupuesto['sobrecubierta']['acabados']]); - if(count($acabado_id)>0){ + 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){ + 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{ + } else { $datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0; } @@ -862,6 +885,151 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } + + 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['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']['posPaginasColor'] = $presupuesto->paginas_color; + $data['datosGenerales']['paginasCuadernillo'] = $presupuesto->paginas_cuadernillo; + $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']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente; + + $data['tiradasPrecio'] = [ + (object) [ + 'tirada' => $presupuesto->tirada, + 'precio' => $presupuesto->total_confirmado, + 'precio_u' => $presupuesto->total_precio_unidad, + ] + ]; + + $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; + array_push($data['tiradasPrecio'], (object) [ + 'tirada' => intval($tirada->tirada), + 'precio' => $tirada->total_pedido, + 'precio_u' => $tirada->precio_unidad, + ]); + } + usort($data['tiradasPrecio'], function ($a, $b) { + return $a->tirada <=> $b->tirada; + }); + + $modelLinea = new PresupuestoLineaModel(); + $lineas = $modelLinea->where('presupuesto_id', $id)->findAll(); + + [$data['datosGenerales']['paginasNegro'], $data['datosGenerales']['paginasColor']] = + $this->getPaginas($lineas); + + + return $this->respond([ + 'status' => 1, + 'data' => $data + ]); + } + ; + /* + + if (this.datos.tipo == "cosido") { + this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val(); + } + + + } + ////////////////////////// + this.datos = { + + + tamanio: this.datosGenerales.getDimensionLibro(), + tirada: this.datosGenerales.getTiradas(), + paginas: this.datosGenerales.paginas.val(), + paginasColor: this.datosGenerales.paginasColor.val(), + paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(), + papelInteriorDiferente: this.datosGenerales.papelDiferente.is(':checked') ? 1 : 0, + + tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'), + + isColor: this.datosGenerales.getIsColor() ? 1 : 0, + isHq: this.disenioInterior.getIsHq() ? 1 : 0, + + interior: { + papelInterior: this.disenioInterior.getPapel(), + gramajeInterior: this.disenioInterior.getGramaje(), + }, + + cubierta: { + tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'), + papelCubierta: this.disenioCubierta.getPapel(), + gramajeCubierta: this.disenioCubierta.getGramaje(), + cabezada: this.disenioCubierta.getCabezada(), + acabados: this.disenioCubierta.getAcabados(), + carasImpresion: this.disenioCubierta.carasCubierta.val(), + }, + + guardas: this.disenioCubierta.getGuardas(), + sobrecubierta: this.disenioCubierta.getSobrecubierta(), + faja: this.disenioCubierta.getFaja(), + + + let solapasCubierta = this.disenioCubierta.getSolapasCubierta(); + if (solapasCubierta !== null && solapasCubierta !== undefined) { + + if (solapasCubierta === false) + this.datos.cubierta.solapas = 0; + else { + this.datos.cubierta.solapas = 1; + this.datos.cubierta.tamanioSolapas = solapasCubierta; + } + } + else { + this.datos.cubierta.solapas = 0; + } + + if (this.direcciones.direcciones.length > 0) { + this.datos.direcciones = []; + for (let i = 0; i < this.direcciones.direcciones.length; i++) { + this.datos.direcciones.push(this.direcciones.direcciones[i].getFormData()); + }; + } + + + } + ////////////////////////////////////////////////////////*/ + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + public function get_files() { @@ -1002,10 +1170,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $peso_envio = $peso_libro * $unidades / 1000.0; $data = $this->getCosteEnvio( - $direccion['id'], - $peso_libro, - $direccion['unidades'], - $direccion['entregaPalets'] == 'false' ? 0 : 1); + $direccion['id'], + $peso_libro, + $direccion['unidades'], + $direccion['entregaPalets'] == 'false' ? 0 : 1 + ); if (count($data) > 0) { @@ -1103,7 +1272,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $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) { @@ -1192,6 +1361,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'guardas' => "", 'servicios' => "", 'serviciosDefecto' => "", + "envios" => "", ]; $coste_servicios = 0.0; @@ -1367,7 +1537,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $acabadoCubierta = []; foreach ($tarifaAcabadoCubierta as $tarifa) { - if($tarifa == 0) + if ($tarifa == 0) continue; $model = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); $acabadoCubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD); @@ -1427,6 +1597,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $acabadoSobrecubierta = []; foreach ($tarifaAcabadoSobrecubierta as $tarifa) { + // NONE + if($tarifaAcabadoSobrecubierta[0] == 0) + continue; $model = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); $acabadoSobrecubierta = $model->getPrecioTarifa($tarifa, $datosPedido->tirada, -1, $POD); @@ -1564,7 +1737,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; } } else if (intval($servicio) == 9) { - // Servicios preimpresion + // Prototipo $resultado = PresupuestoCLienteService::getServiciosExtra([ 'tarifa_id' => $servicio, ]); @@ -1630,11 +1803,11 @@ 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, + //'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, @@ -2082,12 +2255,39 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data = $model->where('code', $value)->first(); $data = $data->id; array_push($tarifas, $data); - } - else{ + } 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/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 8f54389a..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( @@ -94,7 +96,8 @@ class PapelFormatoModel extends \App\Models\BaseModel )->where('is_deleted', 0)->orderBy('orden_select', 'asc')->get()->getResultObject(); } - public function getElementsForMenu2($search = ""){ + public function getElementsForMenu2($search = "") + { $builder = $this->db ->table($this->table . " t1") ->select( @@ -108,9 +111,26 @@ class PapelFormatoModel extends \App\Models\BaseModel return empty($search) ? $builder->get()->getResultObject() : $builder - ->groupStart() - ->like('t1.ancho', $search) - ->orLike('t1.alto', $search) - ->groupEnd()->get()->getResultObject(); + ->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/Services/PresupuestoClienteService.php b/ci4/app/Services/PresupuestoClienteService.php index 46ca2fd9..c02f8ba8 100644 --- a/ci4/app/Services/PresupuestoClienteService.php +++ b/ci4/app/Services/PresupuestoClienteService.php @@ -27,12 +27,13 @@ class PresupuestoClienteService extends BaseService 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']); + 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 { @@ -46,7 +47,7 @@ class PresupuestoClienteService extends BaseService } $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) @@ -305,7 +306,7 @@ class PresupuestoClienteService extends BaseService $datosPedido->paginas = $paginas_color; for ($i = 0; $i < 2; $i++) { - if ($data['papelInteriorDiferente'] == true){ + if ($data['papelInteriorDiferente'] == true) { $papel_generico = $papel_generico_color; $gramaje = $gramaje_color; } @@ -377,8 +378,7 @@ class PresupuestoClienteService extends BaseService return []; } } - } - else{ + } 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'; 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 = ` -
+

Servicios extra

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 90780250..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,10 +1,18 @@ -