Actualizacion automatica: 2024-05-07 21:16:26

This commit is contained in:
imnavajas
2024-05-07 21:16:39 +02:00
parent bdf605b26f
commit a38ebc012f
12 changed files with 100 additions and 255 deletions

6
.idea/safekat.iml generated
View File

@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/ci4" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/ci4/app" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/ci4/app/ThirdParty/DatatablesEditor/" isTestSource="false" packagePrefix="DataTables\" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>

View File

@ -11,7 +11,7 @@ service('auth')->routes($routes);
//WEB ROUTER ------------------------------------------------------
//------------------------------------------------------------------
$routes->get('/', 'Home::index');
$routes->get('/', 'Home::index', ['as' => 'home']);
$routes->get('lang/{locale}', 'Language::index');
$routes->get('viewmode/(:alpha)', 'Viewmode::index/$1');
@ -334,7 +334,29 @@ $routes->group('provincias', ['namespace' => 'App\Controllers\Configuracion'], f
$routes->resource('provincias', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Provincias', 'except' => 'show,new,create,update']);
$routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
/* Rutas para configuraciones */
$routes->group('clientes', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
/* Cliente */
$routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
$routes->get('', 'Cliente::index', ['as' => 'clienteList']);
$routes->match(['get', 'post'], 'add', 'Cliente::add', ['as' => 'clienteAdd']);
$routes->match(['get', 'post'], 'edit/(:num)', 'Cliente::edit/$1', ['as' => 'clienteEdit']);
$routes->get('delete/(:num)', 'Cliente::delete/$1', ['as' => 'clienteDelete']);
$routes->post('datatable', 'Cliente::datatable', ['as' => 'clienteDT']);
});
/* Precios */
/*$routes->group('precios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
$routes->post('datatable', 'ClientePrecios::datatable', ['as' => 'clientePreciosDT']);
$routes->post('datatable_editor', 'ClientePrecios::datatable_editor', ['as' => 'clientePreciosDTE']);
});*/
});
/*$routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
$routes->get('', 'Cliente::index', ['as' => 'clienteList']);
$routes->get('add', 'Cliente::add', ['as' => 'newCliente']);
$routes->post('add', 'Cliente::add', ['as' => 'createCliente']);
@ -346,15 +368,15 @@ $routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function
$routes->post('allmenuitems', 'Cliente::allItemsSelect', ['as' => 'select2ItemsOfClientes']);
$routes->post('menuitems', 'Cliente::menuItems', ['as' => 'menuItemsOfClientes']);
});
$routes->resource('cliente', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Cliente', 'except' => 'show,new,create,update']);
$routes->resource('cliente', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Cliente', 'except' => 'show,new,create,update']);*/
$routes->group('clienteprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
$routes->post('datatable', 'Clienteprecios::datatable', ['as' => 'dataTableOfClienteprecios']);
$routes->post('datatable_editor', 'Clienteprecios::datatable_editor', ['as' => 'editorOfClienteprecios']);
});
$routes->resource('clienteprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clienteprecios', 'except' => 'show,new,create,update']);
$routes->group('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
$routes->get('', 'Clienteplantillaprecios::index', ['as' => 'clienteplantillapreciosList']);
$routes->get('add', 'Clienteplantillaprecios::add', ['as' => 'newClienteplantillaprecios']);

View File

@ -129,7 +129,7 @@ class Cliente extends \App\Controllers\BaseResourceController
$this->viewData['userList2'] = $this->getUserListItems2($clienteEntity->soporte_id ?? null);
$this->viewData['formaDePagoList'] = $this->getFormaDePagoListItems($clienteEntity->forma_pago_id ?? null);
$this->viewData['formAction'] = site_url('cliente/add'); // route_to('createCliente'); IMN
$this->viewData['formAction'] = route_to('clienteAdd');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
@ -227,7 +227,7 @@ class Cliente extends \App\Controllers\BaseResourceController
$this->viewData['userList2'] = $this->getUserListItems2($clienteEntity->soporte_id ?? null);
$this->viewData['formaDePagoList'] = $this->getFormaDePagoListItems($clienteEntity->forma_pago_id ?? null);
$this->viewData['formAction'] = route_to('updateCliente', $id);
$this->viewData['formAction'] = route_to('clienteEdit', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.edit3');
@ -355,10 +355,10 @@ class Cliente extends \App\Controllers\BaseResourceController
protected function getUserListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])];
if (!empty($selId)) :
$userModel = model('App\Models\Usuarios\UserModel');
if (!is_null($selId)) :
$userModel = model('App\Models\UserModel');
$selOption = $userModel->where('id_user', $selId)->findColumn('first_name');
$selOption = $userModel->where('id', $selId)->findColumn('first_name');
if (!empty($selOption)) :
$data[$selId] = $selOption[0];
endif;
@ -370,7 +370,7 @@ class Cliente extends \App\Controllers\BaseResourceController
protected function getComunidadAutonomaListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])];
if (!empty($selId)) :
if (!is_null($selId)) :
$comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel');
$selOption = $comunidadAutonomaModel->where('id', $selId)->findColumn('nombre');
@ -385,10 +385,10 @@ class Cliente extends \App\Controllers\BaseResourceController
protected function getUserListItems2($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])];
if (!empty($selId)) :
$userModel = model('App\Models\Configuracion\UserModel');
if (!is_null($selId)) :
$userModel = model('App\Models\UserModel');
$selOption = $userModel->where('id_user', $selId)->findColumn('last_name');
$selOption = $userModel->where('id', $selId)->findColumn('last_name');
if (!empty($selOption)) :
$data[$selId] = $selOption[0];
endif;

