From c1bef7a7ed91aa2aaa57e8726bade1db6ba9fd27 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Thu, 27 Apr 2023 18:29:38 +0200 Subject: [PATCH] Testeando controlador clientes --- .vscode/sftp.json | 12 ++ ci4/.env | 2 +- ci4/app/Controllers/Impresion/Clientes.php | 19 ++++ ci4/app/Controllers/Test.php | 122 +++++++++------------ ci4/app/Filters/LoginAuthFilter.php | 6 +- 5 files changed, 91 insertions(+), 70 deletions(-) create mode 100644 .vscode/sftp.json create mode 100644 ci4/app/Controllers/Impresion/Clientes.php diff --git a/.vscode/sftp.json b/.vscode/sftp.json new file mode 100644 index 00000000..a4adf0e7 --- /dev/null +++ b/.vscode/sftp.json @@ -0,0 +1,12 @@ +{ + "name": "sk-jjo", + "host": "sk-jjo.imnavajas.es", + "protocol": "ftp", + "port": 21, + "username": "sk-jjo", + "password": "yuh1C^290", + "remotePath": "/", + "uploadOnSave": true, + "useTempFile": false, + "openSsh": false +} diff --git a/ci4/.env b/ci4/.env index 8c0a37d3..fa4d571c 100644 --- a/ci4/.env +++ b/ci4/.env @@ -22,7 +22,7 @@ CI_ENVIRONMENT = development # APP #-------------------------------------------------------------------- -app.baseURL = 'http://safekat.test' +app.baseURL = 'https://sk-jjo.imnavajas.es' # app.forceGlobalSecureRequests = false # app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler' diff --git a/ci4/app/Controllers/Impresion/Clientes.php b/ci4/app/Controllers/Impresion/Clientes.php new file mode 100644 index 00000000..abd7c691 --- /dev/null +++ b/ci4/app/Controllers/Impresion/Clientes.php @@ -0,0 +1,19 @@ +user_model = new UserModel(); - $this->group_user_model = new GroupUserModel(); - $this->group_model = new UserGroupModel(); + } public function index() { - /////////////////////////////////7 - // Join groups access rules - /*$user_token = "a4a60f9f064218b09cf108418e585507"; - $groups = $this->group_user_model - ->select('token_group') - ->where('token_user', $user_token)->findAll(); - - if(sizeof($groups)>0){ - $rules = html_entity_decode($this->group_model->select('rules')->where('token',$groups[0]['token_group'])->first()['rules']); + try { + helper('filesystem'); + helper('directory'); + if(strtolower(PHP_OS) == 'linux'){ + $compatibility = '/'; + }else{ + $compatibility = '\\'; + } + + if(empty($controller)){ + $map = directory_map(APPPATH.'Controllers'); + foreach ($map as $key=>$item) + { + if(!strpos(strtolower($key),$compatibility)){ + var_dump($key); + $name = str_replace('.php', '', $item); + if(!getIgnoreController($name)){ + $controllers[] = [ + 'name' => $name, + 'path' => '', + 'methods' => get_class_methods('App\Controllers\\'.$name) + ]; + } + }else{ + foreach ($item as $subitem){ + $name = str_replace('.php', '', $subitem); + if(!getIgnoreController($name)) { + $controllers[] = [ + 'name' => $name, + 'path' => $key, + 'methods' => get_class_methods('App\Controllers\\' . str_replace('/', '\\', $key) . $name) + ]; + } + } + } + } + }else{ + $array = explode('/',$controller); + $dir = count($array) > 1 ? $array[0] : ''; + $name = count($array) > 1 ? '\\'.$array[1] : $array[0]; + $controllers[] = [ + 'name' => $name, + 'path' => $dir, + 'methods' => get_class_methods('App\Controllers\\'.str_replace('/','\\',$dir).$name) + ]; + } + /*echo '
';
+            var_dump($controllers);
+            echo '
';
+            dd();
+            */
+        } catch (Exception $e) {
+            return [];
         }
-        for ($i = 1; $igroup_model->select('rules')->where('token',$groups[$i]['token_group'])->first()['rules']);
-            $rules = json_encode(
-                array_merge(
-                    json_decode($rules, true),
-                    json_decode($this->group_model->select('rules')->where('token',$groups[$i]['token_group'])->first()['rules'], true)
-                )
-            );
-        }   */
-
-        $user_token = 'c0bf18621f78cb2ffc4a67cf8d5173c7';
-        $groups_token = $this->group_user_model->select('token_group')
-            ->where('token_user',$user_token)
-            ->findAll();
-
-        $groups_names = [];
-        foreach($groups_token as $g_t){
-            $title = $this->group_model->select('title')
-                ->where('token',$g_t)
-                ->first()['title'];
-            array_push($groups_names, $title); 
-                
-        }
-
-        echo '
';
-        var_dump($groups_names);
-        echo '
'; - - dd(); - - - - //Total number of records without filtering - $totalRecords = $this->user_model->select('id_user') - ->join('auth_user_group','auth_user_group.token = auth_user.group') - ->countAllResults(); - - //Total number of records with filtering - $totalRecordwithFilter = $this->user_model->select('id_user') - ->join('auth_user_group','auth_user_group.token = auth_user.group') - ->orLike('first_name', $searchValue) - ->orLike('email', $searchValue) - ->countAllResults(); - - - - - } } diff --git a/ci4/app/Filters/LoginAuthFilter.php b/ci4/app/Filters/LoginAuthFilter.php index f9526375..15830195 100644 --- a/ci4/app/Filters/LoginAuthFilter.php +++ b/ci4/app/Filters/LoginAuthFilter.php @@ -46,6 +46,7 @@ class LoginAuthFilter implements FilterInterface $language->setLocale(session()->lang); $getWhiteList = $this->whiteListController(); + foreach ($getWhiteList as $item){ if(strtolower($item) == $uri->getSegment(1)){ return true; @@ -83,6 +84,8 @@ class LoginAuthFilter implements FilterInterface public function whiteListController(){ return [ '', + 'Clientes', + 'BaseController', 'Home', 'Login', @@ -94,7 +97,8 @@ class LoginAuthFilter implements FilterInterface 'Ajax', 'Integration', 'Migrate', - 'Test' + 'Test', + ]; }