diff --git a/ci4/app/Config/FTP.php b/ci4/app/Config/FTP.php new file mode 100644 index 00000000..f3faf0a0 --- /dev/null +++ b/ci4/app/Config/FTP.php @@ -0,0 +1,58 @@ + "sk-ftp", + "user" => "admin", + "password" => "A77h3b0X4OA2rOYAf4w2", + "base_dir" => "/home/admin/safekat" # FTP server directory + ]; + /** + * This database connection is used when + * running PHPUnit database tests. + */ + public array $production = [ + "host" => "sk-ftp", + "user" => "admin", + "password" => "A77h3b0X4OA2rOYAf4w2", + "base_dir" => "/home/admin/safekat" # FTP server directory + ]; + /** + * This database connection is used when + * running PHPUnit database tests. + */ + public array $development = [ + "host" => "sk-ftp", + "port" => "21000", + "user" => "admin", + "password" => "A77h3b0X4OA2rOYAf4w2", + "base_dir" => "/home/admin/safekat" # FTP server directory + + ]; + + public function __construct() + { + parent::__construct(); + + // Ensure that we always set the database group to 'tests' if + // we are currently running an automated test suite, so that + // we don't overwrite live data on accident. + if (ENVIRONMENT === 'development') { + $this->defaultGroup = 'development'; + } + } +} diff --git a/ci4/app/Config/Services.php b/ci4/app/Config/Services.php index df7c8ad0..572aec46 100755 --- a/ci4/app/Config/Services.php +++ b/ci4/app/Config/Services.php @@ -2,6 +2,7 @@ namespace Config; +use App\Services\FTPService; use CodeIgniter\Config\BaseService; /** @@ -29,4 +30,11 @@ class Services extends BaseService * return new \CodeIgniter\Example(); * } */ + public static function ftp(bool $getShared = true): FTPService + { + if ($getShared) { + return static::getSharedInstance('ftp'); + } + return new FTPService(); + } } diff --git a/ci4/app/Controllers/Pedidos/Pedido.php b/ci4/app/Controllers/Pedidos/Pedido.php index af2dbfc7..6ff1ca79 100755 --- a/ci4/app/Controllers/Pedidos/Pedido.php +++ b/ci4/app/Controllers/Pedidos/Pedido.php @@ -328,7 +328,6 @@ class Pedido extends \App\Controllers\BaseResourceController } public function get_xml_pedido($pedido_id) { - $data = PedidoXMLService::generate_xml($pedido_id); // $xml_service = new PedidoXMLService($this->model); return $this->respond($data); diff --git a/ci4/app/Helpers/general_helper.php b/ci4/app/Helpers/general_helper.php deleted file mode 100755 index e0578134..00000000 --- a/ci4/app/Helpers/general_helper.php +++ /dev/null @@ -1,683 +0,0 @@ -$value){ - if($key==$section){ - foreach($value as $item){ - if($item==$method){ - return true; - } - } - } - } - return false; - - /*var_dump($key. ' '. $value[0]); - - echo '
'; - $rules = - echo ''; - dd();*/ -} - -function getAllClass($controller = null){ - 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)){ - $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) - ]; - } - return $controllers??[]; - } catch (Exception $e) { - return []; - } -} - - -// IMN -function getCurrentLanguageFlag(){ - try { - $session = session(); - - if($session->get('lang') == 'en'){ - return "fi-gb"; - }else{ - return "fi-es"; - } - } catch (Exception $e) { - return "fi-es"; - } -} - - -function getAllClassFolder($folder = null){ - try { - helper('filesystem'); - helper('directory'); - - if(!empty($folder)){ - $map = directory_map(APPPATH.'Controllers'); - foreach ($map as $key=>$item) - { - if(strtolower(PHP_OS) == 'linux'){ - $compatibility = '/'; - }else{ - $compatibility = '\\'; - } - if(str_replace($compatibility,'',strtolower($key)) == strtolower($folder)){ - foreach ($item as $subitem){ - $name = str_replace('.php', '', $subitem); - $controllers[] = [ - 'name' => $name, - 'path' => $key, - 'methods' => get_class_methods('App\Controllers\\'.str_replace('/','\\',$key).$name) - ]; - } - } - } - } - return $controllers??[]; - } catch (Exception $e) { - return []; - } -} - -function getAllFolder(){ - try { - helper('filesystem'); - helper('directory'); - $map = directory_map(APPPATH.'Controllers',1); - if(strtolower(PHP_OS) == 'linux'){ - $compatibility = '/'; - }else{ - $compatibility = '\\'; - } - foreach ($map as $item) { - if(strpos(strtolower($item),$compatibility)){ - $folders[] = str_replace($compatibility,"",$item); - } - } - return $folders??[]; - } catch (Exception $e) { - return []; - } -} - - - -function getIgnoreController($controller) -{ - try { - $loginAuthFilter = new \App\Filters\LoginAuthFilter(); - foreach ($loginAuthFilter->whiteListController() as $item){ - if($controller == $item){ - return true; - } - } - return false; - } catch (Exception $e) { - return []; - } -} - -function getIgnoreMethod($method) -{ - try { - $loginAuthFilter = new \App\Filters\LoginAuthFilter(); - foreach ($loginAuthFilter->whiteListMethod() as $item){ - if($method == $item){ - return true; - } - } - return false; - } catch (Exception $e) { - return []; - } -} - -function getDictionary($word=''){ - try { - $dictionary = [ - 'index' => lang("App.permisos_index"), - 'view' => lang("App.permisos_view"), - 'add' => lang("App.permisos_add"), - 'edit' => lang("App.permisos_editar"), - 'delete' => lang("App.permisos_del"), - 'store' => lang("App.permisos_save"), - 'import' => lang("App.permisos_import"), - 'export' => lang("App.permisos_export"), - - 'Profile' => lang("App.permisos_perfil"), - 'Activity' => lang("App.permisos_actividad"), - 'Settings' => lang("App.permisos_configuracion"), - 'my' => lang("App.permisos_my"), - 'Notification' => lang("App.permisos_notificacion"), - - 'Users' => lang("App.permisos_usuarios"), - 'User' => lang("App.permisos_usuario"), - 'Group' => lang("App.permisos_roles"), - - 'Logistica' => lang("App.permisos_logistica"), - - 'Tarifas' => lang("App.permisos_tarifas"), - 'Tarifapreimpresion' => lang("App.permisos_tarifapreimpresion"), - 'Tarifamanipulado' => lang("App.permisos_tarifamanipulado"), - 'Tarifapapelcompra' => lang("App.permisos_tarifapapelcompra"), - 'Tarifaacabado' => lang("App.permisos_tarifaacabado"), - 'Tarifapapeldefecto' => lang("App.permisos_tarifapapeldefecto"), - 'Tarifaenvio' => lang("App.permisos_tarifaenvio"), - 'Tarifaimpresion' => lang("App.permisos_tarifaimpresion"), - - 'Configuracion' => lang("App.permisos_configuracion"), - 'Tareaservicio' => lang("App.permisos_tareasservicio"), - 'Formaspago' => lang("App.permisos_formaspago"), - 'Papelgenerico' => lang("App.permisos_papelgenerico"), - 'Tiposimpresion' => lang("App.permisos_tiposimpresion"), - 'Trabajo' => lang("App.permisos_trabajo"), - 'Maquina' => lang("App.permisos_maquina"), - 'Tamaniolibros' => lang("App.permisos_tamaniolibros"), - 'Imposiciones' => lang("App.permisos_imposiciones"), - 'Seriefactura' => lang("App.permisos_seriefactura"), - 'Tamanioformatos' => lang("App.permisos_tamanioformatos"), - 'Serviciocliente' => lang("App.permisos_serviciocliente"), - 'Calendario' => lang("App.permisos_calendario"), - 'Correo' => lang("App.permisos_correo"), - 'Paises' => lang("App.permisos_paises"), - 'Tipologias' => lang("App.permisos_tipologias"), - - 'Presupuestos' => lang("App.permisos_presupuestos"), - 'Presupuesto' => lang("App.permisos_presupuestos"), - 'Presupuestomaquetacion' => lang("App.permisos_presupuestomaquetacion"), - - 'Catalogo' => lang("App.permisos_catalogo"), - - 'Cliente' => lang("App.permisos_clientes"), - 'Tarifacliente' => lang("App.permisos_tarifacliente"), - - 'Proveedores' => lang("App.permisos_proveedores"), - 'Proveedor' => lang("App.permisos_proveedores"), - - 'Informes' => lang("App.permisos_informes"), - 'Informe' => lang("App.permisos_informes"), - - 'Facturacion' => lang("App.permisos_facturación"), - 'Albaran' => lang("App.permisos_albaran"), - 'Factura' => lang("App.permisos_facturas"), - - 'Pedidos' => lang("App.permisos_pedidos"), - 'Pedido' => lang("App.permisos_pedidos"), - - 'Serviciosdigitalizacion' => lang("App.permisos_digitalización"), - 'Digitalizacion' => lang("App.permisos_digitalización"), - - 'Produccion' => lang("App.permisos_produccion"), - 'Ordentrabajomaquetacion' => lang("App.permisos_ordentrabajomaquetacion"), - 'Ordenmaquina' => lang("App.permisos_ordenmaquina"), - 'Pedidoproduccion' => lang("App.permisos_pedidoproduccion"), - 'Ordentrabajo' => lang("App.permisos_ordentrabajo"), - - 'oauth' => lang("App.group_rules_label_oauth"), - 'template' => lang("App.group_rules_label_template"), - 'all' => lang("App.group_rules_label_all"), - 'oauth_store' => lang("App.group_rules_label_oauth_store"), - 'template_store' => lang("App.group_rules_label_template_store"), - - ]; - return array_key_exists($word,$dictionary)?$dictionary[$word] : $word; - } catch (Exception $e) { - return ''; - } -} - -function getMenuControl(){ - try { - $getClass = getAllClass(); - $getRules = json_decode(session()->get('rules')??'[]'); - foreach ($getClass as $item){ - foreach ($getRules as $key=>$value){ - if($key == $item['name']){ - $item['methods'] = $value; - $data[] = $item; - } - } - } - return $data??[]; - } catch (Exception $e) { - session()->setFlashdata('alert', 'error_acesso'); - return []; - } -} - -function allowMenuSection(array $array, array $keys, $method){ - try{ - $value = false; - foreach($keys as $key){ - if (count($temp=getArrayItem($array,'name',$key)) > 0){ - if (count(getArrayItem($temp,'methods','index',true)) > 0){ - $value = true; - } - } - } - return $value; - - } catch (Exception $e) { - return []; - } -} - -function getArrayItem(array $array, $key, $word, $isArray=false) -{ - try { - foreach ($array as $item){ - if ($isArray){ - foreach ($item[$key] as $subitem){ - if($subitem == $word){ - $data[]=$subitem; - } - } - }else{ - if($item[$key] == $word){ - $data[]=$item; - } - } - } - return $data??[]; - } catch (Exception $e) { - return []; - } -} - -//////////////////////////////////////////////////// -/// Notification Messages -//////////////////////////////////////////////////// - -function formAlert() -{ - $session = session(); - $alert = $session->getFlashdata('error'); - $validation = \Config\Services::validation()->listErrors(); - if (!empty($alert)){ - return '