View File

@ -2,9 +2,11 @@
namespace App\Models\Clientes;
class ClienteUsuariosModel extends \App\Models\BaseModel
use CodeIgniter\Shield\Models\UserModel as ShieldUserModel;
class ClienteUsuariosModel extends ShieldUserModel
{
protected $table = "auth_user";
protected $table = "users";
/**
* Whether primary key uses auto increment.
@ -16,11 +18,11 @@ class ClienteUsuariosModel extends \App\Models\BaseModel
const SORTABLE = [
0 => "t1.first_name",
1 => "t1.last_name",
2 => "t1.email",
2 => "t2.secret",
];
protected $allowedFields = ["id", "first_name", "last_name", "email"];
protected $returnType = "App\Entities\Usuarios\UserEntity";
protected $returnType = "App\Entities\Usuarios\UsersEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
@ -93,10 +95,12 @@ class ClienteUsuariosModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id_user AS id, t1.first_name AS nombre, t1.last_name AS apellidos, t1.email AS email"
"t1.id AS id, t1.first_name AS nombre, t1.last_name AS apellidos,
t2.secret AS email"
);
$builder->where('t1.id_user', $cliente_id);
$builder->join("auth_identities t2", "t1.id = t2.user_id", "left");
$builder->where('t1.id', $cliente_id);
return empty($search)
? $builder
@ -104,7 +108,7 @@ class ClienteUsuariosModel extends \App\Models\BaseModel
->groupStart()
->like("t1.first_name", $search)
->orLike("t1.last_name", $search)
->orLike("t1.email", $search)
->orLike("t2.secret", $search)
->groupEnd();
}
}

View File

@ -15,7 +15,7 @@
Ficha de Cliente
</button>
</li>
<?php if ($formAction !== site_url('cliente/add')){ ?>
<?php if ($formAction !== route_to('clienteAdd')){ ?>
<li class="nav-item">
<button
type="button"
@ -564,7 +564,7 @@
</div>
<?php if ($formAction !== site_url('cliente/add')){ ?>
<?php if ($formAction !== route_to('clienteAdd')){ ?>
<div class="tab-pane fade" id="tarifascliente" role="tabpanel">
<?= view("themes/backend/vuexy/form/clientes/cliente/convert2templateModal") ?>
<div class='row'>
@ -685,7 +685,7 @@
<?php if ($formAction !== site_url('cliente/add')){ ?>
<?php if ($formAction !== route_to('clienteAdd')){ ?>
<?= $this->section("additionalInlineJs") ?>
/****************************************
Funcionamiento general

View File

@ -9,7 +9,7 @@
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?=lang('Clientes.clienteList') ?></h3>
<?=anchor(route_to('newCliente'), lang('Basic.global.addNew').' '.lang('Clientes.cliente'), ['class'=>'btn btn-primary float-end']); ?>
<?=anchor(route_to('clienteAdd'), lang('Basic.global.addNew').' '.lang('Clientes.cliente'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-header -->
<div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
@ -76,7 +76,7 @@
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfClientes') ?>',
url: '<?= route_to('clienteDT') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,

View File

@ -16,41 +16,13 @@
<ul class="menu-inner py-1">
<li class="menu-item active">
<a href="<?= site_url("") ?>" class="menu-link">
<i class="menu-icon tf-icons ti ti-dashboard"></i>
<?= lang("App.menu_dashboard") ?>
</a>
</li>
<?php
/**
* MENU CLIENTES
*/
if (auth()->user()->can('clientes.menu')) {
require "menus/dashboard_menu.php";
?>
<!-- Clientes -->
<li class="menu-item">
<a href="javascript:void(0);" class="menu-link menu-toggle">
<i class="menu-icon tf-icons ti ti-users"></i>
<?= lang("App.menu_clientes") ?>
</a>
<ul class="menu-sub">
<li class="menu-item">
<a href="<?= site_url("clientes/cliente") ?>" class="menu-link">
<?= lang("App.menu_clientes") ?>
</a>
</li>
<li class="menu-item">
<a href="<?= site_url("clientes/clienteplantillaprecios") ?>" class="menu-link">
<?= lang("App.menu_plantillas_tarifas_clientes") ?>
</a>
</li>
</ul>
</li>
<?php } ?>
require "menus/clientes_menu.php";
?>
<?php

View File

@ -1,12 +1,31 @@
<?php
$clientesItems = [
"link" => "javascript:void(0)",
"text" => lang("App.menu_clientes"),
"submenu" => [
["link" => site_url("clientes/cliente"), "text" => lang("App.menu_clientes")],
["link" => site_url("clientes/clienteplantillaprecios"), "text" => lang("App.menu_plantillas_tarifas_clientes")]
]
];
/**
* MENU CLIENTES
*/
if (auth()->user()->can('clientes.menu') ||
auth()->user()->can('plantilla-tarifa.menu')) {
?>
<!-- Clientes -->
<li class="menu-item">
<a href="javascript:void(0);" class="menu-link menu-toggle">
<i class="menu-icon tf-icons ti ti-users"></i>
<?= lang("App.menu_clientes") ?>
</a>
<ul class="menu-sub">
<?php if (auth()->user()->can('clientes.menu')) { ?>
<li class="menu-item">
<a href="<?= route_to("clienteList") ?>" class="menu-link">
<?= lang("App.menu_clientes") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('plantilla-tarifa.menu')) { ?>
<li class="menu-item">
<a href="<?= site_url("clientes/clienteplantillaprecios") ?>" class="menu-link">
<?= lang("App.menu_plantillas_tarifas_clientes") ?>
</a>
</li>
<?php } ?>
</ul>
</li>
<?php } ?>

View File

@ -1,10 +1,11 @@
<?php
$dashboardItems = [
'icon' => 'ti ti-dashboard',
'langKey' => 'App.menu_dashboard',
'url' => '',
'isActive' => true
];
/**
* MENU DASHBOARD
*/
?>
<li class="menu-item active">
<a href="<?= route_to("home") ?>" class="menu-link">
<i class="menu-icon tf-icons ti ti-dashboard"></i>
<?= lang("App.menu_dashboard") ?>
</a>
</li>

View File

@ -1,99 +0,0 @@
#!/usr/bin/env php
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
/*
* --------------------------------------------------------------------
* CodeIgniter command-line tools
* --------------------------------------------------------------------
* The main entry point into the CLI system and allows you to run
* commands and perform maintenance on your application.
*
* Because CodeIgniter can handle CLI requests as just another web request
* this class mainly acts as a passthru to the framework itself.
*/
// Refuse to run when called from php-cgi
if (strpos(PHP_SAPI, 'cgi') === 0) {
exit("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n");
}
// Check PHP version.
$minPhpVersion = '7.4'; // If you update this, don't forget to update `public/index.php`.
if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
$message = sprintf(
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
$minPhpVersion,
PHP_VERSION
);
exit($message);
}
// We want errors to be shown when using it from the CLI.
error_reporting(-1);
ini_set('display_errors', '1');
/**
* @var bool
*
* @deprecated No longer in use. `CodeIgniter` has `$context` property.
*/
define('SPARKED', true);
// Path to the front controller
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
// Ensure the current directory is pointing to the front controller's directory
chdir(FCPATH);
/*
*---------------------------------------------------------------
* BOOTSTRAP THE APPLICATION
*---------------------------------------------------------------
* This process sets up the path constants, loads and registers
* our autoloader, along with Composer's, loads our constants
* and fires up an environment-specific bootstrapping.
*/
// Load our paths config file
// This is the line that might need to be changed, depending on your folder structure.
require FCPATH . '../app/Config/Paths.php';
// ^^^ Change this line if you move your application folder
$paths = new Config\Paths();
// Location of the framework bootstrap file.
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
// Load environment settings from .env files into $_SERVER and $_ENV
require_once SYSTEMPATH . 'Config/DotEnv.php';
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
// Grab our CodeIgniter
$app = Config\Services::codeigniter();
$app->initialize();
// Grab our Console
$console = new CodeIgniter\CLI\Console();
// Show basic information before we do anything else.
if (is_int($suppress = array_search('--no-header', $_SERVER['argv'], true))) {
unset($_SERVER['argv'][$suppress]); // @codeCoverageIgnore
$suppress = true;
}
$console->showHeader($suppress);
// fire off the command in the main framework.
$exit = $console->run();
exit(is_int($exit) ? $exit : EXIT_SUCCESS);

