mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Compare commits
212 Commits
feat/busca
...
dev/presu_
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e80fddfb6 | |||
| 1e2d550301 | |||
| 0a3618cd00 | |||
| 33fbfc1a5d | |||
| a8612f64a4 | |||
| 0b614d4d58 | |||
| 55b225ab49 | |||
| 315d2a3acd | |||
| 83c8628645 | |||
| d0ee0b27bc | |||
| 8556887567 | |||
| f50987dc2b | |||
| 4180cea16a | |||
| 0b3bf0ed85 | |||
| 14fe3b1461 | |||
| 58ab81d8e8 | |||
| cdb9afc290 | |||
| adcf2fbec3 | |||
| eb806621c6 | |||
| 0963fae240 | |||
| daa10420c7 | |||
| 716019bf81 | |||
| 2ac99d14c0 | |||
| 0f00649f99 | |||
| 3dd9f8f7e3 | |||
| c79bc4343f | |||
| 8f2f19df1b | |||
| a3561d7623 | |||
| 5e2d37ed26 | |||
| 72b6845625 | |||
| 9919496397 | |||
| 33496d81ee | |||
| a1f1151c1b | |||
| b28b383136 | |||
| 0a5f8dee68 | |||
| 7a3c11c343 | |||
| 4afb977577 | |||
| 262aa4a88f | |||
| 9f61faf67a | |||
| 2f83526d7e | |||
| e64788ddb5 | |||
| 1ed5c868b5 | |||
| ecb5abaa6d | |||
| b74495117f | |||
| db67b1946f | |||
| 66a5651a30 | |||
| 2ff86a7743 | |||
| c7c9b54556 | |||
| 9b964a89f6 | |||
| c6b1bd9292 | |||
| 73a60466d3 | |||
| 49e03fb7e9 | |||
| 62a3706049 | |||
| 1914cb01fe | |||
| 09e5149090 | |||
| ac3a93370c | |||
| 859f2a99be | |||
| 4d20b4ac1c | |||
| 8135e635ab | |||
| 643e325e59 | |||
| 3c48d88357 | |||
| 15642d6e47 | |||
| 035d695780 | |||
| f9b12cbcdd | |||
| f1df4559f7 | |||
| 464e136025 | |||
| 23491b2e1a | |||
| 8a044d41fe | |||
| 7c9b8a0b6d | |||
| a0128d8f1e | |||
| fdf838c909 | |||
| b5924dceb5 | |||
| 2c5ea4d7ba | |||
| 19be8591f3 | |||
| a8a741f0bf | |||
| 6865d810da | |||
| de9cf30aac | |||
| 29eeecb905 | |||
| 668d0d79e6 | |||
| 52303e9185 | |||
| 7857e5992a | |||
| f9b7de63fd | |||
| 9c3a7848f3 | |||
| 6b49984c28 | |||
| 44fc60372b | |||
| 287335dc6b | |||
| cb1d280b35 | |||
| c5c4a31521 | |||
| 612b67883c | |||
| 2012ada27f | |||
| 7ad3133a15 | |||
| 0eaac5af28 | |||
| e64022a7b7 | |||
| a069b4109c | |||
| 92389bb5f5 | |||
| 032b09f0a3 | |||
| 91f26520cb | |||
| dfd915e47f | |||
| 4045771c2d | |||
| 1d3f817709 | |||
| 2e2888ec26 | |||
| 78b255fa0d | |||
| cece606bb1 | |||
| ba3ec185ef | |||
| 8b10aa655a | |||
| 13e3a69cd6 | |||
| f09d5aeceb | |||
| daca044cf3 | |||
| cb982bd38a | |||
| 69b27f0cd8 | |||
| 8617553dea | |||
| 2049cb1e02 | |||
| bdc5b0c442 | |||
| c5a5f01fa0 | |||
| c0e90a723b | |||
| 130c5dad88 | |||
| bd22e89a28 | |||
| d3722440c3 | |||
| 21c1bd9bd2 | |||
| a6dbe6de07 | |||
| 68d5a7157e | |||
| bf568fec92 | |||
| 5aa1aa6222 | |||
| c651db61ff | |||
| a2f91866f7 | |||
| 2fc9af9db4 | |||
| d6a95f78ee | |||
| 766347ad81 | |||
| 70fa74333d | |||
| 0b0b928619 | |||
| b1eeddc5bc | |||
| 74041042c5 | |||
| bfea4aa67c | |||
| b25abc19d9 | |||
| b7cfdf87b9 | |||
| 7d26975ac3 | |||
| 0177ca0f73 | |||
| 19e3e6ce0e | |||
| 2f93a8a02c | |||
| 1862d4ccf9 | |||
| 5c72771fbe | |||
| 8777ce19c1 | |||
| 64288baf54 | |||
| f8dd56b74c | |||
| db3f79da29 | |||
| 51dc0ca676 | |||
| 639230f780 | |||
| d3ae73a82d | |||
| cf3cebfcfb | |||
| 9ad062ed27 | |||
| 2469101541 | |||
| 4a3d594347 | |||
| 4ce8b22c5a | |||
| d860d6426c | |||
| 4b2b4dfade | |||
| dd9b49026b | |||
| 07cd952532 | |||
| ca5d70b37c | |||
| f8497e4388 | |||
| 150a7aa158 | |||
| 19e81a6c25 | |||
| 6e0c22d981 | |||
| 2239d39919 | |||
| d01fbbfe4b | |||
| 9e57aef8bc | |||
| 6a307e9fe3 | |||
| 26056082fa | |||
| 9cc8c40434 | |||
| 99bdaf7a24 | |||
| 4614db53cf | |||
| 36a627b737 | |||
| 6bddf1b997 | |||
| 54731f65b2 | |||
| 333d9a8c09 | |||
| 69917caed3 | |||
| adb1335c17 | |||
| 357966cf69 | |||
| 7097ef72cc | |||
| 93714ac955 | |||
| fe4fdb8607 | |||
| 6e41e73997 | |||
| ebe649c7d8 | |||
| 68f2ccb1c5 | |||
| 1d7f06b018 | |||
| 295fd88201 | |||
| 173b6d5a5d | |||
| 23a34d10b0 | |||
| 121708b71c | |||
| 403c742bf3 | |||
| 8653971dd2 | |||
| 43fdafc099 | |||
| 3a0011b49a | |||
| c8335b5740 | |||
| 8e5d208bbf | |||
| 01cc74ed60 | |||
| c3248cd3ec | |||
| 251268fb24 | |||
| eb4ea31cef | |||
| da379a7af9 | |||
| c8106eafa1 | |||
| ee45baec3b | |||
| 144faa9363 | |||
| 5169174e57 | |||
| 070ffb934d | |||
| 5648f43413 | |||
| a91685747c | |||
| 665dc2d86d | |||
| f3ad5d8b06 | |||
| c5e4a70ec0 | |||
| f46a03e66d | |||
| 26f3057bbe | |||
| 35e4e8ef95 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
ci4/.env
|
||||
.vscode/
|
||||
|
||||
xdebug.log
|
||||
xdebug.log
|
||||
xdebug.*
|
||||
|
||||
92
README.md
92
README.md
@ -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.
|
||||
133
acciones.txt
133
acciones.txt
@ -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
|
||||
<div class="col-lg-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4 class="card-title"><?=lang("App.dashboard_chart_auth")?></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-12" id="ct-icon-chart"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12"><div class="ct-pie-chart"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
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
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label class="text-dark"><?=lang("App.notification_field_send_sms")?></label>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" id="send_sms_notification" name="send_sms_notification" class="custom-control-input" <?= $obj['send_sms_notification']??false ? 'checked' : ''?>>
|
||||
<label for="send_sms_notification" class="custom-control-label"><?=lang("App.notification_field_send_label")?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
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
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label class="text-dark"><?=lang("App.settings_field_send_welcome_message_sms")?></label>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" id="send_sms_welcome" name="send_sms_welcome" class="custom-control-input" <?= $obj['send_sms_welcome']??false ? 'checked' : ''?>>
|
||||
<label for="send_sms_welcome" class="custom-control-label"><?=lang("App.global_activate")?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
y
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label class="text-dark"><?=lang("App.settings_field_send_sms_register")?></label>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" id="send_sms_register" name="send_sms_register" class="custom-control-input" <?= $obj['send_sms_register']??false ? 'checked' : ''?>>
|
||||
<label for="send_sms_register" class="custom-control-label"><?=lang("App.global_activate")?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
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
|
||||
@ -15,6 +15,7 @@ namespace Config;
|
||||
|
||||
use App\Entities\Usuarios\UsersEntity;
|
||||
use App\Models\UserModel;
|
||||
use CodeIgniter\Shield\Authentication\Authenticators\JWT;
|
||||
use CodeIgniter\Shield\Authentication\Passwords\ValidationRules;
|
||||
use CodeIgniter\Shield\Config\Auth as ShieldAuth;
|
||||
use CodeIgniter\Shield\Authentication\Actions\ActionInterface;
|
||||
@ -118,7 +119,7 @@ class Auth extends ShieldAuth
|
||||
'tokens' => AccessTokens::class,
|
||||
'session' => Session::class,
|
||||
'hmac' => HmacSha256::class,
|
||||
// 'jwt' => JWT::class,
|
||||
'jwt' => JWT::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -145,7 +146,7 @@ class Auth extends ShieldAuth
|
||||
'session',
|
||||
'tokens',
|
||||
'hmac',
|
||||
// 'jwt',
|
||||
'jwt',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
96
ci4/app/Config/AuthJWT.php
Normal file
96
ci4/app/Config/AuthJWT.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter Shield.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Shield\Config\AuthJWT as ShieldAuthJWT;
|
||||
|
||||
/**
|
||||
* JWT Authenticator Configuration
|
||||
*/
|
||||
class AuthJWT extends ShieldAuthJWT
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------
|
||||
* Name of Authenticator Header
|
||||
* --------------------------------------------------------------------
|
||||
* The name of Header that the Authorization token should be found.
|
||||
* According to the specs, this should be `Authorization`, but rare
|
||||
* circumstances might need a different header.
|
||||
*/
|
||||
public string $authenticatorHeader = 'Authorization';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------
|
||||
* The Default Payload Items
|
||||
* --------------------------------------------------------------------
|
||||
* All JWTs will have these claims in the payload.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $defaultClaims = [
|
||||
'iss' => 'https://safekat.com',
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------
|
||||
* The Keys
|
||||
* --------------------------------------------------------------------
|
||||
* The key of the array is the key group name.
|
||||
* The first key of the group is used for signing.
|
||||
*
|
||||
* @var array<string, array<int, array<string, string>>>
|
||||
* @phpstan-var array<string, list<array<string, string>>>
|
||||
*/
|
||||
public array $keys = [
|
||||
'default' => [
|
||||
// Symmetric Key
|
||||
[
|
||||
'kid' => '', // Key ID. Optional if you have only one key.
|
||||
'alg' => 'HS256', // algorithm.
|
||||
// Set secret random string. Needs at least 256 bits for HS256 algorithm.
|
||||
// E.g., $ php -r 'echo base64_encode(random_bytes(32));'
|
||||
'secret' => 'ZAfosrIVWDaKEhBhicTKCpW8T5ZxC3GYAxFgCkUQjlU=',
|
||||
],
|
||||
// Asymmetric Key
|
||||
// [
|
||||
// 'kid' => '', // Key ID. Optional if you have only one key.
|
||||
// 'alg' => 'RS256', // algorithm.
|
||||
// 'public' => '', // Public Key
|
||||
// 'private' => '', // Private Key
|
||||
// 'passphrase' => '' // Passphrase
|
||||
// ],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------
|
||||
* Time To Live (in seconds)
|
||||
* --------------------------------------------------------------------
|
||||
* Specifies the amount of time, in seconds, that a token is valid.
|
||||
*/
|
||||
public int $timeToLive = HOUR;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------
|
||||
* Record Login Attempts
|
||||
* --------------------------------------------------------------------
|
||||
* Whether login attempts are recorded in the database.
|
||||
*
|
||||
* Valid values are:
|
||||
* - Auth::RECORD_LOGIN_ATTEMPT_NONE
|
||||
* - Auth::RECORD_LOGIN_ATTEMPT_FAILURE
|
||||
* - Auth::RECORD_LOGIN_ATTEMPT_ALL
|
||||
*/
|
||||
public int $recordLoginAttempt = Auth::RECORD_LOGIN_ATTEMPT_FAILURE;
|
||||
}
|
||||
@ -46,6 +46,7 @@ class Autoload extends AutoloadConfig
|
||||
public $psr4 = [
|
||||
APP_NAMESPACE => APPPATH, // For custom app namespace
|
||||
'Config' => APPPATH . 'Config',
|
||||
'Libraries' => APPPATH . 'Libraries',
|
||||
'Dompdf' => APPPATH . 'ThirdParty/dompdf/src',
|
||||
];
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ use CodeIgniter\Filters\DebugToolbar;
|
||||
use CodeIgniter\Filters\Honeypot;
|
||||
use CodeIgniter\Filters\InvalidChars;
|
||||
use CodeIgniter\Filters\SecureHeaders;
|
||||
use CodeIgniter\Shield\Authentication\Authenticators\JWT;
|
||||
|
||||
|
||||
class Filters extends BaseConfig
|
||||
@ -43,6 +44,8 @@ class Filters extends BaseConfig
|
||||
'login*',
|
||||
'register',
|
||||
'auth/a/*',
|
||||
'auth/jwt',
|
||||
'api/*',
|
||||
'logout']
|
||||
],
|
||||
],
|
||||
@ -73,5 +76,9 @@ class Filters extends BaseConfig
|
||||
* Example:
|
||||
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
|
||||
*/
|
||||
public array $filters = [];
|
||||
public array $filters = [
|
||||
/*'jwt' => [
|
||||
'before' => ['api', 'api/*']
|
||||
],*/
|
||||
];
|
||||
}
|
||||
|
||||
27
ci4/app/Config/PedidoXML.php
Normal file
27
ci4/app/Config/PedidoXML.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class PedidoXML extends BaseConfig
|
||||
{
|
||||
|
||||
public string $host;
|
||||
public int $port;
|
||||
public string $username;
|
||||
public string $password;
|
||||
public string $base_dir; # FTP server directory
|
||||
public bool $xml_enabled;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->host = env("HIDRIVE_HOST","10.5.0.6");
|
||||
$this->port = env("HIDRIVE_PORT",21);
|
||||
$this->username = env("HIDRIVE_USER","admin");
|
||||
$this->password = env("HIDRIVE_PASS","A77h3b0X4OA2rOYAf4w2");
|
||||
$this->base_dir = env("HIDRIVE_PATH_ROOT","/home/admin/safekat"); # FTP server directory
|
||||
$this->xml_enabled = env("FTP_XML_ENABLED",false);
|
||||
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,164 @@ const SK_PERMISSION_MATRIX = [
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
"tarifa-preimpresion.create",
|
||||
"tarifa-preimpresion.edit",
|
||||
"tarifa-preimpresion.delete",
|
||||
"tarifa-preimpresion.menu",
|
||||
"tarifa-manipulado.create",
|
||||
"tarifa-manipulado.edit",
|
||||
"tarifa-manipulado.delete",
|
||||
"tarifa-manipulado.menu",
|
||||
"tarifa-acabado.create",
|
||||
"tarifa-acabado.edit",
|
||||
"tarifa-acabado.delete",
|
||||
"tarifa-acabado.menu",
|
||||
"tarifa-encuadernacion.create",
|
||||
"tarifa-encuadernacion.edit",
|
||||
"tarifa-encuadernacion.delete",
|
||||
"tarifa-encuadernacion.menu",
|
||||
"tarifa-envio.create",
|
||||
"tarifa-envio.edit",
|
||||
"tarifa-envio.delete",
|
||||
"tarifa-envio.menu",
|
||||
"tarifa-extra.create",
|
||||
"tarifa-extra.edit",
|
||||
"tarifa-extra.delete",
|
||||
"tarifa-extra.menu",
|
||||
"proveedores.create",
|
||||
"proveedores.edit",
|
||||
"proveedores.delete",
|
||||
"proveedores.menu",
|
||||
"ajustes.create",
|
||||
"ajustes.edit",
|
||||
"ajustes.delete",
|
||||
"ajustes.menu",
|
||||
"actividad.create",
|
||||
"actividad.edit",
|
||||
"actividad.delete",
|
||||
"actividad.menu",
|
||||
"paises.create",
|
||||
"paises.edit",
|
||||
"paises.delete",
|
||||
"paises.menu",
|
||||
"formas-pago.create",
|
||||
"formas-pago.edit",
|
||||
"formas-pago.delete",
|
||||
"formas-pago.menu",
|
||||
"maquinas.create",
|
||||
"maquinas.edit",
|
||||
"maquinas.delete",
|
||||
"maquinas.menu",
|
||||
"maquinas-defecto.create",
|
||||
"maquinas-defecto.edit",
|
||||
"maquinas-defecto.delete",
|
||||
"maquinas-defecto.menu",
|
||||
"papel-generico.create",
|
||||
"papel-generico.edit",
|
||||
"papel-generico.delete",
|
||||
"papel-generico.menu",
|
||||
"papel-impresion.create",
|
||||
"papel-impresion.edit",
|
||||
"papel-impresion.delete",
|
||||
"papel-impresion.menu",
|
||||
"usuarios.create",
|
||||
"usuarios.edit",
|
||||
"usuarios.delete",
|
||||
"usuarios.menu",
|
||||
"roles-permisos.create",
|
||||
"roles-permisos.edit",
|
||||
"roles-permisos.delete",
|
||||
"roles-permisos.menu",
|
||||
"ubicaciones.create",
|
||||
"ubicaciones.edit",
|
||||
"ubicaciones.delete",
|
||||
"ubicaciones.menu",
|
||||
"series-facturas.create",
|
||||
"series-facturas.edit",
|
||||
"series-facturas.delete",
|
||||
"series-facturas.menu",
|
||||
],
|
||||
"cliente-admin" => [
|
||||
"perfil.edit",
|
||||
"perfil.menu",
|
||||
"direcciones.create",
|
||||
"direcciones.edit",
|
||||
"direcciones.delete",
|
||||
"direcciones.menu",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
],
|
||||
"cliente-editor" => [
|
||||
"perfil.create",
|
||||
"perfil.edit",
|
||||
"perfil.delete",
|
||||
"perfil.menu",
|
||||
"direcciones.create",
|
||||
"direcciones.edit",
|
||||
"direcciones.delete",
|
||||
"direcciones.menu",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
],
|
||||
"comercial" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"produccion" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"maquina" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"maquetador" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"director" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"contabilidad" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"editor" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
"Profile.index",
|
||||
"Profile.menu",
|
||||
],
|
||||
"beta" => [
|
||||
"clientes.create",
|
||||
"clientes.edit",
|
||||
"clientes.delete",
|
||||
"clientes.menu",
|
||||
"plantilla-tarifa.create",
|
||||
"plantilla-tarifa.edit",
|
||||
"plantilla-tarifa.delete",
|
||||
"plantilla-tarifa.menu",
|
||||
"perfil.create",
|
||||
"perfil.edit",
|
||||
"perfil.delete",
|
||||
"perfil.menu",
|
||||
"presupuesto.create",
|
||||
"presupuesto.edit",
|
||||
"presupuesto.delete",
|
||||
"presupuesto.menu",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
"tarifa-preimpresion.create",
|
||||
"tarifa-preimpresion.edit",
|
||||
"tarifa-preimpresion.delete",
|
||||
"tarifa-preimpresion.menu",
|
||||
"tarifa-manipulado.create",
|
||||
"tarifa-manipulado.edit",
|
||||
"tarifa-manipulado.delete",
|
||||
@ -90,94 +248,4 @@ const SK_PERMISSION_MATRIX = [
|
||||
"series-facturas.delete",
|
||||
"series-facturas.menu",
|
||||
],
|
||||
"cliente-admin" => [
|
||||
"perfil.edit",
|
||||
"perfil.menu",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
],
|
||||
"cliente-editor" => [
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
],
|
||||
"comercial" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"produccion" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"maquina" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"maquetador" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"director" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"contabilidad" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
],
|
||||
"editor" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
"Profile.index",
|
||||
"Profile.menu",
|
||||
],
|
||||
"beta" => [
|
||||
"clientes.create",
|
||||
"clientes.edit",
|
||||
"clientes.delete",
|
||||
"clientes.menu",
|
||||
"plantilla-tarifa.create",
|
||||
"plantilla-tarifa.edit",
|
||||
"plantilla-tarifa.delete",
|
||||
"plantilla-tarifa.menu",
|
||||
"presupuesto.create",
|
||||
"presupuesto.edit",
|
||||
"presupuesto.delete",
|
||||
"presupuesto.menu",
|
||||
"tarifa-preimpresion.create",
|
||||
"tarifa-preimpresion.edit",
|
||||
"tarifa-preimpresion.delete",
|
||||
"tarifa-preimpresion.menu",
|
||||
"tarifa-manipulado.create",
|
||||
"tarifa-manipulado.edit",
|
||||
"tarifa-manipulado.delete",
|
||||
"tarifa-manipulado.menu",
|
||||
"tarifa-acabado.create",
|
||||
"tarifa-acabado.edit",
|
||||
"tarifa-acabado.delete",
|
||||
"tarifa-acabado.menu",
|
||||
"tarifa-encuadernacion.create",
|
||||
"tarifa-encuadernacion.edit",
|
||||
"tarifa-encuadernacion.delete",
|
||||
"tarifa-encuadernacion.menu",
|
||||
"tarifa-envio.create",
|
||||
"tarifa-envio.edit",
|
||||
"tarifa-envio.delete",
|
||||
"tarifa-envio.menu",
|
||||
"proveedores.create",
|
||||
"proveedores.edit",
|
||||
"proveedores.delete",
|
||||
"proveedores.menu",
|
||||
"ajustes.create",
|
||||
"ajustes.edit",
|
||||
"ajustes.delete",
|
||||
"ajustes.menu",
|
||||
"actividad.create",
|
||||
"actividad.edit",
|
||||
"actividad.delete",
|
||||
"actividad.menu",
|
||||
],
|
||||
];
|
||||
|
||||
@ -13,6 +13,10 @@ const SK_PERMISSIONS = [
|
||||
'perfil.edit' => 'Can edit',
|
||||
'perfil.delete' => 'Can delete',
|
||||
'perfil.menu' => 'Menu shall be visualize',
|
||||
'direcciones.create' => 'Can create',
|
||||
'direcciones.edit' => 'Can edit',
|
||||
'direcciones.delete' => 'Can delete',
|
||||
'direcciones.menu' => 'Menu shall be visualize',
|
||||
'presupuesto.create' => 'Can create',
|
||||
'presupuesto.edit' => 'Can edit',
|
||||
'presupuesto.delete' => 'Can delete',
|
||||
@ -61,6 +65,10 @@ const SK_PERMISSIONS = [
|
||||
'paises.edit' => 'Can edit',
|
||||
'paises.delete' => 'Can delete',
|
||||
'paises.menu' => 'Menu shall be visualize',
|
||||
'formas-pago.create' => 'Can create',
|
||||
'formas-pago.edit' => 'Can edit',
|
||||
'formas-pago.delete' => 'Can delete',
|
||||
'formas-pago.menu' => 'Menu shall be visualize',
|
||||
'maquinas.create' => 'Can create',
|
||||
'maquinas.edit' => 'Can edit',
|
||||
'maquinas.delete' => 'Can delete',
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
const SK_ROLES = [
|
||||
'admin' => [
|
||||
'title' => 'Administrador',
|
||||
'description' => '',
|
||||
'description' => 'Administrador del ERP',
|
||||
],
|
||||
'cliente-admin' => [
|
||||
'title' => 'Cliente administrador',
|
||||
|
||||
@ -9,6 +9,7 @@ use CodeIgniter\Router\RouteCollection;
|
||||
//service('auth')->routes($routes, ['except' => ['login', 'register']]);
|
||||
service('auth')->routes($routes);
|
||||
|
||||
|
||||
//WEB ROUTER ------------------------------------------------------
|
||||
//------------------------------------------------------------------
|
||||
$routes->get('/', 'Home::index', ['as' => 'home']);
|
||||
@ -51,7 +52,6 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function (
|
||||
$routes->get('delete/(:num)', 'TarifaAcabadosLineas::delete/$1', ['as' => 'tarifaAcabadoLineasDelete']);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/* Rutas para configuraciones */
|
||||
@ -65,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 */
|
||||
@ -86,7 +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->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']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -364,32 +376,11 @@ $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']);
|
||||
});
|
||||
|
||||
/* Precios */
|
||||
/*$routes->group('precios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
$routes->post('datatable', 'ClientePrecios::datatable', ['as' => 'clientePreciosDT']);
|
||||
$routes->post('datatable_editor', 'ClientePrecios::datatable_editor', ['as' => 'clientePreciosDTE']);
|
||||
});*/
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*$routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
$routes->get('', 'Cliente::index', ['as' => 'clienteList']);
|
||||
$routes->get('add', 'Cliente::add', ['as' => 'newCliente']);
|
||||
$routes->post('add', 'Cliente::add', ['as' => 'createCliente']);
|
||||
$routes->post('create', 'Cliente::create', ['as' => 'ajaxCreateCliente']);
|
||||
$routes->put('(:num)/update', 'Cliente::update/$1', ['as' => 'ajaxUpdateCliente']);
|
||||
$routes->post('edit/(:num)', 'Cliente::edit/$1', ['as' => 'updateCliente']);
|
||||
$routes->get('delete/(:num)', 'Cliente::delete/$1', ['as' => 'deleteCliente']);
|
||||
$routes->post('datatable', 'Cliente::datatable', ['as' => 'dataTableOfClientes']);
|
||||
$routes->post('allmenuitems', 'Cliente::allItemsSelect', ['as' => 'select2ItemsOfClientes']);
|
||||
|
||||
});
|
||||
$routes->resource('cliente', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Cliente', 'except' => 'show,new,create,update']);*/
|
||||
|
||||
$routes->group('clienteprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
$routes->post('datatable', 'ClientePrecios::datatable', ['as' => 'dataTableOfClienteprecios']);
|
||||
$routes->post('datatable_editor', 'ClientePrecios::datatable_editor', ['as' => 'editorOfClienteprecios']);
|
||||
@ -420,6 +411,15 @@ $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']);
|
||||
});
|
||||
|
||||
|
||||
$routes->group('formas-pagos', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'Formaspagos::index', ['as' => 'formaDePagoList']);
|
||||
$routes->get('add', 'Formaspagos::add', ['as' => 'newFormaDePago']);
|
||||
@ -572,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']);
|
||||
@ -581,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']);
|
||||
|
||||
@ -599,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) {
|
||||
@ -625,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']);
|
||||
@ -639,7 +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->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']);
|
||||
|
||||
@ -737,6 +737,83 @@ $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) {
|
||||
|
||||
/* Interna */
|
||||
$routes->group('internos', ['namespace' => 'App\Controllers\Mensajeria'], function ($routes) {
|
||||
|
||||
$routes->get('', 'MensajesDirectos::index', ['as' => 'mensajeriaView']);
|
||||
$routes->get('chat/(:num)', 'MensajesDirectos::getChatInfo/$1', ['as' => 'getChatInfo']);
|
||||
/*$routes->match(['get', 'post'], 'add', 'TarifaAcabados::add', ['as' => 'tarifaAcabadoAdd']);
|
||||
$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']);
|
||||
$routes->get('department/presupuesto/(:num)/(:num)', 'ChatController::get_chat_presupuesto/$1/$2', ['as' => 'getChatPresupuesto']);
|
||||
$routes->get('department/pedido/(:num)/(:num)', 'ChatController::get_chat_pedido/$1/$2', ['as' => 'getChatPedido']);
|
||||
$routes->get('department/factura/(:num)/(:num)', 'ChatController::get_chat_factura/$1/$2', ['as' => 'getChatFactura']);
|
||||
$routes->get('department/(:num)/users', 'ChatController::get_chat_department_users/$1', ['as' => 'getChatDepartmentUsers']);
|
||||
|
||||
|
||||
$routes->get('(:num)', 'ChatController::get_chat/$1', ['as' => 'getChat']);
|
||||
$routes->post('message/presupuesto', 'ChatController::store_chat_message_presupuesto', ['as' => 'storeChatMessagePresupuesto']);
|
||||
$routes->post('message/pedido', 'ChatController::store_chat_message_pedido', ['as' => 'storeChatMessagePedido']);
|
||||
$routes->post('message/factura', 'ChatController::store_chat_message_factura', ['as' => 'storeChatMessageFactura']);
|
||||
$routes->post('message/internal', 'ChatController::store_chat_message_single', ['as' => 'storeChatMessageSingle']);
|
||||
$routes->get('contacts', 'ChatController::get_chat_internal_contacts', ['as' => 'getChatInternalContacts']);
|
||||
$routes->get('contacts/(:num)', 'ChatController::get_chat_internal_contact/$1', ['as' => 'getChatInternalContact']);
|
||||
$routes->get('contact/(:num)/messages', 'ChatController::get_chat_internal_messages/$1', ['as' => 'getChatInternalMessages']);
|
||||
$routes->get('notifications', 'ChatController::get_chat_cliente/$1', ['as' => 'getChatCliente']);
|
||||
$routes->get('users/internal', 'ChatController::get_chat_users_internal', ['as' => 'getChatUsersInternal']);
|
||||
$routes->post('hebra/presupuesto', 'ChatController::store_hebra_presupuesto', ['as' => 'storeHebraPresupuesto']);
|
||||
$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"]);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* APIs Route Definitions
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
$routes->post('auth/jwt', '\App\Controllers\Sistema\AuthAPIController::jwtLogin');
|
||||
|
||||
$routes->group('api', ['filter' => 'jwt'], static function ($routes) {
|
||||
$routes->get('test', 'Test::echo');
|
||||
// ...
|
||||
});
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* 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' => '']);
|
||||
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Additional Routing
|
||||
@ -752,4 +829,4 @@ $routes->resource('buscadorpresupuestos', ['namespace' => 'App\Controllers\Presu
|
||||
*/
|
||||
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
|
||||
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Config;
|
||||
|
||||
use App\Services\FTPService;
|
||||
use CodeIgniter\Config\BaseService;
|
||||
|
||||
/**
|
||||
|
||||
420
ci4/app/Controllers/Chat/ChatController.php
Normal file
420
ci4/app/Controllers/Chat/ChatController.php
Normal file
@ -0,0 +1,420 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Chat;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Chat\ChatDeparmentModel;
|
||||
use App\Models\Chat\ChatDeparmentUserModel;
|
||||
use App\Models\Chat\ChatMessageModel;
|
||||
use App\Models\Chat\ChatModel;
|
||||
use App\Models\ChatNotification;
|
||||
use App\Models\ChatUser;
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\Log\Logger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ChatController extends BaseController
|
||||
{
|
||||
protected ChatDeparmentModel $chatDeparmentModel;
|
||||
protected ChatDeparmentUserModel $chatDeparmentUserModel;
|
||||
protected ChatModel $chatModel;
|
||||
protected ChatMessageModel $chatMessageModel;
|
||||
protected UserModel $userModel;
|
||||
protected ClienteModel $clienteModel;
|
||||
protected ChatUser $chatUserModel;
|
||||
protected ChatNotification $chatNotificationModel;
|
||||
|
||||
|
||||
|
||||
|
||||
public function initController(
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
// Add your code here.
|
||||
$this->chatDeparmentModel = model(ChatDeparmentModel::class);
|
||||
$this->chatDeparmentUserModel = model(ChatDeparmentUserModel::class);
|
||||
$this->chatModel = model(ChatModel::class);
|
||||
$this->chatMessageModel = model(ChatMessageModel::class);
|
||||
$this->userModel = model(UserModel::class);
|
||||
$this->clienteModel = model(ClienteModel::class);
|
||||
$this->chatUserModel = model(ChatUser::class);
|
||||
$this->chatNotificationModel = model(ChatNotification::class);
|
||||
|
||||
|
||||
}
|
||||
public function index() {}
|
||||
public function get_chat_departments()
|
||||
{
|
||||
|
||||
$data = $this->chatDeparmentModel->getChatDepartments();
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_chat_presupuesto(int $chat_department_id, int $presupuesto_id)
|
||||
{
|
||||
|
||||
$data = [
|
||||
"chat" => null,
|
||||
"messages" => null,
|
||||
"count" => 0,
|
||||
];
|
||||
$chat = $this->chatModel->getChatPresupuesto($chat_department_id, $presupuesto_id);
|
||||
if ($chat) {
|
||||
$data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id);
|
||||
$this->chatMessageModel->set_chat_department_messages_as_read($chat->id);
|
||||
$data["count"] = count($data["messages"]);
|
||||
}
|
||||
$data["chat"] = $chat;
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_chat_pedido(int $chat_department_id, int $pedido_id)
|
||||
{
|
||||
|
||||
$data = [
|
||||
"chat" => null,
|
||||
"messages" => null,
|
||||
"count" => 0,
|
||||
];
|
||||
$chat = $this->chatModel->getChatPedido($chat_department_id, $pedido_id);
|
||||
if ($chat) {
|
||||
$data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id);
|
||||
$this->chatMessageModel->set_chat_department_messages_as_read($chat->id);
|
||||
$data["count"] = count($data["messages"]);
|
||||
|
||||
}
|
||||
$data["chat"] = $chat;
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_chat_factura(int $chat_department_id, int $factura_id)
|
||||
{
|
||||
|
||||
$data = [
|
||||
"chat" => null,
|
||||
"messages" => null,
|
||||
"count" => 0,
|
||||
];
|
||||
$chat = $this->chatModel->getChatFactura($chat_department_id, $factura_id);
|
||||
if ($chat) {
|
||||
$data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id);
|
||||
$this->chatMessageModel->set_chat_department_messages_as_read($chat->id);
|
||||
$data["count"] = count($data["messages"]);
|
||||
}
|
||||
$data["chat"] = $chat;
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_chat(int $chat_id)
|
||||
{
|
||||
|
||||
$data = $this->chatModel->getChat($chat_id);
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function store_chat_message_presupuesto()
|
||||
{
|
||||
|
||||
$data = $this->request->getPost();
|
||||
// $data = $this->chatModel->createChatPresupuesto();
|
||||
$existChat = $this->chatModel->existChatPresupuesto($data["chat_department_id"], $data["model_id"]);
|
||||
if ($existChat == false) {
|
||||
$chatId = $this->chatModel->createChatPresupuesto($data["chat_department_id"], $data["model_id"]);
|
||||
} else {
|
||||
$chat = $this->chatModel->getChatPresupuesto($data["chat_department_id"], $data["model_id"]);
|
||||
$chatId = $chat->id;
|
||||
}
|
||||
$chat_message_id = $this->chatMessageModel->insert(["chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"]]);
|
||||
$dataResponse = $this->chatMessageModel->find($chat_message_id);
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
public function store_chat_message_pedido()
|
||||
{
|
||||
|
||||
$data = $this->request->getPost();
|
||||
$existChat = $this->chatModel->existChatPedido($data["chat_department_id"], $data["model_id"]);
|
||||
if ($existChat == false) {
|
||||
$chatId = $this->chatModel->createChatPedido($data["chat_department_id"], $data["model_id"]);
|
||||
} else {
|
||||
$chat = $this->chatModel->getChatPedido($data["chat_department_id"], $data["model_id"]);
|
||||
$chatId = $chat->id;
|
||||
}
|
||||
$chat_message_id = $this->chatMessageModel->insert(["chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"]]);
|
||||
$dataResponse = $this->chatMessageModel->find($chat_message_id);
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
public function store_chat_message_factura()
|
||||
{
|
||||
|
||||
$data = $this->request->getPost();
|
||||
$existChat = $this->chatModel->existChatFactura($data["chat_department_id"], $data["model_id"]);
|
||||
if ($existChat == false) {
|
||||
$chatId = $this->chatModel->createChatFactura($data["chat_department_id"], $data["model_id"]);
|
||||
} else {
|
||||
$chat = $this->chatModel->getChatFactura($data["chat_department_id"], $data["model_id"]);
|
||||
$chatId = $chat->id;
|
||||
}
|
||||
$chat_message_id = $this->chatMessageModel->insert(["chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"]]);
|
||||
$dataResponse = $this->chatMessageModel->find($chat_message_id);
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
public function store_chat_message_single()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
|
||||
$existChat = $this->chatMessageModel->get_chat_contact_messages($data["receiver_id"]);
|
||||
if (count($existChat) > 0) {
|
||||
$chatId = $existChat[0]->chat_id;
|
||||
} else {
|
||||
$chatId = $this->chatModel->createChatSingle();
|
||||
}
|
||||
$chat_message_id = $this->chatMessageModel->insert(
|
||||
[
|
||||
"chat_id" => $chatId,
|
||||
"sender_id" => auth()->user()->id,
|
||||
"message" => $data["message"],
|
||||
"receiver_id" => $data["receiver_id"]
|
||||
]
|
||||
);
|
||||
$dataResponse = $this->chatMessageModel->find($chat_message_id);
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
public function get_chat_internal_contacts()
|
||||
{
|
||||
if (auth()->user()->cliente_id) {
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
$users = $this->userModel->builder()
|
||||
->where("cliente_id", null)
|
||||
->whereNotIn("id", [auth()->user()->id])
|
||||
->where("deleted_at", null)
|
||||
->get()->getResultObject();
|
||||
foreach ($users as $user) {
|
||||
$user->unreadMessages = $this->chatMessageModel->get_chat_unread_messages_count($user->id);
|
||||
}
|
||||
usort($users, fn($a, $b) => $a->unreadMessages < $b->unreadMessages);
|
||||
return $this->response->setJSON($users);
|
||||
}
|
||||
public function get_chat_internal_contact(int $user_id)
|
||||
{
|
||||
if (auth()->user()->cliente_id) {
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
$users = $this->userModel->builder()
|
||||
->where("cliente_id", null)
|
||||
->where("deleted_at", null)
|
||||
->where("id", $user_id)
|
||||
->get()->getFirstRow();
|
||||
$this->chatMessageModel->set_chat_messages_as_read($user_id);
|
||||
return $this->response->setJSON($users);
|
||||
}
|
||||
public function get_chat_internal_messages(int $user_id)
|
||||
{
|
||||
$conversation = $this->chatMessageModel->get_chat_contact_messages($user_id);
|
||||
return $this->response->setJSON($conversation);
|
||||
}
|
||||
public function get_chat_cliente()
|
||||
{
|
||||
$cliente_id = auth()->user()->cliente_id;
|
||||
$response = [];
|
||||
if ($cliente_id) {
|
||||
$data = $this->clienteModel->getClienteDataPresupuestoPedidoFactura($cliente_id);
|
||||
$response["totalMessages"] = 0;
|
||||
$response["chatFacturas"] = $this->chatModel->getClienteChatFacturas($data["facturas"]);
|
||||
foreach ($response["chatFacturas"] as $key => $value) {
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
}
|
||||
$response["chatPresupuestos"] = $this->chatModel->getClienteChatPresupuestos($data["presupuestos"]);
|
||||
foreach ($response["chatPresupuestos"] as $key => $value) {
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
}
|
||||
$response["chatPedidos"] = $this->chatModel->getClienteChatPedidos($data["pedidos"]);
|
||||
foreach ($response["chatPedidos"] as $key => $value) {
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
}
|
||||
$response["data"] = $data;
|
||||
} else {
|
||||
$response["internals"] = $this->chatModel->getChatDepartmentNotifications();
|
||||
$internal_notifications = $this->chatModel->getChatInternalNotifications();
|
||||
foreach ($internal_notifications as $value) {
|
||||
$response["internals"][] = $value;
|
||||
}
|
||||
$response["totalMessages"] = 0;
|
||||
foreach ($response["internals"] as $key => $value) {
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
public function get_chat_department_users(int $chat_department_id)
|
||||
{
|
||||
$data = $this->chatDeparmentModel->getChatDepartmentUsers($chat_department_id);
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_chat_users_internal()
|
||||
{
|
||||
$query = $this->userModel->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"CONCAT(first_name,' ',last_name,'(',username,')') as name"
|
||||
]
|
||||
)->where("cliente_id", null)
|
||||
->where("deleted_at", null)
|
||||
->whereNotIn("id",[auth()->user()->id]);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("users.username", $this->request->getGet("q"))
|
||||
->orLike("CONCAT(first_name,' ',last_name)", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
}
|
||||
public function store_hebra_presupuesto()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chat_id = $this->chatModel->insert([
|
||||
"presupuesto_id" => $bodyData["modelId"],
|
||||
"title" => $bodyData["title"]
|
||||
]);
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"message" => $bodyData["message"],
|
||||
"sender_id" => auth()->user()->id
|
||||
]);
|
||||
if(isset($bodyData["users"])){
|
||||
$chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]);
|
||||
$this->chatUserModel->insertBatch($chatUserData);
|
||||
foreach ($bodyData["users"] as $userId) {
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $userId]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]);
|
||||
}
|
||||
|
||||
public function store_hebra_pedido()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chat_id = $this->chatModel->insert([
|
||||
"pedido_id" => $bodyData["modelId"],
|
||||
"title" => $bodyData["title"]
|
||||
|
||||
]);
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"message" => $bodyData["message"],
|
||||
"sender_id" => auth()->user()->id
|
||||
]);
|
||||
if(isset($bodyData["users"])){
|
||||
$chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]);
|
||||
$this->chatUserModel->insertBatch($chatUserData);
|
||||
foreach ($bodyData["users"] as $userId) {
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $userId]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]);
|
||||
}
|
||||
|
||||
public function store_hebra_factura()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chat_id = $this->chatModel->insert([
|
||||
"factura_id" => $bodyData["modelId"],
|
||||
"title" => $bodyData["title"]
|
||||
]);
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"message" => $bodyData["message"],
|
||||
"sender_id" => auth()->user()->id
|
||||
]);
|
||||
if(isset($bodyData["users"])){
|
||||
$chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]);
|
||||
$this->chatUserModel->insertBatch($chatUserData);
|
||||
foreach ($bodyData["users"] as $userId) {
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $userId]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]);
|
||||
|
||||
}
|
||||
public function update_hebra($chat_id)
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"message" => $bodyData["message"],
|
||||
"sender_id" => auth()->user()->id
|
||||
]);
|
||||
$actualUsers = $this->chatUserModel->builder()->select("user_id")->where("chat_id",$chat_id)->get()->getResultArray();
|
||||
$actualUsersArray = array_map(fn($x) => $x["user_id"],$actualUsers);
|
||||
foreach ($actualUsersArray as $key => $user_id) {
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $user_id]);
|
||||
}
|
||||
if(isset($bodyData["users"])){
|
||||
foreach ($bodyData["users"] as $userId) {
|
||||
if(in_array($userId,$actualUsersArray) == false){
|
||||
$chatUserData = ["user_id" => $userId,"chat_id" => $chat_id];
|
||||
$this->chatUserModel->insert($chatUserData);
|
||||
|
||||
}
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $userId]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra actualizada correctamente","status" => true]);
|
||||
}
|
||||
public function get_hebra_presupuesto($presupuesto_id){
|
||||
$data = $this->chatModel->getPresupuestoHebras($presupuesto_id);
|
||||
$notifications = $this->chatModel->builder()->select([
|
||||
"chat_notifications.id"
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chats.presupuesto_id",$presupuesto_id)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->get()->getResultArray();
|
||||
foreach ($notifications as $notification) {
|
||||
$this->chatNotificationModel->update($notification["id"],["viewed" => true]);
|
||||
}
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_hebra_pedido($pedido_id){
|
||||
$data = $this->chatModel->getPedidoHebras($pedido_id);
|
||||
$notifications = $this->chatModel->builder()->select([
|
||||
"chat_notifications.id"
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chats.pedido_id",$pedido_id)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->get()->getResultArray();
|
||||
foreach ($notifications as $notification) {
|
||||
$this->chatNotificationModel->update($notification["id"],["viewed" => true]);
|
||||
}
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_hebra_factura($factura_id){
|
||||
$data = $this->chatModel->getFacturaHebras($factura_id);
|
||||
$notifications = $this->chatModel->builder()->select([
|
||||
"chat_notifications.id"
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chats.factura_id",$factura_id)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->get()->getResultArray();
|
||||
foreach ($notifications as $notification) {
|
||||
$this->chatNotificationModel->update($notification["id"],["viewed" => true]);
|
||||
}
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Clientes;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Clientes;
|
||||
|
||||
|
||||
|
||||
@ -152,7 +154,7 @@ class Cliente extends \App\Controllers\BaseResourceController
|
||||
return $this->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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Clientes;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Clientes;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
@ -6,6 +8,8 @@ use App\Entities\Clientes\ClienteDireccionesEntity;
|
||||
|
||||
use App\Models\Clientes\ClienteDireccionesModel;
|
||||
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
use DataTables\Editor;
|
||||
use DataTables\Editor\Field;
|
||||
use DataTables\Editor\Validate;
|
||||
@ -22,21 +26,69 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
|
||||
protected static $controllerSlug = 'clientedirecciones';
|
||||
|
||||
public function add(){
|
||||
protected static $viewPath = 'themes/vuexy/form/clientes/direcciones/';
|
||||
|
||||
protected $indexRoute = 'clienteDireccionesList';
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('Clientes.direccionesEnvio');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
$this->viewData = ['usingServerSideDataTable' => true]; // JJO
|
||||
|
||||
// Breadcrumbs (IMN)
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Clientes.direccionesEnvio"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
|
||||
];
|
||||
|
||||
$this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null);
|
||||
$this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteEntity->provincia_id ?? null);
|
||||
$this->viewData['paisList'] = $this->getPaisListItems($clienteEntity->pais_id ?? null);
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$id = auth()->user()->id;
|
||||
$user_model = new UserModel();
|
||||
$user = $user_model->find($id);
|
||||
$cliente_id = $user->cliente_id;
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Clientes.cliente')]),
|
||||
'cliente_id' => $cliente_id,
|
||||
"user_id" => $id,
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewClienteDireccionesList', $viewData);
|
||||
}
|
||||
|
||||
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,
|
||||
@ -50,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);
|
||||
}
|
||||
@ -68,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 = [
|
||||
@ -89,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()) {
|
||||
@ -96,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);
|
||||
@ -111,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);
|
||||
}
|
||||
@ -135,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()) {
|
||||
@ -145,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();
|
||||
@ -221,9 +378,46 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPaisListItems($selId = null)
|
||||
{
|
||||
$paisModel = model('App\Models\Configuracion\PaisModel');
|
||||
$onlyActiveOnes = true;
|
||||
$data = $paisModel->getAllForMenu('id, nombre', 'nombre', $onlyActiveOnes);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getComunidadAutonomaListItems($selId = null)
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])];
|
||||
if (!is_null($selId)) :
|
||||
$comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel');
|
||||
|
||||
$selOption = $comunidadAutonomaModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getProvinciaListItems($selId = null)
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])];
|
||||
if (!empty($selId)) :
|
||||
$provinciaModel = model('App\Models\Configuracion\ProvinciaModel');
|
||||
|
||||
$selOption = $provinciaModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
81
ci4/app/Controllers/Configuracion/ConfigErrores.php
Normal file
81
ci4/app/Controllers/Configuracion/ConfigErrores.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Presupuestos\ErrorPresupuesto as ErrorPresupuestoModel;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
|
||||
class ConfigErrores extends BaseResourceController
|
||||
{
|
||||
|
||||
protected ErrorPresupuestoModel $errorPresupuestoModel;
|
||||
protected $format = 'json';
|
||||
protected array $viewData = [];
|
||||
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/error_presupuesto/';
|
||||
protected static $controllerSlug = "errores-presupuesto";
|
||||
protected $indexRoute = 'viewErrorPresupuestoList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->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()->orderBy("created_at", "DESC");
|
||||
return DataTable::of($query)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
}
|
||||
92
ci4/app/Controllers/Configuracion/ConfigVariables.php
Normal file
92
ci4/app/Controllers/Configuracion/ConfigVariables.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Configuracion\ConfigVariableModel;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
|
||||
class ConfigVariables extends BaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = ConfigVariableModel::class;
|
||||
protected ConfigVariableModel $configVariableModel;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Variables';
|
||||
protected static $singularObjectNameCc = 'variables';
|
||||
protected static $pluralObjectName = 'Variables';
|
||||
protected static $pluralObjectNameCc = 'variables';
|
||||
|
||||
protected static $controllerSlug = 'variables';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/variables/';
|
||||
|
||||
protected $indexRoute = 'viewVariablesList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->configVariableModel = model(ConfigVariableModel::class);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . $this->indexRoute, $viewData);
|
||||
}
|
||||
public function store()
|
||||
{
|
||||
$data = [];
|
||||
$variableCreated = $this->configVariableModel->store($data);
|
||||
return $this->response->setJSON($variableCreated);
|
||||
}
|
||||
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)
|
||||
{
|
||||
$reqData = [];
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
$status = $this->configVariableModel->update($config_variable_id, $reqData);
|
||||
return $this->response->setJSON([
|
||||
"message" => "Variable actualizada correctamente",
|
||||
"status" => $status
|
||||
]);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
public function deleteVariable(int $config_variable_id): Response
|
||||
{
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = $this->configVariableModel->builder()->select([
|
||||
"id",
|
||||
"name",
|
||||
"value",
|
||||
"description"
|
||||
])->orderBy("name", "asc");
|
||||
return DataTable::of($query)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
<?php
|
||||
namespace App\Controllers\Configuracion;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -12,8 +13,8 @@ use App\Models\Configuracion\MaquinasTarifasImpresionModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Editor\Field;
|
||||
DataTables\Editor,
|
||||
DataTables\Editor\Field;
|
||||
|
||||
class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
@ -69,9 +70,9 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -81,10 +82,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -98,14 +99,14 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -129,25 +130,25 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$maquinasTarifasImpresion = $this->model->find($id);
|
||||
|
||||
if ($maquinasTarifasImpresion == false) :
|
||||
if ($maquinasTarifasImpresion == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -160,10 +161,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -180,12 +181,12 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $maquinasTarifasImpresion->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -220,30 +221,48 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
$response = Editor::inst($db, 'lg_maquinas_tarifas_impresion')
|
||||
->fields(
|
||||
Field::inst('uso')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.uso.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.uso.required')
|
||||
)
|
||||
),
|
||||
Field::inst('tipo')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
|
||||
)
|
||||
),
|
||||
Field::inst('precio')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal'))
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
|
||||
)
|
||||
),
|
||||
Field::inst('margen')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal'))
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
|
||||
)
|
||||
),
|
||||
Field::inst('maquina_id'),
|
||||
Field::inst('user_created_id'),
|
||||
@ -269,16 +288,21 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
'maquina_id' => $values['maquina_id'],
|
||||
'tipo' => $values['tipo'],
|
||||
'uso' => $values['uso'],
|
||||
'is_deleted' => 0));
|
||||
'is_deleted' => 0
|
||||
));
|
||||
|
||||
$id = $builder->get()->getFirstRow()->id;
|
||||
$id = $builder->get()->getFirstRow();
|
||||
if ($id) {
|
||||
$id = $id->id;
|
||||
// No se pueden duplicar valores al crear o al editar
|
||||
if ($builder->countAllResults() >= 1) {
|
||||
if (
|
||||
($action === Editor::ACTION_EDIT && $id != $pkey)
|
||||
|| $action === Editor::ACTION_CREATE
|
||||
) {
|
||||
|
||||
// No se pueden duplicar valores al crear o al editar
|
||||
if ($builder->countAllResults() >= 1) {
|
||||
if (($action === Editor::ACTION_EDIT && $id != $pkey)
|
||||
|| $action === Editor::ACTION_CREATE) {
|
||||
|
||||
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
||||
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -413,11 +437,11 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
protected function getMaquinaListItems($selId = null)
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
|
||||
if (!empty($selId)) :
|
||||
if (!empty($selId)):
|
||||
$maquinaModel = model('App\Models\Configuracion\MaquinaModel');
|
||||
|
||||
$selOption = $maquinaModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
if (!empty($selOption)):
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
|
||||
use App\Entities\Usuarios\UserEntity;
|
||||
|
||||
use App\Models\Chat\ChatDeparmentModel;
|
||||
use App\Models\Chat\ChatDeparmentUserModel;
|
||||
use App\Models\Usuarios\GroupModel;
|
||||
|
||||
use App\Models\UserModel;
|
||||
@ -16,6 +16,9 @@ class Users extends \App\Controllers\GoBaseController
|
||||
private $group_model;
|
||||
private $group_user_model;
|
||||
private $user_model;
|
||||
private ChatDeparmentModel $chat_department_model;
|
||||
private ChatDeparmentUserModel $chat_department_user_model;
|
||||
|
||||
|
||||
|
||||
use \CodeIgniter\API\ResponseTrait;
|
||||
@ -38,6 +41,9 @@ class Users extends \App\Controllers\GoBaseController
|
||||
$this->group_model = new GroupModel();
|
||||
$this->group_user_model = new GroupsUsersModel();
|
||||
$this->user_model = new UserModel();
|
||||
$this->chat_department_model = model(ChatDeparmentModel::class);
|
||||
$this->chat_department_user_model = model(ChatDeparmentUserModel::class);
|
||||
|
||||
|
||||
$this->viewData['pageTitle'] = lang('Users.moduleTitle');
|
||||
|
||||
@ -76,7 +82,10 @@ class Users extends \App\Controllers\GoBaseController
|
||||
}
|
||||
// Obtener los grupos a los que pertenece
|
||||
$currentGroups = $postData['group'] ?? [];
|
||||
$chatDepartments = $postData['chatDepartments'] ?? [];
|
||||
unset($postData['group']);
|
||||
unset($postData['chatDepartments']);
|
||||
|
||||
// Generar el nombre de usuario
|
||||
$postData['username'] = strstr($postData['email'], '@', true);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
@ -128,6 +137,14 @@ class Users extends \App\Controllers\GoBaseController
|
||||
];
|
||||
$this->group_user_model->insert($group_user_data);
|
||||
}
|
||||
$this->chat_department_user_model->where("user_id",$id)->delete();
|
||||
foreach($chatDepartments as $chatDepartment)
|
||||
{
|
||||
$this->chat_department_user_model->insert([
|
||||
"user_id" => $id,
|
||||
"chat_department_id" => $this->chat_department_model->where("name",$chatDepartment)->first()["id"]
|
||||
]);
|
||||
}
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Users.user'))]) . '.';
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
@ -150,6 +167,7 @@ class Users extends \App\Controllers\GoBaseController
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems();
|
||||
$this->viewData['formAction'] = route_to('createUser');
|
||||
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
||||
$this->viewData['chatDepartments'] = $this->chat_department_model->findAll();
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Users.user') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
@ -176,7 +194,10 @@ class Users extends \App\Controllers\GoBaseController
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$currentGroups = $postData['group'] ?? [];
|
||||
$chatDepartments = $postData['chatDepartments'] ?? [];
|
||||
|
||||
unset($postData['group']);
|
||||
unset($postData['chatDepartments']);
|
||||
|
||||
// Obtener contraseña nueva si se ha introducido en texto plano
|
||||
// Obtener contraseña nueva si se ha introducido en texto plano
|
||||
@ -233,7 +254,14 @@ class Users extends \App\Controllers\GoBaseController
|
||||
];
|
||||
$this->group_user_model->insert($group_user_data);
|
||||
}
|
||||
|
||||
$this->chat_department_user_model->where("user_id",$id)->delete();
|
||||
foreach($chatDepartments as $chatDepartment)
|
||||
{
|
||||
$this->chat_department_user_model->insert([
|
||||
"user_id" => $id,
|
||||
"chat_department_id" => $this->chat_department_model->where("name",$chatDepartment)->first()["id"]
|
||||
]);
|
||||
}
|
||||
$id = $user->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Users.user'))]) . '.';
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
@ -256,6 +284,8 @@ class Users extends \App\Controllers\GoBaseController
|
||||
$this->viewData['formAction'] = route_to('updateUser', $id);
|
||||
$this->viewData['selectedGroups'] = $this->group_model->getUsersRoles($requestedId);
|
||||
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
||||
$this->viewData['chatDepartments'] = $this->chat_department_model->select(["display","name","id as chatDepartmentId"])->findAll();
|
||||
$this->viewData['chatDepartmentUser'] = $this->chat_department_user_model->getChatDepartmentUser($user->id);
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Users.user') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
|
||||
@ -41,6 +41,17 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
public function index()
|
||||
{
|
||||
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
// 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;
|
||||
} else {
|
||||
$clienteId = 0;
|
||||
}
|
||||
|
||||
$this->viewData['cliente_id'] = $clienteId;
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifaextra.tarifaextra')]);
|
||||
@ -64,6 +75,17 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
['title' => lang("Facturas.facturaList"), 'route' => "javascript:void(0);", 'active' => true]
|
||||
];
|
||||
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
// 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;
|
||||
} else {
|
||||
$clienteId = 0;
|
||||
}
|
||||
|
||||
$viewData['cliente_id'] = $clienteId;
|
||||
|
||||
return view(static::$viewPath . 'viewFacturasList', $viewData);
|
||||
}
|
||||
|
||||
@ -105,6 +127,10 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
$sanitizedData['user_created_id'] = auth()->user()->id;
|
||||
|
||||
if(!$sanitizedData['creditoAsegurado']){
|
||||
$sanitizedData['creditoAsegurado'] = 0;
|
||||
}
|
||||
|
||||
if ($allData && $successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
@ -205,13 +231,14 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||
$order = FacturaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
$cliente_id = $reqData['cliente_id'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$resourceData = $this->model->getResource($search, $cliente_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource("")->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
$this->model->getResource("", $cliente_id)->countAllResults(),
|
||||
$this->model->getResource($search, $cliente_id)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
|
||||
@ -117,5 +117,13 @@ class Js_loader extends BaseController
|
||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||
return view('themes/vuexy/form/presupuestos/cliente/previews.js');
|
||||
}
|
||||
|
||||
function chat_js()
|
||||
{
|
||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||
return view('themes/vuexy/form/mensajes/mensajeria.js');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
64
ci4/app/Controllers/Mensajeria/MensajesDirectos.php
Normal file
64
ci4/app/Controllers/Mensajeria/MensajesDirectos.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php namespace App\Controllers\Mensajeria;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Entities\Mensajeria\ConversacionEntity;
|
||||
use App\Entities\Sistema\ActivityEntity;
|
||||
use App\Models\CollectionModel;
|
||||
use App\Models\Mensajeria\ConversacionModel;
|
||||
use App\Models\Sistema\ActivityModel;
|
||||
|
||||
class MensajesDirectos extends BaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = ConversacionModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $controllerSlug = 'mensajes-internos';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/mensajes/';
|
||||
|
||||
protected static $indexRoute = 'mensajesView';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = "Mensajeria interna";
|
||||
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => "Home", 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_mensajes"), 'route' => route_to('mensajeriaView'), 'active' => true]
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view(static::$viewPath . static::$indexRoute);
|
||||
}
|
||||
|
||||
|
||||
public function getChatInfo($conversacionId)
|
||||
{
|
||||
// Modelos
|
||||
$conversacionModel = model('App\Models\Mensajeria\ConversacionModel');
|
||||
|
||||
// Verificar si es una solicitud AJAX
|
||||
if ($this->request->isAJAX()) {
|
||||
// Obtener los datos
|
||||
$data = [
|
||||
'people' => $conversacionModel->getChatParticipants($conversacionId),
|
||||
'messages' => $conversacionModel->getChatMessages($conversacionId)
|
||||
];
|
||||
|
||||
// Devolver respuesta JSON
|
||||
return $this->respond($data, 200, 'Chat information retrieved successfully');
|
||||
} else {
|
||||
return $this->failForbidden('Only AJAX requests are allowed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ use App\Controllers\BaseController;
|
||||
use App\Entities\Pedidos\PedidoEntity;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Pedidos\PedidoModel;
|
||||
|
||||
use App\Services\PedidoXMLService;
|
||||
|
||||
class Pedido extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
@ -21,7 +21,6 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
|
||||
protected $indexRoute = 'pedidoList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('Pedidos.moduleTitle');
|
||||
@ -41,6 +40,17 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
public function index()
|
||||
{
|
||||
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
// 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;
|
||||
} else {
|
||||
$clienteId = -1;
|
||||
}
|
||||
|
||||
$this->viewData['cliente_id'] = $clienteId;
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifaextra.tarifaextra')]);
|
||||
@ -53,13 +63,24 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
|
||||
'presupuestoEntity' => new PedidoEntity(),
|
||||
'pedidoEntity' => new PedidoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
'pageTitle' => lang('Pedidos.Pedidos'),
|
||||
'estadoPedidos' => 'activo',
|
||||
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
|
||||
];
|
||||
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
// 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;
|
||||
} else {
|
||||
$clienteId = -1;
|
||||
}
|
||||
|
||||
$viewData['cliente_id'] = $clienteId;
|
||||
|
||||
return view(static::$viewPath . 'viewPedidosList', $viewData);
|
||||
}
|
||||
|
||||
@ -68,13 +89,24 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
|
||||
'presupuestoEntity' => new PedidoEntity(),
|
||||
'pedidoEntity' => new PedidoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
'pageTitle' => lang('Pedidos.Pedidos'),
|
||||
'estadoPedidos' => 'finalizado',
|
||||
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
|
||||
];
|
||||
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
// 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;
|
||||
} else {
|
||||
$clienteId = -1;
|
||||
}
|
||||
|
||||
$viewData['cliente_id'] = $clienteId;
|
||||
|
||||
return view(static::$viewPath . 'viewPedidosList', $viewData);
|
||||
}
|
||||
|
||||
@ -83,13 +115,24 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
|
||||
'presupuestoEntity' => new PedidoEntity(),
|
||||
'pedidoEntity' => new PedidoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
'pageTitle' => lang('Pedidos.Pedidos'),
|
||||
'estadoPedidos' => 'cancelado',
|
||||
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
|
||||
];
|
||||
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
// 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;
|
||||
} else {
|
||||
$clienteId = -1;
|
||||
}
|
||||
|
||||
$viewData['cliente_id'] = $clienteId;
|
||||
|
||||
return view(static::$viewPath . 'viewPedidosList', $viewData);
|
||||
}
|
||||
|
||||
@ -99,13 +142,24 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
|
||||
'presupuestoEntity' => new PedidoEntity(),
|
||||
'pedidoEntity' => new PedidoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
'pageTitle' => lang('Pedidos.Pedidos'),
|
||||
'estadoPedidos' => 'todos',
|
||||
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
|
||||
];
|
||||
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
// 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;
|
||||
} else {
|
||||
$clienteId = -1;
|
||||
}
|
||||
|
||||
$viewData['cliente_id'] = $clienteId;
|
||||
|
||||
return view(static::$viewPath . 'viewPedidosList', $viewData);
|
||||
|
||||
}
|
||||
@ -243,6 +297,7 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$order = PedidoModel::SORTABLE_TODOS[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
$estado = $reqData['estado'] ?? 'todos';
|
||||
$cliente_id = $reqData['cliente_id'] ?? -1;
|
||||
if($estado == 'todos') $estado = '';
|
||||
|
||||
$showTotal = $reqData['showTotal'] ?? false;
|
||||
@ -250,9 +305,9 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$searchValues = get_filter_datatables_columns($reqData);
|
||||
|
||||
$model_linea = model('\App\Models\Pedidos\PedidoLineaModel');
|
||||
$resourceData = $model_linea->getResource($searchValues, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$totalTirada = $model_linea->getSumOfTirada($searchValues, $estado, $start, $length);
|
||||
$total = $model_linea->getSumOfTotalAceptado($searchValues, $estado, $start, $length);
|
||||
$resourceData = $model_linea->getResource($searchValues, $estado, $cliente_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$totalTirada = $model_linea->getSumOfTirada($searchValues, $estado, $cliente_id, $start, $length);
|
||||
$total = $model_linea->getSumOfTotalAceptado($searchValues, $estado, $cliente_id, $start, $length);
|
||||
$total2 = 0;
|
||||
if($showTotal){
|
||||
$total2 = $model_linea->getTotalOfTotalAceptado();
|
||||
@ -327,5 +382,11 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$pedidoEntity->fecha_encuadernado_text = $pedidoEntity->fecha_encuadernado ? date('d/m/Y', strtotime($pedidoEntity->fecha_encuadernado)) : '';
|
||||
$pedidoEntity->fecha_entrega_externo_text = $pedidoEntity->fecha_entrega_externo ? date('d/m/Y', strtotime($pedidoEntity->fecha_entrega_externo)) : '';
|
||||
}
|
||||
public function get_xml_pedido($pedido_id)
|
||||
{
|
||||
$data = PedidoXMLService::generate_xml($pedido_id);
|
||||
// $xml_service = new PedidoXMLService($this->model);
|
||||
return $this->respond($data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1278,8 +1278,8 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController
|
||||
$input_data['is_duplicado'] = $presupuestoEntity->is_duplicado;
|
||||
|
||||
if($presupuestoEntity->papel_formato_personalizado){
|
||||
$input_data['ancho'] = $presupuestoEntity->ancho;
|
||||
$input_data['alto'] = $presupuestoEntity->alto;
|
||||
$input_data['ancho'] = $presupuestoEntity->papel_formato_ancho ;
|
||||
$input_data['alto'] = $presupuestoEntity->papel_formato_alto ;
|
||||
}
|
||||
else{
|
||||
$model = model("App\Models\Configuracion\PapelFormatoModel");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -110,7 +110,7 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
$proveedor_id = $reqData['proveedor_id'] ?? 0;
|
||||
}
|
||||
else{
|
||||
$solapas = $reqData['solapas'] ?? -1;
|
||||
$solapas = $reqData['solapas'] ?? 0;
|
||||
}
|
||||
$paginas = $reqData['paginas'] ?? 0;
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
|
||||
78
ci4/app/Controllers/Sistema/AuthAPIController.php
Normal file
78
ci4/app/Controllers/Sistema/AuthAPIController.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Sistema;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Shield\Authentication\Authenticators\Session;
|
||||
use CodeIgniter\Shield\Authentication\JWTManager;
|
||||
use CodeIgniter\Shield\Validation\ValidationRules;
|
||||
|
||||
class AuthAPIController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
/**
|
||||
* Authenticate Existing User and Issue JWT.
|
||||
*/
|
||||
public function jwtLogin(): ResponseInterface
|
||||
{
|
||||
// Get the validation rules
|
||||
$rules = $this->getValidationRules();
|
||||
|
||||
// Validate credentials
|
||||
if (! $this->validateData($this->request->getJSON(true), $rules, [], config('Auth')->DBGroup)) {
|
||||
return $this->fail(
|
||||
['errors' => $this->validator->getErrors()],
|
||||
$this->codes['unauthorized']
|
||||
);
|
||||
}
|
||||
|
||||
// Get the credentials for login
|
||||
$credentials = $this->request->getJsonVar(setting('Auth.validFields'));
|
||||
$credentials = array_filter($credentials);
|
||||
$credentials['password'] = $this->request->getJsonVar('password');
|
||||
|
||||
/** @var Session $authenticator */
|
||||
$authenticator = auth('session')->getAuthenticator();
|
||||
|
||||
// Check the credentials
|
||||
$result = $authenticator->check($credentials);
|
||||
|
||||
// Credentials mismatch.
|
||||
if (! $result->isOK()) {
|
||||
// @TODO Record a failed login attempt
|
||||
|
||||
return $this->failUnauthorized($result->reason());
|
||||
}
|
||||
|
||||
// Credentials match.
|
||||
// @TODO Record a successful login attempt
|
||||
|
||||
$user = $result->extraInfo();
|
||||
|
||||
/** @var JWTManager $manager */
|
||||
$manager = service('jwtmanager');
|
||||
|
||||
// Generate JWT and return to client
|
||||
$jwt = $manager->generateToken($user);
|
||||
|
||||
return $this->respond([
|
||||
'access_token' => $jwt,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rules that should be used for validation.
|
||||
*
|
||||
* @return array<string, array<string, array<string>|string>>
|
||||
* @phpstan-return array<string, array<string, string|list<string>>>
|
||||
*/
|
||||
protected function getValidationRules(): array
|
||||
{
|
||||
$rules = new ValidationRules();
|
||||
|
||||
return $rules->getLoginRules();
|
||||
}
|
||||
}
|
||||
@ -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');
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
<?php
|
||||
namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -10,15 +11,15 @@ use App\Entities\Tarifas\TarifaEncuadernacionLinea;
|
||||
use App\Models\Tarifas\TarifaEncuadernacionLineaModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
|
||||
|
||||
class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
@ -73,9 +74,9 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -84,10 +85,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -101,14 +102,14 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -134,20 +135,20 @@ class Tarifaencuadernacionlineas 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);
|
||||
$tarifaEncuadernacionLinea = $this->model->find($id);
|
||||
|
||||
if ($tarifaEncuadernacionLinea == false) :
|
||||
if ($tarifaEncuadernacionLinea == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -156,10 +157,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -176,12 +177,12 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $tarifaEncuadernacionLinea->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -214,45 +215,90 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas')
|
||||
->fields(
|
||||
Field::inst('paginas_libro_min')
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal'))
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('paginas_libro_max')
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal'))
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')
|
||||
)
|
||||
),
|
||||
Field::inst('precio_min')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('precio_max')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')
|
||||
)
|
||||
),
|
||||
Field::inst('total_min')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('margen')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required')
|
||||
)
|
||||
),
|
||||
Field::inst('tirada_encuadernacion_id'),
|
||||
Field::inst('user_created_id'),
|
||||
@ -322,10 +368,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
|
||||
$cleandatatable = $reqData['cleandatatable'] ?? 0;
|
||||
|
||||
if($cleandatatable){
|
||||
|
||||
if ($cleandatatable) {
|
||||
|
||||
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
|
||||
|
||||
@ -338,11 +384,9 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
} else {
|
||||
|
||||
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);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
<?php
|
||||
namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -10,15 +11,15 @@ use App\Entities\Tarifas\TarifaEncuadernacionLinea;
|
||||
use App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
|
||||
|
||||
class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceController
|
||||
@ -71,9 +72,9 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -82,10 +83,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -99,14 +100,14 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -134,20 +135,20 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$tarifaEncuadernacionLinea = $this->model->find($id);
|
||||
|
||||
if ($tarifaEncuadernacionLinea == false) :
|
||||
if ($tarifaEncuadernacionLinea == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -156,10 +157,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -176,12 +177,12 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $tarifaEncuadernacionLinea->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -214,40 +215,79 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas_horas')
|
||||
->fields(
|
||||
Field::inst('tiempo_min')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('tiempo_max')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')
|
||||
)
|
||||
),
|
||||
Field::inst('precio_hora')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('total_min')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('margen')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required')
|
||||
)
|
||||
),
|
||||
Field::inst('tirada_encuadernacion_id'),
|
||||
Field::inst('user_created_id'),
|
||||
@ -314,10 +354,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
|
||||
$cleandatatable = $reqData['cleandatatable'] ?? 0;
|
||||
|
||||
if($cleandatatable){
|
||||
|
||||
if ($cleandatatable) {
|
||||
|
||||
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
|
||||
|
||||
@ -330,9 +370,8 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
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);
|
||||
|
||||
@ -126,15 +126,6 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\BaseResourceControlle
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required'))
|
||||
),
|
||||
Field::inst('precio_min')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal'))
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required'))
|
||||
),
|
||||
Field::inst('proveedor_id')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required'))
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -100,7 +102,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
if ($this->request->getPost('servicio_encuadernacion') == null) {
|
||||
$sanitizedData['servicio_encuadernacion'] = false;
|
||||
}
|
||||
|
||||
|
||||
if ($this->request->getPost('por_horas') == null) {
|
||||
$sanitizedData['por_horas'] = false;
|
||||
}
|
||||
@ -146,7 +148,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
|
||||
$this->viewData['tarifaEncuadernacionEntity'] = isset($sanitizedData) ? new TarifaEncuadernacionEntity($sanitizedData) : new TarifaEncuadernacionEntity();
|
||||
|
||||
$this->viewData['formAction'] = site_url('tarifas/tarifasencuadernacion/add');//route_to('createTarifaEncuadernacion');
|
||||
$this->viewData['formAction'] = site_url('tarifas/tarifasencuadernacion/add'); //route_to('createTarifaEncuadernacion');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
@ -171,7 +173,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -188,7 +190,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
|
||||
$sanitizedData['mostrar_en_presupuesto'] = false;
|
||||
}
|
||||
|
||||
|
||||
if ($this->request->getPost('tipo_encuadernacion') == null) {
|
||||
$sanitizedData['tipo_encuadernacion'] = false;
|
||||
}
|
||||
@ -335,7 +337,8 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
private function getProveedores(){
|
||||
private function getProveedores()
|
||||
{
|
||||
$provTipoModel = new ProveedorTipoModel();
|
||||
$provModel = new ProveedorModel();
|
||||
|
||||
@ -343,12 +346,13 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
return $provModel->getProvList($tipoId);
|
||||
}
|
||||
|
||||
private function getDimensiones(){
|
||||
private function getDimensiones()
|
||||
{
|
||||
$dimensionModel = new TarifaEncuadernacionDimensionesModel();
|
||||
|
||||
$dimensiones = $dimensionModel->getDimensiones();
|
||||
foreach($dimensiones as $dim){
|
||||
$dim->label= lang("TarifaEncuadernacionLineas." . $dim->label);
|
||||
foreach ($dimensiones as $dim) {
|
||||
$dim->label = lang("TarifaEncuadernacionLineas." . $dim->label);
|
||||
}
|
||||
return $dimensiones;
|
||||
}
|
||||
|
||||
@ -18,6 +18,12 @@ class Test extends BaseController
|
||||
{
|
||||
}
|
||||
|
||||
public function echo(){
|
||||
|
||||
echo "echo";
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
/*
|
||||
@ -76,10 +82,10 @@ class Test extends BaseController
|
||||
|
||||
|
||||
|
||||
private function test_get_tirada_alt($tirada, $merma, $tipo_impresion_id,
|
||||
$json_data, $cliente_id, $ancho, $alto,
|
||||
$solapas_cubierta, $solapas_ancho_cubierta, $solapas_sobrecubierta, $solapas_ancho_sobrecubierta, $lomo)
|
||||
{
|
||||
private function test_get_tirada_alt($tirada, $merma, $tipo_impresion_id,
|
||||
$json_data, $cliente_id, $ancho, $alto,
|
||||
$solapas_cubierta, $solapas_ancho_cubierta, $solapas_sobrecubierta, $solapas_ancho_sobrecubierta, $lomo)
|
||||
{
|
||||
$values = [];
|
||||
|
||||
if ($json_data) {
|
||||
|
||||
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class ChatDepartments extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"auto_increment" => true
|
||||
],
|
||||
"name" => [
|
||||
"type" => "VARCHAR",
|
||||
"constraint" => '45',
|
||||
"unique" => true,
|
||||
],
|
||||
"display" => [
|
||||
"type" => "VARCHAR",
|
||||
"constraint" => '255',
|
||||
],
|
||||
"description" => [
|
||||
"type" => "TEXT",
|
||||
"null" => true,
|
||||
],
|
||||
"type" => [
|
||||
"type" => "ENUM",
|
||||
'constraint' => ['general', 'presupuesto', 'pedido'],
|
||||
'default' => 'general',
|
||||
],
|
||||
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->createTable("chat_departments", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
$this->forge->dropTable("chat_departments");
|
||||
}
|
||||
}
|
||||
81
ci4/app/Database/Migrations/2024-09-17-151440_ChatsTable.php
Normal file
81
ci4/app/Database/Migrations/2024-09-17-151440_ChatsTable.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\RawSql;
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class ChatsTable extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"auto_increment" => true
|
||||
],
|
||||
"chat_department_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"null" => true
|
||||
],
|
||||
"pedido_id" => [
|
||||
"type" => "INT",
|
||||
"constraint" => 16,
|
||||
"unsigned" => true,
|
||||
"null" => true
|
||||
],
|
||||
"presupuesto_id" => [
|
||||
"type" => "INT",
|
||||
"constraint" => 10,
|
||||
"unsigned" => true,
|
||||
"null" => true
|
||||
],
|
||||
"factura_id" => [
|
||||
"type" => "INT",
|
||||
"constraint" => 10,
|
||||
"unsigned" => true,
|
||||
"null" => true
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->dropTable("chat_conversaciones", true);
|
||||
$this->forge->dropTable("chat_mensajes", true);
|
||||
$this->forge->dropTable("chat_participantes", true);
|
||||
|
||||
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey('pedido_id', 'pedidos', 'id');
|
||||
$this->forge->addForeignKey('chat_department_id', 'chat_departments', 'id');
|
||||
$this->forge->addForeignKey('factura_id', 'facturas', 'id');
|
||||
$this->forge->addForeignKey('presupuesto_id', 'presupuestos', 'id');
|
||||
|
||||
|
||||
$this->forge->createTable("chats", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
$this->forge->dropTable("chats", true);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class ChatMessages extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"auto_increment" => true,
|
||||
],
|
||||
"chat_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true
|
||||
],
|
||||
|
||||
"sender_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"receiver_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"null" => true,
|
||||
],
|
||||
"message" => [
|
||||
"type" => "TEXT",
|
||||
],
|
||||
"viewed" => [
|
||||
"type" => "TEXT",
|
||||
"type" => "boolean",
|
||||
"default" => false,
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey(['receiver_id'], 'users', ['id']);
|
||||
$this->forge->addForeignKey(['sender_id'], 'users', ['id']);
|
||||
$this->forge->addForeignKey(['chat_id'], 'chats', ['id']);
|
||||
$this->forge->createTable("chat_messages", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("chat_messages", true);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class ChatDepartmentUsers extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"chat_department_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
"user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addForeignKey(["user_id"], "users", ["id"]);
|
||||
$this->forge->addForeignKey(["chat_department_id"], "chat_departments", ["id"]);
|
||||
$this->forge->createTable("chat_department_users", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("chat_department_users");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class ConfigVariablesApp extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"auto_increment" => true
|
||||
],
|
||||
"name" => [
|
||||
"type" => "VARCHAR",
|
||||
"constraint" => '45',
|
||||
"unique" => true,
|
||||
],
|
||||
"value" => [
|
||||
"type" => "VARCHAR",
|
||||
"constraint" => '255',
|
||||
"null" => true
|
||||
],
|
||||
"description" => [
|
||||
"type" => "TEXT",
|
||||
"null" => true
|
||||
],
|
||||
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->createTable("config_variables_app", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("config_variables_app");
|
||||
}
|
||||
}
|
||||
55
ci4/app/Database/Migrations/2024-10-12-151500_ChatUsers.php
Normal file
55
ci4/app/Database/Migrations/2024-10-12-151500_ChatUsers.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class ChatUsers extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"auto_increment" => true
|
||||
],
|
||||
"chat_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
"user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey(["user_id"], "users", ["id"]);
|
||||
$this->forge->addForeignKey(["chat_id"], "chats", ["id"]);
|
||||
$this->forge->createTable("chat_users", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("chat_users");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\RawSql;
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AlterChatTableAddTitleColumn extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
|
||||
"title" => [
|
||||
"type" => "VARCHAR",
|
||||
"constraint" => 255,
|
||||
"null" => true
|
||||
],
|
||||
|
||||
|
||||
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
|
||||
$this->forge->addColumn("chats",$this->COLUMNS);
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
$this->forge->dropColumn("chats","title");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class ChatNotifications extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"auto_increment" => true
|
||||
],
|
||||
"chat_message_id" => [
|
||||
"type" => "INT",
|
||||
],
|
||||
"user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
"viewed" => [
|
||||
"type" => "BOOLEAN",
|
||||
"default" => false
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey(["chat_message_id"], "chat_messages", ["id"]);
|
||||
$this->forge->addForeignKey(["user_id"], "users", ["id"]);
|
||||
$this->forge->createTable("chat_notifications", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("chat_notifications");
|
||||
}
|
||||
}
|
||||
89
ci4/app/Database/Seeds/ChatSeeder.php
Normal file
89
ci4/app/Database/Seeds/ChatSeeder.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Seeds;
|
||||
|
||||
use App\Models\Chat\ChatDeparmentModel;
|
||||
use App\Models\Chat\ChatDeparmentUserModel;
|
||||
use CodeIgniter\Database\Seeder;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
class ChatSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$data = [
|
||||
[
|
||||
"name" => "_produccion",
|
||||
"display" => "Producción",
|
||||
"users" => [
|
||||
"mbalbaci@safekat.com",
|
||||
"mari.cano@safekat.com",
|
||||
"beatriz@safekat.com",
|
||||
"imnavajas@coit.es",
|
||||
],
|
||||
],
|
||||
[
|
||||
"name" => "_pod",
|
||||
"display" => "POD",
|
||||
"users" => [
|
||||
"pod@safekat.com",
|
||||
"imnavajas@coit.es",
|
||||
],
|
||||
],
|
||||
[
|
||||
"name" => "_maquetacion",
|
||||
"display" => "Maquetación",
|
||||
"users" => [
|
||||
"maquetacion@safekat.com",
|
||||
"imnavajas@coit.es",
|
||||
],
|
||||
],
|
||||
// [
|
||||
// "name" => "_comercial",
|
||||
// "display" => "Comercial",
|
||||
// "users" => [
|
||||
// "incidencias@safekat.com",
|
||||
// ],
|
||||
// ],
|
||||
[
|
||||
"name" => "_incidencias",
|
||||
"display" => "Incidencias",
|
||||
"users" => [
|
||||
"incidencias@safekat.com",
|
||||
],
|
||||
],
|
||||
[
|
||||
"name" => "_logistica",
|
||||
"display" => "Logística",
|
||||
"users" => [
|
||||
"logistica@safekat.com",
|
||||
"imnavajas@coit.es",
|
||||
],
|
||||
],
|
||||
[
|
||||
"name" => "_admin",
|
||||
"display" => "Administración",
|
||||
"users" => [
|
||||
"contabilidad@safekat.com",
|
||||
"imnavajas@coit.es",
|
||||
],
|
||||
],
|
||||
];
|
||||
$chatDeparmentModel = model(ChatDeparmentModel::class);
|
||||
$chatDeparmentUsersModel = model(ChatDeparmentUserModel::class);
|
||||
$userModel = model(UserModel::class);
|
||||
foreach ($data as $row) {
|
||||
$chatDeparmentId = $chatDeparmentModel->insert(["name" => $row["name"], "display" => $row["display"]]);
|
||||
if (count($row["users"]) > 0) {
|
||||
foreach ($row["users"] as $mail) {
|
||||
$user = $userModel->like("username", explode("@",$mail)[0])->first();
|
||||
|
||||
if ($user) {
|
||||
echo $user->id."\r\n";
|
||||
$chatDeparmentUsersModel->insert(['user_id' => $user->id, "chat_department_id" => $chatDeparmentId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
37
ci4/app/Database/Seeds/DefaultConfigVariablesSeeder.php
Normal file
37
ci4/app/Database/Seeds/DefaultConfigVariablesSeeder.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Seeds;
|
||||
|
||||
use App\Models\Configuracion\ConfigVariableModel;
|
||||
use CodeIgniter\Database\Seeder;
|
||||
|
||||
class DefaultConfigVariablesSeeder extends Seeder
|
||||
{
|
||||
protected array $data = [
|
||||
[
|
||||
"name" => "tamanio_solapas_min",
|
||||
"value" => 50,
|
||||
"description" => "Mínimo tamaño solapas"
|
||||
],
|
||||
[
|
||||
"name" => "tamanio_solapas_max",
|
||||
"value" => 150,
|
||||
"description" => "Máximo tamaño solapas"
|
||||
],
|
||||
[
|
||||
"name" => "limite_produccion_diaria",
|
||||
"value" => 6000,
|
||||
"description" => "Número de libros máximos que se puede producir al día"
|
||||
],
|
||||
];
|
||||
public function run()
|
||||
{
|
||||
|
||||
$variableModel = model(ConfigVariableModel::class);
|
||||
foreach ($this->data as $row) {
|
||||
if($variableModel->where("name",$row["name"])->first() == null){
|
||||
$variableModel->insert($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
ci4/app/Entities/Mensajeria/ConversacionEntity.php
Normal file
28
ci4/app/Entities/Mensajeria/ConversacionEntity.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Mensajeria;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class ConversacionEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'pedido_libro_id' => null,
|
||||
'pedido_maquetacion_id' => null,
|
||||
'factura_id' => null,
|
||||
'departamento' => null,
|
||||
'asunto' => null,
|
||||
'created_at' => null,
|
||||
'updated_at' => null,
|
||||
'deleted_at' => null,
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
"pedido_libro_id" => "?int",
|
||||
"pedido_maquetacion_id" => "?int",
|
||||
"factura_id" => "?int"
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
26
ci4/app/Entities/Mensajeria/ParticipanteEntity.php
Normal file
26
ci4/app/Entities/Mensajeria/ParticipanteEntity.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Mensajeria;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class ParticipanteEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'conversacion_id' => null,
|
||||
'usuario_id' => null,
|
||||
'cliente_id' => null,
|
||||
'email' => null,
|
||||
'last_read' => null,
|
||||
'created_at' => null,
|
||||
'updated_at' => null,
|
||||
'deleted_at' => null,
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
"conversacion_id" => "?int",
|
||||
"usuario_id" => "?int",
|
||||
"cliente_id" => "?int"
|
||||
];
|
||||
}
|
||||
@ -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",
|
||||
];
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -15,6 +15,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity
|
||||
"precio_max" => 0,
|
||||
"tirada_min" => 0,
|
||||
"tirada_max" => 0,
|
||||
"total_min" => 0,
|
||||
"margen" => 0,
|
||||
"user_created_id" => 0,
|
||||
"user_updated_id" => 0,
|
||||
@ -31,6 +32,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity
|
||||
"precio_max" => "float",
|
||||
"tirada_min" => "float",
|
||||
"tirada_max" => "float",
|
||||
"total_min" => "float",
|
||||
"margen" => "float",
|
||||
"user_created_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
|
||||
@ -11,6 +11,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity
|
||||
"tiempo_min" => 0,
|
||||
"tiempo_max" => 0,
|
||||
"precio_hora" => 0,
|
||||
"total_min" => 0,
|
||||
"margen" => 0,
|
||||
"user_created_id" => 0,
|
||||
"user_updated_id" => 0,
|
||||
@ -22,6 +23,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity
|
||||
"tirada_encuadernacion_id" => "int",
|
||||
"tiempo_min" => "float",
|
||||
"tiempo_max" => "float",
|
||||
"total_min" => "float",
|
||||
"precio_hora" => "float",
|
||||
"margen" => "float",
|
||||
"user_created_id" => "int",
|
||||
|
||||
@ -11,7 +11,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity
|
||||
"tirada_min" => 0,
|
||||
"tirada_max" => 0,
|
||||
"proveedor_id" => 0,
|
||||
"precio_min" => 0,
|
||||
"importe_fijo" => 0,
|
||||
"user_created_id" => 0,
|
||||
"user_updated_id" => 0,
|
||||
@ -24,7 +23,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity
|
||||
"tirada_min" => "float",
|
||||
"tirada_max" => "float",
|
||||
"proveedor_id" => "int",
|
||||
"precio_min" => "float",
|
||||
"importe_fijo" => "float",
|
||||
"user_created_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -8,9 +8,9 @@ class TarifaextraEntity extends \CodeIgniter\Entity\Entity
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"code" => null,
|
||||
"comment" => null,
|
||||
"precio" => null,
|
||||
"precio_min" => 0,
|
||||
"importe_fijo" => 0,
|
||||
"margen" => 0,
|
||||
"mostrar_en_presupuesto" => 1,
|
||||
"user_created_id" => 1,
|
||||
@ -22,8 +22,8 @@ class TarifaextraEntity extends \CodeIgniter\Entity\Entity
|
||||
];
|
||||
protected $casts = [
|
||||
"precio" => "float",
|
||||
"precio_min" => "float",
|
||||
"importe_fijo" => "float",
|
||||
"code" => "string",
|
||||
"comment" => "string",
|
||||
"margen" => "float",
|
||||
"mostrar_en_presupuesto" => "int",
|
||||
"user_created_id" => "int",
|
||||
|
||||
@ -8,9 +8,9 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"code" => null,
|
||||
"comment" => null,
|
||||
"precio" => null,
|
||||
"precio_min" => 0,
|
||||
"importe_fijo" => 0,
|
||||
"margen" => 0,
|
||||
"mostrar_en_presupuesto" => 1,
|
||||
"user_created_id" => 1,
|
||||
@ -22,9 +22,9 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity
|
||||
];
|
||||
protected $casts = [
|
||||
"precio" => "float",
|
||||
"precio_min" => "float",
|
||||
"importe_fijo" => "float",
|
||||
"margen" => "float",
|
||||
"code" => "string",
|
||||
"comment" => "string",
|
||||
"mostrar_en_presupuesto" => "int",
|
||||
"user_created_id" => "int",
|
||||
"user_update_id" => "int",
|
||||
|
||||
0
ci4/app/Helpers/general_helper.php
Executable file → Normal file
0
ci4/app/Helpers/general_helper.php
Executable file → Normal file
@ -54,6 +54,9 @@ return [
|
||||
'userCreatedId' => 'User Created ID',
|
||||
'userUpdateId' => 'User Update ID',
|
||||
'vencimiento' => 'Vencimiento',
|
||||
|
||||
'direccionesEnvio' => 'Shipping Addresses',
|
||||
|
||||
'validation' => [
|
||||
'ccc' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -13,7 +13,7 @@ return [
|
||||
'nombre' => 'Name',
|
||||
'precioMax' => 'Price Max',
|
||||
'precioMin' => 'Price Min',
|
||||
'precioMin' => 'Min Price',
|
||||
'importeMinimo' => 'Min Price',
|
||||
'importeFijo' => 'Fixed amount',
|
||||
'mostrar_en_presupuesto' => 'Show in budget',
|
||||
'margen' => 'Margin',
|
||||
|
||||
@ -19,6 +19,7 @@ return [
|
||||
'updatedAt' => 'Updated At',
|
||||
'userCreatedId' => 'User Created ID',
|
||||
'userUpdateId' => 'User Update ID',
|
||||
'coste' => 'Cost',
|
||||
'validation' => [
|
||||
'nombre' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
@ -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",
|
||||
@ -670,15 +674,17 @@ return [
|
||||
|
||||
// MENUS
|
||||
"menu_dashboard" => "Panel de control",
|
||||
|
||||
"menu_clientes" => "Clientes",
|
||||
"menu_plantillas_tarifas_clientes" => "Plantillas Tarifas",
|
||||
"menu_perfil_clientes" => "Perfil",
|
||||
"menu_direcciones_clientes" => "Direcciones",
|
||||
"menu_cliente" => "Cliente",
|
||||
"menu_clientes_nuevo" => "Nuevo",
|
||||
"menu_tarifacliente" => "Tarifas",
|
||||
|
||||
"menu_configuration" => "Configuración",
|
||||
"menu_variables" => "Variables sistema",
|
||||
"menu_error_presupuesto" => "Errores presupuesto",
|
||||
"menu_calendario" => "Calendario",
|
||||
"menu_paises" => "Paises",
|
||||
"menu_correo" => "Correo",
|
||||
|
||||
14
ci4/app/Language/es/Chat.php
Normal file
14
ci4/app/Language/es/Chat.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
"chat" => "Mensajería",
|
||||
"messages" => "Mensajes",
|
||||
"modal" => [
|
||||
"new_hebra" => "Nueva hebra",
|
||||
"title" => "Título",
|
||||
"new_message" => "Nuevo mensaje",
|
||||
"new_receivers" => "Nuevos participantes",
|
||||
"btn_send" => "Enviar",
|
||||
"btn_send_update" => "Enviar"
|
||||
]
|
||||
];
|
||||
@ -46,6 +46,9 @@ return [
|
||||
'userCreatedId' => 'User Created ID',
|
||||
'userUpdateId' => 'User Update ID',
|
||||
'vencimiento' => 'Vencimiento',
|
||||
|
||||
'direccionesEnvio' => 'Direcciones de Envío',
|
||||
|
||||
'validation' => [
|
||||
'ccc' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
|
||||
22
ci4/app/Language/es/ConfigVariables.php
Normal file
22
ci4/app/Language/es/ConfigVariables.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
return [
|
||||
|
||||
"cardTitle" => "Variables del sistema",
|
||||
"modal" => [
|
||||
"title" => "Editar variable"
|
||||
],
|
||||
"datatable" =>
|
||||
[
|
||||
"columns" => [
|
||||
"name" => "Nombre",
|
||||
"value" => "Valor",
|
||||
"description" => "Descripción",
|
||||
]
|
||||
],
|
||||
"form" =>
|
||||
[
|
||||
"name" => "Nombre",
|
||||
"value" => "Valor",
|
||||
"description" => "Descripción",
|
||||
]
|
||||
];
|
||||
21
ci4/app/Language/es/ErrorPresupuesto.php
Normal file
21
ci4/app/Language/es/ErrorPresupuesto.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
return [
|
||||
|
||||
"cardTitle" => "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",
|
||||
]
|
||||
];
|
||||
@ -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 <b>cosido</b> debe ser múltiplo de 4',
|
||||
'paginas_pares' => 'El número de páginas debe ser par',
|
||||
],
|
||||
|
||||
'errores' => [
|
||||
|
||||
@ -27,6 +27,7 @@ return [
|
||||
'clientesSection' => 'Clientes',
|
||||
'plantillaTarifaSection' => 'Plantilla de tarifas',
|
||||
'perfilSection' => 'Perfil',
|
||||
'direccionesSection' => 'Direcciones',
|
||||
'presupuestoSection' => 'Presupuestos',
|
||||
'presupuestoClienteSection' => 'Presupuestos',
|
||||
'tarifaPreimpresionSection' => 'Tarifas de preimpresión',
|
||||
|
||||
@ -20,6 +20,10 @@ return [
|
||||
'menor_a5' =>'Hasta A5',
|
||||
'entre_a5_a4' =>'Entre A5 y A4',
|
||||
'mayor_a4' =>'Desde A4',
|
||||
'menor_a5_apaisado' =>'Hasta A5 apaisado',
|
||||
'entre_a5_a4_apaisado' =>'Entre A5 y A4 apaisado',
|
||||
'mayor_a4_apaisado' =>'Desde A4 apaisado',
|
||||
'210x210' =>'210x210',
|
||||
'por_defecto' =>'Genérico',
|
||||
'moduleExplanation' => 'El número de páginas reflejado en este apartado se refiere por ejemplar, no al total del pedido',
|
||||
'margen' => 'Margen',
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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',
|
||||
@ -18,6 +21,7 @@ return [
|
||||
'updatedAt' => 'Actualizado en',
|
||||
'userCreatedId' => 'ID Usuario \"Creado en\"',
|
||||
'userUpdateId' => 'ID Usuario \"Actualizado en\"',
|
||||
'coste' => 'Coste',
|
||||
'validation' => [
|
||||
'nombre' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
|
||||
@ -10,6 +10,10 @@ 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',
|
||||
'importeFijo' => 'Importe Fijo',
|
||||
|
||||
@ -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',
|
||||
@ -18,13 +21,23 @@ return [
|
||||
'updatedAt' => 'Actualizado en',
|
||||
'userCreatedId' => 'ID Usuario \"Creado en\"',
|
||||
'userUpdateId' => 'ID Usuario \"Actualizado en\"',
|
||||
'coste' => 'Coste',
|
||||
'validation' => [
|
||||
'nombre' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
'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.',
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -18,6 +18,7 @@ return [
|
||||
'emailConfirmed' => 'Email Confirmado',
|
||||
'firstName' => 'Nombre',
|
||||
'group' => 'Rol',
|
||||
'chatDepartments' => 'Chat departamento',
|
||||
'idUser' => 'ID Usuario',
|
||||
'language' => 'Idioma',
|
||||
'lastAccess' => 'Último acceso',
|
||||
|
||||
81
ci4/app/Libraries/SafekatFtpClient.php
Normal file
81
ci4/app/Libraries/SafekatFtpClient.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
use App\Models\Pedidos\PedidoLineaModel;
|
||||
use App\Models\Presupuestos\PresupuestoFicheroModel;
|
||||
use Exception;
|
||||
use phpseclib3\Net\SFTP;
|
||||
|
||||
class SafekatFtpClient
|
||||
{
|
||||
protected SFTP $ftp;
|
||||
protected string $host;
|
||||
protected int $port;
|
||||
protected string $username;
|
||||
protected string $password;
|
||||
protected string $base_dir;
|
||||
protected bool $xml_enabled;
|
||||
protected object $pedido_xml_config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pedido_xml_config = config("PedidoXML");
|
||||
$this->host = $this->pedido_xml_config->host;
|
||||
$this->username = $this->pedido_xml_config->username;
|
||||
$this->password = $this->pedido_xml_config->password;
|
||||
$this->port = $this->pedido_xml_config->port;
|
||||
$this->base_dir = $this->pedido_xml_config->base_dir;
|
||||
$this->xml_enabled = $this->pedido_xml_config->xml_enabled;
|
||||
$this->ftp = new SFTP($this->host);
|
||||
|
||||
}
|
||||
/**
|
||||
* Upload the content of $filename to the base directory declared in App\Config\FTP.php
|
||||
*
|
||||
* @param string $content
|
||||
* @param string $filename
|
||||
* @return boolean
|
||||
*/
|
||||
public function uploadXML(string $content, string $filename): bool
|
||||
{
|
||||
try {
|
||||
if ($this->xml_enabled == false) return false;
|
||||
$remotePath = implode("/", [$this->base_dir,'pedidos','xml_nuevos']);
|
||||
$this->ftp->login(username: $this->username, password: $this->password);
|
||||
if(!$this->ftp->is_dir($remotePath)){
|
||||
$this->ftp->mkdir($remotePath,recursive:true);
|
||||
}
|
||||
$this->ftp->put($remotePath.'/'.$filename, $content);
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
log_message('error', $th->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function uploadFilePresupuesto(int $presupuesto_id)
|
||||
{
|
||||
try {
|
||||
$model = model(PresupuestoFicheroModel::class);
|
||||
$modelPedidoLinea = model(PedidoLineaModel::class);
|
||||
$pedidoLinea = $modelPedidoLinea->findByPresupuesto($presupuesto_id);
|
||||
$rootIdExtern = 1e6 + $pedidoLinea->pedido_id;
|
||||
$presupuestoFiles = $model->getFiles($presupuesto_id);
|
||||
$this->ftp->login(username: $this->username, password: $this->password);
|
||||
foreach ($presupuestoFiles as $key => $value) {
|
||||
$filename = array_reverse(explode("/", $value->file_path))[0];
|
||||
$remoteDir = implode("/", [$this->base_dir,"pedidos_files",$rootIdExtern]);
|
||||
$remoteFile = implode("/", [$this->base_dir,"pedidos_files",$rootIdExtern,$filename]);
|
||||
if(!$this->ftp->is_dir($remoteDir)){
|
||||
$this->ftp->mkdir($remoteDir,recursive:true);
|
||||
}
|
||||
$this->ftp->put($remoteFile,$value->file_path,mode:$this->ftp::SOURCE_LOCAL_FILE);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
log_message('error', $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
134
ci4/app/Models/Chat/ChatDeparmentModel.php
Normal file
134
ci4/app/Models/Chat/ChatDeparmentModel.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Chat;
|
||||
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ChatDeparmentModel extends Model
|
||||
{
|
||||
protected $table = 'chat_departments';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"name",
|
||||
"display",
|
||||
"description",
|
||||
"type"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
public function getChatDepartments(string $type = "general"): array
|
||||
{
|
||||
$userModel = model(UserModel::class);
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
|
||||
$query = $this->db->table('chat_departments')
|
||||
->select(
|
||||
[
|
||||
|
||||
'chat_departments.id',
|
||||
'chat_departments.name',
|
||||
'chat_departments.display',
|
||||
'chat_department_users.user_id',
|
||||
'chats.id as chatId',
|
||||
]
|
||||
)
|
||||
->join(
|
||||
"chat_department_users",
|
||||
"chat_department_users.chat_department_id = chat_departments.id",
|
||||
'left'
|
||||
)
|
||||
->join("chats", "chats.chat_department_id = chat_departments.id", "left")
|
||||
->join(
|
||||
"users",
|
||||
"chat_department_users.user_id = users.id",
|
||||
'left'
|
||||
)->join(
|
||||
"chat_messages",
|
||||
"chat_messages.chat_id = chats.id",
|
||||
"left"
|
||||
)
|
||||
->where("chat_departments.type", $type);
|
||||
if (auth()->user()->cliente_id == null) {
|
||||
$query->where("chat_department_users.user_id", auth()->user()->id);
|
||||
}
|
||||
|
||||
$results = $query->get()->getResultArray();
|
||||
// Create the desired structure
|
||||
$departments = [];
|
||||
|
||||
foreach ($results as $row) {
|
||||
$departmentName = $row['name'];
|
||||
|
||||
// If the department is not yet added to the array, initialize it
|
||||
if (!isset($departments[$departmentName])) {
|
||||
$departments[$departmentName] = [
|
||||
'id' => $row['id'],
|
||||
'name' => $row['name'],
|
||||
'display' => $row['display'],
|
||||
'users' => [] // Initialize users as an empty array
|
||||
];
|
||||
}
|
||||
|
||||
// If user_id is not null, add the user to the department's 'users' array
|
||||
if ($row['user_id']) {
|
||||
$departments[$departmentName]['users'][] = $userModel->find($row["user_id"]);
|
||||
}
|
||||
}
|
||||
return $departments;
|
||||
}
|
||||
public function getChatDepartmentUsers(int $chat_deparment_id)
|
||||
{
|
||||
$result = $this->db->table('chat_departments')
|
||||
->select(
|
||||
[
|
||||
"users.*"
|
||||
]
|
||||
)
|
||||
->join(
|
||||
"chat_department_users",
|
||||
"chat_department_users.chat_department_id = chat_departments.id",
|
||||
'left'
|
||||
)
|
||||
->join(
|
||||
"users",
|
||||
"chat_department_users.user_id = users.id",
|
||||
'left'
|
||||
)->where("chat_departments.id", $chat_deparment_id)
|
||||
->get()->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
58
ci4/app/Models/Chat/ChatDeparmentUserModel.php
Normal file
58
ci4/app/Models/Chat/ChatDeparmentUserModel.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Chat;
|
||||
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ChatDeparmentUserModel extends Model
|
||||
{
|
||||
protected $table = 'chat_department_users';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"chat_department_id",
|
||||
"user_id"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
public function getChatDepartmentUser(int $user_id)
|
||||
{
|
||||
return $this->db->table($this->table." t1")
|
||||
->select("chat_departments.*")
|
||||
->join("chat_departments","t1.chat_department_id = chat_departments.id","left")
|
||||
->where("t1.user_id",$user_id)->get()->getResultObject();
|
||||
|
||||
}
|
||||
}
|
||||
144
ci4/app/Models/Chat/ChatMessageModel.php
Normal file
144
ci4/app/Models/Chat/ChatMessageModel.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Chat;
|
||||
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ChatMessageModel extends Model
|
||||
{
|
||||
protected $table = 'chat_messages';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"message",
|
||||
"chat_id",
|
||||
"sender_id",
|
||||
"receiver_id",
|
||||
"viewed"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Devuelve los mensajes del chat
|
||||
*
|
||||
* @param integer $chat_id
|
||||
* @return object
|
||||
*/
|
||||
public function get_chat_messages(int $chat_id): array
|
||||
{
|
||||
$user = model(UserModel::class);
|
||||
$messages = $this->builder()->where("chat_id", $chat_id)->orderBy("created_at", "asc")->get()->getResultObject();
|
||||
foreach ($messages as $message) {
|
||||
$message->pos = auth()->user()->id == $message->sender_id ? "right" : "left";
|
||||
if (auth()->user()->id == $message->sender_id) {
|
||||
$message->user = auth()->user();
|
||||
} else {
|
||||
$message->user = $user->find($message->sender_id);
|
||||
}
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
public function get_chat_contact_messages(int $receiver_id): array
|
||||
{
|
||||
$conversationArray = [];
|
||||
$userModel = model(UserModel::class);
|
||||
$receiverUser = $userModel->find($receiver_id);
|
||||
$messagesFromClient = $this->builder()
|
||||
->where("sender_id", auth()->user()->id)
|
||||
->where("receiver_id", $receiverUser->id)
|
||||
->get()->getResultObject();
|
||||
$messagesFromReceiver = $this->builder()
|
||||
->where("sender_id", $receiver_id)
|
||||
->where("receiver_id", auth()->user()->id)
|
||||
->get()->getResultObject();
|
||||
foreach ($messagesFromClient as $message) {
|
||||
$message->pos = "right";
|
||||
$message->user = auth()->user();
|
||||
$conversationArray[] = $message;
|
||||
}
|
||||
foreach ($messagesFromReceiver as $message) {
|
||||
$message->pos = "left";
|
||||
$message->user = $receiverUser;
|
||||
$conversationArray[] = $message;
|
||||
}
|
||||
$dates = array();
|
||||
foreach ($conversationArray as $key => $row) {
|
||||
$dates[$key] = strtotime($row->created_at);
|
||||
}
|
||||
array_multisort($dates, SORT_ASC, $conversationArray);
|
||||
return $conversationArray;
|
||||
}
|
||||
|
||||
public function get_chat_unread_messages_count(int $sender_id): int
|
||||
{
|
||||
$messagesFromReceiver = $this->builder()
|
||||
->where("sender_id", $sender_id)
|
||||
->where("viewed", false)
|
||||
->where("receiver_id", auth()->user()->id)->countAllResults();
|
||||
return $messagesFromReceiver;
|
||||
}
|
||||
public function set_chat_messages_as_read(int $sender_id): int
|
||||
{
|
||||
$messagesFromReceiver = $this->builder()
|
||||
->set("viewed", true)
|
||||
->where("sender_id", $sender_id)
|
||||
->where("receiver_id", auth()->user()->id)->update();
|
||||
return $messagesFromReceiver;
|
||||
}
|
||||
public function set_chat_department_messages_as_read(int $chat_id): int
|
||||
{
|
||||
$chatDepartmentModel = model(ChatDeparmentModel::class);
|
||||
$chatModel = model(ChatModel::class);
|
||||
|
||||
if(auth()->user()->cliente_id){
|
||||
$messagesFromReceiver = $this->builder()
|
||||
->set("viewed", true)
|
||||
->where("chat_id", $chat_id)
|
||||
->whereNotIn("sender_id", [auth()->user()->id])->update();
|
||||
}else{
|
||||
$chat_department_id = $chatModel->find($chat_id)->chat_department_id;
|
||||
$users_in_chat = array_map(fn($x) => $x->id, $chatDepartmentModel->getChatDepartmentUsers($chat_department_id));
|
||||
$messagesFromReceiver = $this->builder()
|
||||
->set("viewed", true)
|
||||
->where("chat_id", $chat_id)
|
||||
->whereNotIn("sender_id", $users_in_chat)
|
||||
->update();
|
||||
}
|
||||
|
||||
return $messagesFromReceiver;
|
||||
}
|
||||
|
||||
}
|
||||
544
ci4/app/Models/Chat/ChatModel.php
Normal file
544
ci4/app/Models/Chat/ChatModel.php
Normal file
@ -0,0 +1,544 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Chat;
|
||||
|
||||
use App\Models\ChatNotification;
|
||||
use App\Models\Facturas\FacturaModel;
|
||||
use App\Models\Pedidos\PedidoModel;
|
||||
use App\Models\Presupuestos\PresupuestoModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Model;
|
||||
use stdClass;
|
||||
|
||||
class ChatModel extends Model
|
||||
{
|
||||
protected $table = 'chats';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"pedido_id",
|
||||
"chat_department_id",
|
||||
"presupuesto_id",
|
||||
"factura_id",
|
||||
"title"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
|
||||
public function getChat(int $chat_id): array
|
||||
{
|
||||
return $this->db->table('chats')
|
||||
->select(
|
||||
[
|
||||
"chats.*",
|
||||
"chat_messages.created_at as messageCreatedAt",
|
||||
"chat_messages.message as messageText",
|
||||
]
|
||||
)
|
||||
->join("chat_messages", "chats.id = chat_messages.chat_id", "left")
|
||||
->orderBy("created_at", "desc")
|
||||
->where("chats.id", $chat_id)
|
||||
->get()->getResultObject();
|
||||
}
|
||||
public function getChatPresupuesto(int $chat_department_id, int $presupuesto_id)
|
||||
{
|
||||
return $this->builder()->where("presupuesto_id", $presupuesto_id)->where("chat_department_id", $chat_department_id)->get()->getFirstRow();
|
||||
}
|
||||
public function getChatPedido(int $chat_department_id, int $pedido_id)
|
||||
{
|
||||
return $this->builder()->where("pedido_id", $pedido_id)->where("chat_department_id", $chat_department_id)->get()->getFirstRow();
|
||||
}
|
||||
public function getChatFactura(int $chat_department_id, int $factura_id)
|
||||
{
|
||||
return $this->builder()->where("factura_id", $factura_id)->where("chat_department_id", $chat_department_id)->get()->getFirstRow();
|
||||
}
|
||||
|
||||
public function createChatPresupuesto(int $chat_department_id, int $presupuesto_id): int
|
||||
{
|
||||
return $this->insert([
|
||||
"presupuesto_id" => $presupuesto_id,
|
||||
"chat_department_id" => $chat_department_id
|
||||
]);
|
||||
}
|
||||
public function createChatPedido(int $chat_department_id, int $pedido_id) : int
|
||||
{
|
||||
|
||||
return $this->insert([
|
||||
"pedido_id" => $pedido_id,
|
||||
"chat_department_id" => $chat_department_id
|
||||
]);
|
||||
}
|
||||
public function createChatFactura(int $chat_department_id, int $factura_id) : int
|
||||
{
|
||||
|
||||
return $this->insert([
|
||||
"factura_id" => $factura_id,
|
||||
"chat_department_id" => $chat_department_id
|
||||
]);
|
||||
}
|
||||
public function createChatSingle() : int
|
||||
{
|
||||
return $this->insert(["chat_department_id" => null]);
|
||||
}
|
||||
public function existChatPresupuesto(int $chat_department_id, int $presupuesto_id): bool
|
||||
{
|
||||
$countChatPresupuesto = $this->builder()
|
||||
->where("presupuesto_id", $presupuesto_id)
|
||||
->where("chat_department_id", $chat_department_id)
|
||||
->countAllResults();
|
||||
return $countChatPresupuesto > 0;
|
||||
}
|
||||
public function existChatPedido(int $chat_department_id, int $pedido_id): bool
|
||||
{
|
||||
$countChatPresupuesto = $this->builder()
|
||||
->where("pedido_id", $pedido_id)
|
||||
->where("chat_department_id", $chat_department_id)
|
||||
->countAllResults();
|
||||
return $countChatPresupuesto > 0;
|
||||
}
|
||||
public function existChatFactura(int $chat_department_id, int $factura_id): bool
|
||||
{
|
||||
$countChatPresupuesto = $this->builder()
|
||||
->where("factura_id", $factura_id)
|
||||
->where("chat_department_id", $chat_department_id)
|
||||
->countAllResults();
|
||||
return $countChatPresupuesto > 0;
|
||||
}
|
||||
|
||||
public function getChatPedidosChat() : array
|
||||
{
|
||||
$query = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.pedido_id as pedidoId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"pedidos.id as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("pedidos","pedidos.id = chats.pedido_id","left")
|
||||
->get()->getResultObject();
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getChatPresupuestosChat() : array
|
||||
{
|
||||
$query = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.pedido_id as pedidoId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"presupuestos.titulo as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("presupuestos","presupuestos.id = chats.pedido_id","left")
|
||||
->get()->getResultObject();
|
||||
return $query;
|
||||
}
|
||||
public function getChatFacturasChat() : array
|
||||
{
|
||||
$query = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.pedido_id as pedidoId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"facturas.numero as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("facturas","facturas.id = chats.pedido_id","left")
|
||||
->get()->getResultObject();
|
||||
return $query;
|
||||
}
|
||||
public function getChatSingleChat() : array
|
||||
{
|
||||
$query = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"facturas.numero as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("facturas","facturas.id = chats.pedido_id","left")
|
||||
->get()->getResultObject();
|
||||
return $query;
|
||||
}
|
||||
public function getClienteChatPedidos(array $pedidos) : array
|
||||
{
|
||||
$q = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.pedido_id as pedidoId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"pedidos.id as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("pedidos","pedidos.id = chats.pedido_id","left")
|
||||
->where('chats.chat_department_id is NOT NULL', NULL, FALSE);
|
||||
if(count($pedidos)>0){
|
||||
$q->whereIn("pedidos.id",$pedidos);
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
$results = $q->get()->getResultObject();
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
$count = 0;
|
||||
foreach ($results as $row) {
|
||||
$messages = $chatMessageModel->get_chat_messages($row->chatId);
|
||||
foreach ($messages as $key => $message) {
|
||||
if($message->sender_id != auth()->user()->id && $message->viewed == false){
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$row->uri = "/pedidos/edit/".$row->pedidoId;
|
||||
$row->unreadMessages=$count;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
public function getClienteChatFacturas(array $facturas) : array
|
||||
{
|
||||
$q = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.factura_id as facturaId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"facturas.numero as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("facturas","facturas.id = chats.factura_id","left")
|
||||
->where('chats.chat_department_id is NOT NULL', NULL, FALSE);
|
||||
|
||||
if(count($facturas)>0){
|
||||
$q->whereIn("facturas.id",$facturas);
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
$results = $q->get()->getResultObject();
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
$count = 0;
|
||||
foreach ($results as $row) {
|
||||
$messages = $chatMessageModel->get_chat_messages($row->chatId);
|
||||
foreach ($messages as $key => $message) {
|
||||
if($message->sender_id != auth()->user()->id && $message->viewed == false){
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$row->uri = "/facturas/edit/".$row->facturaId;
|
||||
$row->unreadMessages=$count;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
public function getClienteChatPresupuestos(array $presupuestos) : array
|
||||
{
|
||||
$q = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.presupuesto_id as presupuestoId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"presupuestos.titulo as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("presupuestos","presupuestos.id = chats.presupuesto_id","left")
|
||||
->where('chats.chat_department_id is NOT NULL', NULL, FALSE);
|
||||
|
||||
if(count($presupuestos)>0){
|
||||
$q->whereIn("presupuestos.id",$presupuestos);
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
$results = $q->get()->getResultObject();
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
$count = 0;
|
||||
foreach ($results as $row) {
|
||||
$messages = $chatMessageModel->get_chat_messages($row->chatId);
|
||||
foreach ($messages as $key => $message ) {
|
||||
if($message->sender_id != auth()->user()->id && $message->viewed == false){
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$row->uri = "/presupuestos/presupuestocliente/edit/".$row->presupuestoId;
|
||||
$row->unreadMessages=$count;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
public function getChatDepartmentNotifications()
|
||||
{
|
||||
$chatDeparmentModel = model(ChatDeparmentModel::class);
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
$presupuestoModel = model(PresupuestoModel::class);
|
||||
$facturaModel = model(FacturaModel::class);
|
||||
$pedidoModel = model(PedidoModel::class);
|
||||
|
||||
$q = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.pedido_id as pedidoId",
|
||||
"chats.presupuesto_id as presupuestoId",
|
||||
"chats.factura_id as facturaId",
|
||||
"chats.presupuesto_id as presupuestoId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("chat_department_users","chat_department_users.chat_department_id = chats.chat_department_id","left")
|
||||
->where("chat_department_users.user_id",auth()->user()->id);
|
||||
$rows = $q->get()->getResultObject();
|
||||
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$messages = $chatMessageModel->get_chat_messages($row->chatId);
|
||||
$count = 0;
|
||||
$chatDeparmentUsers = $chatDeparmentModel->getChatDepartmentUsers($row->chatDepartmentId);
|
||||
$chatDeparmentUsersId = array_map(fn($x) => $x->id,$chatDeparmentUsers);
|
||||
foreach ($messages as $m) {
|
||||
if($m->viewed == false && $m->sender_id != auth()->user()->id && in_array($m->sender_id,$chatDeparmentUsersId) == false)
|
||||
$count++;
|
||||
}
|
||||
if($row->presupuestoId){
|
||||
$row->model = $presupuestoModel->find($row->presupuestoId);
|
||||
$row->uri = "/presupuestos/cosidotapablanda/edit/".$row->presupuestoId;
|
||||
$row->title = $row->presupuestoId;
|
||||
$row->avatar = "PRE";
|
||||
$row->unreadMessages = $count;
|
||||
}
|
||||
elseif($row->pedidoId){
|
||||
$row->model = $pedidoModel->find($row->pedidoId);
|
||||
$row->uri = "/pedidos/edit/".$row->pedidoId;
|
||||
$row->title = $row->pedidoId;
|
||||
$row->avatar = "P";
|
||||
$row->unreadMessages = $count;
|
||||
|
||||
}
|
||||
elseif($row->facturaId){
|
||||
$row->model = $facturaModel->find($row->facturaId);
|
||||
$row->uri = "/facturas/edit/".$row->facturaId;
|
||||
$row->avatar = "F";
|
||||
$row->title = $row->facturaId;
|
||||
$row->unreadMessages = $count;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
|
||||
}
|
||||
public function getChatInternalNotifications()
|
||||
{
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
$presupuestoModel = model(PresupuestoModel::class);
|
||||
$facturaModel = model(FacturaModel::class);
|
||||
$pedidoModel = model(PedidoModel::class);
|
||||
$chatNotificationModel = model(ChatNotification::class);
|
||||
|
||||
$q = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.pedido_id as pedidoId",
|
||||
"chats.presupuesto_id as presupuestoId",
|
||||
"chats.factura_id as facturaId",
|
||||
"chats.presupuesto_id as presupuestoId",
|
||||
"chats.title as chatDisplay"
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->where("chat_notifications.viewed",false);
|
||||
$rows = $q->get()->getResultObject();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if($row->presupuestoId){
|
||||
$row->model = $presupuestoModel->find($row->presupuestoId);
|
||||
$row->uri = "/presupuestos/cosidotapablanda/edit/".$row->presupuestoId;
|
||||
$row->title = $row->presupuestoId;
|
||||
$row->avatar = "PRE";
|
||||
$row->unreadMessages = $this->countUnreadMessagePresupuesto($row->presupuestoId);
|
||||
}
|
||||
elseif($row->pedidoId){
|
||||
$row->model = $pedidoModel->find($row->pedidoId);
|
||||
$row->uri = "/pedidos/edit/".$row->pedidoId;
|
||||
$row->title = $row->pedidoId;
|
||||
$row->avatar = "P";
|
||||
$row->unreadMessages = $this->countUnreadMessagePedido($row->pedidoId);
|
||||
|
||||
|
||||
}
|
||||
elseif($row->facturaId){
|
||||
$row->model = $facturaModel->find($row->facturaId);
|
||||
$row->uri = "/facturas/edit/".$row->facturaId;
|
||||
$row->avatar = "F";
|
||||
$row->title = $row->facturaId;
|
||||
$row->unreadMessages = $this->countUnreadMessageFactura($row->facturaId);
|
||||
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
public function getChatInternalHebraPresupuesto(int $chat_id,int $presupuesto_id) : array
|
||||
{
|
||||
|
||||
$data = [];
|
||||
$query = $this->builder()->select([
|
||||
"chats.id as chatId",
|
||||
"chat_messages.message",
|
||||
"users.username as senderUserName",
|
||||
"chat_messages.created_at",
|
||||
"CONCAT(users.first_name,' ',users.last_name) as senderFullName",
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("users","users.id = chat_messages.sender_id","left")
|
||||
->where("chats.id",$chat_id)
|
||||
->where("chats.presupuesto_id",$presupuesto_id);
|
||||
$data["chatId"] = $chat_id;
|
||||
$data["messages"] = $query->get()->getResultObject();
|
||||
$data["chatTitle"] = $this->find($chat_id)->title;
|
||||
$data["users"] = $this->getChatUsers($chat_id);
|
||||
return $data;
|
||||
}
|
||||
public function getChatInternalHebraPedido($chat_id,$pedido_id){
|
||||
$data = [];
|
||||
$query = $this->builder()->select([
|
||||
"chats.id as chatId",
|
||||
"chat_messages.message",
|
||||
"users.username as senderUserName",
|
||||
"chat_messages.created_at",
|
||||
"CONCAT(users.first_name,' ',users.last_name) as senderFullName",
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("users","users.id = chat_messages.sender_id","left")
|
||||
->where("chats.id",$chat_id)
|
||||
->where("chats.pedido_id",$pedido_id);
|
||||
$data["chatId"] = $chat_id;
|
||||
$data["messages"] = $query->get()->getResultObject();
|
||||
$data["chatTitle"] = $this->find($chat_id)->title;
|
||||
$data["users"] = $this->getChatUsers($chat_id);
|
||||
return $data;
|
||||
}
|
||||
public function getChatInternalHebraFactura($chat_id,$factura_id){
|
||||
$data = [];
|
||||
$query = $this->builder()->select([
|
||||
"chats.id as chatId",
|
||||
"chat_messages.message",
|
||||
"users.username as senderUserName",
|
||||
"chat_messages.created_at",
|
||||
"CONCAT(users.first_name,' ',users.last_name) as senderFullName",
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("users","users.id = chat_messages.sender_id","left")
|
||||
->where("chats.id",$chat_id)
|
||||
->where("chats.factura_id",$factura_id);
|
||||
$data["chatId"] = $chat_id;
|
||||
$data["messages"] = $query->get()->getResultObject();
|
||||
$data["chatTitle"] = $this->find($chat_id)->title;
|
||||
$data["users"] = $this->getChatUsers($chat_id);
|
||||
return $data;
|
||||
}
|
||||
public function getChatUsers(int $chat_id)
|
||||
{
|
||||
$query = $this->builder()->select([
|
||||
"users.username",
|
||||
"CONCAT(users.first_name,' ',users.last_name) as userFullName",
|
||||
])
|
||||
->join("chat_users","chat_users.chat_id = chats.id")
|
||||
->join("users","users.id = chat_users.user_id","left")
|
||||
->where("chats.id",$chat_id);
|
||||
return $query->get()->getResultObject();
|
||||
}
|
||||
public function getPresupuestoHebras($presupuesto_id) : array
|
||||
{
|
||||
$data = [];
|
||||
$chats = $this->builder()->select("chats.id as chatId")
|
||||
->where("chats.chat_department_id",null)
|
||||
->where("chats.presupuesto_id",$presupuesto_id)->get()->getResultObject();
|
||||
foreach ($chats as $chat) {
|
||||
$data[$chat->chatId] = $this->getChatInternalHebraPresupuesto($chat->chatId,$presupuesto_id);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function getPedidoHebras($pedido_id) : array
|
||||
{
|
||||
$data = [];
|
||||
$chats = $this->builder()->select("chats.id as chatId")
|
||||
->where("chats.chat_department_id",null)
|
||||
->where("chats.pedido_id",$pedido_id)->get()->getResultObject();
|
||||
foreach ($chats as $chat) {
|
||||
$data[$chat->chatId] = $this->getChatInternalHebraPedido($chat->chatId,$pedido_id);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function getFacturaHebras($factura_id) : array
|
||||
{
|
||||
$data = [];
|
||||
$chats = $this->builder()->select("chats.id as chatId")
|
||||
->where("chats.chat_department_id",null)
|
||||
->where("chats.factura_id",$factura_id)->get()->getResultObject();
|
||||
foreach ($chats as $chat) {
|
||||
$data[$chat->chatId] = $this->getChatInternalHebraFactura($chat->chatId,$factura_id);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function countUnreadMessagePresupuesto($presupuesto_id) : int|string
|
||||
{
|
||||
return $this->builder()->select()
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chats.presupuesto_id",$presupuesto_id)
|
||||
->where("chat_notifications.viewed",false)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->countAllResults();
|
||||
}
|
||||
public function countUnreadMessagePedido($pedido_id) : int|string
|
||||
{
|
||||
return $this->builder()->select()
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chats.pedido_id",$pedido_id)
|
||||
->where("chat_notifications.viewed",false)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->countAllResults();
|
||||
}
|
||||
public function countUnreadMessageFactura($factura_id) : int|string
|
||||
{
|
||||
return $this->builder()->select()
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chats.factura_id",$factura_id)
|
||||
->where("chat_notifications.viewed",false)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)->countAllResults();
|
||||
}
|
||||
}
|
||||
50
ci4/app/Models/ChatNotification.php
Normal file
50
ci4/app/Models/ChatNotification.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ChatNotification extends Model
|
||||
{
|
||||
protected $table = 'chat_notifications';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"chat_message_id",
|
||||
"user_id",
|
||||
"viewed"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
}
|
||||
49
ci4/app/Models/ChatUser.php
Normal file
49
ci4/app/Models/ChatUser.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ChatUser extends Model
|
||||
{
|
||||
protected $table = 'chat_users';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"user_id",
|
||||
"chat_id"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
}
|
||||
@ -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",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Clientes;
|
||||
|
||||
class ClienteModel extends \App\Models\BaseModel
|
||||
@ -293,30 +294,32 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->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,7 +332,61 @@ 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
|
||||
{
|
||||
$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",
|
||||
|
||||
])
|
||||
->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 = [];
|
||||
$pedidos = [];
|
||||
$result = [];
|
||||
foreach ($data as $row) {
|
||||
$facturas[] = $row->facturaId;
|
||||
$presupuestos[] = $row->presupuestoId;
|
||||
$pedidos[] = $row->pedidoId;
|
||||
}
|
||||
$result["facturas"] = array_unique(array_filter($facturas));
|
||||
$result["presupuestos"] = array_unique(array_filter($presupuestos));
|
||||
$result["pedidos"] = array_unique(array_filter($pedidos));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,6 +209,7 @@ class ProveedorModel extends \App\Models\BaseModel
|
||||
->select(
|
||||
"t1.id AS value, t1.nombre AS label, t1.propiedades AS options")
|
||||
->where("tipo_id", $tipoId)
|
||||
->where("is_deleted", 0)
|
||||
->orderBy('t1.nombre', 'asc');
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
|
||||
50
ci4/app/Models/Configuracion/ConfigVariableModel.php
Normal file
50
ci4/app/Models/Configuracion/ConfigVariableModel.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ConfigVariableModel extends Model
|
||||
{
|
||||
protected $table = 'config_variables_app';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"name",
|
||||
"value",
|
||||
"description"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class PapelFormatoModel extends \App\Models\BaseModel
|
||||
@ -72,25 +73,64 @@ class PapelFormatoModel extends \App\Models\BaseModel
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
*
|
||||
|
||||
@ -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 "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
public function getResource(string $search = "")
|
||||
public function getResource(string $search = "", $cliente_id=-1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -90,8 +90,16 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
$builder->join("formas_pago t4", "t3.forma_pago_id = t4.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
if(auth()->user()->inGroup("cliente-admin") || auth()->user()->inGroup("cliente-editor")) {
|
||||
$builder->where("t1.estado", "validada");
|
||||
}
|
||||
|
||||
if($cliente_id != -1) {
|
||||
$builder->where("t1.cliente_id", $cliente_id);
|
||||
}
|
||||
|
||||
$builder->groupBy("t1.id"); // Agrupa por id de la factura
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
|
||||
201
ci4/app/Models/Mensajeria/ConversacionModel.php
Normal file
201
ci4/app/Models/Mensajeria/ConversacionModel.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Mensajeria;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
|
||||
class ConversacionModel extends Model
|
||||
{
|
||||
protected $table = 'chat_conversaciones'; // Asegúrate de que este sea el nombre correcto de la tabla
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'App\Entities\Mensajeria\ConversacionEntity';
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $allowedFields = [
|
||||
'asunto',
|
||||
'pedido_libro_id',
|
||||
'pedido_maquetacion_id',
|
||||
'factura_id',
|
||||
'departamento'
|
||||
];
|
||||
|
||||
public function pedidoLibro()
|
||||
{
|
||||
return $this->db
|
||||
->table('pedido_libros')
|
||||
->where('id', $this->pedido_libro_id)
|
||||
->get()
|
||||
->getFirstRow();
|
||||
}
|
||||
|
||||
public function pedidoMaquetacion()
|
||||
{
|
||||
return $this->db
|
||||
->table('pedido_maquetaciones')
|
||||
->where('id', $this->pedido_maquetacion_id)
|
||||
->get()
|
||||
->getFirstRow();
|
||||
}
|
||||
|
||||
public function factura()
|
||||
{
|
||||
return $this->db
|
||||
->table('facturas')
|
||||
->where('id', $this->factura_id)
|
||||
->get()
|
||||
->getFirstRow();
|
||||
}
|
||||
|
||||
|
||||
public function getConversacion($convesacionId)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
//->select("t1.conversacion_id AS id, t2.asunto AS asunto")
|
||||
->where("t1.id", $convesacionId)
|
||||
->join("chat_participantes t2", "t2.conversacion_id = t1.id", "left")
|
||||
->join("chat_mensajes t3", "t3.conversacion_id = t1.id", "left")
|
||||
->orderBy('t1.created_at', 'DESC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getChatParticipants($chatId)
|
||||
{
|
||||
return $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t2.usuario_id as user_id, t3.first_name AS nombre, t3.last_name AS apellidos")
|
||||
->where("t1.id", $chatId)
|
||||
->join("chat_participantes t2", "t2.conversacion_id = t1.id", "left")
|
||||
->join("users t3", "t3.id = t2.usuario_id", "left")
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
public function getChatMessages($chatId)
|
||||
{
|
||||
return $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t2.mensaje AS mensaje, t2.usuario_id as user_id")
|
||||
->select("t3.first_name AS nombre, t3.last_name AS apellidos")
|
||||
->where("t1.id", intval($chatId))
|
||||
->join("chat_mensajes t2", "t2.conversacion_id = t1.id", "left")
|
||||
->join("users t3", "t3.id = t2.usuario_id", "left")
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Devuelve si la conversacion tiene algún cliente
|
||||
*/
|
||||
public function isClient()
|
||||
{
|
||||
$isCliente = false;
|
||||
$participantes = $this->participantes(); // Asegúrate de implementar este método
|
||||
foreach ($participantes as $p) {
|
||||
if (($p->user && $p->user->customer_id) || $p->customer_id) {
|
||||
$isCliente = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $isCliente;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si la conversacion del mensaje tiene el cliente
|
||||
*/
|
||||
public function haveCliente($userCustomer)
|
||||
{
|
||||
$customer_id = $userCustomer->customer_id;
|
||||
$participants = $this->participantes(); // Asegúrate de implementar este método
|
||||
|
||||
foreach ($participants as $p) {
|
||||
if ($p->customer_id && $p->customer_id === $customer_id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getParticipanteDesdeCliente($cliente_id)
|
||||
{
|
||||
return $this->db->table('chat_participantes')
|
||||
->where('cliente_id', $cliente_id)
|
||||
->where('conversacion_id', $this->id)
|
||||
->get()
|
||||
->getFirstRow();
|
||||
}
|
||||
|
||||
public function marcarLeidoCliente($cliente_id)
|
||||
{
|
||||
try {
|
||||
$participante = $this->getParticipanteDesdeCliente($cliente_id);
|
||||
if ($participante) {
|
||||
$this->db->table('chat_participantes')
|
||||
->where('id', $participante->id)
|
||||
->update(['last_read' => date('Y-m-d H:i:s')]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
public function marcarNoLeido($usuario_id)
|
||||
{
|
||||
try {
|
||||
$participante = $this->getParticipanteDesdeUsuario($usuario_id); // Asegúrate de implementar este método
|
||||
if ($participante) {
|
||||
$this->db->table('chat_participantes')
|
||||
->where('id', $participante->id)
|
||||
->update(['last_read' => null]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
protected function participantes()
|
||||
{
|
||||
return $this->db
|
||||
->table('chat_participantes')
|
||||
->where('conversacion_id', $this->id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
protected function getParticipanteDesdeUsuario($usuario_id)
|
||||
{
|
||||
return $this->db->table('chat_participantes')
|
||||
->where('usuario_id', $usuario_id)
|
||||
->where('conversacion_id', $this->id)
|
||||
->get()
|
||||
->getFirstRow();
|
||||
}
|
||||
}
|
||||
52
ci4/app/Models/Mensajeria/ParticipanteModel.php
Normal file
52
ci4/app/Models/Mensajeria/ParticipanteModel.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Mensajeria;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use App\Models\Customers\Customer;
|
||||
|
||||
class ParticipanteModel extends BaseModel
|
||||
{
|
||||
protected $table = 'chat_participantes';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'App\Entities\Mensajeria\ParticipanteEntity';
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $allowedFields = [
|
||||
'conversacion_id',
|
||||
'usuario_id',
|
||||
'cliente_id',
|
||||
'email',
|
||||
'last_read',
|
||||
];
|
||||
|
||||
public function getPeopleInChat($conversacionId){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->where("t1.conversacion_id", $conversacionId);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getChatsByUser($userId){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t1.conversacion_id AS id, t2.asunto AS asunto")
|
||||
->where("t1.usuario_id", $userId)
|
||||
->join("chat_conversaciones t2", "t2.id = conversacion_id", "left")
|
||||
->orderBy('t1.created_at', 'DESC')
|
||||
->get()
|
||||
->getResultObject();
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function getCustomer()
|
||||
{
|
||||
//$customerModel = new Customer();
|
||||
//return $customerModel->find($this->attributes['customer_id']);
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
public static $labelField = "id";
|
||||
|
||||
|
||||
public function getResource($search = [], $estado="")
|
||||
public function getResource($search = [], $estado="", $cliente_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -75,6 +75,10 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
if($cliente_id != -1) {
|
||||
$builder->where("t3.cliente_id", $cliente_id);
|
||||
}
|
||||
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
@ -93,7 +97,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
public function getSumOfTirada(array $search, $estado = '', $start = 0, $length = 5)
|
||||
public function getSumOfTirada(array $search, $estado = '', $cliente_id=-1, $start = 0, $length = 5)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
@ -104,6 +108,9 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
|
||||
|
||||
|
||||
if($cliente_id != -1) {
|
||||
$builder->where("t3.cliente_id", $cliente_id);
|
||||
}
|
||||
|
||||
// Aplica los filtros de búsqueda y estado
|
||||
if (!empty($search)) {
|
||||
@ -130,7 +137,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
return $builder->get()->getRow()->total_tirada;
|
||||
}
|
||||
|
||||
public function getSumOfTotalAceptado(array $search, $estado = '', $start = 0, $length = 5)
|
||||
public function getSumOfTotalAceptado(array $search, $estado = '', $cliente_id=-1, $start = 0, $length = 5)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
@ -140,7 +147,9 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
|
||||
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
|
||||
|
||||
|
||||
if($cliente_id != -1) {
|
||||
$builder->where("t3.cliente_id", $cliente_id);
|
||||
}
|
||||
|
||||
// Aplica los filtros de búsqueda y estado
|
||||
if (!empty($search)) {
|
||||
@ -216,5 +225,10 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
|
||||
return $resultaArray;
|
||||
}
|
||||
|
||||
public function findByPresupuesto(int $presupuestoId){
|
||||
$builder = $this->db
|
||||
->table($this->table)
|
||||
->select();
|
||||
return $builder->where('presupuesto_id',$presupuestoId)->get()->getFirstRow();
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models\Pedidos;
|
||||
|
||||
use function PHPSTORM_META\map;
|
||||
|
||||
class PedidoModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "pedidos";
|
||||
@ -29,11 +31,11 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"total_precio",
|
||||
"total_tirada",
|
||||
"estado",
|
||||
"user_created_id",
|
||||
"user_updated_id",
|
||||
"total_precio",
|
||||
"total_tirada",
|
||||
"estado",
|
||||
"user_created_id",
|
||||
"user_updated_id",
|
||||
"user_validated_id",
|
||||
"fecha_entrega_real",
|
||||
"fecha_impresion",
|
||||
@ -53,22 +55,25 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
public function obtenerDatosForm($pedido_id){
|
||||
public function obtenerDatosForm($pedido_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t4.id AS cliente_id, t4.nombre AS cliente, CONCAT(t5.first_name, ' ', t5.last_name) AS comercial");
|
||||
"t4.id AS cliente_id, t4.nombre AS cliente, CONCAT(t5.first_name, ' ', t5.last_name) AS comercial"
|
||||
);
|
||||
|
||||
$builder->join("pedidos_linea t2", "t2.pedido_id = t1.id", "left");
|
||||
$builder->join("presupuestos t3", "t2.presupuesto_id = t3.id", "left");
|
||||
$builder->join("pedidos_linea t2", "t2.pedido_id = t1.id", "left");
|
||||
$builder->join("presupuestos t3", "t2.presupuesto_id = t3.id", "left");
|
||||
$builder->join("clientes t4", "t4.id = t3.cliente_id", "left");
|
||||
$builder->join("users t5", "t5.id = t4.comercial_id", "left");
|
||||
|
||||
|
||||
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function obtenerLineasPedido($pedido_id){
|
||||
public function obtenerLineasPedido($pedido_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
@ -79,10 +84,116 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
$model_presupuesto = model("App\Models\Presupuestos\PresupuestoModel");
|
||||
$lineasPresupuesto = [];
|
||||
|
||||
foreach($builder->get()->getResultObject() as $row){
|
||||
foreach ($builder->get()->getResultObject() as $row) {
|
||||
array_push($lineasPresupuesto, $model_presupuesto->generarLineaPedido($row->presupuesto_id)[0]);
|
||||
}
|
||||
|
||||
return $lineasPresupuesto;
|
||||
}
|
||||
}
|
||||
public function getPedidoPresupuestoTipoImpresion(int $presupuesto_id) : array|object|null
|
||||
{
|
||||
$q = $this->db->table($this->table)
|
||||
->select(
|
||||
[
|
||||
'tipos_presupuesto.codigo',
|
||||
'presupuestos.solapas'
|
||||
]
|
||||
)
|
||||
->join('tipos_presupuestos', 'tipos_presupuestos.id = presupuestos.tipo_impresion_id', 'left')
|
||||
->where('presupuestos.id', $presupuesto_id);
|
||||
return $q->get()->getFirstRow();
|
||||
}
|
||||
public function getPedidoClientePresupuesto(int $pedido_id)
|
||||
{
|
||||
$query = $this->db->table($this->table)
|
||||
->select([
|
||||
'pedidos.id as pedidoId',
|
||||
'clientes.nombre as customerName',
|
||||
'presupuestos.total_aceptado as totalAceptado',
|
||||
'presupuestos.id as presupuestoId',
|
||||
'presupuestos.cliente_id as presupuestoClienteId',
|
||||
'presupuestos.margen',
|
||||
'presupuestos.inc_rei',
|
||||
'presupuestos.tirada',
|
||||
'presupuestos.tirada',
|
||||
'presupuestos.titulo',
|
||||
'presupuestos.paginas',
|
||||
'presupuestos.solapas',
|
||||
'presupuestos.solapas_ancho',
|
||||
'presupuestos.marcapaginas',
|
||||
'presupuestos.comentarios_cliente',
|
||||
'presupuestos.comentarios_safekat',
|
||||
'presupuestos.papel_formato_personalizado',
|
||||
'presupuestos.papel_formato_ancho as papelAnchoPersonalidado ',
|
||||
'presupuestos.papel_formato_alto as papelAltoPersonalidado',
|
||||
'tipos_presupuestos.codigo as codigoTipoImpresion',
|
||||
'lg_papel_formato.ancho as lgPapelFormatoAncho ',
|
||||
'lg_papel_formato.alto as lgPapelFormatoAlto',
|
||||
|
||||
|
||||
])
|
||||
->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left')
|
||||
->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left')
|
||||
->join('presupuesto_ficheros', 'presupuesto_ficheros.presupuesto_id = presupuestos.id', 'left')
|
||||
->join('tipos_presupuestos', 'tipos_presupuestos.id = presupuestos.tipo_impresion_id', 'left')
|
||||
// ->join('presupuesto_linea','presupuestos.id = presupuesto_linea.presupuesto_id','left')
|
||||
->join('clientes', 'clientes.id = presupuestos.cliente_id', 'left')
|
||||
->join('lg_papel_formato', 'lg_papel_formato.id = presupuestos.papel_formato_id', 'left')
|
||||
->where('pedidos.id', $pedido_id);
|
||||
$cliente_presupuesto = $query->get()->getFirstRow();
|
||||
return $cliente_presupuesto;
|
||||
}
|
||||
public function getPedidoPresupuestoLineas(int $pedido_id)
|
||||
{
|
||||
$query = $this->db->table($this->table)
|
||||
->select([
|
||||
'pedidos.id as pedidoId',
|
||||
'presupuesto_linea.tipo',
|
||||
'presupuesto_linea.paginas',
|
||||
'presupuesto_linea.gramaje',
|
||||
'lg_papel_generico.code as papelCode',
|
||||
])
|
||||
->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left')
|
||||
->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left')
|
||||
->join('presupuesto_linea', 'presupuestos.id = presupuesto_linea.presupuesto_id', 'left')
|
||||
->join('lg_papel_generico', 'lg_papel_generico.id = presupuesto_linea.papel_id', 'left')
|
||||
->where('pedidos.id', $pedido_id);
|
||||
|
||||
$pedido_presupuesto_lineas = $query->get()->getResultObject();
|
||||
return $pedido_presupuesto_lineas;
|
||||
}
|
||||
public function getPedidoPresupuestoDirecciones($pedido_id)
|
||||
{
|
||||
$query = $this->db->table($this->table)
|
||||
->select([
|
||||
'pedidos.id as pedidoId',
|
||||
'presupuestos.id as presupuestoId',
|
||||
'clientes.nombre as customerName',
|
||||
'presupuesto_direcciones.*',
|
||||
'lg_paises.code3 as paisCode3'
|
||||
])
|
||||
->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left')
|
||||
->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left')
|
||||
->join('presupuesto_direcciones', 'presupuestos.id = presupuesto_direcciones.presupuesto_id', 'left')
|
||||
->join('clientes', 'clientes.id = presupuestos.cliente_id', 'left')
|
||||
->join('cliente_direcciones', 'clientes.id = cliente_direcciones.cliente_id', 'left')
|
||||
->join('lg_paises', 'lg_paises.id = presupuesto_direcciones.pais_id', 'left')
|
||||
->where('pedidos.id', $pedido_id);
|
||||
$pedido_cliente_direcciones = $query->get()->getResultObject();
|
||||
return $pedido_cliente_direcciones;
|
||||
}
|
||||
public function getPedidoPresupuestoFicheros($pedido_id)
|
||||
{
|
||||
$query = $this->db->table($this->table)
|
||||
->select([
|
||||
'presupuesto_ficheros.nombre as fileName',
|
||||
'presupuesto_ficheros.file_path as filePath'
|
||||
])
|
||||
->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left')
|
||||
->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left')
|
||||
->join('presupuesto_ficheros', 'presupuesto_ficheros.presupuesto_id = presupuestos.id', 'left')
|
||||
->where('pedidos.id', $pedido_id);
|
||||
$presupuesto_ficheros = $query->get()->getFirstRow();
|
||||
return $presupuesto_ficheros;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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",
|
||||
@ -139,6 +139,7 @@ class BuscadorModel extends \App\Models\BaseModel
|
||||
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
|
||||
115
ci4/app/Models/Presupuestos/ErrorPresupuesto.php
Normal file
115
ci4/app/Models/Presupuestos/ErrorPresupuesto.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ErrorPresupuesto extends Model
|
||||
{
|
||||
protected $table = 'presupuesto_errores';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"presupuesto_id",
|
||||
"presupuesto_user_id",
|
||||
"error",
|
||||
"datos_presupuesto",
|
||||
"visto",
|
||||
"last_user_id",
|
||||
"comment",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"deleted_at",
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
//protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
public function insertError(int $presupuesto_id, int $presupuesto_user_id, string $error, mixed $datos)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
@ -283,6 +283,13 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
$total = $precio_unidad * $tirada;
|
||||
$margen = floatval($tarifa->margen);
|
||||
|
||||
if($tarifa->tarifa_precio_min > $total){
|
||||
$total = $total-($total * $margen/100.0);
|
||||
$margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $total) / floatval($tarifa->tarifa_precio_min), 0);
|
||||
$total = floatval($tarifa->tarifa_precio_min);
|
||||
$precio_unidad = round(floatval($total / $tirada), 2);
|
||||
}
|
||||
|
||||
if (!$is_POD){
|
||||
$total += floatval($tarifa->tarifa_importe_fijo);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user