group_model->select('rules')->where('token',$groups[$i])->first();
- if($temp_rules==null){
- // group doesn't exists now -> then delete from group-user
- $groups = $this->group_user_model
- ->where('token_group',$groups[$i])
- ->delete();
- }
- else{
- $temp_rules=$temp_rules->rules;
- foreach ($rules as $key => $value){
- if (array_key_exists($key, json_decode(html_entity_decode($temp_rules), true))){
- $value2 = json_decode(html_entity_decode($temp_rules), true)[$key];
- $rules[$key] = array_unique(array_merge($value, $value2));
- }
- else{
- $rules[$key]= $value;
- }
- }
- foreach (json_decode(html_entity_decode($temp_rules), true) as $key2 => $value2){
- if (!array_key_exists($key2, $rules)){
- $rules[$key2] = $value2;
- }
- }
- }
- }
- }
- else{
- $rules = json_decode($this->group_model->select('rules')->where('token',$groups[0])->first()->rules);
-
- }
-
-
-
-
- // Save data in session
- $session->set('id_user', $login->id_user);
- //$session->set('group', $login->'group']);
- $session->set('first_name', $login->first_name);
- $session->set('last_name', $login->last_name);
- $session->set('email', $login->email);
- $session->set('token', $login->token);
- // JJO
- $dashboard = 'user';
- foreach ($groups as $group){
- if($this->group_model->select('dashboard')->where('token',$group)->first()->dashboard == 'admin')
- $dashboard = 'admin';
- }
- $session->set('dashboard', $dashboard);
-
- $session->set('rules', html_entity_decode(json_encode($rules)));
- $session->set('picture', $login->picture);
- $session->set('tfa', $login->tfa);
- $session->set('tfa_secret', $login->tfa_secret);
- $session->set('tfa_code', $login->tfa_code);
- $session->set('lang', $login->language ?? 'en');
- // Update last access
- $last_access = date('Y-m-d H:i:s');
- $this->user_model->set('last_access', $last_access)->set('last_ip', $last_ip)->where('id_user', $session->get('id_user'))->update();
-
- // Register Access Log
- $integration = new \App\Controllers\Integration;
- $integration->setLog('information','login-authenticate');
-
- // Check if it has two factors
- if($login->tfa??false){
- return redirect()->to('/login/authentication');
- }else{
- return redirect()->to('home');
- }
- }
- else
- {
- $session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_user_not_found")]);
- return redirect()->to('login');
- }
- }
-
- public function logout()
- {
- // Destroy the session
- $session = session();
- $lang = $session->get('lang');
- $session->destroy();
- return redirect()->to('/lang/'.$lang);
- }
-
- public function signup()
- {
- $session = session();
- helper('form');
- $data['settings'] = $session->get('settings');
- $header['title'] = lang("App.login_title_signup");
-
- echo view(getenv('theme.path').'login/header',$header);
- echo view(getenv('theme.path').'form/login/signup',$data);
- echo view(getenv('theme.path').'login/footer');
- }
-
- public function authentication()
- {
- $session = session();
- if($session->get('tfa')??false){
- $header['title'] = lang("App.login_title_otp");
- echo view(getenv('theme.path').'login/header',$header);
- echo view(getenv('theme.path').'form/login/authentication');
- echo view(getenv('theme.path').'login/footer');
- }else{
- return redirect()->to('/login');
- }
- }
-
- public function otp()
- {
- $session = session();
- $tfa_secret = $session->get('tfa_secret');
- $tfa_code = $session->get('tfa_code');
- $pin = $this->request->getVar();
- $otp = "";
-
- foreach ($pin as $key=>$value){
- if(strpos($key, 'pin') !== false){
- $otp .= $value;
- }
- }
-
- $tfa = new Authenticator();
- $backup_pass = false;
- $checkResult = $tfa->verify($tfa_secret??'', $otp);
-
- if($tfa_code??'') {
- $backup_codes = explode(',' , $tfa_code??'');
- if (in_array($otp, $backup_codes)) {
- $backup_pass = true;
- $key = array_search($otp, $backup_codes);
- unset($backup_codes[$key]);
- }
- }
-
- if($checkResult || $backup_pass == true) {
- $session->set('tfa',false);
- $session->set('tfa_secret','');
- $session->set('tfa_code','');
- return redirect()->to('/home');
- } else {
- $session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_code_invalid")]);
- return redirect()->to('/login/authentication');
- }
- }
-
- public function store()
- {
- $session = session();
- $settings = $session->get('settings');
-
- helper('form');
- helper('text');
-
- $rules = [
- 'first_name' => 'required',
- 'last_name' => 'required',
- 'email' => 'required|valid_email|is_unique[auth_user.email]',
- 'password' => 'required|min_length[8]'
- ];
- $rules_error = [
- 'first_name' => [
- 'required' => lang("App.login_rules_first_name_r")
- ],
- 'last_name' => [
- 'required' => lang("App.login_rules_last_name_r")
- ],
- 'email' => [
- 'required' => lang("App.login_rules_email_r"),
- 'is_unique' => lang("App.login_rules_email_i"),
- 'valid_email' => lang("App.login_rules_email_v"),
- ],
- 'password' => [
- 'required' => lang("App.login_rules_password_r"),
- 'min_length' => lang("App.login_rules_password_m")
- ]
- ];
-
- if ($this->validate($rules,$rules_error)){
- if($listPost = $this->request->getPost()) {
-
- if($settings['captcha_register']??false){
- if($settings['captcha_gateway'] == 'recaptcha'){
- if(isset($listPost['g-recaptcha-response'])){
- $captcha = $listPost['g-recaptcha-response'];
- $url = 'https://www.google.com/recaptcha/api/siteverify?secret='.urlencode($settings['captcha_secret_key']??'').'&response='.urlencode($captcha);
- $response = file_get_contents($url);
- $responseKeys = json_decode($response,true);
- if(!$responseKeys["success"]) {
- $session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_captcha_invalid")]);
- $this->signup();
- die();
- }
- }else{
- $session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_captcha_not_found")]);
- $this->signup();
- die();
- }
- }
- if($settings['captcha_gateway'] == 'hcaptcha'){
- if(isset($listPost['h-captcha-response'])){
- $captcha = $listPost['h-captcha-response'];
- $url = 'https://hcaptcha.com/siteverify?secret='.urlencode($settings['captcha_secret_key']??'').'&response='.urlencode($captcha).'&remoteip='.$_SERVER['REMOTE_ADDR'];
- $response = file_get_contents($url);
- $responseKeys = json_decode($response,true);
- if(!$responseKeys["success"]) {
- $session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_captcha_invalid")]);
- $this->signup();
- die();
- }
- }else{
- $session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_captcha_not_found")]);
- $this->signup();
- die();
- }
- }
- }
- $phpass = new PasswordHash(8, true);
- $userToken = md5(uniqid(rand(), true));
- $this->user_model->skipValidation(true)->save([
- //'group' => $settings['default_role'],
- 'first_name' => $listPost['first_name'],
- 'last_name' => $listPost['last_name'],
- 'mobile' => '',
- 'picture' => '/assets/img/default-user.png',
- 'email' => $listPost['email'],
- 'password' => $phpass->HashPassword($listPost['password']),
- 'last_access' => date('Y-m-d h:i:s'),
- 'last_ip' => '::1',
- 'language' => $settings['default_language'],
- 'token' => $userToken,
- 'status' => 1,
- 'address' => '',
- 'city' => '',
- 'state' => '',
- 'country' => '',
- 'zip_code' => '',
- ]);
- //Get Data Template
- $templates = $this->template_model->findAll();
-
- //Notification E-mail User Welcome
- if($settings['send_email_welcome']??false){
- $template = templateSelect($templates,'template_label_welcome','email');
- if($template != null){
- try {
- $this->integration->send_email($listPost['email'],$template['subject'],$template['body'],$phpass->HashPassword(MD5($listPost['email'])));
- }catch (\Exception $e){
-
- }
- }
- }
-
- //E-mail Account Confirmation
- if($settings['email_confirmation']??false){
- $template = templateSelect($templates,'template_label_confirmation_email','email');
- if($template != null){
- $token = random_string("alnum", 50);
- $url = base_url().'/login/confirmation/'.$token;
- $body = str_replace('[link_confirmation]',$url,$template['body']);
- try {
- $this->integration->send_email($listPost['email'],$template['subject'],$body,$phpass->HashPassword(MD5($listPost['email'])));
- $this->confirmation_model->save([
- 'id_confirmation' => null,
- 'user' => $userToken,
- 'token' => $token,
- 'confirmed' => false,
- 'type' => 'email'
- ]);
- }catch (\Exception $e){
- }
- }
- }
-
- //Notification New Register
- if($settings['send_notification_register']??false){
- $template = templateSelect($templates,'template_label_notification','email');
- if($template != null){
- if(!empty($settings['send_user_register']??null)){
- $data = [
- 'id_notification' => null,
- 'user_sender' => $settings['send_user_register']??null,
- 'user_recipient' => $settings['send_user_register']??null,
- 'title' => $template['subject'],
- 'body' => $template['body'],
- 'is_read' => false,
- 'is_send_email' => false,
- 'send_email_notification' => $settings['send_email_register']??false,
- 'token' => md5(uniqid(rand(), true))
- ];
- $this->notification_model->save($data);
- }
- }
- }else{
- $userAdm = $this->user_model->where('token',$settings['send_user_register']??null)->first();
- if($settings['send_email_register']??false){
- $template = templateSelect($templates,'template_label_notification','email');
- if($template != null){
- try {
- $this->integration->send_email($userAdm['email'],$template['subject'],$template['body'],$phpass->HashPassword(MD5($listPost['email'])));
- }catch (\Exception $e){
- }
- }
- }
-
- }
- $session = session();
- $session->setFlashdata('toast', ['success', lang("App.login_alert_success"), lang("App.login_alert_success_register")]);
- return redirect()->to('/login');
- }else{
- $session->setFlashdata('toast', ['error', lang("App.login_alert"),lang("App.login_alert_parameter_invalid")]);
- $this->signup();
- }
- }else{
- $session = session();
- $session->setFlashdata('error','error');
- $this->signup();
- }
- }
-
- public function recovery($token=null)
- {
- $session = session();
- if(!empty($token) && $session->get('settings')['forgot_password']??false){
- $pass_recovery = $this->pass_recovery_model->where('token',$token)->where('changed',false)->first();
- if($pass_recovery != null){
- $data['token'] = $token;
- $data['user'] = $pass_recovery['user'];
- $header['title'] = lang("App.login_title_recovery");
- echo view(getenv('theme.path').'login/header',$header);
- echo view(getenv('theme.path').'form/login/password_recovery',$data);
- echo view(getenv('theme.path').'login/footer');
- }else{
- $session->setFlashdata('toast', ['error', lang("App.login_alert"), lang("App.login_alert_invalid_token")]);
- return redirect()->to('/login');
- }
- }else{
- $session->setFlashdata('toast', ['error', lang("App.login_alert"), lang("App.login_alert_empty_token")]);
- return redirect()->to('/login');
- }
- }
-
- public function recovery_store()
- {
- $session = session();
-
- helper('form');
-
- $rules = [
- 'password' => 'required|min_length[8]'
- ];
-
- $rules_error = [
- 'password' => [
- 'required' => lang("App.login_rules_password_r"),
- 'min_length' => lang("App.login_rules_password_m")
- ]
- ];
-
- if ($this->validate($rules,$rules_error)){
- if($listPost = $this->request->getPost()) {
- $pass_recovery = $this->pass_recovery_model->where('user',$listPost['user'])->where('token',$listPost['token'])->where('changed',false)->first();
- if($pass_recovery != null){
- $user = $this->user_model->select('id_user')->where('token',$listPost['user'])->first();
- if($user != null){
- $phpass = new PasswordHash(8, true);
- $this->user_model->save([
- 'id_user' => $user->id_user,
- 'password' => $phpass->HashPassword($listPost['password'])
- ]);
- $this->pass_recovery_model->save([
- 'id_pass_recovery' => $pass_recovery['id_pass_recovery'],
- 'changed' => true
- ]);
- $session->setFlashdata('toast', ['success', lang("App.login_alert_success"), lang("App.login_alert_success_recovery")]);
- }
- }
- return redirect()->to('/login');
- }else{
- $session->setFlashdata('toast', ['error', lang("App.login_alert"), lang("App.login_alert_parameter_invalid")]);
- $this->recovery($this->request->getVar('token'));
- }
- }else{
- $session->setFlashdata('error','error');
- $this->recovery($this->request->getVar('token'));
- }
- }
-
- public function confirmation($token=null)
- {
- $session = session();
- if(!empty($token)){
- $confirmation = $this->confirmation_model->where('token',$token)->where('confirmed',false)->first();
- if($confirmation != null){
- $user = $this->user_model->select('id_user')->where('token',$confirmation['user'])->first();
- if($confirmation['type'] == 'email'){
- $this->user_model->save([
- 'id_user'=>$user['id_user'],
- 'email_confirmed'=>true
- ]);
- }
- $this->confirmation_model->save([
- 'id_confirmation'=>$confirmation['id_confirmation'],
- 'confirmed'=>true
- ]);
- $session->setFlashdata('toast', ['success', lang("App.login_alert_success"), lang("App.login_alert_success_confirmation")]);
- return redirect()->to('/login');
- }else{
- $session->setFlashdata('toast', ['error', lang("App.login_alert"), lang("App.login_alert_invalid_token")]);
- return redirect()->to('/login');
- }
- }else{
- $session->setFlashdata('toast', ['error', lang("App.login_alert"), lang("App.login_alert_empty_token")]);
- return redirect()->to('/login');
- }
- }
-}
diff --git a/ci4/app/Controllers/Migrate.php b/ci4/app/Controllers/Migrate.php
deleted file mode 100755
index ad48780d..00000000
--- a/ci4/app/Controllers/Migrate.php
+++ /dev/null
@@ -1,24 +0,0 @@
-force($file);
-
- } catch (\Exception $e) {
-
- echo $e->getMessage();
- }
- }
-}
\ No newline at end of file
diff --git a/ci4/app/Controllers/Notification.php b/ci4/app/Controllers/Notification.php
deleted file mode 100755
index 7d30f614..00000000
--- a/ci4/app/Controllers/Notification.php
+++ /dev/null
@@ -1,190 +0,0 @@
-user_model = new UserModel();
- $this->countries_model = new CountriesModel();
- $this->id_user = session()->get('id_user');
- $this->token_user = session()->get('token');
- $this->notification_model = new NotificationModel();
- }
-
- public function index()
- {
- $data['title'] = [
- 'module' => lang("App.notification_title"),
- 'page' => lang("App.notification_subtitle"),
- 'icon' => 'fas fa-bell'
- ];
-
- $data['breadcrumb'] = [
- ['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
- ['title' => lang("App.notification_title"), 'route' => "", 'active' => true]
- ];
-
- $data['btn_add'] = [
- 'title' => lang("App.notification_btn_add"),
- 'route' => '/notification/add',
- 'class' => 'btn btn-lg btn-primary float-md-right',
- 'icon' => 'fas fa-plus'
- ];
-
- echo view(getenv('theme.path').'main/header');
- echo view(getenv('theme.path').'form/notification/index',$data);
- echo view(getenv('theme.path').'main/footer');
- }
-
- public function add()
- {
- helper('form');
-
- $data['title'] = [
- 'module' => lang("App.notification_add_title"),
- 'page' => lang("App.notification_add_subtitle"),
- 'icon' => 'far fa-plus-square'
- ];
-
- $data['breadcrumb'] = [
- ['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
- ['title' => lang("App.notification_title"), 'route' => "/user", 'active' => false],
- ['title' => lang("App.notification_add_title"), 'route' => "", 'active' => true]
- ];
-
- $data['btn_return'] = [
- 'title' => lang("App.global_come_back"),
- 'route' => '/notification',
- 'class' => 'btn btn-dark mr-1',
- 'icon' => 'fas fa-angle-left'
- ];
-
- $data['btn_submit'] = [
- 'title' => lang("App.global_save"),
- 'route' => '',
- 'class' => 'btn btn-primary mr-1',
- 'icon' => 'fas fa-save'
- ];
-
- $data['user'] = $this->user_model->where('status',true)->findAll();
-
- echo view(getenv('theme.path').'main/header');
- echo view(getenv('theme.path').'form/notification/form',$data);
- echo view(getenv('theme.path').'main/footer');
- }
-
- public function store()
- {
- //Demo Mode
- if(env('demo.mode')??false){
- session()->setFlashdata('sweet', ['warning',lang("App.general_demo_mode")]);
- return redirect()->to('/notification');
- }
-
- $session = session();
- helper('form');
-
- $rules = [
- 'title' => 'required',
- 'body' => 'required'
- ];
-
- $rules_error = [
- 'title' => [
- 'required' => lang("App.notification_rules_title_r"),
- ],
- 'body' => [
- 'required' => lang("App.notification_rules_body_r"),
- ]
- ];
-
- if ($this->validate($rules,$rules_error)){
- if($listPost = $this->request->getPost()){
-
- $listPost['send_email_notification'] = isset($listPost['send_email_notification']) && $listPost['send_email_notification'] == 'on';
-
- if(!empty($listPost['user_recipient'])){
- $user = $this->user_model->where('token',$session->get('token'))->first();
- foreach (keywordEmail()??[] as $item){
- $field = str_replace(['[','user_',']'],'',$item);
- $listPost['title'] = str_replace('['.$item.']',$user[$field],$listPost['title']);
- $listPost['body'] = str_replace('['.$item.']',$user[$field],$listPost['body']);
- }
- $listPost['token'] = md5(uniqid(rand(), true));
- $listPost['user_sender'] = $session->get('token');
- $this->notification_model->save($listPost);
- }else{
- $users = $this->user_model->where('status',true)->findAll();
- $data = [];
- foreach ($users as $user){
- $title = $listPost['title'];
- $template = $listPost['body'];
- foreach (keywordEmail()??[] as $item){
- $field = str_replace(['[','user_',']'],'',$item);
- $title = str_replace('['.$item.']',$user[$field],$title);
- $template = str_replace('['.$item.']',$user[$field],$template);
- }
- array_push($data,[
- 'id_notification' => null,
- 'user_sender' => $session->get('token'),
- 'user_recipient' => $user['token'],
- 'title' => $title,
- 'body' => $template,
- 'is_read' => false,
- 'is_send_email' => false,
- 'send_email_notification' => $listPost['send_email_notification'],
- 'token' => md5(uniqid(rand(), true)),
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s')
- ]);
- }
- if(count($data)>0){
- $this->notification_model->insertBatch($data);
- }
- }
- if(empty($this->request->getPost('id_notification'))){
- $session->setFlashdata('sweet', ['success',lang("App.notification_alert_add")]);
- return redirect()->to('/notification');
- }else{
- $session->setFlashdata('sweet', ['success',lang("App.notification_alert_edit")]);
- return redirect()->to('/notification');
- }
- }
- }else{
- $session->setFlashdata('error','error');
- $this->add();
- }
- }
-
- public function delete($token)
- {
- //Demo Mode
- if(env('demo.mode')??false){
- session()->setFlashdata('sweet', ['warning',lang("App.general_demo_mode")]);
- return redirect()->to('/notification');
- }
-
- $session = session();
- if(!empty($session->get('token'))){
- $this->notification_model->where('token', $token)->delete();
- $session->setFlashdata('sweet', ['success',lang("App.notification_alert_delete")]);
- return redirect()->to('/notification');
- }else{
- return redirect()->to('/login');
- }
- }
-
-
-}
diff --git a/ci4/app/Controllers/Presupuestos/Buscador.php b/ci4/app/Controllers/Presupuestos/Buscador.php
index 19616cc8..6c02de80 100644
--- a/ci4/app/Controllers/Presupuestos/Buscador.php
+++ b/ci4/app/Controllers/Presupuestos/Buscador.php
@@ -2,7 +2,7 @@
namespace App\Controllers\Presupuestos;
-use App\Controllers\GoBaseResourceController;
+use App\Controllers\BaseResourceController;
use App\Entities\Configuracion\Maquina;
use App\Models\Collection;
@@ -19,7 +19,7 @@ use App\Models\Configuracion\PapelImpresionModel;
use App\Models\Configuracion\MaquinaModel;
use Exception;
-class Buscador extends \App\Controllers\GoBaseResourceController
+class Buscador extends \App\Controllers\BaseResourceController
{
protected $modelName = "BuscadorModel";
diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php
index c39c0f90..37471d33 100755
--- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php
+++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php
@@ -2,7 +2,7 @@
namespace App\Controllers\Presupuestos;
-use App\Controllers\GoBaseResourceController;
+use App\Controllers\BaseResourceController;
use App\Entities\Configuracion\Maquina;
use App\Models\Collection;
@@ -24,7 +24,7 @@ use App\Models\Configuracion\PapelImpresionModel;
use App\Models\Configuracion\MaquinaModel;
use Exception;
-class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
+class Cosidotapablanda extends \App\Controllers\BaseResourceController
{
protected $modelName = "PresupuestoModel";
@@ -83,12 +83,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
public function add($tipo_impresion_id = null)
{
- // JJO
- $session = session();
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -97,7 +95,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
- $sanitizedData['user_created_id'] = $session->id_user;
+ $sanitizedData['user_created_id'] = auth()->user()->id;
if (!isset($sanitizedData['papel_formato_id']) || $sanitizedData['papel_formato_id'] == null) {
$sanitizedData['papel_formato_id'] = 0;
@@ -170,8 +168,6 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
public function edit($requestedId = null)
{
- // JJO
- $session = session();
if ($requestedId == null) :
return $this->redirect2listView();
@@ -184,9 +180,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -197,7 +193,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
- $sanitizedData['user_updated_id'] = $session->id_user;
+ $sanitizedData['user_updated_id'] = auth()->user()->id;
if ($this->request->getPost('is_duplicado') == null) {
$sanitizedData['is_duplicado'] = 0;
diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php
index a449aaf9..625a0577 100755
--- a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php
+++ b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php
@@ -1,7 +1,7 @@
settings_model = new SettingsModel();
- $this->countries_model = new CountriesModel();
- $this->theme_model = new ThemeModel();
- $this->currency_model = new CurrencyModel();
- $this->timezone_model = new TimezoneModel();
- $this->group_model = new UserGroupModel();
- $this->template_model = new TemplateModel();
- $this->user_model = new UserModel();
- $this->crontab_model = new CronTabModel();
- $this->integration = new Integration();
- }
-
- public function index()
- {
- helper('form');
-
- $data['title'] = [
- 'module' => lang("App.settings_title"),
- 'page' => lang("App.settings_subtitle"),
- 'icon' => 'fas fa-sliders-h'
- ];
-
- $data['breadcrumb'] = [
- ['title' => lang("App.menu_settings"), 'route' => site_url('settings'), 'active' => true]
- ];
-
- $data['obj'] = $this->settings_model->first();
- $data['countries'] = $this->countries_model->select('id_country,code,name')->where('data_lang',session()->get('lang')??'en')->findAll();
- $data['theme'] = $this->theme_model->select('id_theme,type,name')->findAll();
- $data['currency'] = $this->currency_model->select('id_currency,code,name')->findAll();
- $data['timezone'] = $this->timezone_model->select('id_timezone,timezone,description')->findAll();
- $data['group'] = $this->group_model->select('token,title')->findAll();
- $db = db_connect('default');
- $data['tables'] = $db->listTables();
- $data['user'] = $this->user_model->select('token,first_name,email')->where('status',true)->findAll();
-
- echo view(getenv('theme.path').'form/settings/index', $data);
-
- }
-
- public function store()
- {
- //Demo Mode
- if(env('demo.mode')??false){
- session()->setFlashdata('sweet', ['warning',lang("App.general_demo_mode")]);
- return redirect()->to('/settings');
- }
-
- helper('form');
- $session = session();
- if($listPost = $this->request->getPost()){
- $listPost['id_settings'] = 1;
- $listPost['captcha_register'] = isset($listPost['captcha_register']) && $listPost['captcha_register'] == 'on';
- $listPost['captcha_login'] = isset($listPost['captcha_login']) && $listPost['captcha_login'] == 'on';
- $listPost['captcha_recovery'] = isset($listPost['captcha_recovery']) && $listPost['captcha_recovery'] == 'on';
- $listPost['registration'] = isset($listPost['registration']) && $listPost['registration'] == 'on';
- $listPost['terms_conditions'] = isset($listPost['terms_conditions']) && $listPost['terms_conditions'] == 'on';
- $listPost['email_confirmation'] = isset($listPost['email_confirmation']) && $listPost['email_confirmation'] == 'on';
- $listPost['send_email_register'] = isset($listPost['send_email_register']) && $listPost['send_email_register'] == 'on';
- $listPost['send_notification_register'] = isset($listPost['send_notification_register']) && $listPost['send_notification_register'] == 'on';
- $listPost['send_email_welcome'] = isset($listPost['send_email_welcome']) && $listPost['send_email_welcome'] == 'on';
- $listPost['remember_me'] = isset($listPost['remember_me']) && $listPost['remember_me'] == 'on';
- $listPost['forgot_password'] = isset($listPost['forgot_password']) && $listPost['forgot_password'] == 'on';
- $listPost['two_factor_auth'] = isset($listPost['two_factor_auth']) && $listPost['two_factor_auth'] == 'on';
- $listPost['throttle_auth'] = isset($listPost['throttle_auth']) && $listPost['throttle_auth'] == 'on';
- $listPost['enable_api'] = isset($listPost['enable_api']) && $listPost['enable_api'] == 'on';
- $listPost['block_external_api'] = isset($listPost['block_external_api']) && $listPost['block_external_api'] == 'on';
- $listPost['remove_log'] = isset($listPost['remove_log']) && $listPost['remove_log'] == 'on';
- $listPost['backup_notification_email'] = isset($listPost['backup_notification_email']) && $listPost['backup_notification_email'] == 'on';
- $listPost['backup_automatic'] = isset($listPost['backup_automatic']) && $listPost['backup_automatic'] == 'on';
- $listPost['backup_table'] = implode(",",$listPost['backup_table']??[]);
- $this->settings_model->save($listPost);
- $settings = $this->settings_model->first()??[];
- $session->set('settings', $settings);
- $session->set('lang', $settings['default_language'] ?? 'es');
- $session->setFlashdata('sweet', ['success',lang("App.settings_alert_add")]);
- return redirect()->to('/settings');
- } else{
- $session->setFlashdata('sweet', ['error',lang("App.settings_alert_error")]);
- return redirect()->to('/settings');
- }
- }
-
- public function template()
- {
- helper('form');
-
- $data['title'] = [
- 'module' => lang("App.template_title"),
- 'page' => lang("App.template_subtitle"),
- 'icon' => 'fas fa-mail-bulk'
- ];
-
- $data['breadcrumb'] = [
- ['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
- ['title' => lang("App.menu_settings"), 'route' => "/settings", 'active' => false],
- ['title' => lang("App.template_title"), 'route' => "", 'active' => true]
- ];
-
- $data['btn_return'] = [
- 'title' => lang("App.global_come_back"),
- 'route' => '/home',
- 'class' => 'btn btn-dark mr-1',
- 'icon' => 'fas fa-angle-left'
- ];
-
- $data['btn_submit'] = [
- 'title' => lang("App.global_save"),
- 'route' => '',
- 'class' => 'btn btn-primary mr-1',
- 'icon' => 'fas fa-save'
- ];
-
- $data['template'] = $this->template_model->findAll();
-
- echo view(getenv('theme.path').'main/header');
- echo view(getenv('theme.path').'form/settings/template', $data);
- echo view(getenv('theme.path').'main/footer');
- }
-
- public function template_store()
- {
- //Demo Mode
- if(env('demo.mode')??false){
- session()->setFlashdata('sweet', ['warning',lang("App.general_demo_mode")]);
- return redirect()->to('/settings/template');
- }
-
- $session = session();
- helper('form');
-
- if($field = $this->request->getPost()){
- $ids = [];
- $template = [];
- unset($field['files']);
- foreach ($field as $key=>$value){
- $id = explode('_',$key);
- array_push($ids,$id[2]);
- }
- foreach (array_unique($ids) as $item){
- $template[$item] = [];
- foreach ($field as $key=>$value){
- $id = explode('_',$key);
- if($id[2] == $item){
- if(empty($template[$item])){
- $template[$item] = array_merge( $template[$item],['id_template' => intval($id[2])]);
- $template[$item] = array_merge( $template[$item],['subject' => ""]);
- $template[$item] = array_merge( $template[$item],['body' => ""]);
- }
- switch($id[1])
- {
- case 'email';
- switch($id[0])
- {
- case 'title';
- $template[$item] = array_merge( $template[$item],['subject' => $value]);
- break;
- default;
- $template[$item] = array_merge( $template[$item],[$id[0] => $value]);
- break;
- }
- break;
- }
- }
- }
- }
- $this->template_model->updateBatch($template,'id_template');
- $session->setFlashdata('sweet', ['success',lang("App.template_alert_add")]);
- return redirect()->to('/settings/template');
- } else{
- $session->setFlashdata('sweet', ['error',lang("App.template_alert_error")]);
- return redirect()->to('/settings/template');
- }
- }
-}
diff --git a/ci4/app/Controllers/Sistema/Actividad.php b/ci4/app/Controllers/Sistema/Actividad.php
new file mode 100644
index 00000000..5bcf1627
--- /dev/null
+++ b/ci4/app/Controllers/Sistema/Actividad.php
@@ -0,0 +1,83 @@
+viewData['pageTitle'] = lang('Paises.moduleTitle');
+
+ // Breadcrumbs
+ $this->viewData['breadcrumb'] = [
+ ['title' => "Home", 'route' => "javascript:void(0);", 'active' => false],
+ ['title' => lang("App.menu_activity"), 'route' => route_to('activityList'), 'active' => true]
+ ];
+
+ parent::initController($request, $response, $logger);
+ }
+
+
+ public function index()
+ {
+
+ $viewData = [
+
+ 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Paises.pais')]),
+ 'activityEntity' => new ActivityEntity(),
+ 'usingServerSideDataTable' => true,
+ 'logs' => $this->model->getLogs()->get()->getResultArray()[0] // MEJORAR!!!
+
+ ];
+
+ $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
+
+ return view(static::$viewPath . static::$indexRoute, $viewData);
+ }
+
+
+ public function datatable()
+ {
+ if ($this->request->isAJAX()) {
+ $reqData = $this->request->getPost();
+ if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
+ $errstr = 'No data available in response to this specific request.';
+ $response = $this->respond(CollectionModel::datatable([], 0, 0, $errstr), 400, $errstr);
+ return $response;
+ }
+ $start = $reqData['start'] ?? 0;
+ $length = $reqData['length'] ?? 5;
+ $search = $reqData['search']['value'];
+ $requestedOrder = $reqData['order']['0']['column'] ?? 1;
+ $order = ActivityModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
+ $dir = $reqData['order']['0']['dir'] ?? 'asc';
+
+ $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
+
+ return $this->respond(CollectionModel::datatable(
+ $resourceData,
+ $this->model->getResource()->countAllResults(),
+ $this->model->getResource($search)->countAllResults()
+ ));
+ } else {
+ return $this->failUnauthorized('Invalid request', 403);
+ }
+ }
+
+
+}
diff --git a/ci4/app/Controllers/Sistema/Ajustes.php b/ci4/app/Controllers/Sistema/Ajustes.php
new file mode 100644
index 00000000..b70769e7
--- /dev/null
+++ b/ci4/app/Controllers/Sistema/Ajustes.php
@@ -0,0 +1,103 @@
+viewData['pageTitle'] = lang('Provincias.moduleTitle');
+ $this->viewData['usingSweetAlert'] = true;
+ parent::initController($request, $response, $logger);
+ }
+
+
+ public function settings()
+ {
+
+ $id = 1;
+ $settingsEntity = $this->model->find($id);
+
+ if (!$settingsEntity) :
+ $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Provincias.provincia')), $id]);
+ return $this->redirect2listView('sweet-error', $message);
+ endif;
+
+
+ if ($this->request->is('post')) :
+
+ $postData = $this->request->getPost();
+
+ $sanitizedData = $this->sanitized($postData, true);
+
+ $noException = true;
+ if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
+
+
+ if ($this->canValidate()) :
+ try {
+ $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
+ } catch (\Exception $e) {
+ $noException = false;
+ $this->dealWithException($e);
+ }
+ else:
+ $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Provincias.provincia'))]);
+ $this->session->setFlashdata('formErrors', $this->model->errors());
+
+ endif;
+
+ $settingsEntity->fill($sanitizedData);
+
+ $thenRedirect = false;
+ endif;
+ if ($noException && $successfulResult) :
+ $id = $settingsEntity->id ?? $id;
+ $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
+
+ if ($thenRedirect) :
+ if (!empty($this->indexRoute)) :
+ return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
+ else:
+ return $this->redirect2listView('sweet-success', $message);
+ endif;
+ else:
+ $this->session->setFlashData('sweet-success', $message);
+ endif;
+
+ endif; // $noException && $successfulResult
+ endif; // ($requestMethod === 'post')
+
+ $this->viewData['settingsEntity'] = $settingsEntity;
+ $this->viewData['formAction'] = route_to('settingsEdit');
+
+ $this->viewData['tables'] = db_connect()->listTables();
+
+
+ return $this->displayForm(__METHOD__, $id);
+ } // end function settings(...)
+
+
+
+
+
+}
diff --git a/ci4/app/Controllers/Tarifas/Tarifaacabado.php b/ci4/app/Controllers/Tarifas/Tarifaacabado.php
index 09f6e89e..b887c0a2 100755
--- a/ci4/app/Controllers/Tarifas/Tarifaacabado.php
+++ b/ci4/app/Controllers/Tarifas/Tarifaacabado.php
@@ -1,7 +1,7 @@
request->getMethod();
-
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -83,7 +78,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
- $sanitizedData['user_created_id'] = $session->id_user;
+ $sanitizedData['user_created_id'] = auth()->user()->id;
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
$sanitizedData['mostrar_en_presupuesto'] = false;
@@ -149,8 +144,6 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
public function edit($requestedId = null)
{
- // JJO
- $session = session();
if ($requestedId == null) :
return $this->redirect2listView();
@@ -163,9 +156,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
-
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -174,7 +165,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
- $sanitizedData['user_updated_id'] = $session->id_user;
+ $sanitizedData['user_updated_id'] = auth()->user()->id;
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
$sanitizedData['mostrar_en_presupuesto'] = false;
diff --git a/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php b/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php
index 88c311bc..e2dd423c 100755
--- a/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php
+++ b/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -150,9 +150,9 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php
index 6dfcb06f..8790a749 100755
--- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php
+++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -145,9 +145,9 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php
index 99665755..d6c14c06 100755
--- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php
+++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -145,9 +145,9 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\GoBaseResourceCon
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php
index 006cd3a4..d67b6565 100755
--- a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php
+++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -117,8 +117,6 @@ class Tarifaextra extends \App\Controllers\GoBaseController
public function edit($requestedId = null)
{
- // JJO
- $session = session();
if ($requestedId == null) :
return $this->redirect2listView();
@@ -131,9 +129,9 @@ class Tarifaextra extends \App\Controllers\GoBaseController
return $this->redirect2listView('errorMessage', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -142,7 +140,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
// JJO
if (isset($this->model->user_updated_id)) {
- $sanitizedData['user_updated_id'] = $session->id_user;
+ $sanitizedData['user_updated_id'] = auth()->user()->id;
}
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
$sanitizedData['mostrar_en_presupuesto'] = false;
diff --git a/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php
index b9e6d365..211e1791 100755
--- a/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php
+++ b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -147,9 +147,9 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
diff --git a/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php b/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php
index 06de776c..259cf32c 100755
--- a/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php
+++ b/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php
@@ -52,9 +52,9 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
{
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -117,8 +117,6 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
public function edit($requestedId = null)
{
- // JJO
- $session = session();
if ($requestedId == null) :
return $this->redirect2listView();
@@ -131,9 +129,9 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
return $this->redirect2listView('errorMessage', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -142,7 +140,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
// JJO
if (isset($this->model->user_updated_id)) {
- $sanitizedData['user_updated_id'] = $session->id_user;
+ $sanitizedData['user_updated_id'] = auth()->user()->id;
}
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
$sanitizedData['mostrar_en_presupuesto'] = false;
diff --git a/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php
index 3cf97601..be72c4d0 100755
--- a/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php
+++ b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -88,7 +86,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
// JJO
if (isset($this->model->user_updated_id)) {
- $sanitizedData['user_created_id'] = $session->id_user;
+ $sanitizedData['user_created_id'] = auth()->user()->id;
}
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
$sanitizedData['mostrar_en_presupuesto'] = false;
@@ -159,8 +157,6 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
public function edit($requestedId = null)
{
- // JJO
- $session = session();
if ($requestedId == null) :
return $this->redirect2listView();
@@ -173,9 +169,9 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -185,7 +181,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
// JJO
if (isset($this->model->user_updated_id)) {
- $sanitizedData['user_updated_id'] = $session->id_user;
+ $sanitizedData['user_updated_id'] = auth()->user()->id;
}
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
$sanitizedData['mostrar_en_presupuesto'] = false;
diff --git a/ci4/app/Controllers/Tarifas/Tarifasenvios.php b/ci4/app/Controllers/Tarifas/Tarifasenvios.php
index f5ce1e26..497343b3 100755
--- a/ci4/app/Controllers/Tarifas/Tarifasenvios.php
+++ b/ci4/app/Controllers/Tarifas/Tarifasenvios.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -87,7 +85,7 @@ class Tarifasenvios extends \App\Controllers\GoBaseResourceController {
// JJO
if (isset($this->model->user_updated_id)) {
- $sanitizedData['user_created_id'] = $session->id_user;
+ $sanitizedData['user_created_id'] = auth()->user()->id;
}
$noException = true;
@@ -144,8 +142,6 @@ class Tarifasenvios extends \App\Controllers\GoBaseResourceController {
public function edit($requestedId = null) {
- // JJO
- $session = session();
if ($requestedId == null) :
return $this->redirect2listView();
@@ -158,9 +154,9 @@ class Tarifasenvios extends \App\Controllers\GoBaseResourceController {
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -170,7 +166,7 @@ class Tarifasenvios extends \App\Controllers\GoBaseResourceController {
// JJO
if (isset($this->model->user_updated_id)) {
- $sanitizedData['user_updated_id'] = $session->id_user;
+ $sanitizedData['user_updated_id'] = auth()->user()->id;
}
$noException = true;
diff --git a/ci4/app/Controllers/Tarifas/Tarifasenviosprecios.php b/ci4/app/Controllers/Tarifas/Tarifasenviosprecios.php
index 146a133e..48454f0d 100755
--- a/ci4/app/Controllers/Tarifas/Tarifasenviosprecios.php
+++ b/ci4/app/Controllers/Tarifas/Tarifasenviosprecios.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -145,9 +145,9 @@ class Tarifasenviosprecios extends \App\Controllers\GoBaseResourceController {
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
diff --git a/ci4/app/Controllers/Tarifas/Tarifasenvioszonas.php b/ci4/app/Controllers/Tarifas/Tarifasenvioszonas.php
index e193ba54..834337c1 100755
--- a/ci4/app/Controllers/Tarifas/Tarifasenvioszonas.php
+++ b/ci4/app/Controllers/Tarifas/Tarifasenvioszonas.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -144,9 +144,9 @@ class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
diff --git a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php
index b245f1dd..07d706a0 100755
--- a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php
+++ b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php
@@ -1,7 +1,7 @@
request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -84,7 +82,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController
// JJO
if (isset($this->model->user_updated_id)) {
- $sanitizedData['user_created_id'] = $session->id_user;
+ $sanitizedData['user_created_id'] = auth()->user()->id;
}
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
$sanitizedData['mostrar_en_presupuesto'] = false;
@@ -142,8 +140,6 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController
public function edit($requestedId = null)
{
- // JJO
- $session = session();
if ($requestedId == null) :
return $this->redirect2listView();
@@ -156,9 +152,9 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController
return $this->redirect2listView('sweet-error', $message);
endif;
- $requestMethod = $this->request->getMethod();
+
- if ($requestMethod === 'post') :
+ if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
@@ -168,7 +164,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController
// JJO
if (isset($this->model->user_updated_id)) {
- $sanitizedData['user_updated_id'] = $session->id_user;
+ $sanitizedData['user_updated_id'] = auth()->user()->id;
}
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
$sanitizedData['mostrar_en_presupuesto'] = false;
diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php
index 240f8103..7d5ca1f6 100755
--- a/ci4/app/Controllers/Test.php
+++ b/ci4/app/Controllers/Test.php
@@ -7,6 +7,8 @@ use App\Models\Configuracion\MaquinasTarifasImpresionModel;
use App\Models\Configuracion\PapelGenericoModel;
use App\Models\Configuracion\MaquinaModel;
use App\Models\Presupuestos\PresupuestoModel;
+use App\Models\Usuarios\GroupModel;
+use App\Models\Usuarios\PermisosModel;
use App\Services\PresupuestoService;
class Test extends BaseController
@@ -17,9 +19,19 @@ class Test extends BaseController
public function index()
{
- $status = PresupuestoService::checkMaquina(1995);
- var_dump($status);
- echo xdebug_info();
+ helper('rbac');
+
+ //$user = auth()->user();
+
+
+ //echo generate_php_permissions_matrix_constant();
+
+ //$user->syncGroups('admin');
+
+ //var_dump($user->can('token.menu'));
+
+
+
}
diff --git a/ci4/app/Controllers/ViewMode.php b/ci4/app/Controllers/ViewMode.php
new file mode 100755
index 00000000..f08a63ee
--- /dev/null
+++ b/ci4/app/Controllers/ViewMode.php
@@ -0,0 +1,31 @@
+remove('view_mode');
+ $session->set('view_mode', $viewMode);
+ $url = previous_url();
+ return redirect()->to($url);
+ }
+}
diff --git a/ci4/app/Controllers/Viewmode.php b/ci4/app/Controllers/Viewmode.php
deleted file mode 100755
index 1be08ba3..00000000
--- a/ci4/app/Controllers/Viewmode.php
+++ /dev/null
@@ -1,18 +0,0 @@
-remove('view_mode');
- $session->set('view_mode', $viewMode);
- $url = previous_url();
- return redirect()->to($url);
- }
-}
diff --git a/ci4/app/Database/Migrations/2023-04-22-074343_ChangeTablesNames.php b/ci4/app/Database/Migrations/2023-04-22-074343_ChangeTablesNames.php
deleted file mode 100755
index 0e0782ae..00000000
--- a/ci4/app/Database/Migrations/2023-04-22-074343_ChangeTablesNames.php
+++ /dev/null
@@ -1,45 +0,0 @@
-forge->renameTable('wg_activity', 'auth_activity');
- $this->forge->renameTable('wg_backup', 'auth_backup');
- $this->forge->renameTable('wg_confirmation_token', 'auth_confirmation_token');
- $this->forge->renameTable('wg_crontab_history', 'auth_crontab_history');
- $this->forge->renameTable('wg_notification', 'auth_notification');
- $this->forge->renameTable('wg_password_recovery', 'auth_password_recovery');
- $this->forge->renameTable('wg_settings', 'auth_settings');
- $this->forge->renameTable('wg_template', 'auth_template');
- $this->forge->renameTable('wg_theme', 'auth_theme');
- $this->forge->renameTable('wg_timezone', 'auth_timezone');
- $this->forge->renameTable('wg_user', 'auth_user');
- $this->forge->renameTable('wg_user_group', 'auth_user_group');
- $this->forge->renameTable('wg_user_group', 'auth_user_group');
- $this->forge->renameTable('wg_countries', 'auth_countries');
- $this->forge->renameTable('wg_currency', 'auth_currency');
- }
-
- public function down()
- {
- $this->forge->renameTable('auth_activity', 'wg_activity');
- $this->forge->renameTable('auth_backup', 'wg_backup');
- $this->forge->renameTable('auth_confirmation_token', 'wg_confirmation_token');
- $this->forge->renameTable('auth_crontab_history', 'wg_crontab_history');
- $this->forge->renameTable('wg_notification', 'auth_notification');
- $this->forge->renameTable('auth_password_recovery', 'wg_password_recovery');
- $this->forge->renameTable('auth_settings', 'wg_settings');
- $this->forge->renameTable('auth_template', 'wg_template');
- $this->forge->renameTable('auth_theme', 'wg_theme');
- $this->forge->renameTable('auth_timezone', 'wg_timezone');
- $this->forge->renameTable('auth_user', 'wg_user');
- $this->forge->renameTable('auth_user_group', 'wg_user_group');
- $this->forge->renameTable('auth_countries', 'wg_countries');
- $this->forge->renameTable('auth_currency', 'wg_currency');
- }
-}
diff --git a/ci4/app/Database/Migrations/2023-04-22-083118_CreateGroupUserTable.php b/ci4/app/Database/Migrations/2023-04-22-083118_CreateGroupUserTable.php
deleted file mode 100755
index 622f5229..00000000
--- a/ci4/app/Database/Migrations/2023-04-22-083118_CreateGroupUserTable.php
+++ /dev/null
@@ -1,33 +0,0 @@
- array(
- 'type' => 'VARCHAR',
- 'constraint' => 35
- ),
- 'token_group' => array(
- 'type' => 'VARCHAR',
- 'constraint' => 35
- )
- );
-
- $this->forge->addField($fields);
-
- // create table
- $this->forge->createTable('group_user');
- }
-
- public function down()
- {
- $this->forge->dropTable('group_user',TRUE);
- }
-}
diff --git a/ci4/app/Database/Migrations/2023-04-25-161753_RemoveGroupFromUser.php b/ci4/app/Database/Migrations/2023-04-25-161753_RemoveGroupFromUser.php
deleted file mode 100755
index ee72788e..00000000
--- a/ci4/app/Database/Migrations/2023-04-25-161753_RemoveGroupFromUser.php
+++ /dev/null
@@ -1,19 +0,0 @@
-forge->dropColumn('auth_user', ['group']);
- }
-
- public function down()
- {
- $sql = "ALTER TABLE `auth_user` ADD `group` varchar(216) COLLATE latin1_general_ci;";
- $this->db->query($sql);
- }
-}
diff --git a/ci4/app/Database/Migrations/2023_03_27_185500_DeleteOauthTables.php b/ci4/app/Database/Migrations/2023_03_27_185500_DeleteOauthTables.php
deleted file mode 100755
index 510986cb..00000000
--- a/ci4/app/Database/Migrations/2023_03_27_185500_DeleteOauthTables.php
+++ /dev/null
@@ -1,43 +0,0 @@
-forge->dropTable('wg_user_oauth');
- $this->forge->dropTable('wg_settings_oauth');
- }
-
- public function down()
- {
- $sql = "CREATE TABLE IF NOT EXISTS `wg_settings_oauth` (
- `id_oauth` int(11) NOT NULL AUTO_INCREMENT,
- `provider` enum('facebook','google','twitter','linkedin','github','instagram','slack','spotify','reddit','discord','dribbble','dropbox','gitlab','strava','tumblr','twitch','vkontakte','wordpress','yahoo','bitbucket','wechat') COLLATE latin1_general_ci NOT NULL,
- `key` varchar(200) COLLATE latin1_general_ci DEFAULT NULL,
- `secret` varchar(200) COLLATE latin1_general_ci DEFAULT NULL,
- `btn_class` varchar(50) COLLATE latin1_general_ci NOT NULL,
- `btn_text` varchar(50) COLLATE latin1_general_ci DEFAULT NULL,
- `show_text` tinyint(1) NOT NULL DEFAULT '0',
- `icon_class` varchar(50) COLLATE latin1_general_ci NOT NULL,
- `status` tinyint(1) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id_oauth`)
- ) ENGINE=MyISAM AUTO_INCREMENT=22 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;";
- $this->db->query($sql);
-
- $sql = "CREATE TABLE IF NOT EXISTS `wg_user_oauth` (
- `id_user_oauth` int(11) NOT NULL AUTO_INCREMENT,
- `user` varchar(35) COLLATE latin1_general_ci NOT NULL,
- `provider` enum('facebook','google','twitter','linkedin','github','instagram','slack','spotify','reddit','discord','dribbble','dropbox','gitlab','strava','tumblr','twitch','vkontakte','wordpress','yahoo','bitbucket') COLLATE latin1_general_ci NOT NULL,
- `identifier` varchar(50) COLLATE latin1_general_ci NOT NULL,
- `picture` varchar(150) COLLATE latin1_general_ci NOT NULL,
- `created_at` timestamp NOT NULL,
- `updated_at` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (`id_user_oauth`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;";
- $this->db->query($sql);
- }
-}
\ No newline at end of file
diff --git a/ci4/app/Database/Migrations/2023_03_28_200000_DeleteSMSColumns.php b/ci4/app/Database/Migrations/2023_03_28_200000_DeleteSMSColumns.php
deleted file mode 100755
index 0246bac6..00000000
--- a/ci4/app/Database/Migrations/2023_03_28_200000_DeleteSMSColumns.php
+++ /dev/null
@@ -1,42 +0,0 @@
-forge->dropColumn('notification', ['is_send_sms', 'send_sms_notification']);
- $this->forge->dropColumn('settings', ['sms_gateway','sms_account_id', 'sms_auth_token', 'sms_info_add',
- 'sms_confirmation', 'send_sms_register', 'send_sms_welcome']);
- $this->forge->dropColumn('user', ['sms_confirmed']);
- }
-
- public function down()
- {
- $sql = "ALTER TABLE `wg_notification` ADD `is_send_sms` tinyint(1) NOT NULL DEFAULT '0';";
- $this->db->query($sql);
- $sql = "ALTER TABLE `wg_notification` ADD `send_sms_notification` tinyint(1) NOT NULL DEFAULT '0';";
- $this->db->query($sql);
-
- $sql = "ALTER TABLE `wg_settings` ADD `sms_gateway` enum('twilio') COLLATE latin1_general_ci NOT NULL DEFAULT 'twilio';";
- $this->db->query($sql);
- $sql = "ALTER TABLE `wg_settings` ADD `sms_account_id` varchar(255) COLLATE latin1_general_ci DEFAULT NULL;";
- $this->db->query($sql);
- $sql = "ALTER TABLE `wg_settings` ADD `sms_auth_token` varchar(255) COLLATE latin1_general_ci DEFAULT NULL;";
- $this->db->query($sql);
- $sql = "ALTER TABLE `wg_settings` ADD `sms_info_add` varchar(255) COLLATE latin1_general_ci DEFAULT NULL;";
- $this->db->query($sql);
- $sql = "ALTER TABLE `wg_settings` ADD `sms_confirmation` tinyint(1) NOT NULL DEFAULT '0';";
- $this->db->query($sql);
- $sql = "ALTER TABLE `wg_settings` ADD `send_sms_register` tinyint(1) NOT NULL DEFAULT '0';";
- $this->db->query($sql);
- $sql = "ALTER TABLE `wg_settings` ADD `send_sms_welcome` tinyint(1) NOT NULL DEFAULT '0';";
- $this->db->query($sql);
-
- $sql = "ALTER TABLE `wg_user` ADD `sms_confirmed` tinyint(4) NOT NULL DEFAULT '0';";
- $this->db->query($sql);
- }
-}
\ No newline at end of file
diff --git a/ci4/app/Entities/GoBaseEntity.php b/ci4/app/Entities/GoBaseEntity.php
deleted file mode 100755
index d28a00be..00000000
--- a/ci4/app/Entities/GoBaseEntity.php
+++ /dev/null
@@ -1,26 +0,0 @@
- $value) {
- if (isset($this->attributes[$key])) {
- $this->attributes[$key] = $value;
- }
- }
- return $this;
- }
-}
\ No newline at end of file
diff --git a/ci4/app/Entities/Sistema/ActivityEntity.php b/ci4/app/Entities/Sistema/ActivityEntity.php
new file mode 100644
index 00000000..672e282a
--- /dev/null
+++ b/ci4/app/Entities/Sistema/ActivityEntity.php
@@ -0,0 +1,24 @@
+ null,
+ "user_id" => null,
+ "level" => null,
+ "event" => null,
+ "ip" => null,
+ "os" => null,
+ "browser" => null,
+ "detail" => null,
+ "created_at" => null,
+ "updated_at" => null,
+ ];
+ protected $casts = [
+
+ ];
+}
diff --git a/ci4/app/Entities/Sistema/SettingsEntity.php b/ci4/app/Entities/Sistema/SettingsEntity.php
new file mode 100644
index 00000000..0daaba12
--- /dev/null
+++ b/ci4/app/Entities/Sistema/SettingsEntity.php
@@ -0,0 +1,32 @@
+ null,
+ "email_name" => null,
+ "email_address" => null,
+ "email_smtp" => null,
+ "email_port" => null,
+ "email_pass" => null,
+ "email_cert" => null,
+ "remove_log" => null,
+ "remove_log_time" => null,
+ "remove_log_latest" => null,
+ "storage_gateway" => null,
+ "backup_storage" => null,
+ "backup_table" => null,
+ "backup_email" => null,
+ "backup_notification_email" => null,
+ "backup_automatic" => null,
+ "backup_time" => null,
+ "backup_latest" => null,
+ ];
+ protected $casts = [
+
+ ];
+}
diff --git a/ci4/app/Entities/Usuarios/UserGroupEntity.php b/ci4/app/Entities/Usuarios/GroupEntity.php
old mode 100755
new mode 100644
similarity index 52%
rename from ci4/app/Entities/Usuarios/UserGroupEntity.php
rename to ci4/app/Entities/Usuarios/GroupEntity.php
index 866535d2..9bd28a63
--- a/ci4/app/Entities/Usuarios/UserGroupEntity.php
+++ b/ci4/app/Entities/Usuarios/GroupEntity.php
@@ -3,16 +3,18 @@ namespace App\Entities\Usuarios;
use CodeIgniter\Entity;
-class UserGroupEntity extends \CodeIgniter\Entity\Entity
+class GroupEntity extends \CodeIgniter\Entity\Entity
{
protected $attributes = [
- "id_group" => null,
+ "id" => null,
+ "keyword" => null,
"title" => null,
- "dashboard" => null,
+ "description" => null,
"rules" => null,
- "token" => null,
"created_at" => null,
"updated_at" => null,
];
- protected $casts = [];
+ protected $casts = [
+ "rules" => "json",
+ ];
}
diff --git a/ci4/app/Entities/Usuarios/PermisosEntity.php b/ci4/app/Entities/Usuarios/PermisosEntity.php
new file mode 100644
index 00000000..339cdd56
--- /dev/null
+++ b/ci4/app/Entities/Usuarios/PermisosEntity.php
@@ -0,0 +1,20 @@
+ null,
+ "keyword" => null,
+ "name" => null,
+ "description" => null,
+ "rules" => null,
+ "created_at" => null,
+ "updated_at" => null,
+ ];
+ protected $casts = [
+ "rules" => "json",
+ ];
+}
diff --git a/ci4/app/Filters/JWTAuthFilter.php b/ci4/app/Filters/JWTAuthFilter.php
deleted file mode 100755
index 9f9a5bdc..00000000
--- a/ci4/app/Filters/JWTAuthFilter.php
+++ /dev/null
@@ -1,28 +0,0 @@
-getServer('HTTP_AUTHORIZATION')));
- return $request;
- } catch (Exception $e) {
- return Services::response()->setJSON(['error' => $e->getMessage()])->setStatusCode(ResponseInterface::HTTP_UNAUTHORIZED);
- }
- }
-
- public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
- {
-
- }
-}
\ No newline at end of file
diff --git a/ci4/app/Filters/LoginAuthFilter.php b/ci4/app/Filters/LoginAuthFilter.php
old mode 100755
new mode 100644
diff --git a/ci4/app/Filters/ThrottlerFilter.php b/ci4/app/Filters/ThrottlerFilter.php
deleted file mode 100755
index d7538ba0..00000000
--- a/ci4/app/Filters/ThrottlerFilter.php
+++ /dev/null
@@ -1,43 +0,0 @@
-getIPAddress();
- $settingsBase = new SettingsModel();
- $settings = $settingsBase->first()??[];
- if(!$settings['enable_api']){
- return Services::response()->setJSON(['error' => 'ApiRest is currently disabled.'])->setStatusCode(ResponseInterface::HTTP_UNAUTHORIZED);
- }
- if($settings['block_external_api']){
- if($ip != $settings['ip_allowed_api']??''){
- return Services::response()->setJSON(['error' => 'Endpoint access from external domains is not allowed.'])->setStatusCode(ResponseInterface::HTTP_UNAUTHORIZED);
- }
- if ($throttler->check($ip, 60, MINUTE) === false)
- {
- return Services::response()->setStatusCode(429);
- }
- }
- } catch (Exception $e) {
- return Services::response()->setJSON(['error' => $e->getMessage()])->setStatusCode(ResponseInterface::HTTP_UNAUTHORIZED);
- }
- }
-
- public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
- {
-
- }
-}
\ No newline at end of file
diff --git a/ci4/app/Helpers/general_helper.php b/ci4/app/Helpers/general_helper.php
index 8e5ea3ed..e0578134 100755
--- a/ci4/app/Helpers/general_helper.php
+++ b/ci4/app/Helpers/general_helper.php
@@ -8,8 +8,10 @@ function ruleIsChecked($rules, $section, $method){
if ($rules==null){
return false;
}
- $json = json_decode($rules);
- foreach($json as $key=>$value){
+ if(is_string($rules)){
+ $rules = json_decode($rules);
+ }
+ foreach($rules as $key=>$value){
if($key==$section){
foreach($value as $item){
if($item==$method){
diff --git a/ci4/app/Helpers/go_common_helper.php b/ci4/app/Helpers/go_common_helper.php
index 624017df..7adcc2be 100755
--- a/ci4/app/Helpers/go_common_helper.php
+++ b/ci4/app/Helpers/go_common_helper.php
@@ -165,4 +165,18 @@ if (!function_exists('newUUID')) {
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
+}
+
+if (!function_exists('getSystemSettings')) {
+ function getSystemSettings()
+ {
+ // Get Settings
+ $session = session();
+ $settingsBase = new \App\Models\Sistema\SettingsModel();
+ $settings = $settingsBase->asArray()->first() ?? [];
+ $session->set('settings', $settings);
+ if (empty($session->get('lang'))) {
+ $session->set('lang', 'es');
+ }
+ }
}
\ No newline at end of file
diff --git a/ci4/app/Helpers/jwt_helper.php b/ci4/app/Helpers/jwt_helper.php
deleted file mode 100755
index d00d4529..00000000
--- a/ci4/app/Helpers/jwt_helper.php
+++ /dev/null
@@ -1,59 +0,0 @@
-first()??[];
- $decode = JWT::decode($token, $settings['jwt_private_key']??'', ['HS256']);
- $userModel = new UserModel();
- return $userModel->where('email', $decode->email)->first();
- }
-}
-
-/**
- * Signs a new token.
- * @access public
- * @param string $email
- * @return string
- */
-if(!function_exists('jwtSignature')) {
- function jwtSignature(string $email)
- {
- $settingsBase = new SettingsModel();
- $settings = $settingsBase->first()??[];
- $time = time();
- $expiration = $time + (intval($settings['jwt_token_lifetime']??0) * 60);
- $payload = [
- 'email' => $email,
- 'iat' => $time,
- 'exp' => $expiration,
- ];
- return JWT::encode($payload, $settings['jwt_private_key']??'');
- }
-}
\ No newline at end of file
diff --git a/ci4/app/Helpers/logger_helper.php b/ci4/app/Helpers/logger_helper.php
new file mode 100644
index 00000000..58883455
--- /dev/null
+++ b/ci4/app/Helpers/logger_helper.php
@@ -0,0 +1,41 @@
+getIPAddress();
+ $agent = $request->getUserAgent();
+
+ $currentAgent = identifyAgent($agent);
+
+ $activity_model->save([
+ 'user_id' => $user_id,
+ 'level' => $level,
+ 'event' => $event,
+ 'ip' => $ip,
+ 'os' => $agent->getPlatform(),
+ 'browser' => $currentAgent,
+ 'detail' => $agent
+ ]);
+ }
+}
+
+
+if (!function_exists('identifyAgent')) {
+ function identifyAgent($agent)
+ {
+ if ($agent->isBrowser()) {
+ return $agent->getBrowser() . ' ' . $agent->getVersion();
+ }
+ if ($agent->isRobot()) {
+ return $agent->getRobot();
+ }
+ if ($agent->isMobile()) {
+ return $agent->getMobile();
+ }
+ return 'Unidentified User Agent';
+ }
+}
diff --git a/ci4/app/Helpers/rbac_helper.php b/ci4/app/Helpers/rbac_helper.php
new file mode 100644
index 00000000..04d8f403
--- /dev/null
+++ b/ci4/app/Helpers/rbac_helper.php
@@ -0,0 +1,96 @@
+getRolesList();
+
+ // Start of the file
+ $phpCode = " $values) {
+ $phpCode .= " '{$key}' => [\n";
+ foreach ($values as $subkey => $value) {
+ $phpCode .= " '{$subkey}' => '{$value}',\n";
+ }
+ $phpCode .= " ],\n";
+ }
+
+ // Close the array
+ $phpCode .= "];\n";
+
+ // Write PHP code to a file
+ $filePath = APPPATH . "Config/RBAC/roles.php";
+ file_put_contents($filePath, $phpCode);
+
+ }
+}
+
+
+if (!function_exists('generate_php_permissions_constant')) {
+ function generate_php_permissions_constant()
+ {
+ // Generate the array of keys
+ $array = (new PermisosModel())->getPermissionsList();
+
+ // Start of the file
+ $phpCode = " $value) {
+ // Using single quotes to ensure keys/values are emitted as literals
+ $phpCode .= "\t'{$key}' => '{$value}',\n";
+ }
+
+ // Close the array
+ $phpCode .= "];\n";
+
+ // Write PHP code to a file
+ $filePath = APPPATH . "Config/RBAC/permissions.php";
+ file_put_contents($filePath, $phpCode);
+ }
+}
+
+if (!function_exists('generate_php_permissions_matrix_constant')) {
+ function generate_php_permissions_matrix_constant()
+ {
+ $matrix = (new GroupModel())->getRolesPermissionMatrix();
+
+
+ // Start of the file
+ $phpCode = " $permissions) {
+ $phpCode .= "\t\"{$role}\" => [\n";
+ foreach ($permissions as $permission) {
+ $phpCode .= "\t\t\"{$permission}\",\n";
+ }
+ $phpCode .= "\t],\n";
+ }
+ // Close the array
+ $phpCode .= "];\n";
+
+ // Write PHP code to a file
+ $filePath = APPPATH . "Config/RBAC/permissionMatrix.php";
+ file_put_contents($filePath, $phpCode);
+ }
+}
+
+
+
diff --git a/ci4/app/Language/en/Auth.php b/ci4/app/Language/en/Auth.php
new file mode 100644
index 00000000..6f34fe3e
--- /dev/null
+++ b/ci4/app/Language/en/Auth.php
@@ -0,0 +1,117 @@
+
+ *
+ * For the full copyright and license information, please view
+ * the LICENSE file that was distributed with this source code.
+ */
+
+return [
+ // Exceptions
+ 'unknownAuthenticator' => '{0} is not a valid authenticator.',
+ 'unknownUserProvider' => 'Unable to determine the User Provider to use.',
+ 'invalidUser' => 'Unable to locate the specified user.',
+ 'bannedUser' => 'Can not log you in as you are currently banned.',
+ 'logOutBannedUser' => 'You have been logged out because you have been banned.',
+ 'badAttempt' => 'Unable to log you in. Please check your credentials.',
+ 'noPassword' => 'Cannot validate a user without a password.',
+ 'invalidPassword' => 'Unable to log you in. Please check your password.',
+ 'noToken' => 'Every request must have a bearer token in the {0} header.',
+ 'badToken' => 'The access token is invalid.',
+ 'oldToken' => 'The access token has expired.',
+ 'noUserEntity' => 'User Entity must be provided for password validation.',
+ 'invalidEmail' => 'Unable to verify the email address matches the email on record.',
+ 'unableSendEmailToUser' => 'Sorry, there was a problem sending the email. We could not send an email to "{0}".',
+ 'throttled' => 'Too many requests made from this IP address. You may try again in {0} seconds.',
+ 'notEnoughPrivilege' => 'You do not have the necessary permission to perform the desired operation.',
+ // JWT Exceptions
+ 'invalidJWT' => 'The token is invalid.',
+ 'expiredJWT' => 'The token has expired.',
+ 'beforeValidJWT' => 'The token is not yet available.',
+
+ 'email' => 'Email Address',
+ 'username' => 'Username',
+ 'password' => 'Password',
+ 'passwordConfirm' => 'Password (again)',
+ 'haveAccount' => 'Already have an account?',
+ 'token' => 'Token',
+
+ // Buttons
+ 'confirm' => 'Confirm',
+ 'send' => 'Send',
+
+ // Registration
+ 'register' => 'Register',
+ 'registerDisabled' => 'Registration is not currently allowed.',
+ 'registerSuccess' => 'Welcome aboard!',
+
+ // Login
+ 'login' => 'Login',
+ 'needAccount' => 'Need an account?',
+ 'rememberMe' => 'Remember me?',
+ 'forgotPassword' => 'Forgot your password?',
+ 'useMagicLink' => 'Use a Login Link',
+ 'magicLinkSubject' => 'Your Login Link',
+ 'magicTokenNotFound' => 'Unable to verify the link.',
+ 'magicLinkExpired' => 'Sorry, link has expired.',
+ 'checkYourEmail' => 'Check your email!',
+ 'magicLinkDetails' => 'We just sent you an email with a Login link inside. It is only valid for {0} minutes.',
+ 'magicLinkDisabled' => 'Use of MagicLink is currently not allowed.',
+ 'successLogout' => 'You have successfully logged out.',
+ 'backToLogin' => 'Back to Login',
+
+ // Passwords
+ 'errorPasswordLength' => 'Passwords must be at least {0, number} characters long.',
+ 'suggestPasswordLength' => 'Pass phrases - up to 255 characters long - make more secure passwords that are easy to remember.',
+ 'errorPasswordCommon' => 'Password must not be a common password.',
+ 'suggestPasswordCommon' => 'The password was checked against over 65k commonly used passwords or passwords that have been leaked through hacks.',
+ 'errorPasswordPersonal' => 'Passwords cannot contain re-hashed personal information.',
+ 'suggestPasswordPersonal' => 'Variations on your email address or username should not be used for passwords.',
+ 'errorPasswordTooSimilar' => 'Password is too similar to the username.',
+ 'suggestPasswordTooSimilar' => 'Do not use parts of your username in your password.',
+ 'errorPasswordPwned' => 'The password {0} has been exposed due to a data breach and has been seen {1, number} times in {2} of compromised passwords.',
+ 'suggestPasswordPwned' => '{0} should never be used as a password. If you are using it anywhere change it immediately.',
+ 'errorPasswordEmpty' => 'A Password is required.',
+ 'errorPasswordTooLongBytes' => 'Password cannot exceed {param} bytes in length.',
+ 'passwordChangeSuccess' => 'Password changed successfully',
+ 'userDoesNotExist' => 'Password was not changed. User does not exist',
+ 'resetTokenExpired' => 'Sorry. Your reset token has expired.',
+
+ // Email Globals
+ 'emailInfo' => 'Some information about the person:',
+ 'emailIpAddress' => 'IP Address:',
+ 'emailDevice' => 'Device:',
+ 'emailDate' => 'Date:',
+
+ // 2FA
+ 'email2FATitle' => 'Two Factor Authentication',
+ 'confirmEmailAddress' => 'Confirm your email address.',
+ 'emailEnterCode' => 'Confirm your Email',
+ 'emailConfirmCode' => 'Enter the 6-digit code we just sent to your email address.',
+ 'email2FASubject' => 'Your authentication code',
+ 'email2FAMailBody' => 'Your authentication code is:',
+ 'invalid2FAToken' => 'The code was incorrect.',
+ 'need2FA' => 'You must complete a two-factor verification.',
+ 'needVerification' => 'Check your email to complete account activation.',
+
+ // Activate
+ 'emailActivateTitle' => 'Email Activation',
+ 'emailActivateBody' => 'We just sent an email to you with a code to confirm your email address. Copy that code and paste it below.',
+ 'emailActivateSubject' => 'Your activation code',
+ 'emailActivateMailBody' => 'Please use the code below to activate your account and start using the site.',
+ 'invalidActivateToken' => 'The code was incorrect.',
+ 'needActivate' => 'You must complete your registration by confirming the code sent to your email address.',
+ 'activationBlocked' => 'You must activate your account before logging in.',
+
+ // Groups
+ 'unknownGroup' => '{0} is not a valid group.',
+ 'missingTitle' => 'Groups must have a title.',
+
+ // Permissions
+ 'unknownPermission' => '{0} is not a valid permission.',
+];
diff --git a/ci4/app/Language/es/Auth.php b/ci4/app/Language/es/Auth.php
new file mode 100644
index 00000000..def23c16
--- /dev/null
+++ b/ci4/app/Language/es/Auth.php
@@ -0,0 +1,117 @@
+
+ *
+ * For the full copyright and license information, please view
+ * the LICENSE file that was distributed with this source code.
+ */
+
+return [
+ // Excepciones
+ 'unknownAuthenticator' => '{0} no es un autenticador válido.',
+ 'unknownUserProvider' => 'No se puede determinar el proveedor de usuario a utilizar.',
+ 'invalidUser' => 'No se puede localizar al usuario especificado.',
+ 'bannedUser' => 'No puedes iniciar sesión ya que estás actualmente vetado.',
+ 'logOutBannedUser' => 'Se ha cerrado la sesión porque se ha vetado al usuario.',
+ 'badAttempt' => 'No se puede iniciar sesión. Por favor, comprueba tus credenciales.',
+ 'noPassword' => 'No se puede validar un usuario sin contraseña.',
+ 'invalidPassword' => 'No se puede iniciar sesión. Por favor, comprueba tu contraseña.',
+ 'noToken' => 'Cada solicitud debe tener un token de portador en la cabecera {0}.',
+ 'badToken' => 'El token de acceso no es válido.',
+ 'oldToken' => 'El token de acceso ha caducado.',
+ 'noUserEntity' => 'Se debe proporcionar una entidad de usuario para la validación de contraseña.',
+ 'invalidEmail' => 'No se puede verificar que la dirección de correo electrónico coincida con la registrada.',
+ 'unableSendEmailToUser' => 'Lo siento, hubo un problema al enviar el correo electrónico. No pudimos enviar un correo electrónico a "{0}".',
+ 'throttled' => 'Se han realizado demasiadas solicitudes desde esta dirección IP. Puedes intentarlo de nuevo en {0} segundos.',
+ 'notEnoughPrivilege' => 'No tienes los permisos necesarios para realizar la operación deseada.',
+ // JWT Exceptions
+ 'invalidJWT' => '(To be translated) The token is invalid.',
+ 'expiredJWT' => '(To be translated) The token has expired.',
+ 'beforeValidJWT' => '(To be translated) The token is not yet available.',
+
+ 'email' => 'Correo Electrónico',
+ 'username' => 'Nombre de usuario',
+ 'password' => 'Contraseña',
+ 'passwordConfirm' => 'Contraseña (otra vez)',
+ 'haveAccount' => '¿Ya tienes una cuenta?',
+ 'token' => '(To be translated) Token',
+
+ // Botones
+ 'confirm' => 'Confirmar',
+ 'send' => 'Enviar',
+
+ // Registro
+ 'register' => 'Registrarse',
+ 'registerDisabled' => 'Actualmente no se permite el registro.',
+ 'registerSuccess' => '¡Bienvenido a bordo!',
+
+ // Login
+ 'login' => 'Iniciar sesión',
+ 'needAccount' => '¿Necesitas una cuenta?',
+ 'rememberMe' => 'Recordarme',
+ 'forgotPassword' => '¿Olvidaste tu contraseña?',
+ 'useMagicLink' => 'Usar un enlace de inicio de sesión',
+ 'magicLinkSubject' => 'Tu enlace de inicio de sesión',
+ 'magicTokenNotFound' => 'No se puede verificar el enlace.',
+ 'magicLinkExpired' => 'Lo siento, el enlace ha caducado.',
+ 'checkYourEmail' => '¡Revisa tu correo electrónico!',
+ 'magicLinkDetails' => 'Acabamos de enviarte un correo electrónico con un enlace de inicio de sesión. Solo es válido durante {0} minutos.',
+ 'magicLinkDisabled' => '(To be translated) Use of MagicLink is currently not allowed.',
+ 'successLogout' => 'Has cerrado sesión correctamente.',
+ 'backToLogin' => 'Volver al inicio de sesión',
+
+ // Contraseñas
+ 'errorPasswordLength' => 'Las contraseñas deben tener al menos {0, number} caracteres.',
+ 'suggestPasswordLength' => 'Las frases de contraseña, de hasta 255 caracteres de longitud, hacen que las contraseñas sean más seguras y fáciles de recordar.',
+ 'errorPasswordCommon' => 'La contraseña no puede ser una contraseña común.',
+ 'suggestPasswordCommon' => 'La contraseña se comprobó frente a más de 65k contraseñas comúnmente utilizadas o contraseñas que se filtraron a través de ataques.',
+ 'errorPasswordPersonal' => 'Las contraseñas no pueden contener información personal reutilizada.',
+ 'suggestPasswordPersonal' => 'No se deben usar variaciones de su dirección de correo electrónico o nombre de usuario como contraseña.',
+ 'errorPasswordTooSimilar' => 'La contraseña es demasiado similar al nombre de usuario.',
+ 'suggestPasswordTooSimilar' => 'No use partes de su nombre de usuario en su contraseña.',
+ 'errorPasswordPwned' => 'La contraseña {0} se ha expuesto debido a una violación de datos y se ha visto {1, number} veces en {2} de contraseñas comprometidas.',
+ 'suggestPasswordPwned' => 'Nunca se debe usar {0} como contraseña. Si lo está utilizando en algún lugar, cambie su contraseña de inmediato.',
+ 'errorPasswordEmpty' => 'Se requiere una contraseña.',
+ 'errorPasswordTooLongBytes' => 'La contraseña no puede tener más de {param} caracteres',
+ 'passwordChangeSuccess' => 'Contraseña cambiada correctamente',
+ 'userDoesNotExist' => 'La contraseña no se cambió. El usuario no existe',
+ 'resetTokenExpired' => 'Lo siento. Su token de reinicio ha caducado.',
+
+ // Email Globals
+ 'emailInfo' => 'Alguna información sobre la persona:',
+ 'emailIpAddress' => 'Dirección IP:',
+ 'emailDevice' => 'Dispositivo:',
+ 'emailDate' => 'Fecha:',
+
+ // 2FA
+ 'email2FATitle' => 'Autenticación de dos factores',
+ 'confirmEmailAddress' => 'Confirma tu dirección de correo electrónico.',
+ 'emailEnterCode' => 'Confirma tu correo electrónico',
+ 'emailConfirmCode' => 'Ingresa el código de 6 dígitos que acabamos de enviar a tu correo electrónico.',
+ 'email2FASubject' => 'Tu código de autenticación',
+ 'email2FAMailBody' => 'Tu código de autenticación es:',
+ 'invalid2FAToken' => 'El código era incorrecto.',
+ 'need2FA' => 'Debes completar la verificación de dos factores.',
+ 'needVerification' => 'Verifica tu correo electrónico para completar la activación de la cuenta.',
+
+ // Activar
+ 'emailActivateTitle' => 'Activación de correo electrónico',
+ 'emailActivateBody' => 'Acabamos de enviarte un correo electrónico con un código para confirmar tu dirección de correo electrónico. Copia ese código y pégalo a continuación.',
+ 'emailActivateSubject' => 'Tu código de activación',
+ 'emailActivateMailBody' => 'Utiliza el código siguiente para activar tu cuenta y comenzar a usar el sitio.',
+ 'invalidActivateToken' => 'El código era incorrecto.',
+ 'needActivate' => 'Debes completar tu registro confirmando el código enviado a tu dirección de correo electrónico.',
+ 'activationBlocked' => 'Debes activar tu cuenta antes de iniciar sesión.',
+
+ // Grupos
+ 'unknownGroup' => '{0} no es un grupo válido.',
+ 'missingTitle' => 'Los grupos deben tener un título.',
+
+ // Permisos
+ 'unknownPermission' => '{0} no es un permiso válido.',
+];
diff --git a/ci4/app/Language/es/Group.php b/ci4/app/Language/es/Group.php
deleted file mode 100755
index 8f1a9e18..00000000
--- a/ci4/app/Language/es/Group.php
+++ /dev/null
@@ -1,56 +0,0 @@
- 'Creado en',
- 'dashboard' => 'Panel',
- 'group_grid_dashboard' => 'Panel',
- 'idGroup' => 'ID Rol',
- 'moduleTitle' => 'Roles y Permisos',
- 'rules' => 'Reglas',
- 'title' => 'Nombre',
- 'group_grid_title' => 'Nombre',
- 'token' => 'Token',
- 'updatedAt' => 'Actualizado en',
- 'groups' => 'Roles y Permisos',
- 'Group' => 'Rol y Permisos',
- 'userGroup' => 'Rol y Permisos',
- 'group' => 'Rol y Permisos',
- 'grouplist' => 'Lista Roles y Permisos',
- 'Groups' => 'Roles y Permisos',
- 'validation' => [
- 'id_group' => [
- 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
-
- ],
-
- 'dashboard' => [
- 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
- 'required' => 'El campo {field} es obligatorio.',
-
- ],
-
- 'rules' => [
- 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
- 'required' => 'El campo {field} es obligatorio.',
-
- ],
-
- 'title' => [
- 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
- 'required' => 'El campo {field} es obligatorio.',
-
- ],
-
- 'token' => [
- 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
- 'required' => 'El campo {field} es obligatorio.',
-
- ],
-
-
- ],
-
-
-];
\ No newline at end of file
diff --git a/ci4/app/Language/es/RolesPermisos.php b/ci4/app/Language/es/RolesPermisos.php
new file mode 100644
index 00000000..7f0a9d4b
--- /dev/null
+++ b/ci4/app/Language/es/RolesPermisos.php
@@ -0,0 +1,65 @@
+ 'Roles y Permisos',
+ 'name' => 'Nombre del Grupo',
+ 'rules' => 'Reglas',
+ 'createdAt' => 'Creado en',
+ 'updatedAt' => 'Actualizado en',
+
+ 'addRol' => 'Añadir rol si no existe',
+ 'totalUsers' => ' usuarios en total',
+ 'editRol' => 'Editar Rol',
+ 'rolName' => 'Nombre del Rol',
+ 'rolDescription' => 'Descripción del Rol',
+ 'rolPermissions' => 'Permisos del Rol',
+ 'selectAll' => 'Seleccionar todos',
+
+ 'adminRol' => 'Rol de Administrador',
+ 'adminRolTooltip' => 'Permitir acceso completo al sistema',
+
+ // System permissions
+ 'createPermission' => 'Crear',
+ 'editPermission' => 'Editar',
+ 'deletePermission' => 'Eliminar',
+
+ // System sections
+ 'clientesSection' => 'Clientes',
+ 'plantillaTarifaSection' => 'Plantilla de tarifas',
+ 'presupuestoSection' => 'Presupuestos',
+ 'tarifaPreimpresionSection' => 'Tarifas de preimpresión',
+ 'tarifaManipuladoSection' => 'Tarifas de manipulado',
+ 'tarifaAcabadoSection' => 'Tarifas de acabado',
+ 'tarifaEncuadernacionSection' => 'Tarifas de encuadernación',
+ 'tarifaEnvioSection' => 'Tarifas de envio',
+ 'proveedoresSection' => 'Proveedores',
+ 'ajustesSection' => 'Ajustes',
+ 'actividadSection' => 'Accesos',
+
+
+
+ 'validation' => [
+ 'id' => [
+ 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
+ ],
+ 'keyword' => [
+ 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
+ 'required' => 'El campo {field} es obligatorio.',
+ ],
+ 'name' => [
+ 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
+ 'required' => 'El campo {field} es obligatorio.',
+ ],
+ 'description' => [
+ 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
+ 'required' => 'El campo {field} es obligatorio.',
+ ],
+ 'rules' => [
+ 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
+ 'required' => 'El campo {field} es obligatorio.',
+
+ ],
+ ],
+
+
+];
\ No newline at end of file
diff --git a/ci4/app/Libraries/Authenticator.php b/ci4/app/Libraries/Authenticator.php
deleted file mode 100755
index 2c895b19..00000000
--- a/ci4/app/Libraries/Authenticator.php
+++ /dev/null
@@ -1,160 +0,0 @@
-Base32T();
- if ($secretLength < 16 || $secretLength > 128) {
- throw new Exception('Bad secret length');
- }
- $secret = '';
- $rnd = false;
- if (function_exists('random_bytes')) {
- $rnd = random_bytes($secretLength);
- } elseif (function_exists('mcrypt_create_iv')) {
- $rnd = mcrypt_create_iv($secretLength, MCRYPT_DEV_URANDOM);
- } elseif (function_exists('openssl_random_pseudo_bytes')) {
- $rnd = openssl_random_pseudo_bytes($secretLength, $cryptoStrong);
- if (!$cryptoStrong) {
- $rnd = false;
- }
- }
- if ($rnd !== false) {
- for ($i = 0; $i < $secretLength; ++$i) {
- $secret .= $validChars[ord($rnd[$i]) & 31];
- }
- } else {
- throw new Exception('No source of secure random');
- }
-
- return $secret;
- }
-
-
- public function getCode($secret, $timeSlice = null) {
- if ($timeSlice === null) {
- $timeSlice = floor(time() / 30);
- }
-
- $secretkey = $this->decode($secret);
-
- $time = chr(0).chr(0).chr(0).chr(0).pack('N*', $timeSlice);
- $hm = hash_hmac('SHA1', $time, $secretkey, true);
- $offset = ord(substr($hm, -1)) & 0x0F;
- $hashpart = substr($hm, $offset, 4);
- $value = unpack('N', $hashpart);
- $value = $value[1];
- $value = $value & 0x7FFFFFFF;
- $modulo = pow(10, $this->codeLength);
- return str_pad($value % $modulo, $this->codeLength, '0', STR_PAD_LEFT);
- }
-
- public function GetQR($name, $secret, $title = null, $params = array()) {
- $width = !empty($params['width']) && (int) $params['width'] > 0 ? (int) $params['width'] : 160;
- $height = !empty($params['height']) && (int) $params['height'] > 0 ? (int) $params['height'] : 160;
- $level = !empty($params['level']) && array_search($params['level'], array('L', 'M', 'Q', 'H')) !== false ? $params['level'] : 'M';
-
- $urlencoded = urlencode('otpauth://totp/'.$name.'?secret='.$secret.'');
- if (isset($title)) {
- $urlencoded .= urlencode('&issuer='.urlencode($title));
- }
-
- return "https://api.qrserver.com/v1/create-qr-code/?data=$urlencoded&size=${width}x${height}&ecc=$level";
- }
-
- public function verify($secret, $code, $discrepancy = 1, $currentTimeSlice = null) {
- if ($currentTimeSlice === null) {
- $currentTimeSlice = floor(time() / 30);
- }
-
- if (strlen($code) != 6) {
- return false;
- }
-
- for ($i = -$discrepancy; $i <= $discrepancy; ++$i) {
- $calculatedCode = $this->getCode($secret, $currentTimeSlice + $i);
- if ($this->timingSafeEquals($calculatedCode, $code)) {
- return true;
- }
- }
-
- return false;
- }
-
-
- public function setCodeLength($length) {
- $this->codeLength = $length;
- return $this;
- }
-
- protected function decode($secret) {
- if (empty($secret)) {
- return '';
- }
-
- $base32chars = $this->Base32T();
- $base32charsFlipped = array_flip($base32chars);
-
- $paddingCharCount = substr_count($secret, $base32chars[32]);
- $allowedValues = array(6, 4, 3, 1, 0);
- if (!in_array($paddingCharCount, $allowedValues)) {
- return false;
- }
- for ($i = 0; $i < 4; ++$i) {
- if ($paddingCharCount == $allowedValues[$i] &&
- substr($secret, -($allowedValues[$i])) != str_repeat($base32chars[32], $allowedValues[$i])) {
- return false;
- }
- }
- $secret = str_replace('=', '', $secret);
- $secret = str_split($secret);
- $binaryString = '';
- for ($i = 0; $i < count($secret); $i = $i + 8) {
- $x = '';
- if (!in_array($secret[$i], $base32chars)) {
- return false;
- }
- for ($j = 0; $j < 8; ++$j) {
- $x .= str_pad(base_convert(@$base32charsFlipped[@$secret[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
- }
- $eightBits = str_split($x, 8);
- for ($z = 0; $z < count($eightBits); ++$z) {
- $binaryString .= (($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48) ? $y : '';
- }
- }
-
- return $binaryString;
- }
-
- protected function Base32T() {
- return array(
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 7
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 15
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 23
- 'Y', 'Z', '2', '3', '4', '5', '6', '7', // 31
- '=', // padding char
- );
- }
-
- private function timingSafeEquals($safeString, $userString) {
- if (function_exists('hash_equals')) {
- return hash_equals($safeString, $userString);
- }
- $safeLen = strlen($safeString);
- $userLen = strlen($userString);
-
- if ($userLen != $safeLen) {
- return false;
- }
-
- $result = 0;
-
- for ($i = 0; $i < $userLen; ++$i) {
- $result |= (ord($safeString[$i]) ^ ord($userString[$i]));
- }
-
- // They are only identical strings if $result is exactly 0...
- return $result === 0;
- }
-}
diff --git a/ci4/app/Libraries/PasswordHash.php b/ci4/app/Libraries/PasswordHash.php
deleted file mode 100755
index 8c406353..00000000
--- a/ci4/app/Libraries/PasswordHash.php
+++ /dev/null
@@ -1,227 +0,0 @@
- in 2004-2006 and placed in
-# the public domain. Revised in subsequent years, still public domain.
-#
-# There's absolutely no warranty.
-#
-# The homepage URL for this framework is:
-#
-# http://www.openwall.com/phpass/
-#
-# Please be sure to update the Version line if you edit this file in any way.
-# It is suggested that you leave the main version number intact, but indicate
-# your project name (after the slash) and add your own revision information.
-#
-# Please do not change the "private" password hashing method implemented in
-# here, thereby making your hashes incompatible. However, if you must, please
-# change the hash type identifier (the "$P$") to something different.
-#
-# Obviously, since this code is in the public domain, the above are not
-# requirements (there can be none), but merely suggestions.
-#
-class PasswordHash {
- var $itoa64;
- var $iteration_count_log2;
- var $portable_hashes;
- var $random_state;
-
- function __construct($iteration_count_log2, $portable_hashes)
- {
- $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
-
- if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
- $iteration_count_log2 = 8;
- $this->iteration_count_log2 = $iteration_count_log2;
-
- $this->portable_hashes = $portable_hashes;
-
- $this->random_state = microtime();
- if (function_exists('getmypid'))
- $this->random_state .= getmypid();
- }
-
- function PasswordHash($iteration_count_log2, $portable_hashes)
- {
- self::__construct($iteration_count_log2, $portable_hashes);
- }
-
- function get_random_bytes($count)
- {
- $output = '';
- if (@is_readable('/dev/urandom') &&
- ($fh = @fopen('/dev/urandom', 'rb'))) {
- $output = fread($fh, $count);
- fclose($fh);
- }
-
- if (strlen($output) < $count) {
- $output = '';
- for ($i = 0; $i < $count; $i += 16) {
- $this->random_state =
- md5(microtime() . $this->random_state);
- $output .= md5($this->random_state, TRUE);
- }
- $output = substr($output, 0, $count);
- }
-
- return $output;
- }
-
- function encode64($input, $count)
- {
- $output = '';
- $i = 0;
- do {
- $value = ord($input[$i++]);
- $output .= $this->itoa64[$value & 0x3f];
- if ($i < $count)
- $value |= ord($input[$i]) << 8;
- $output .= $this->itoa64[($value >> 6) & 0x3f];
- if ($i++ >= $count)
- break;
- if ($i < $count)
- $value |= ord($input[$i]) << 16;
- $output .= $this->itoa64[($value >> 12) & 0x3f];
- if ($i++ >= $count)
- break;
- $output .= $this->itoa64[($value >> 18) & 0x3f];
- } while ($i < $count);
-
- return $output;
- }
-
- function gensalt_private($input)
- {
- $output = '$P$';
- $output .= $this->itoa64[min($this->iteration_count_log2 +
- ((PHP_VERSION >= '5') ? 5 : 3), 30)];
- $output .= $this->encode64($input, 6);
-
- return $output;
- }
-
- function crypt_private($password, $setting)
- {
- $output = '*0';
- if (substr($setting, 0, 2) === $output)
- $output = '*1';
-
- $id = substr($setting, 0, 3);
- # We use "$P$", phpBB3 uses "$H$" for the same thing
- if ($id !== '$P$' && $id !== '$H$')
- return $output;
-
- $count_log2 = strpos($this->itoa64, $setting[3]);
- if ($count_log2 < 7 || $count_log2 > 30)
- return $output;
-
- $count = 1 << $count_log2;
-
- $salt = substr($setting, 4, 8);
- if (strlen($salt) !== 8)
- return $output;
-
- # We were kind of forced to use MD5 here since it's the only
- # cryptographic primitive that was available in all versions
- # of PHP in use. To implement our own low-level crypto in PHP
- # would have resulted in much worse performance and
- # consequently in lower iteration counts and hashes that are
- # quicker to crack (by non-PHP code).
- $hash = md5($salt . $password, TRUE);
- do {
- $hash = md5($hash . $password, TRUE);
- } while (--$count);
-
- $output = substr($setting, 0, 12);
- $output .= $this->encode64($hash, 16);
-
- return $output;
- }
-
- function gensalt_blowfish($input)
- {
- # This one needs to use a different order of characters and a
- # different encoding scheme from the one in encode64() above.
- # We care because the last character in our encoded string will
- # only represent 2 bits. While two known implementations of
- # bcrypt will happily accept and correct a salt string which
- # has the 4 unused bits set to non-zero, we do not want to take
- # chances and we also do not want to waste an additional byte
- # of entropy.
- $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
-
- $output = '$2a$';
- $output .= chr(ord('0') + $this->iteration_count_log2 / 10);
- $output .= chr(ord('0') + $this->iteration_count_log2 % 10);
- $output .= '$';
-
- $i = 0;
- do {
- $c1 = ord($input[$i++]);
- $output .= $itoa64[$c1 >> 2];
- $c1 = ($c1 & 0x03) << 4;
- if ($i >= 16) {
- $output .= $itoa64[$c1];
- break;
- }
-
- $c2 = ord($input[$i++]);
- $c1 |= $c2 >> 4;
- $output .= $itoa64[$c1];
- $c1 = ($c2 & 0x0f) << 2;
-
- $c2 = ord($input[$i++]);
- $c1 |= $c2 >> 6;
- $output .= $itoa64[$c1];
- $output .= $itoa64[$c2 & 0x3f];
- } while (1);
-
- return $output;
- }
-
- function HashPassword($password)
- {
- $random = '';
-
- if (CRYPT_BLOWFISH === 1 && !$this->portable_hashes) {
- $random = $this->get_random_bytes(16);
- $hash =
- crypt($password, $this->gensalt_blowfish($random));
- if (strlen($hash) === 60)
- return $hash;
- }
-
- if (strlen($random) < 6)
- $random = $this->get_random_bytes(6);
- $hash =
- $this->crypt_private($password,
- $this->gensalt_private($random));
- if (strlen($hash) === 34)
- return $hash;
-
- # Returning '*' on error is safe here, but would _not_ be safe
- # in a crypt(3)-like function used _both_ for generating new
- # hashes and for validating passwords against existing hashes.
- return '*';
- }
-
- function CheckPassword($password, $stored_hash)
- {
- $hash = $this->crypt_private($password, $stored_hash);
- if ($hash[0] === '*')
- $hash = crypt($password, $stored_hash);
-
- # This is not constant-time. In order to keep the code simple,
- # for timing safety we currently rely on the salts being
- # unpredictable, which they are at least in the non-fallback
- # cases (that is, when we use /dev/urandom and bcrypt).
- return $hash === $stored_hash;
- }
-}
-
-?>
diff --git a/ci4/app/Models/ActivityModel.php b/ci4/app/Models/ActivityModel.php
deleted file mode 100755
index 3a82f883..00000000
--- a/ci4/app/Models/ActivityModel.php
+++ /dev/null
@@ -1,20 +0,0 @@
-table;
+ }
+
+ /**
+ * Returns the model's DB table name (Alias of getDbTableName() )
+ *
+ * @return string
+ */
+ public function getTableName() {
+ return $this->table;
+ }
+
+ /**
+ * Returns the model's name of primary key in the database
+ *
+ * @return string
+ */
+ public function getPrimaryKeyName() {
+ return $this->primaryKey;
+ }
+
+ /**
+ * Returns the number of rows in the database table
+ *
+ * @return int
+ */
+ public function getCount() {
+ $name = $this->table;
+ $count = $this->db->table($name)->countAll();
+ return $count;
+ }
+
+ /**
+ * @param string $columns2select
+ * @param string $resultSorting
+ * @param bool $onlyActiveOnes
+ * @param bool $alsoDeletedOnes
+ * @param array $additionalConditions
+ * @return array
+ */
+ public function getAllForMenu($columns2select='*', $resultSorting='id', bool $onlyActiveOnes=false, bool $alsoDeletedOnes=true, $additionalConditions = []) {
+
+ $theseConditionsAreMet = [];
+
+ if ($onlyActiveOnes) {
+ if ( in_array('enabled', $this->allowedFields) ) {
+ $theseConditionsAreMet['enabled'] = true;
+ } elseif (in_array('active', $this->allowedFields)) {
+ $theseConditionsAreMet['active'] = true;
+ }
+ }
+
+ // This check is deprecated and left here only for backward compatibility and this method should be overridden in extending classes so as to check if the bound entity class has these attributes
+ if (!$alsoDeletedOnes) {
+ if (in_array('deleted_at', $this->allowedFields)) {
+ $theseConditionsAreMet['deleted_at'] = null;
+ }
+ if (in_array('deleted', $this->allowedFields) ) {
+ $theseConditionsAreMet['deleted'] = false;
+ }
+ if (in_array('date_time_deleted', $this->allowedFields)) {
+ $theseConditionsAreMet['date_time_deleted'] = null;
+ }
+ }
+
+ if (!empty($additionalConditions)) {
+ $theseConditionsAreMet = array_merge($theseConditionsAreMet, $additionalConditions);
+ }
+ $queryBuilder = $this->db->table($this->table);
+ $queryBuilder->select($columns2select);
+ if (!empty($theseConditionsAreMet)) {
+ $queryBuilder->where($theseConditionsAreMet);
+ }
+ $queryBuilder->orderBy($resultSorting);
+ $result = $queryBuilder->get()->getResult();
+
+ return $result;
+ }
+
+ /**
+ *
+ * @param mixed $columns2select either array or string
+ * @param mixed $sortResultsBy either string or array
+ * @param bool $onlyActiveOnes
+ * @param string $select1str e.g. 'Please select one...'
+ * @param bool $alsoDeletedOnes
+ * @param array $additionalConditions
+ * @return array for use in dropdown menus
+ */
+ public function getAllForCiMenu( $columns2select = ['id', 'designation'], $sortResultsBy = 'id', bool $onlyActiveOnes=false, $selectionRequestLabel = 'Please select one...', bool $alsoDeletedOnes = true, $additionalConditions = []) {
+
+ $ciDropDownOptions = [];
+
+ if (is_array($columns2select) && count($columns2select) >= 2) {
+
+ $key = $columns2select[0];
+ $val = $columns2select[1];
+
+ $cols2selectStr = implode(',', $columns2select);
+
+ $valInd = strpos($val, ' AS ');
+ if ($valInd !== false) {
+ $val = substr($val, $valInd+4);
+ }
+
+ } elseif (is_string($columns2select) && strpos($columns2select,',')!==false) {
+
+ $cols2selectStr = $columns2select;
+
+ $arr = explode(",", $columns2select, 2);
+ $key = trim($arr[0]);
+ $val = trim($arr[1]);
+
+ } else {
+ return ['error'=>'Invalid argument for columns/fields to select'];
+ }
+
+ $resultList = $this->getAllForMenu($cols2selectStr, $sortResultsBy, $onlyActiveOnes, $alsoDeletedOnes, $additionalConditions);
+
+ if ($resultList != false) {
+
+ if (!empty($selectionRequestLabel)) {
+ $ciDropDownOptions[''] = $selectionRequestLabel;
+ }
+
+ foreach ($resultList as $res) {
+
+ if (isset($res->$key) && isset($res->$val)) {
+ $ciDropDownOptions[$res->$key] = $res->$val;
+ }
+ }
+ }
+
+ return $ciDropDownOptions;
+ }
+
+ /**
+ * @param array|string[] $columns2select
+ * @param null $resultSorting
+ * @param bool|bool $onlyActiveOnes
+ * @param null $searchStr
+ * @return array
+ */
+ public function getSelect2MenuItems(array $columns2select = ['id', 'designation'], $resultSorting=null, bool $onlyActiveOnes=true, $searchStr = null, $isDeleteField=false) {
+
+ $theseConditionsAreMet = [];
+
+ $id = $columns2select[0].' AS id';
+ $text = $columns2select[1].' AS text';
+
+ if (empty($resultSorting)) {
+ $resultSorting = $this->getPrimaryKeyName();
+ }
+
+ if ($onlyActiveOnes) {
+ if ( in_array('enabled', $this->allowedFields) ) {
+ $theseConditionsAreMet['enabled'] = true;
+ } elseif (in_array('active', $this->allowedFields)) {
+ $theseConditionsAreMet['active'] = true;
+ }
+ }
+ //JJO
+ if($isDeleteField)
+ $theseConditionsAreMet['is_deleted'] = 0;
+
+ $queryBuilder = $this->db->table($this->table);
+ $queryBuilder->select([$id, $text]);
+ $queryBuilder->where($theseConditionsAreMet);
+ if (!empty($searchStr)) {
+ $queryBuilder->groupStart()
+ ->like($columns2select[0], $searchStr)
+ ->orLike($columns2select[1], $searchStr)
+ ->groupEnd();
+ }
+ $queryBuilder->orderBy($resultSorting);
+ $result = $queryBuilder->get()->getResult();
+
+ return $result;
+ }
+
+ /**
+ * Custom method allowing you to add a form validation rule to the model on-the-fly
+ * @param string $fieldName
+ * @param string $rule
+ * @param string|null $msg
+ */
+ public function addValidationRule(string $fieldName, string $rule, string $msg = null ) {
+ if (empty(trim($fieldName)) ||empty(trim($fieldName))) {
+ return;
+ }
+ if (!isset($this->validationRules[$fieldName]) || empty($this->validationRules[$fieldName])) {
+ $this->validationRules[$fieldName] = substr($rule, 0, 1) == '|' ? substr($rule, 1) : trim($rule);
+ } else if (isset($this->validationRules[$fieldName]['rules'])) {
+ $this->validationRules[$fieldName]['rules'] .= substr($rule, 0, 1) == '|' ? trim($rule) : '|' . trim($rule);
+ } else {
+ $this->validationRules[$fieldName] .= $rule;
+ }
+ if (isset($msg) && !empty(trim($msg))) {
+ $ruleKey = strtok($rule, '[');
+ if ($ruleKey === false) {
+ return;
+ }
+ $item = [$ruleKey => "'".$msg."'"];
+ if (!isset($this->validationMessages[$fieldName]) || empty(trim($this->validationMessages[$fieldName]))) {
+ $this->validationMessages[$fieldName] = $item;
+ } else {
+ $this->validationMessages[$fieldName][$ruleKey] = "'".$msg."'";
+ }
+ }
+ }
+
+}
diff --git a/ci4/app/Models/Clientes/ClienteContactoModel.php b/ci4/app/Models/Clientes/ClienteContactoModel.php
index 5f4c6f68..5dba9b92 100755
--- a/ci4/app/Models/Clientes/ClienteContactoModel.php
+++ b/ci4/app/Models/Clientes/ClienteContactoModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Clientes;
-class ClienteContactoModel extends \App\Models\GoBaseModel
+class ClienteContactoModel extends \App\Models\BaseModel
{
protected $table = "cliente_contactos";
diff --git a/ci4/app/Models/Clientes/ClienteDireccionesModel.php b/ci4/app/Models/Clientes/ClienteDireccionesModel.php
index 3b75ba4c..8f5e3b97 100755
--- a/ci4/app/Models/Clientes/ClienteDireccionesModel.php
+++ b/ci4/app/Models/Clientes/ClienteDireccionesModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Clientes;
-class ClienteDireccionesModel extends \App\Models\GoBaseModel
+class ClienteDireccionesModel extends \App\Models\BaseModel
{
protected $table = "cliente_direcciones";
diff --git a/ci4/app/Models/Clientes/ClienteModel.php b/ci4/app/Models/Clientes/ClienteModel.php
index 5b6508b8..1d67958e 100755
--- a/ci4/app/Models/Clientes/ClienteModel.php
+++ b/ci4/app/Models/Clientes/ClienteModel.php
@@ -1,7 +1,7 @@
table .
- " t1 LEFT JOIN lg_comunidades_autonomas t2 ON t1.comunidad_autonoma_id = t2.id LEFT JOIN lg_provincias t3 ON t1.provincia_id = t3.id LEFT JOIN lg_paises t4 ON t1.pais_id = t4.id LEFT JOIN auth_user t5 ON t1.comercial_id = t5.id_user LEFT JOIN auth_user t6 ON t1.soporte_id = t6.id_user LEFT JOIN lg_formas_pago t7 ON t1.forma_pago_id = t7.id";
+ " t1 LEFT JOIN lg_comunidades_autonomas t2 ON t1.comunidad_autonoma_id = t2.id
+ LEFT JOIN lg_provincias t3 ON t1.provincia_id = t3.id
+ LEFT JOIN lg_paises t4 ON t1.pais_id = t4.id
+ LEFT JOIN users t5 ON t1.comercial_id = t5.id
+ LEFT JOIN users t6 ON t1.soporte_id = t6.id
+ LEFT JOIN lg_formas_pago t7 ON t1.forma_pago_id = t7.id";
if (!is_null($limit) && intval($limit) > 0) {
$sql .= " LIMIT " . intval($limit);
}
@@ -280,7 +286,7 @@ class ClienteModel extends \App\Models\GoBaseModel
"t1.id AS id, t1.nombre AS nombre, t1.alias AS alias, t1.cif AS cif, t1.email AS email, t1.vencimiento AS vencimiento, t5.first_name AS comercial, t7.nombre AS forma_pago_id"
)
->where("is_deleted", 0);;
- $builder->join("auth_user t5", "t1.comercial_id = t5.id_user", "left");
+ $builder->join("users t5", "t1.comercial_id = t5.id", "left");
$builder->join("lg_formas_pago t7", "t1.forma_pago_id = t7.id", "left");
diff --git a/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php b/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php
index 3b663fda..9b3072d4 100755
--- a/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php
+++ b/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Clientes;
-class ClientePlantillaPreciosLineasModel extends \App\Models\GoBaseModel
+class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
{
protected $table = "cliente_plantilla_precios_lineas";
@@ -137,7 +137,7 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\GoBaseModel
t1.user_updated_id AS user_updated_id, t1.updated_at AS updated_at, CONCAT(t2.first_name, ' ', t2.last_name) AS user_updated"
);
- $builder->join("auth_user t2", "t1.user_updated_id = t2.id_user", "left");
+ $builder->join("users t2", "t1.user_updated_id = t2.id", "left");
$builder->where('t1.is_deleted', 0);
$builder->where('t1.plantilla_id', $plantilla_id);
diff --git a/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php b/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php
index a55a8dc7..2ec9978d 100755
--- a/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php
+++ b/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Clientes;
-class ClientePlantillaPreciosModel extends \App\Models\GoBaseModel
+class ClientePlantillaPreciosModel extends \App\Models\BaseModel
{
protected $table = "cliente_plantilla_precios";
diff --git a/ci4/app/Models/Clientes/ClientePreciosModel.php b/ci4/app/Models/Clientes/ClientePreciosModel.php
index efc2b7d0..a52893c8 100755
--- a/ci4/app/Models/Clientes/ClientePreciosModel.php
+++ b/ci4/app/Models/Clientes/ClientePreciosModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Clientes;
-class ClientePreciosModel extends \App\Models\GoBaseModel
+class ClientePreciosModel extends \App\Models\BaseModel
{
protected $table = "cliente_precios";
@@ -267,7 +267,7 @@ class ClientePreciosModel extends \App\Models\GoBaseModel
t1.user_updated_id AS user_updated_id, t1.updated_at AS updated_at, CONCAT(t2.first_name, ' ', t2.last_name) AS user_updated"
);
- $builder->join("auth_user t2", "t1.user_updated_id = t2.id_user", "left");
+ $builder->join("users t2", "t1.user_updated_id = t2.id", "left");
$builder->where('t1.is_deleted', 0);
$builder->where('t1.cliente_id', $cliente_id);
diff --git a/ci4/app/Models/Clientes/ClienteUsuariosModel.php b/ci4/app/Models/Clientes/ClienteUsuariosModel.php
index 6bec17a9..948cee51 100644
--- a/ci4/app/Models/Clientes/ClienteUsuariosModel.php
+++ b/ci4/app/Models/Clientes/ClienteUsuariosModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Clientes;
-class ClienteUsuariosModel extends \App\Models\GoBaseModel
+class ClienteUsuariosModel extends \App\Models\BaseModel
{
protected $table = "auth_user";
diff --git a/ci4/app/Models/CollectionModel.php b/ci4/app/Models/CollectionModel.php
new file mode 100644
index 00000000..3b1ceaa3
--- /dev/null
+++ b/ci4/app/Models/CollectionModel.php
@@ -0,0 +1,39 @@
+getPostGet('data') ?? [];
+ $draw = $reqData['draw'] ?? $req->getPostGet('draw') ?? 1;
+
+ $response = [
+ 'draw' => $draw,
+ 'recordsTotal' => $recordsTotal,
+ 'recordsFiltered' => $recordsFiltered,
+ 'data' => $data,
+ 'token' => csrf_hash(), // in case the CSRF token is regenerated
+ ];
+
+ if (!empty($error)) {
+ $response['error'] = $error;
+ }
+
+ return $response;
+ }
+}
\ No newline at end of file
diff --git a/ci4/app/Models/Compras/ProveedorModel.php b/ci4/app/Models/Compras/ProveedorModel.php
index 45ec3589..3e4d3fa0 100755
--- a/ci4/app/Models/Compras/ProveedorModel.php
+++ b/ci4/app/Models/Compras/ProveedorModel.php
@@ -1,7 +1,7 @@
table;
- }
-
- /**
- * Returns the model's DB table name (Alias of getDbTableName() )
- *
- * @return string
- */
- public function getTableName() {
- return $this->table;
- }
-
- /**
- * Returns the model's name of primary key in the database
- *
- * @return string
- */
- public function getPrimaryKeyName() {
- return $this->primaryKey;
- }
-
- /**
- * Returns the number of rows in the database table
- *
- * @return int
- */
- public function getCount() {
- $name = $this->table;
- $count = $this->db->table($name)->countAll();
- return $count;
- }
-
- /**
- * @param string $columns2select
- * @param string $resultSorting
- * @param bool $onlyActiveOnes
- * @param bool $alsoDeletedOnes
- * @param array $additionalConditions
- * @return array
- */
- public function getAllForMenu($columns2select='*', $resultSorting='id', bool $onlyActiveOnes=false, bool $alsoDeletedOnes=true, $additionalConditions = []) {
-
- $theseConditionsAreMet = [];
-
- if ($onlyActiveOnes) {
- if ( in_array('enabled', $this->allowedFields) ) {
- $theseConditionsAreMet['enabled'] = true;
- } elseif (in_array('active', $this->allowedFields)) {
- $theseConditionsAreMet['active'] = true;
- }
- }
-
- // This check is deprecated and left here only for backward compatibility and this method should be overridden in extending classes so as to check if the bound entity class has these attributes
- if (!$alsoDeletedOnes) {
- if (in_array('deleted_at', $this->allowedFields)) {
- $theseConditionsAreMet['deleted_at'] = null;
- }
- if (in_array('deleted', $this->allowedFields) ) {
- $theseConditionsAreMet['deleted'] = false;
- }
- if (in_array('date_time_deleted', $this->allowedFields)) {
- $theseConditionsAreMet['date_time_deleted'] = null;
- }
- }
-
- if (!empty($additionalConditions)) {
- $theseConditionsAreMet = array_merge($theseConditionsAreMet, $additionalConditions);
- }
- $queryBuilder = $this->db->table($this->table);
- $queryBuilder->select($columns2select);
- if (!empty($theseConditionsAreMet)) {
- $queryBuilder->where($theseConditionsAreMet);
- }
- $queryBuilder->orderBy($resultSorting);
- $result = $queryBuilder->get()->getResult();
-
- return $result;
- }
-
- /**
- *
- * @param mixed $columns2select either array or string
- * @param mixed $sortResultsBy either string or array
- * @param bool $onlyActiveOnes
- * @param string $select1str e.g. 'Please select one...'
- * @param bool $alsoDeletedOnes
- * @param array $additionalConditions
- * @return array for use in dropdown menus
- */
- public function getAllForCiMenu( $columns2select = ['id', 'designation'], $sortResultsBy = 'id', bool $onlyActiveOnes=false, $selectionRequestLabel = 'Please select one...', bool $alsoDeletedOnes = true, $additionalConditions = []) {
-
- $ciDropDownOptions = [];
-
- if (is_array($columns2select) && count($columns2select) >= 2) {
-
- $key = $columns2select[0];
- $val = $columns2select[1];
-
- $cols2selectStr = implode(',', $columns2select);
-
- $valInd = strpos($val, ' AS ');
- if ($valInd !== false) {
- $val = substr($val, $valInd+4);
- }
-
- } elseif (is_string($columns2select) && strpos($columns2select,',')!==false) {
-
- $cols2selectStr = $columns2select;
-
- $arr = explode(",", $columns2select, 2);
- $key = trim($arr[0]);
- $val = trim($arr[1]);
-
- } else {
- return ['error'=>'Invalid argument for columns/fields to select'];
- }
-
- $resultList = $this->getAllForMenu($cols2selectStr, $sortResultsBy, $onlyActiveOnes, $alsoDeletedOnes, $additionalConditions);
-
- if ($resultList != false) {
-
- if (!empty($selectionRequestLabel)) {
- $ciDropDownOptions[''] = $selectionRequestLabel;
- }
-
- foreach ($resultList as $res) {
-
- if (isset($res->$key) && isset($res->$val)) {
- $ciDropDownOptions[$res->$key] = $res->$val;
- }
- }
- }
-
- return $ciDropDownOptions;
- }
-
- /**
- * @param array|string[] $columns2select
- * @param null $resultSorting
- * @param bool|bool $onlyActiveOnes
- * @param null $searchStr
- * @return array
- */
- public function getSelect2MenuItems(array $columns2select = ['id', 'designation'], $resultSorting=null, bool $onlyActiveOnes=true, $searchStr = null, $isDeleteField=false) {
-
- $theseConditionsAreMet = [];
-
- $id = $columns2select[0].' AS id';
- $text = $columns2select[1].' AS text';
-
- if (empty($resultSorting)) {
- $resultSorting = $this->getPrimaryKeyName();
- }
-
- if ($onlyActiveOnes) {
- if ( in_array('enabled', $this->allowedFields) ) {
- $theseConditionsAreMet['enabled'] = true;
- } elseif (in_array('active', $this->allowedFields)) {
- $theseConditionsAreMet['active'] = true;
- }
- }
- //JJO
- if($isDeleteField)
- $theseConditionsAreMet['is_deleted'] = 0;
-
- $queryBuilder = $this->db->table($this->table);
- $queryBuilder->select([$id, $text]);
- $queryBuilder->where($theseConditionsAreMet);
- if (!empty($searchStr)) {
- $queryBuilder->groupStart()
- ->like($columns2select[0], $searchStr)
- ->orLike($columns2select[1], $searchStr)
- ->groupEnd();
- }
- $queryBuilder->orderBy($resultSorting);
- $result = $queryBuilder->get()->getResult();
-
- return $result;
- }
-
- /**
- * Custom method allowing you to add a form validation rule to the model on-the-fly
- * @param string $fieldName
- * @param string $rule
- * @param string|null $msg
- */
- public function addValidationRule(string $fieldName, string $rule, string $msg = null ) {
- if (empty(trim($fieldName)) ||empty(trim($fieldName))) {
- return;
- }
- if (!isset($this->validationRules[$fieldName]) || empty($this->validationRules[$fieldName])) {
- $this->validationRules[$fieldName] = substr($rule, 0, 1) == '|' ? substr($rule, 1) : trim($rule);
- } else if (isset($this->validationRules[$fieldName]['rules'])) {
- $this->validationRules[$fieldName]['rules'] .= substr($rule, 0, 1) == '|' ? trim($rule) : '|' . trim($rule);
- } else {
- $this->validationRules[$fieldName] .= $rule;
- }
- if (isset($msg) && !empty(trim($msg))) {
- $ruleKey = strtok($rule, '[');
- if ($ruleKey === false) {
- return;
- }
- $item = [$ruleKey => "'".$msg."'"];
- if (!isset($this->validationMessages[$fieldName]) || empty(trim($this->validationMessages[$fieldName]))) {
- $this->validationMessages[$fieldName] = $item;
- } else {
- $this->validationMessages[$fieldName][$ruleKey] = "'".$msg."'";
- }
- }
- }
-
-}
diff --git a/ci4/app/Models/NotificationModel.php b/ci4/app/Models/NotificationModel.php
deleted file mode 100755
index 6ae6588c..00000000
--- a/ci4/app/Models/NotificationModel.php
+++ /dev/null
@@ -1,21 +0,0 @@
-join("clientes t2", "t1.cliente_id = t2.id", "left");
- $builder->join("auth_user t3", "t1.user_update_id = t3.id_user", "left");
+ $builder->join("users t3", "t1.user_update_id = t3.id", "left");
$builder->join("lg_paises t5", "t1.pais_id = t5.id", "left");
$builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left");
$builder->join("tipos_presupuestos t7", "t1.tipo_impresion_id = t7.id", "left");
diff --git a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php
index b3e5b954..37c937ff 100755
--- a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php
+++ b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Presupuestos;
-class PresupuestoAcabadosModel extends \App\Models\GoBaseModel
+class PresupuestoAcabadosModel extends \App\Models\BaseModel
{
protected $table = "presupuesto_acabados";
diff --git a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php
index 2788f78f..f89ddfd3 100755
--- a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php
+++ b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Presupuestos;
-class PresupuestoDireccionesModel extends \App\Models\GoBaseModel
+class PresupuestoDireccionesModel extends \App\Models\BaseModel
{
protected $table = "presupuesto_direcciones";
diff --git a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php
index ac18482a..d183932b 100755
--- a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php
+++ b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Presupuestos;
-class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
+class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
{
protected $table = "presupuesto_encuadernaciones";
diff --git a/ci4/app/Models/Presupuestos/PresupuestoEstadoModel.php b/ci4/app/Models/Presupuestos/PresupuestoEstadoModel.php
index 59f330f1..986c42d4 100755
--- a/ci4/app/Models/Presupuestos/PresupuestoEstadoModel.php
+++ b/ci4/app/Models/Presupuestos/PresupuestoEstadoModel.php
@@ -1,7 +1,7 @@
0) {
$sql .= " LIMIT " . intval($limit);
@@ -239,7 +239,7 @@ class PresupuestoModel extends \App\Models\GoBaseModel
t1.total_presupuesto AS total_presupuesto, t1.total_presupuesto AS total_presupuesto, t6.estado AS estado"
);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
- $builder->join("auth_user t3", "t1.user_update_id = t3.id_user", "left");
+ $builder->join("users t3", "t1.user_update_id = t3.id", "left");
$builder->join("lg_paises t5", "t1.pais_id = t5.id", "left");
$builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left");
@@ -299,7 +299,7 @@ class PresupuestoModel extends \App\Models\GoBaseModel
CONCAT(t4.ancho, 'x', t4.alto) AS formato"
);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
- $builder->join("auth_user t3", "t1.user_update_id = t3.id_user", "left");
+ $builder->join("users t3", "t1.user_update_id = t3.id", "left");
$builder->join("lg_papel_formato t4", "t1.papel_formato_id = t4.id", "left");
$builder->where("t1.is_deleted", 0);
diff --git a/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php
index 33c49394..209c0467 100755
--- a/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php
+++ b/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Presupuestos;
-class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
+class PresupuestoPreimpresionesModel extends \App\Models\BaseModel
{
protected $table = "presupuesto_preimpresiones";
diff --git a/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php b/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php
index 76916a8e..7675bda7 100755
--- a/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php
+++ b/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Presupuestos;
-class PresupuestoServiciosExtraModel extends \App\Models\GoBaseModel
+class PresupuestoServiciosExtraModel extends \App\Models\BaseModel
{
protected $table = "presupuesto_serviciosExtra";
diff --git a/ci4/app/Models/Presupuestos/TipoPresupuestoServiciosDefectoModel.php b/ci4/app/Models/Presupuestos/TipoPresupuestoServiciosDefectoModel.php
index 6eabe873..1cc1f9e9 100755
--- a/ci4/app/Models/Presupuestos/TipoPresupuestoServiciosDefectoModel.php
+++ b/ci4/app/Models/Presupuestos/TipoPresupuestoServiciosDefectoModel.php
@@ -2,7 +2,7 @@
namespace App\Models\Presupuestos;
-class TipoPresupuestoServiciosDefectoModel extends \App\Models\GoBaseModel
+class TipoPresupuestoServiciosDefectoModel extends \App\Models\BaseModel
{
protected $table = "tipos_presupuestos_servicios_defecto";
diff --git a/ci4/app/Models/SettingsModel.php b/ci4/app/Models/SettingsModel.php
deleted file mode 100755
index 2f57ab5e..00000000
--- a/ci4/app/Models/SettingsModel.php
+++ /dev/null
@@ -1,82 +0,0 @@
- "t1.id",
+ 2 => "t2.username",
+ 3 => "t1.level",
+ 4 => "t1.event",
+ 5 => "t1.ip",
+ 6 => "t1.os",
+ 7 => "t1.browser",
+ 8 => "t1.detail"
+ ];
+
+ protected $allowedFields = [
+ 'user_id',
+ 'level',
+ 'event',
+ 'ip',
+ 'os',
+ 'browser',
+ 'detail'
+ ];
+
+ protected $useTimestamps = true;
+ protected $createdField = 'created_at';
+ protected $updatedField = 'updated_at';
+
+
+ /**
+ * Retrieves a resource from the database based on the given search string.
+ *
+ * @param string $search The search string to filter the resource by. Defaults to an empty string.
+ * @return mixed The resource query builder instance if search string is empty, otherwise the filtered resource query builder instance.
+ */
+ public function getResource(string $search = "")
+ {
+ $builder = $this->db
+ ->table($this->table . " t1")
+ ->select(
+ "t1.id AS id, t2.username AS user, t1.level AS level, t1.event AS event, t1.ip AS ip, t1.os AS os,
+ t1.browser AS browser, t1.created_at AS created_at"
+ )
+ ->join("users t2", "t1.user_id = t2.id", "left")
+ ->orderBy('t1.created_at', 'DESC');
+
+ return empty($search)
+ ? $builder
+ : $builder
+ ->groupStart()
+ ->like("t1.id", $search)
+ ->orLike("t2.username", $search)
+ ->orLike("t1.level", $search)
+ ->orLike("t1.event", $search)
+ ->orLike("t1.ip", $search)
+ ->orLike("t1.os", $search)
+ ->orLike("t1.browser", $search)
+ ->orLike("t1.created_at", $search)
+ ->groupEnd();
+ }
+
+ public function getLogs()
+ {
+ $builder = $this->db
+ ->table($this->table . " t1")
+ ->select(
+ 'SUM( IF( os LIKE "%Windows%", 1, 0 ) ) AS windows,
+ SUM( IF( os = "Mac OS X", 1, 0 ) ) AS mac,
+ SUM( IF( os = "Linux", 1, 0 ) ) AS linux,
+ SUM( IF( os = "Android", 1, 0 ) ) AS android,
+ SUM( IF( os = "iOS", 1, 0 ) ) AS iphone,
+ SUM( IF( browser LIKE "%Chrome%", 1, 0 ) ) AS chrome,
+ SUM( IF( browser LIKE "%Firefox%", 1, 0 ) ) AS firefox,
+ SUM( IF( browser LIKE "%Safari%", 1, 0 ) ) AS safari,
+ SUM( IF( browser LIKE "%Internet Explorer%", 1, 0 ) ) AS ie,
+ SUM( IF( browser LIKE "%Edge%", 1, 0 ) ) AS edge,
+ SUM( IF( browser LIKE "%Opera%", 1, 0 ) ) AS opera'
+ );
+
+ return $builder;
+ }
+
+}
\ No newline at end of file
diff --git a/ci4/app/Models/Sistema/SettingsModel.php b/ci4/app/Models/Sistema/SettingsModel.php
new file mode 100644
index 00000000..32525a23
--- /dev/null
+++ b/ci4/app/Models/Sistema/SettingsModel.php
@@ -0,0 +1,38 @@
+allowedFields = [
+ ...$this->allowedFields,
+ 'first_name', // Añadido
+ 'last_name', // Añadido
+ ];
+ }
+}
diff --git a/ci4/app/Models/Usuarios/GroupModel.php b/ci4/app/Models/Usuarios/GroupModel.php
new file mode 100644
index 00000000..b7c34473
--- /dev/null
+++ b/ci4/app/Models/Usuarios/GroupModel.php
@@ -0,0 +1,155 @@
+ "t1.id",
+ 2 => "t1.keyword",
+ 3 => "t1.title",
+ 4 => "t1.description",
+ 5 => "t1.rules",
+ 6 => "t1.created_at",
+ 7 => "t1.updated_at",
+ ];
+
+ protected $allowedFields = ["id", "keyword", "title", "description", "rules"];
+ protected $returnType = "App\Entities\Usuarios\GroupEntity";
+
+ public static $labelField = "title";
+
+ protected $validationRules = [
+ "description" => [
+ "label" => "RolesPermisos.description",
+ "rules" => "max_length[150]",
+ ],
+ "title" => [
+ "label" => "RolesPermisos.title",
+ "rules" => "required|max_length[50]",
+ ],
+
+ ];
+
+ protected $validationMessages = [
+ "description" => [
+ "max_length" => "RolesPermisos.validation.description.max_length",
+ "required" => "RolesPermisos.validation.description.required",
+ ],
+ "title" => [
+ "max_length" => "RolesPermisos.validation.title.max_length",
+ "required" => "RolesPermisos.validation.title.required",
+ ],
+
+ ];
+
+ /**
+ * Get resource data.
+ *
+ * @param string $search
+ *
+ * @return \CodeIgniter\Database\BaseBuilder
+ */
+ public function getResource(string $search = "")
+ {
+ $builder = $this->db
+ ->table($this->table . " t1")
+ ->select(
+ "t1.id AS id, t1.keyword AS keyword, t1.title AS title, t1.description AS description, t1.rules AS rules,
+ t1.token AS token, t1.created_at AS created_at, t1.updated_at AS updated_at"
+ );
+
+ return empty($search)
+ ? $builder
+ : $builder
+ ->groupStart()
+ ->like("t1.id", $search)
+ ->orLike("t1.keyword", $search)
+ ->orLike("t1.title", $search)
+ ->orLike("t1.description", $search)
+ ->orLike("t1.rules", $search)
+ ->orLike("t1.created_at", $search)
+ ->orLike("t1.updated_at", $search)
+ ->groupEnd();
+ }
+
+
+ public function getUsersWithRol($groupKeyWord)
+ {
+
+ return $this->db
+ ->table('auth_groups_users')
+ ->select('user_id')
+ ->where('group', $groupKeyWord)
+ ->countAllResults();
+ }
+
+ public function getRolPermissionList($rolId)
+ {
+ $rolRecord = $this->find($rolId);
+ $result = [];
+
+ foreach ($rolRecord->rules as $section => $permissions) {
+ if (!is_null($permissions)) {
+ foreach ($permissions as $permission) {
+ $result[$section . "." . $permission] = "Can " . $permission;
+ }
+ // Add menu visibility permission (automatic management)
+ $result[$section . ".menu"] = "Menu shall be visualize";
+ }
+ }
+ return $result;
+ }
+
+ public function getRolesPermissionMatrix()
+ {
+ $rolesRecord = $this->findAll();
+ $result = [];
+
+ foreach ($rolesRecord as $rolRecord) {
+ $rolePermissions = [];
+ foreach ($rolRecord->rules as $section => $permissions) {
+ foreach ($permissions as $permission) {
+ $rolePermissions[] = $section . "." . $permission;
+ }
+ // Add menu visibility permission (automatic management)
+ $rolePermissions[] = $section . ".menu";
+ }
+ $result[$rolRecord->keyword] = $rolePermissions;
+ }
+ return $result;
+ }
+
+
+ public function getRolesList()
+ {
+ $rolesRecord = $this->findAll();
+ $result = [];
+
+ foreach ($rolesRecord as $rolRecord) {
+ $result[$rolRecord->keyword] = array(
+ 'title' => $rolRecord->title,
+ 'description' => $rolRecord->description
+ );
+ }
+ return $result;
+ }
+
+
+}
diff --git a/ci4/app/Models/Usuarios/GroupUserModel.php b/ci4/app/Models/Usuarios/GroupUserModel.php
deleted file mode 100755
index b93cf80e..00000000
--- a/ci4/app/Models/Usuarios/GroupUserModel.php
+++ /dev/null
@@ -1,19 +0,0 @@
-select('token_user')->where('token_group', $token_group)->countAllResults();
- return $result;
- }
-}
\ No newline at end of file
diff --git a/ci4/app/Models/Usuarios/PermisosModel.php b/ci4/app/Models/Usuarios/PermisosModel.php
new file mode 100644
index 00000000..aa391b76
--- /dev/null
+++ b/ci4/app/Models/Usuarios/PermisosModel.php
@@ -0,0 +1,80 @@
+ "t1.id",
+ 2 => "t1.keyword",
+ 3 => "t1.name",
+ 4 => "t1.description",
+ 5 => "t1.rules",
+ 6 => "t1.created_at",
+ 7 => "t1.updated_at",
+ ];
+
+ protected $allowedFields = ["id", "keyword", "name", "description", "rules"];
+ protected $returnType = "App\Entities\Usuarios\PermisosEntity";
+
+ public static $labelField = "name";
+
+ protected $validationRules = [
+ "description" => [
+ "label" => "UserGroups.description",
+ "rules" => "max_length[150]",
+ ],
+ "name" => [
+ "label" => "UserGroups.name",
+ "rules" => "required|max_length[50]",
+ ],
+
+ ];
+
+ protected $validationMessages = [
+ "description" => [
+ "max_length" => "UserGroups.validation.description.max_length",
+ "required" => "UserGroups.validation.description.required",
+ ],
+ "name" => [
+ "max_length" => "UserGroups.validation.name.max_length",
+ "required" => "UserGroups.validation.name.required",
+ ],
+
+ ];
+
+
+ public function getPermissionsList()
+ {
+ $allRecords = $this->findAll();
+ $result = [];
+ foreach ($allRecords as $record) {
+ foreach ($record->rules as $section => $permissions) {
+ foreach ($permissions as $permission) {
+ $result[$section . "." . $permission] = "Can " . $permission;
+ }
+ // Add menu visibility permission (automatic management)
+ $result[$section . ".menu"] = "Menu shall be visualize";
+ }
+ }
+ return $result;
+ }
+
+
+}
diff --git a/ci4/app/Models/Usuarios/UserGroupModel.php b/ci4/app/Models/Usuarios/UserGroupModel.php
deleted file mode 100755
index 48c908c6..00000000
--- a/ci4/app/Models/Usuarios/UserGroupModel.php
+++ /dev/null
@@ -1,96 +0,0 @@
- "t1.id_group",
- 2 => "t1.title",
- 3 => "t1.dashboard",
- 4 => "t1.rules",
- 5 => "t1.token",
- 6 => "t1.created_at",
- 7 => "t1.updated_at",
- ];
-
- protected $allowedFields = ["id_group", "title", "dashboard", "rules", "token"];
- protected $returnType = "App\Entities\Usuarios\UserGroupEntity";
-
- public static $labelField = "title";
-
- protected $validationRules = [
- "dashboard" => [
- "label" => "UserGroups.dashboard",
- "rules" => "required|max_length[50]",
- ],
- "title" => [
- "label" => "UserGroups.title",
- "rules" => "required|max_length[150]",
- ],
-
- ];
-
- protected $validationMessages = [
- "dashboard" => [
- "max_length" => "UserGroups.validation.dashboard.max_length",
- "required" => "UserGroups.validation.dashboard.required",
- ],
- "title" => [
- "max_length" => "UserGroups.validation.title.max_length",
- "required" => "UserGroups.validation.title.required",
- ],
-
- ];
-
- /**
- * Get resource data.
- *
- * @param string $search
- *
- * @return \CodeIgniter\Database\BaseBuilder
- */
- public function getResource(string $search = "")
- {
- $builder = $this->db
- ->table($this->table . " t1")
- ->select(
- "t1.id_group AS id_group, t1.title AS title, t1.dashboard AS dashboard, t1.rules AS rules, t1.token AS token, t1.created_at AS created_at, t1.updated_at AS updated_at"
- );
-
- return empty($search)
- ? $builder
- : $builder
- ->groupStart()
- ->like("t1.id_group", $search)
- ->orLike("t1.title", $search)
- ->orLike("t1.dashboard", $search)
- ->orLike("t1.rules", $search)
- ->orLike("t1.token", $search)
- ->orLike("t1.created_at", $search)
- ->orLike("t1.updated_at", $search)
- ->orLike("t1.id_group", $search)
- ->orLike("t1.title", $search)
- ->orLike("t1.dashboard", $search)
- ->orLike("t1.rules", $search)
- ->orLike("t1.token", $search)
- ->orLike("t1.created_at", $search)
- ->orLike("t1.updated_at", $search)
- ->groupEnd();
- }
-}
diff --git a/ci4/app/Models/Usuarios/UserModel.php b/ci4/app/Models/Usuarios/UserModel.php
index d91d94b5..0de24e85 100755
--- a/ci4/app/Models/Usuarios/UserModel.php
+++ b/ci4/app/Models/Usuarios/UserModel.php
@@ -1,7 +1,7 @@
where('email',$data['email'])->first();
- $phpass = new PasswordHash(8, true);
- return $phpass->CheckPassword($data['password']??'', $obj['password']);
- } catch (Exception $e) {
- return false;
- }
- }
-
- public function validateAuthPermission(string $str, string $fields, array $data): bool
- {
- try {
- $user_model = new UserModel();
- $settings_model = new SettingsModel();
- $settings = $settings_model->first()??[];
- $obj = $user_model->where('email',$data['email'])->first();
- return $settings['group_api'] == $obj['group'];
- } catch (Exception $e) {
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/ci4/app/Views/Shield/Email/email_2fa_email.php b/ci4/app/Views/Shield/Email/email_2fa_email.php
new file mode 100644
index 00000000..c93d8e80
--- /dev/null
+++ b/ci4/app/Views/Shield/Email/email_2fa_email.php
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+ = lang('Auth.email2FASubject') ?>
+
+
+
+ = lang('Auth.email2FAMailBody') ?>
+
+
= $code ?>
+
+
+ = lang('Auth.emailInfo') ?>
+ = lang('Auth.emailIpAddress') ?> = esc($ipAddress) ?>
+ = lang('Auth.emailDevice') ?> = esc($userAgent) ?>
+ = lang('Auth.emailDate') ?> = esc($date) ?>
+
+
+