mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/papelimp_tip3'
# Conflicts: # ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php
This commit is contained in:
@ -43,9 +43,7 @@ class Activity extends BaseController
|
||||
SUM( IF( browser LIKE "%Edge%", 1, 0 ) ) AS edge,
|
||||
SUM( IF( browser LIKE "%Opera%", 1, 0 ) ) AS opera')->where('auth_activity.user',$session->get('token'))->first();
|
||||
$data['all'] = "";
|
||||
echo view(getenv('theme.path').'main/header');
|
||||
echo view(getenv('theme.path').'form/activity/index',$data);
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
}
|
||||
|
||||
public function all()
|
||||
@ -79,8 +77,6 @@ class Activity extends BaseController
|
||||
SUM( IF( browser LIKE "%Edge%", 1, 0 ) ) AS edge,
|
||||
SUM( IF( browser LIKE "%Opera%", 1, 0 ) ) AS opera')->first();
|
||||
$data['all'] = "/all";
|
||||
echo view(getenv('theme.path').'main/header');
|
||||
echo view(getenv('theme.path').'form/activity/index',$data);
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@ namespace App\Controllers;
|
||||
use App\Models\CronTabModel;
|
||||
use App\Models\NotificationModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use App\Models\UserGroupModel;
|
||||
use App\Models\GroupUserModel;
|
||||
use App\Models\Usuarios\UserGroupModel;
|
||||
use App\Models\Usuarios\GroupUserModel;
|
||||
use App\Models\ActivityModel;
|
||||
use CodeIgniter\RESTful\ResourceController;
|
||||
|
||||
|
||||
@ -13,12 +13,22 @@ class Catalogo extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Hola2';
|
||||
echo 'Catalogo Libros';
|
||||
}
|
||||
|
||||
public function import()
|
||||
public function importar()
|
||||
{
|
||||
echo 'Importar Catalogo Libros';
|
||||
}
|
||||
|
||||
public function nuevo()
|
||||
{
|
||||
echo 'Nuevo Catalogo Libros';
|
||||
}
|
||||
|
||||
public function categorias()
|
||||
{
|
||||
echo 'Categorias de Catalogo de Libros';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php namespace App\Controllers\Usuarios;
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Entities\Usuarios\UserGroupEntity;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php namespace App\Controllers\Usuarios;
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
|
||||
use App\Entities\Usuarios\UserEntity;
|
||||
@ -14,9 +14,19 @@ class Logistica extends BaseController
|
||||
public function index()
|
||||
{
|
||||
echo 'Logistica';
|
||||
}
|
||||
}
|
||||
|
||||
public function etiquetas()
|
||||
{
|
||||
echo 'Etiquetas';
|
||||
}
|
||||
|
||||
public function tracking()
|
||||
{
|
||||
echo 'Traking';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -14,7 +14,18 @@ class Factura extends BaseController
|
||||
public function index()
|
||||
{
|
||||
echo 'Facturas';
|
||||
}
|
||||
}
|
||||
|
||||
public function nueva()
|
||||
{
|
||||
echo 'Nueva Factura';
|
||||
}
|
||||
|
||||
public function vencimiento()
|
||||
{
|
||||
echo 'Vencimiento Factura';
|
||||
}
|
||||
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
36
ci4/app/Controllers/Importacion/Importar.php
Normal file
36
ci4/app/Controllers/Importacion/Importar.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Importacion;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Importar extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Importar';
|
||||
}
|
||||
|
||||
|
||||
// public function delete_files()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public function pedidos_maquetacion()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public function pedidos_prestashop()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ class Language extends BaseController
|
||||
$locale = $this->request->getLocale();
|
||||
$session->remove('lang');
|
||||
$session->set('lang', $locale);
|
||||
$url = base_url();
|
||||
$url = previous_url();
|
||||
return redirect()->to($url);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,8 +13,28 @@ class Pedido extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Pedido';
|
||||
}
|
||||
echo 'Pedidos';
|
||||
}
|
||||
|
||||
public function activos()
|
||||
{
|
||||
echo 'Pedidos Activos';
|
||||
}
|
||||
|
||||
public function finalizados()
|
||||
{
|
||||
echo 'Pedidos Finalizados';
|
||||
}
|
||||
|
||||
public function cancelados()
|
||||
{
|
||||
echo 'Pedidos Cancelados';
|
||||
}
|
||||
|
||||
public function manuales()
|
||||
{
|
||||
echo 'Pedidos Manuales';
|
||||
}
|
||||
|
||||
// public function delete_files()
|
||||
// {
|
||||
|
||||
@ -13,8 +13,23 @@ class Presupuestomaquetacion extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Presupuesto maquetacion';
|
||||
}
|
||||
echo 'Presupuesto maquetacion Todos';
|
||||
}
|
||||
|
||||
public function nuevo()
|
||||
{
|
||||
echo 'Presupuesto maquetacion Nuevo';
|
||||
}
|
||||
|
||||
public function borrador()
|
||||
{
|
||||
echo 'Presupuesto maquetacion Borrador';
|
||||
}
|
||||
|
||||
public function aceptados()
|
||||
{
|
||||
echo 'Presupuesto maquetacion Aceptados';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
@ -14,7 +14,7 @@ class Ordentrabajo extends BaseController
|
||||
public function index()
|
||||
{
|
||||
echo 'Orden trabajo';
|
||||
}
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
@ -31,5 +31,20 @@ class Ordentrabajo extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function cien()
|
||||
{
|
||||
echo 'Orden trabajo 100%';
|
||||
}
|
||||
|
||||
public function finalizado()
|
||||
{
|
||||
echo 'Orden trabajo finalizado';
|
||||
}
|
||||
|
||||
public function pendiente()
|
||||
{
|
||||
echo 'Orden trabajo pendiente';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
26
ci4/app/Controllers/Servicios/Compras.php
Normal file
26
ci4/app/Controllers/Servicios/Compras.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Servicios;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Compras extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Compras';
|
||||
}
|
||||
|
||||
public function ajustes()
|
||||
{
|
||||
echo 'Ajustes de Compras';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
22
ci4/app/Controllers/Servicios/Digitalizacion.php
Normal file
22
ci4/app/Controllers/Servicios/Digitalizacion.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Servicios;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Digitalizacion extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Digitalización';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
21
ci4/app/Controllers/Servicios/Impresion.php
Normal file
21
ci4/app/Controllers/Servicios/Impresion.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Servicios;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Impresion extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Impresion';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
24
ci4/app/Controllers/Servicios/Maquetacion.php
Normal file
24
ci4/app/Controllers/Servicios/Maquetacion.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Servicios;
|
||||
use App\Controllers\BaseController;
|
||||
use function App\Controllers\ServiciosDigitalizacion\base_url;
|
||||
use function App\Controllers\ServiciosDigitalizacion\service;
|
||||
use function App\Controllers\ServiciosDigitalizacion\view;
|
||||
|
||||
|
||||
class Maquetacion extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Maquetacion';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
24
ci4/app/Controllers/Servicios/Mensajes.php
Normal file
24
ci4/app/Controllers/Servicios/Mensajes.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Servicios;
|
||||
use App\Controllers\BaseController;
|
||||
use function App\Controllers\ServiciosDigitalizacion\base_url;
|
||||
use function App\Controllers\ServiciosDigitalizacion\service;
|
||||
use function App\Controllers\ServiciosDigitalizacion\view;
|
||||
|
||||
|
||||
class Mensajes extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Mensajes';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Configuracion;
|
||||
namespace App\Controllers\Servicios;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Correo extends BaseController
|
||||
class Productos extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
@ -13,9 +13,10 @@ class Correo extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Correo';
|
||||
echo 'Productos';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Proveedores;
|
||||
namespace App\Controllers\Servicios;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
@ -16,15 +16,6 @@ class Proveedor extends BaseController
|
||||
echo 'Proveedor';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\ServiciosDigitalizacion;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Digitalizacion extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$uri = service('uri');
|
||||
$data['page_name'] = "Digitalizacion";
|
||||
$data['url'] = base_url() . $uri->getSegment(1) . '/' . $uri->getSegment(2);
|
||||
echo view(getenv('theme.path').'main/demo_view', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
313
ci4/app/Controllers/Usuarios/Groupold.php
Normal file
313
ci4/app/Controllers/Usuarios/Groupold.php
Normal file
@ -0,0 +1,313 @@
|
||||
<?php namespace App\Controllers\Usuarios;
|
||||
|
||||
use App\Entities\Usuarios\UserGroupEntity;
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
use App\Models\Usuarios\UserGroupModel;
|
||||
use App\Models\Usuarios\GroupUserModel;
|
||||
|
||||
class Groupold extends \App\Controllers\GoBaseController
|
||||
{
|
||||
use \CodeIgniter\API\ResponseTrait;
|
||||
|
||||
protected static $primaryModelName = 'App\Models\Usuarios\UserGroupModel';
|
||||
protected $modelName = UserGroupModel::class;
|
||||
|
||||
protected static $singularObjectNameCc = 'userGroup';
|
||||
protected static $singularObjectName = 'Group';
|
||||
protected static $pluralObjectName = 'Groups';
|
||||
protected static $controllerSlug = 'groups';
|
||||
|
||||
static $viewPath = '';
|
||||
|
||||
protected $indexRoute = 'userGroupList';
|
||||
|
||||
private $group_user_model;
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('Group.moduleTitle');
|
||||
self::$viewPath = getenv('theme.path').'form/group/';
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Groups.group')]);
|
||||
// IMN
|
||||
$this->group_user_model = new GroupUserModel();
|
||||
$this->viewData['model'] = $this->group_user_model;
|
||||
|
||||
parent::index();
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
|
||||
|
||||
$title = $postData['title'];
|
||||
$dashboard = $postData['dashboard'];
|
||||
unset($postData['title']);
|
||||
unset($postData['dashboard']);
|
||||
unset($postData['id_group']);
|
||||
unset($postData['save']);
|
||||
|
||||
$controller = null;
|
||||
$rules_access = null;
|
||||
|
||||
foreach ($postData as $key=>$value){
|
||||
$exp = explode('_',$key);
|
||||
$controller[] = $exp[0];
|
||||
}
|
||||
|
||||
if($controller != null){
|
||||
foreach (array_unique($controller) as $item){
|
||||
$rules_access[$item] = [];
|
||||
|
||||
foreach ($postData as $key=>$value){
|
||||
$exp = explode('_',$key);
|
||||
if($exp[0] == $item){
|
||||
array_push($rules_access[$item],str_replace($exp[0].'_','',$key)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$temp_data['rules'] = json_encode($rules_access??'{}');
|
||||
$temp_data['token'] = md5(uniqid(rand(), true));;
|
||||
$temp_data['title'] = $title;
|
||||
$temp_data['dashboard'] = $dashboard;
|
||||
|
||||
$sanitizedData = $this->sanitized($temp_data, $nullIfEmpty);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Group.userGroup'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Group.userGroup'))]).'.';
|
||||
$message .= anchor( "admin/user-groups/{$id}/edit" , lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
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->viewData['successMessage'] = $message;
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['group'] = isset($sanitizedData) ? new UserGroupModel($sanitizedData) : new UserGroupModel();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createGroup');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Group.moduleTitle').' '.lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
}
|
||||
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
helper('general');
|
||||
$session = session();
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$groupEntity = $this->model->find($id);
|
||||
|
||||
if ($groupEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Group.userGroup')), $id]);
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$id_group = $groupEntity->id_group;
|
||||
$token = $groupEntity->token;
|
||||
$title = $postData['title'];
|
||||
$dashboard = $postData['dashboard'];
|
||||
|
||||
unset($postData['id_group']);
|
||||
unset($postData['title']);
|
||||
unset($postData['dashboard']);
|
||||
|
||||
$controller = null;
|
||||
$rules_access = null;
|
||||
|
||||
foreach ($postData as $key=>$value){
|
||||
$exp = explode('_',$key);
|
||||
$controller[] = $exp[0];
|
||||
}
|
||||
|
||||
if($controller != null){
|
||||
foreach (array_unique($controller) as $item){
|
||||
$rules_access[$item] = [];
|
||||
|
||||
foreach ($postData as $key=>$value){
|
||||
$exp = explode('_',$key);
|
||||
if($exp[0] == $item){
|
||||
array_push($rules_access[$item],str_replace($exp[0].'_','',$key)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$temp_data['id_group'] = $id_group;
|
||||
$temp_data['rules'] = json_encode($rules_access??'{}');
|
||||
$temp_data['token'] = $token;
|
||||
$temp_data['title'] = $title;
|
||||
$temp_data['dashboard'] = $dashboard;
|
||||
|
||||
$sanitizedData = $this->sanitized($temp_data, $nullIfEmpty);
|
||||
|
||||
|
||||
$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('Group.userGroup'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$groupEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $groupEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Group.userGroup'))]).'.';
|
||||
$message .= anchor(route_to('editGroup', $id), lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if($session->get('group') == $this->request->getPost('token')){
|
||||
$session->set('rules', $temp_data['rules']);
|
||||
}
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('successMessage', $message);
|
||||
else:
|
||||
return $this->redirect2listView('successMessage', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->viewData['successMessage'] = $message;
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['group'] = $groupEntity;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateGroup', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Group.userGroup').' '.lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
|
||||
public function allItemsSelect() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id';
|
||||
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
310
ci4/app/Controllers/Usuarios/Usersold.php
Normal file
310
ci4/app/Controllers/Usuarios/Usersold.php
Normal file
@ -0,0 +1,310 @@
|
||||
<?php namespace App\Controllers\Usuarios;
|
||||
|
||||
|
||||
use App\Entities\Usuarios\UserEntity;
|
||||
|
||||
use App\Models\Usuarios\UserGroupModel;
|
||||
use App\Models\Usuarios\GroupUserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
use App\Libraries\PasswordHash;
|
||||
|
||||
class Usersold extends \App\Controllers\GoBaseController {
|
||||
|
||||
private $group_model;
|
||||
private $group_user_model;
|
||||
private $user_model;
|
||||
|
||||
|
||||
use \CodeIgniter\API\ResponseTrait;
|
||||
|
||||
protected static $primaryModelName = 'App\Models\Usuarios\UserModel';
|
||||
|
||||
protected static $singularObjectNameCc = 'user';
|
||||
protected static $singularObjectName = 'User';
|
||||
protected static $pluralObjectName = 'Users';
|
||||
protected static $controllerSlug = 'users';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/user/';
|
||||
|
||||
protected $indexRoute = 'userList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
|
||||
$this->group_model = new UserGroupModel();
|
||||
$this->group_user_model = new GroupUserModel();
|
||||
$this->user_model = new UserModel();
|
||||
|
||||
$this->viewData['pageTitle'] = lang('Users.moduleTitle');
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Users.user')]);
|
||||
|
||||
$this->viewData['user_model'] = $this->user_model;
|
||||
|
||||
parent::index();
|
||||
|
||||
}
|
||||
|
||||
public function add() {
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
if(!empty($postData['password'])){
|
||||
$phpass = new PasswordHash(8, true);
|
||||
$postData['password'] = $phpass->HashPassword($this->request->getPost('password'));
|
||||
}
|
||||
|
||||
$currentGroups = $postData['group'];
|
||||
unset($postData['group']);
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
if ($this->request->getPost('last_ip') == null ) {
|
||||
$sanitizedData['last_ip'] = '::1';
|
||||
}
|
||||
|
||||
$sanitizedData['token'] = md5(uniqid(rand(), true));
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
foreach($currentGroups as $group){
|
||||
$group_user_data = [
|
||||
'token_user' => $sanitizedData['token'],
|
||||
'token_group' => $group
|
||||
];
|
||||
$this->group_user_model->insert($group_user_data);
|
||||
}
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Users.user'))]) . 'Downloads';
|
||||
$message .= anchor(route_to('editUser', $id), lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('successMessage', $message);
|
||||
else:
|
||||
return $this->redirect2listView('successMessage', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->viewData['successMessage'] = $message;
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['user'] = isset($sanitizedData) ? new UserEntity($sanitizedData) : new UserEntity();
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createUser');
|
||||
$this->viewData['groups'] = $this->group_model->select('token,title')->findAll();
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' Users.php' .lang('Users.user').' '.lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$user = $this->model->find($id);
|
||||
|
||||
if ($user == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Users.user')), $id]);
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$currentGroups = $postData['group'];
|
||||
unset($postData['group']);
|
||||
|
||||
if(!empty($postData['password'])){
|
||||
$phpass = new PasswordHash(8, true);
|
||||
$postData['password'] = $phpass->HashPassword($this->request->getPost('password'));
|
||||
}
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
if ($this->request->getPost('tfa') == null ) {
|
||||
$sanitizedData['tfa'] = false;
|
||||
}
|
||||
if ($this->request->getPost('blocked') == null ) {
|
||||
$sanitizedData['blocked'] = false;
|
||||
}
|
||||
if ($this->request->getPost('last_ip') == null ) {
|
||||
$sanitizedData['last_ip'] = '::1';
|
||||
}
|
||||
|
||||
$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('Users.user'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
$user->fill($sanitizedData);
|
||||
|
||||
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$this->group_user_model->where('token_user', $user->token)->delete();
|
||||
foreach($currentGroups as $group){
|
||||
$group_user_data = [
|
||||
'token_user' => $user->token,
|
||||
'token_group' => $group
|
||||
];
|
||||
$this->group_user_model->insert($group_user_data);
|
||||
}
|
||||
|
||||
$id = $user->id_user ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Users.user'))]) . 'Downloads';
|
||||
$message .= anchor(route_to('editUser', $id), lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('successMessage', $message);
|
||||
else:
|
||||
return $this->redirect2listView('successMessage', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->viewData['successMessage'] = $message;
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['user'] = $user;
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateUser', $id);
|
||||
|
||||
$this->viewData['selectedGroups'] = $this->group_user_model->select('token_group')->where('token_user', $user->token)->findAll();
|
||||
$this->viewData['groups'] = $this->group_model->select('token,title')->findAll();
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' Users.php' .lang('Users.user').' '.lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
|
||||
public function allItemsSelect() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id_user';
|
||||
$menu = $this->model->getAllForMenu($reqVal.', first_name', 'first_name', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id_user = '';
|
||||
$nonItem->first_name = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id_user', $reqText ?? 'first_name'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPaisListItems() {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Pais.pais'))])];
|
||||
$paisModel = model('App\Models\Configuracion\PaisModel');
|
||||
|
||||
$registers = $paisModel->findAll();
|
||||
|
||||
return $registers;
|
||||
}
|
||||
|
||||
}
|
||||
18
ci4/app/Controllers/Viewmode.php
Normal file
18
ci4/app/Controllers/Viewmode.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
class Viewmode extends BaseController
|
||||
{
|
||||
public function index($view_mode = VIEW_MODE_IMPRESION)
|
||||
{
|
||||
$session = session();
|
||||
$viewMode = $view_mode;
|
||||
$session->remove('view_mode');
|
||||
$session->set('view_mode', $viewMode);
|
||||
$url = previous_url();
|
||||
return redirect()->to($url);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user