View File

@ -1,78 +0,0 @@
<?php
// Valid PHP Version?
$minPHPVersion = '7.3';
if (phpversion() < $minPHPVersion)
{
die("Your PHP version must be {$minPHPVersion} or higher to run CodeIgniter 4.<br>Current version: " . phpversion());
}
unset($minPHPVersion);
// Path to the front controller (this file)
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);
/*
*---------------------------------------------------------------
* BOOTSTRAP THE APPLICATION
*---------------------------------------------------------------
* This process sets up the path constants, loads and registers
* our autoloader, along with Composer's, loads our constants
* and fires up an environment-specific bootstrapping.
*/
// Ensure the current directory is pointing to the front controller's directory
chdir(FCPATH);
// Load our paths config file
// This is the line that might need to be changed, depending on your folder structure.
$pathsConfig = FCPATH . '../ci4/app/Config/Paths.php';
// ^^^ Change this if you move your application folder
require realpath($pathsConfig) ?: $pathsConfig;
$paths = new Config\Paths();
//Check Installation
$rootFolder = realpath(rtrim($paths->appDirectory, '/ ') . '/../');
$env = file_exists($rootFolder . '/.env');
if($env == false) {
$domain = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
$domain = preg_replace('/index.php.*/', '', $domain); //remove everything after index.php
if (!empty($_SERVER['HTTPS'])) {
$domain = 'https://' . $domain;
} else {
$domain = 'http://' . $domain;
}
header("Location: $domain./install");
exit;
}
// Location of the framework bootstrap file.
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
// Load environment settings from .env files into $_SERVER and $_ENV
require_once SYSTEMPATH . 'Config/DotEnv.php';
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
/*
* ---------------------------------------------------------------
* GRAB OUR CODEIGNITER INSTANCE
* ---------------------------------------------------------------
*
* The CodeIgniter class contains the core functionality to make
* the application run, and does all of the dirty work to get
* the pieces all working together.
*/
$app = Config\Services::codeigniter();
$app->initialize();
$context = is_cli() ? 'php-cli' : 'web';
$app->setContext($context);
/*
*---------------------------------------------------------------
* LAUNCH THE APPLICATION
*---------------------------------------------------------------
* Now that everything is setup, it's time to actually fire
* up the engines and make this app do its thang.
*/
$app->run();