mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/vuexy'
# Conflicts: # ci4/app/Controllers/Home.php # ci4/app/Controllers/Test.php
This commit is contained in:
@ -34,7 +34,17 @@ $routes->setAutoRoute(true);
|
||||
|
||||
$routes->group('', [], function($routes) {
|
||||
|
||||
|
||||
$routes->group('paises', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'Paises::index', ['as' => 'paisList']);
|
||||
$routes->get('index', 'Paises::index', ['as' => 'paisIndex']);
|
||||
$routes->get('add', 'Paises::add', ['as' => 'newPais']);
|
||||
$routes->post('add', 'Paises::add', ['as' => 'createPais']);
|
||||
$routes->get('edit/(:num)', 'Paises::edit/$1', ['as' => 'editPais']);
|
||||
$routes->post('edit/(:num)', 'Paises::edit/$1', ['as' => 'updatePais']);
|
||||
$routes->get('delete/(:num)', 'Paises::delete/$1', ['as' => 'deletePais']);
|
||||
$routes->post('allmenuitems', 'Paises::allItemsSelect', ['as' => 'select2ItemsOfPaises']);
|
||||
$routes->post('menuitems', 'Paises::menuItems', ['as' => 'menuItemsOfPaises']);
|
||||
});
|
||||
|
||||
$routes->group('tarifaacabado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
||||
$routes->get('', 'Tarifaacabado::index', ['as' => 'tarifaacabadoList']);
|
||||
@ -48,6 +58,32 @@ $routes->group('', [], function($routes) {
|
||||
$routes->post('allmenuitems', 'Tarifaacabado::allItemsSelect', ['as' => 'select2ItemsOfTarifasacabado']);
|
||||
$routes->post('menuitems', 'Tarifaacabado::menuItems', ['as' => 'menuItemsOfTarifasacabado']);
|
||||
});
|
||||
|
||||
$routes->group('users', ['namespace' => 'App\Controllers\Usuarios'], function ($routes) {
|
||||
$routes->get('', 'Users::index', ['as' => 'userList']);
|
||||
$routes->get('index', 'Users::index', ['as' => 'userIndex']);
|
||||
$routes->get('list', 'Users::index', ['as' => 'userList2']);
|
||||
$routes->get('add', 'Users::add', ['as' => 'newUser']);
|
||||
$routes->post('add', 'Users::add', ['as' => 'createUser']);
|
||||
$routes->get('edit/(:num)', 'Users::edit/$1', ['as' => 'editUser']);
|
||||
$routes->post('edit/(:num)', 'Users::edit/$1', ['as' => 'updateUser']);
|
||||
$routes->get('delete/(:num)', 'Users::delete/$1', ['as' => 'deleteUser']);
|
||||
$routes->post('allmenuitems', 'Users::allItemsSelect', ['as' => 'select2ItemsOfUsers']);
|
||||
$routes->post('menuitems', 'Users::menuItems', ['as' => 'menuItemsOfUsers']);
|
||||
});
|
||||
|
||||
$routes->group('group', ['namespace' => 'App\Controllers\Usuarios'], function ($routes) {
|
||||
$routes->get('', 'Group::index', ['as' => 'userGroupList']);
|
||||
$routes->get('index', 'Group::index', ['as' => 'groupIndex']);
|
||||
$routes->post('edit/(:num)', 'Group::edit/$1', ['as' => 'updateGroup']);
|
||||
$routes->get('edit/(:num)', 'Group::edit/$1', ['as' => 'editGroup']);
|
||||
$routes->get('delete/(:num)', 'Group::delete/$1', ['as' => 'deleteGroup']);
|
||||
});
|
||||
$routes->resource('group', ['namespace' => 'App\Controllers\Usuarios', 'controller' => 'UserGroups', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -36,6 +36,8 @@ class Validation
|
||||
public $templates = [
|
||||
'list' => 'CodeIgniter\Validation\Views\list',
|
||||
'single' => 'CodeIgniter\Validation\Views\single',
|
||||
'bootstrap_style' => 'themes/_commonPartialsBs/_form_validation_errors',
|
||||
|
||||
];
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\ActivityModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
class Activity extends BaseController
|
||||
{
|
||||
|
||||
@ -4,7 +4,7 @@ namespace App\Controllers;
|
||||
|
||||
use App\Models\CronTabModel;
|
||||
use App\Models\NotificationModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use App\Models\UserGroupModel;
|
||||
use App\Models\GroupUserModel;
|
||||
use App\Models\ActivityModel;
|
||||
|
||||
@ -4,7 +4,7 @@ namespace App\Controllers;
|
||||
|
||||
use App\Libraries\PasswordHash;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\RESTful\ResourceController;
|
||||
|
||||
231
ci4/app/Controllers/Configuracion/Paises.php
Normal file
231
ci4/app/Controllers/Configuracion/Paises.php
Normal file
@ -0,0 +1,231 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Entities\Configuracion\Pais;
|
||||
|
||||
class Paises extends \App\Controllers\GoBaseController {
|
||||
|
||||
use \CodeIgniter\API\ResponseTrait;
|
||||
|
||||
protected static $primaryModelName = 'App\Models\Configuracion\PaisModel';
|
||||
|
||||
protected static $singularObjectNameCc = 'pais';
|
||||
protected static $singularObjectName = 'Pais';
|
||||
protected static $pluralObjectName = 'Paises';
|
||||
protected static $controllerSlug = 'paises';
|
||||
|
||||
static $viewPath = '';
|
||||
|
||||
protected $indexRoute = 'paisList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('Paises.moduleTitle');
|
||||
self::$viewPath = getenv('theme.path').'form/configuracion/paises/';
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Paises.pais')]);
|
||||
parent::index();
|
||||
|
||||
}
|
||||
|
||||
public function add() {
|
||||
|
||||
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $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('Paises.pais'))]);
|
||||
$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('Paises.pais'))]).'.';
|
||||
$message .= anchor(route_to('editPais', $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['pais'] = isset($sanitizedData) ? new Pais($sanitizedData) : new Pais();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createPais');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Paises.pais').' '.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);
|
||||
$pais = $this->model->find($id);
|
||||
|
||||
if ($pais == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Paises.pais')), $id]);
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
if ($this->request->getPost('show_erp') == null ) {
|
||||
$sanitizedData['show_erp'] = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$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('Paises.pais'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$pais->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $pais->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Paises.pais'))]).'.';
|
||||
$message .= anchor(route_to('editPais', $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['pais'] = $pais;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updatePais', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Paises.pais').' '.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.', Select a field...', 'Select a field...', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
//$nonItem->'Select a field...' = '- '.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 ?? 'Select a field...'];
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,7 +7,7 @@ use App\Models\BackupModel;
|
||||
use App\Models\CronTabModel;
|
||||
use App\Models\NotificationModel;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
class Cron extends BaseController
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\ActivityModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
class Home extends BaseController
|
||||
{
|
||||
@ -18,6 +18,7 @@ class Home extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
/*
|
||||
$session = session();
|
||||
$id_user = $session->get('id_user');
|
||||
$name = $session->get('first_name');
|
||||
@ -77,8 +78,8 @@ class Home extends BaseController
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$notFound = true;
|
||||
foreach ($return_char_bar_geral as $item){
|
||||
if($i == intval($item['month'])){
|
||||
array_push($year,intval($item['total']));
|
||||
if($i == intval($item->month)){
|
||||
array_push($year,intval($item->total));
|
||||
$notFound = false;
|
||||
break;
|
||||
}
|
||||
@ -92,8 +93,8 @@ class Home extends BaseController
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$notFound = true;
|
||||
foreach ($return_char_bar_enabled as $item){
|
||||
if($i == intval($item['month'])){
|
||||
array_push($year,intval($item['total']));
|
||||
if($i == intval($item->month)){
|
||||
array_push($year,intval($item->total));
|
||||
$notFound = false;
|
||||
break;
|
||||
}
|
||||
@ -107,8 +108,8 @@ class Home extends BaseController
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$notFound = true;
|
||||
foreach ($return_char_bar_disabled as $item){
|
||||
if($i == intval($item['month'])){
|
||||
array_push($year,intval($item['total']));
|
||||
if($i == intval($item->month)){
|
||||
array_push($year,intval($item->total));
|
||||
$notFound = false;
|
||||
break;
|
||||
}
|
||||
@ -131,7 +132,7 @@ class Home extends BaseController
|
||||
->findAll(30);
|
||||
|
||||
echo view(getenv('theme.path').'main/header');
|
||||
echo view(getenv('theme.path').'form/dashboard/admin',$data);
|
||||
//echo view(getenv('theme.path').'form/dashboard/admin',$data);
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
break;
|
||||
|
||||
@ -147,12 +148,12 @@ class Home extends BaseController
|
||||
];
|
||||
|
||||
echo view(getenv('theme.path').'main/header');
|
||||
echo view(getenv('theme.path').'form/dashboard/user',$data);
|
||||
//echo view(getenv('theme.path').'form/dashboard/user',$data);
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
break;
|
||||
default:
|
||||
echo view(getenv('theme.path').'main/header');
|
||||
echo view(getenv('theme.path').'form/dashboard/index');
|
||||
//echo view(getenv('theme.path').'form/dashboard/index');
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
endswitch;
|
||||
*/
|
||||
|
||||
@ -6,7 +6,7 @@ use App\Models\ActivityModel;
|
||||
use App\Models\PasswordRecoveryModel;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\TemplateModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use App\Libraries\PasswordHash;
|
||||
use CodeIgniter\HTTP\Files\FileCollection;
|
||||
|
||||
|
||||
@ -9,9 +9,9 @@ use App\Models\NotificationModel;
|
||||
use App\Models\PasswordRecoveryModel;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\TemplateModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\UserGroupModel;
|
||||
use App\Models\GroupUserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use App\Models\Usuarios\UserGroupModel;
|
||||
use App\Models\Usuarios\GroupUserModel;
|
||||
|
||||
class login extends BaseController
|
||||
{
|
||||
@ -127,15 +127,15 @@ class login extends BaseController
|
||||
if(!empty($login))
|
||||
{
|
||||
// Blocked Validation
|
||||
if($login['blocked']!=null){
|
||||
$dateBlocked = date($login['blocked']);
|
||||
if($login->blocked!=null){
|
||||
$dateBlocked = date($login->blocked);
|
||||
$dateNow = date('Y-m-d H:i:s');
|
||||
if($dateBlocked > $dateNow){
|
||||
$session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_user_blocked").$settings['throttle_auth_lockour_time'].' '.lang("App.global_hours")]);
|
||||
return redirect()->to('login');
|
||||
}else{
|
||||
$this->user_model->save([
|
||||
'id_user' => $login['id_user'],
|
||||
'id_user' => $login->id_user,
|
||||
'blocked' => null
|
||||
]);
|
||||
}
|
||||
@ -148,23 +148,23 @@ class login extends BaseController
|
||||
if(empty($session->get('oauth'))){
|
||||
// Check user password
|
||||
$phpass = new PasswordHash(8, true);
|
||||
if(!$phpass->CheckPassword($getVar['password']??'', $login['password'])){
|
||||
if(!$phpass->CheckPassword($getVar['password']??'', $login->password)){
|
||||
// Throttling Validation
|
||||
if($settings['throttle_auth']??false){
|
||||
$initialDate = date('Y-m-d H:i:s', strtotime('-12 hour', time()));
|
||||
$finalDate = date('Y-m-d H:i:s');
|
||||
$amount = $this->activity_model->where('user',$login['token'])->where('level','throttling')->where('created_at between \''.$initialDate.'\' and \''.$finalDate.'\'')->countAllResults();
|
||||
$amount = $this->activity_model->where('user',$login->token)->where('level','throttling')->where('created_at between \''.$initialDate.'\' and \''.$finalDate.'\'')->countAllResults();
|
||||
if($amount >= intval($settings['throttle_auth_max_attempts']??'')){
|
||||
$session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_user_blocked").$settings['throttle_auth_lockour_time'].' '.lang("App.global_hours")]);
|
||||
$blocked = date('Y-m-d H:i:s', strtotime('+'.$settings['throttle_auth_lockour_time'].' hour', time()));
|
||||
$this->user_model->save([
|
||||
'id_user' => $login['id_user'],
|
||||
'id_user' => $login->id_user,
|
||||
'blocked' => $blocked
|
||||
]);
|
||||
return redirect()->to('login');
|
||||
}else{
|
||||
// Register Throttling Log
|
||||
$this->integration->setLog('throttling','login-authenticate',$login['token']);
|
||||
$this->integration->setLog('throttling','login-authenticate',$login->token);
|
||||
$session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_pass_invalid_2"). ($amount+1) .lang("App.login_alert_pass_attempt"). $settings['throttle_auth_max_attempts']??0]);
|
||||
return redirect()->to('login');
|
||||
}
|
||||
@ -174,7 +174,7 @@ class login extends BaseController
|
||||
}
|
||||
// Check email confirmed
|
||||
if($settings['email_confirmation']??false){
|
||||
if(!$login['email_confirmed']){
|
||||
if(!$login->email_confirmed){
|
||||
$session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.user_alert_email_confirmed")]);
|
||||
return redirect()->to('login');
|
||||
}
|
||||
@ -182,23 +182,23 @@ class login extends BaseController
|
||||
}
|
||||
|
||||
// Check user status
|
||||
if(!$login['status']){
|
||||
if(!$login->status){
|
||||
$session->setFlashdata('toast', ['error',lang("App.login_alert"),lang("App.login_alert_disabled_access")]);
|
||||
return redirect()->to('/login');
|
||||
}
|
||||
|
||||
// Get access rules
|
||||
#$rules = $this->group_model->where('token', $login['group'])->first();
|
||||
#$rules = $this->group_model->where('token', $login->'group'])->first();
|
||||
$groups = $this->group_user_model
|
||||
->select('token_group')
|
||||
->where('token_user',$login['token'])->findAll();
|
||||
->where('token_user',$login->token)->findAll();
|
||||
|
||||
if (sizeof($groups)>1){
|
||||
|
||||
$rules = $this->group_model->select('rules')->where('token',$groups[0])->first()['rules'];
|
||||
$rules = $this->group_model->select('rules')->where('token',$groups[0])->first()->rules;
|
||||
$rules = json_decode(html_entity_decode($rules), true);
|
||||
for ($i=1; $i<sizeof($groups); $i++){
|
||||
$temp_rules = $this->group_model->select('rules')->where('token',$groups[$i])->first()['rules'];
|
||||
$temp_rules = $this->group_model->select('rules')->where('token',$groups[$i])->first()->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];
|
||||
@ -223,26 +223,26 @@ class login extends BaseController
|
||||
|
||||
|
||||
// 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']);
|
||||
$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')
|
||||
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');
|
||||
$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();
|
||||
@ -252,7 +252,7 @@ class login extends BaseController
|
||||
$integration->setLog('information','login-authenticate');
|
||||
|
||||
// Check if it has two factors
|
||||
if($login['tfa']??false){
|
||||
if($login->tfa??false){
|
||||
return redirect()->to('/login/authentication');
|
||||
}else{
|
||||
return redirect()->to('home');
|
||||
|
||||
@ -11,11 +11,11 @@ class Migrate extends Controller
|
||||
{
|
||||
$migrate = \Config\Services::migrations();
|
||||
|
||||
$file = 'Database\\Migrations\\2023-04-25-161753_RemoveGroupFromUser.php';
|
||||
|
||||
try {
|
||||
#$migrate->regress(-1);
|
||||
$migrate->latest();
|
||||
echo "migrated";
|
||||
|
||||
$migrate->force($file);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
echo $e->getMessage();
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\NotificationModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
class My extends BaseController
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\CountriesModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use App\Models\NotificationModel;
|
||||
|
||||
class Notification extends BaseController
|
||||
|
||||
@ -5,7 +5,7 @@ namespace App\Controllers;
|
||||
use App\Libraries\PasswordHash;
|
||||
use App\Models\CountriesModel;
|
||||
use App\Models\UserGroupModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
class Profile extends BaseController
|
||||
{
|
||||
|
||||
@ -10,7 +10,7 @@ use App\Models\TemplateModel;
|
||||
use App\Models\ThemeModel;
|
||||
use App\Models\TimezoneModel;
|
||||
use App\Models\UserGroupModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
class Settings extends BaseController
|
||||
{
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
class Test extends BaseController
|
||||
{
|
||||
|
||||
@ -13,7 +16,12 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo languages[$currentLocale] ?? config('Basics')->i18n;
|
||||
|
||||
$user_model = new UserModel();
|
||||
echo '<pre>';
|
||||
var_dump($user_model->getGroupsTitles('c0bf18621f78cb2ffc4a67cf8d5173c7'));
|
||||
echo '</pre>';
|
||||
|
||||
}
|
||||
|
||||
public function validateControllerAccess(){
|
||||
|
||||
@ -1,45 +1,40 @@
|
||||
<?php
|
||||
<?php namespace App\Controllers\Usuarios;
|
||||
|
||||
namespace App\Controllers\Usuarios;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Entities\Usuarios\UserGroupEntity;
|
||||
|
||||
use App\Models\UserModel;
|
||||
use App\Models\UserGroupModel;
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
use App\Models\Usuarios\UserGroupModel;
|
||||
|
||||
class Group extends BaseController
|
||||
class Group extends \App\Controllers\GoBaseController
|
||||
{
|
||||
private $user_model;
|
||||
private $group_model;
|
||||
use \CodeIgniter\API\ResponseTrait;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->user_model = new UserModel();
|
||||
$this->group_model = new UserGroupModel();
|
||||
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 = 'groupList';
|
||||
|
||||
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()
|
||||
{
|
||||
$data['title'] = [
|
||||
'module' => lang("App.group_title"),
|
||||
'page' => lang("App.group_subtitle"),
|
||||
'icon' => 'fas fa-user-lock'
|
||||
];
|
||||
|
||||
$data['breadcrumb'] = [
|
||||
['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
|
||||
['title' => lang("App.group_title"), 'route' => "", 'active' => true]
|
||||
];
|
||||
|
||||
$data['btn_add'] = [
|
||||
'title' => lang("App.group_btn_add"),
|
||||
'route' => '/usuarios/group/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/group/index',$data);
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Groups.group')]);
|
||||
|
||||
parent::index();
|
||||
}
|
||||
|
||||
public function add()
|
||||
@ -77,8 +72,81 @@ class Group extends BaseController
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
//public function edit($id)
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$group = $this->model->find($id);
|
||||
|
||||
if ($group == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Paises.pais')), $id]);
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $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('Paises.pais'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$group->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $group->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Group.group'))]).'.';
|
||||
$message .= anchor(route_to('editGroup', $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['group'] = $group;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateGroup', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Paises.pais').' '.lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
/*
|
||||
helper('form');
|
||||
|
||||
$data['title'] = [
|
||||
@ -115,8 +183,13 @@ class Group extends BaseController
|
||||
echo view(getenv('theme.path').'main/header');
|
||||
echo view(getenv('theme.path').'form/group/form',$data);
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
public function store()
|
||||
{
|
||||
//Demo Mode
|
||||
@ -214,4 +287,5 @@ class Group extends BaseController
|
||||
}
|
||||
return redirect()->to('/usuarios/group');
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@ -1,339 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Usuarios;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
use App\Libraries\PasswordHash;
|
||||
use App\Models\ActivityModel;
|
||||
use App\Models\CountriesModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\UserGroupModel;
|
||||
use App\Models\GroupUserModel;
|
||||
|
||||
class User extends BaseController
|
||||
{
|
||||
private $user_model;
|
||||
private $group_model;
|
||||
private $group_user_model;
|
||||
private $countries_model;
|
||||
private $activity_model;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->user_model = new UserModel();
|
||||
$this->group_model = new UserGroupModel();
|
||||
$this->countries_model = new CountriesModel();
|
||||
$this->activity_model = new ActivityModel();
|
||||
$this->group_user_model = new GroupUserModel();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = [
|
||||
'module' => lang("App.user_title"),
|
||||
'page' => lang("App.user_subtitle"),
|
||||
'icon' => 'fas fa-user-friends'
|
||||
];
|
||||
|
||||
$data['breadcrumb'] = [
|
||||
['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
|
||||
['title' => lang("App.user_title"), 'route' => "", 'active' => true]
|
||||
];
|
||||
|
||||
$data['btn_add'] = [
|
||||
'title' => lang("App.user_btn_add"),
|
||||
'route' => '/user/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/user/index',$data);
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
helper('form');
|
||||
|
||||
$data['title'] = [
|
||||
'module' => lang("App.user_add_title"),
|
||||
'page' => lang("App.user_add_subtitle"),
|
||||
'icon' => 'far fa-plus-square'
|
||||
];
|
||||
|
||||
$data['breadcrumb'] = [
|
||||
['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
|
||||
['title' => lang("App.user_title"), 'route' => "/user", 'active' => false],
|
||||
['title' => lang("App.user_add_title"), 'route' => "", 'active' => true]
|
||||
];
|
||||
|
||||
$data['btn_return'] = [
|
||||
'title' => lang("App.global_come_back"),
|
||||
'route' => '/user',
|
||||
'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['selected_groups'] = [];
|
||||
|
||||
$data['group'] = $this->group_model->select('token,title')->findAll();
|
||||
$data['country'] = $this->countries_model->select('code,name')->where('data_lang',session()->get('lang')??'en')->findAll();
|
||||
|
||||
echo view(getenv('theme.path').'main/header');
|
||||
echo view(getenv('theme.path').'form/user/form',$data);
|
||||
echo view(getenv('theme.path').'main/footer');
|
||||
}
|
||||
|
||||
public function edit($token=null)
|
||||
{
|
||||
if(empty($token)){
|
||||
return redirect()->to('/user');
|
||||
}
|
||||
|
||||
helper('form');
|
||||
|
||||
$data['title'] = [
|
||||
'module' => lang("App.user_edit_title"),
|
||||
'page' => lang("App.user_edit_subtitle"),
|
||||
'icon' => 'fas fa-edit'
|
||||
];
|
||||
|
||||
$data['breadcrumb'] = [
|
||||
['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
|
||||
['title' => lang("App.user_title"), 'route' => "/user", 'active' => false],
|
||||
['title' => lang("App.user_edit_title"), 'route' => "", 'active' => true]
|
||||
];
|
||||
|
||||
$data['btn_return'] = [
|
||||
'title' => lang("App.global_come_back"),
|
||||
'route' => '/user',
|
||||
'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['obj'] = $this->user_model->where('token', $token)->first();
|
||||
if($data['obj']==null){
|
||||
return redirect()->to('/user');
|
||||
}
|
||||
if(!empty($data['obj']['date_birth'])){
|
||||
$data['obj']['date_birth'] = dateFormatWeb($data['obj']['date_birth']);
|
||||
}
|
||||
|
||||
$data['selected_groups'] = $this->group_user_model->select('token_group')->where('token_user', $token)->findAll();
|
||||
|
||||
$data['group'] = $this->group_model->select('token,title')->findAll();
|
||||
$data['country'] = $this->countries_model->select('code,name')->where('data_lang',session()->get('lang')??'en')->findAll();
|
||||
|
||||
echo view(getenv('theme.path').'main/header');
|
||||
echo view(getenv('theme.path').'form/user/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('/user');
|
||||
}
|
||||
|
||||
$session = session();
|
||||
helper('form');
|
||||
|
||||
$password = 'max_length[35]';
|
||||
$confirm_password = 'max_length[35]';
|
||||
$email = 'required|valid_email';
|
||||
|
||||
if(empty($this->request->getPost('id_user'))){
|
||||
$email = 'required|valid_email|is_unique[auth_user.email]';
|
||||
$password = 'required|min_length[8]';
|
||||
$confirm_password = 'matches[password]';
|
||||
}else{
|
||||
if(!empty($this->request->getPost('password'))){
|
||||
$password = 'required|min_length[8]';
|
||||
$confirm_password = 'matches[password]';
|
||||
}
|
||||
}
|
||||
|
||||
$rules = [
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => $email,
|
||||
'password' => $password,
|
||||
'confirm_password' => $confirm_password
|
||||
];
|
||||
|
||||
$rules_error = [
|
||||
'first_name' => [
|
||||
'required' => lang("App.user_rules_first_name_r"),
|
||||
],
|
||||
'last_name' => [
|
||||
'required' => lang("App.user_rules_last_name_r"),
|
||||
],
|
||||
'email' => [
|
||||
'required' => lang("App.user_rules_email_r"),
|
||||
'is_unique' => lang("App.user_rules_email_i"),
|
||||
],
|
||||
'password' => [
|
||||
'required' => lang("App.user_rules_password_r"),
|
||||
'min_length' => lang("App.user_rules_password_m"),
|
||||
],
|
||||
'confirm_password' => [
|
||||
'matches' => lang("App.user_rules_password_confirm_m"),
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->validate($rules,$rules_error)){
|
||||
$date_birth = !empty($this->request->getPost('date_birth')??'') ? dateFormatMysql($this->request->getPost('date_birth')):null;
|
||||
if(empty($this->request->getPost('id_user'))){
|
||||
$phpass = new PasswordHash(8, true);
|
||||
$this->user_model->save([
|
||||
'id_user' => null,
|
||||
//'group' => $this->request->getPost('group'),
|
||||
'first_name' => $this->request->getPost('first_name'),
|
||||
'last_name' => $this->request->getPost('last_name'),
|
||||
'date_birth' => $date_birth,
|
||||
'address' => $this->request->getPost('address'),
|
||||
'city' => $this->request->getPost('city'),
|
||||
'state' => $this->request->getPost('state'),
|
||||
'country' => $this->request->getPost('country'),
|
||||
'zip_code' => $this->request->getPost('zip_code'),
|
||||
'mobile' => $this->request->getPost('mobile'),
|
||||
'email' => $this->request->getPost('email'),
|
||||
'password' => $phpass->HashPassword($this->request->getPost('password')),
|
||||
'last_access' => date('Y-m-d h:i:s'),
|
||||
'last_ip' => '::1',
|
||||
'picture' => '/assets/img/default-user.png',
|
||||
'language' => $this->request->getPost('language'),
|
||||
'token' => md5(uniqid(rand(), true)),
|
||||
'status' => $this->request->getPost('status'),
|
||||
'email_confirmed' => $this->request->getPost('email_confirmed')
|
||||
]);
|
||||
|
||||
}else{
|
||||
|
||||
$this->user_model->save([
|
||||
'id_user' => $this->request->getPost('id_user'),
|
||||
//'group' => $this->request->getPost('group'),
|
||||
'first_name' => $this->request->getPost('first_name'),
|
||||
'last_name' => $this->request->getPost('last_name'),
|
||||
'date_birth' => $date_birth,
|
||||
'address' => $this->request->getPost('address'),
|
||||
'city' => $this->request->getPost('city'),
|
||||
'state' => $this->request->getPost('state'),
|
||||
'country' => $this->request->getPost('country'),
|
||||
'zip_code' => $this->request->getPost('zip_code'),
|
||||
'mobile' => $this->request->getPost('mobile'),
|
||||
'email' => $this->request->getPost('email'),
|
||||
'language' => $this->request->getPost('language'),
|
||||
'status' => $this->request->getPost('status'),
|
||||
'email_confirmed' => $this->request->getPost('email_confirmed')
|
||||
]);
|
||||
if(!empty($this->request->getPost('password'))){
|
||||
$phpass = new PasswordHash(8, true);
|
||||
$this->user_model->save([
|
||||
'id_user' => $this->request->getPost('id_user'),
|
||||
'password' => $phpass->HashPassword($this->request->getPost('password')),
|
||||
]);
|
||||
}
|
||||
|
||||
// Update group_user pivot table
|
||||
$user_token = $this->user_model
|
||||
->select('token')
|
||||
->where('id_user',$this->request->getPost('id_user'))->first()['token'];
|
||||
$this->group_user_model->where('token_user', $user_token)->delete();
|
||||
$groups = $this->request->getPost('group');
|
||||
foreach ($groups as $group){
|
||||
$group_user_data = [
|
||||
'token_user' => $user_token,
|
||||
'token_group' => $group
|
||||
];
|
||||
$this->group_user_model->insert($group_user_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(empty($this->request->getPost('id_user'))){
|
||||
$session->setFlashdata('sweet', ['success',lang("App.user_alert_add")]);
|
||||
return redirect()->to('/user');
|
||||
}else{
|
||||
if($session->get('id_user') == $this->request->getPost('id_user')){
|
||||
// Get groups tokens
|
||||
$user_token = $this->user_model
|
||||
->select('token')
|
||||
->where('id_user',$this->request->getPost('id_user'))->first()['token'];
|
||||
$groups = $this->group_user_model
|
||||
->select('token_group')
|
||||
->where('token_user',$user_token)->findAll();
|
||||
|
||||
if (sizeof($groups)>1){
|
||||
|
||||
$access_rules = $this->group_model->select('rules')->where('token',$groups[0])->first()['rules'];
|
||||
$access_rules = json_decode(html_entity_decode($access_rules), true);
|
||||
for ($i=1; $i<sizeof($groups); $i++){
|
||||
$temp_rules = $this->group_model->select('rules')->where('token',$groups[$i])->first()['rules'];
|
||||
foreach ($access_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];
|
||||
$access_rules[$key] = array_unique(array_merge($value, $value2));
|
||||
}
|
||||
else{
|
||||
$access_rules[$key]= $value;
|
||||
}
|
||||
}
|
||||
foreach (json_decode(html_entity_decode($temp_rules), true) as $key2 => $value2){
|
||||
if (!array_key_exists($key2, $access_rules)){
|
||||
$access_rules[$key2] = $value2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$access_rules = $this->group_model->select('rules')->where('token',$groups)->first();
|
||||
}
|
||||
$session->set('rules', html_entity_decode(json_encode($access_rules)));
|
||||
}
|
||||
$session->setFlashdata('sweet', ['success',lang("App.user_alert_edit")]);
|
||||
return redirect()->to('/user');
|
||||
}
|
||||
|
||||
}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('/user');
|
||||
}
|
||||
$session = session();
|
||||
if(!empty($session->get('token'))){
|
||||
$this->user_model->where('token', $token)->delete();
|
||||
$this->activity_model->where('user', $token)->delete();
|
||||
$session->setFlashdata('sweet', ['success',lang("App.user_alert_delete")]);
|
||||
return redirect()->to('/user');
|
||||
}else{
|
||||
return redirect()->to('/login');
|
||||
}
|
||||
}
|
||||
}
|
||||
306
ci4/app/Controllers/Usuarios/Users.php
Normal file
306
ci4/app/Controllers/Usuarios/Users.php
Normal file
@ -0,0 +1,306 @@
|
||||
<?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 Users 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/focus2/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'))]).'.';
|
||||
$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').' '.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']);
|
||||
|
||||
$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'))]).'.';
|
||||
$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').' '.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;
|
||||
}
|
||||
|
||||
}
|
||||
22
ci4/app/Entities/Configuracion/Pais.php
Normal file
22
ci4/app/Entities/Configuracion/Pais.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class Pais extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"code" => null,
|
||||
"code3" => null,
|
||||
"moneda" => null,
|
||||
"url_erp" => null,
|
||||
"user_erp" => null,
|
||||
"key_erp" => null,
|
||||
"show_erp" => false,
|
||||
];
|
||||
protected $casts = [
|
||||
"show_erp" => "boolean",
|
||||
];
|
||||
}
|
||||
64
ci4/app/Entities/Usuarios/UserEntity.php
Normal file
64
ci4/app/Entities/Usuarios/UserEntity.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace App\Entities\Usuarios;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class UserEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id_user" => null,
|
||||
"group" => null,
|
||||
"first_name" => null,
|
||||
"last_name" => null,
|
||||
"date_birth" => null,
|
||||
"address" => null,
|
||||
"city" => null,
|
||||
"state" => null,
|
||||
"country" => null,
|
||||
"zip_code" => null,
|
||||
"mobile" => null,
|
||||
"email" => null,
|
||||
"password" => null,
|
||||
"last_ip" => null,
|
||||
"last_access" => null,
|
||||
"picture" => "/assets/img/default-user.png",
|
||||
"language" => null,
|
||||
"tfa" => false,
|
||||
"tfa_secret" => null,
|
||||
"tfa_code" => null,
|
||||
"blocked" => null,
|
||||
"email_confirmed" => 0,
|
||||
"token" => null,
|
||||
"status" => false,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"tfa" => "boolean",
|
||||
"email_confirmed" => "int",
|
||||
"status" => "boolean",
|
||||
];
|
||||
/**
|
||||
* Returns a full name: "first last"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFullName()
|
||||
{
|
||||
$fullName =
|
||||
(!empty($this->attributes["first_name"]) ? trim($this->attributes["first_name"]) . " " : "") .
|
||||
(!empty($this->attributes["last_name"]) ? trim($this->attributes["last_name"]) : "");
|
||||
$name = empty($fullName) ? $this->attributes["username"] : $fullName;
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for getFullName()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fullName()
|
||||
{
|
||||
return $this->getFullName();
|
||||
}
|
||||
}
|
||||
18
ci4/app/Entities/Usuarios/UserGroupEntity.php
Normal file
18
ci4/app/Entities/Usuarios/UserGroupEntity.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace App\Entities\Usuarios;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class UserGroupEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id_group" => null,
|
||||
"title" => null,
|
||||
"dashboard" => null,
|
||||
"rules" => null,
|
||||
"token" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [];
|
||||
}
|
||||
@ -139,8 +139,7 @@ class LoginAuthFilter implements FilterInterface
|
||||
'Integration',
|
||||
'Migrate',
|
||||
'Test',
|
||||
|
||||
|
||||
'GoBaseController'
|
||||
];
|
||||
}
|
||||
|
||||
@ -171,7 +170,11 @@ class LoginAuthFilter implements FilterInterface
|
||||
'__construct',
|
||||
'validateControllerAccess',
|
||||
'whiteListController',
|
||||
'whiteListMethod'
|
||||
'whiteListMethod',
|
||||
'allItemsSelect',
|
||||
'menuItems',
|
||||
'collect',
|
||||
'cast',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -161,8 +161,8 @@ function getDictionary($word=''){
|
||||
'my' => lang("App.permisos_my"),
|
||||
'Notification' => lang("App.permisos_notificacion"),
|
||||
|
||||
'Usuarios' => lang("App.permisos_usuarios"),
|
||||
'Usuario' => lang("App.permisos_usuario"),
|
||||
'Users' => lang("App.permisos_usuarios"),
|
||||
'User' => lang("App.permisos_usuario"),
|
||||
'Group' => lang("App.permisos_roles"),
|
||||
|
||||
'Logistica' => lang("App.permisos_logistica"),
|
||||
@ -190,6 +190,7 @@ function getDictionary($word=''){
|
||||
'Serviciocliente' => lang("App.permisos_serviciocliente"),
|
||||
'Calendario' => lang("App.permisos_calendario"),
|
||||
'Correo' => lang("App.permisos_correo"),
|
||||
'Paises' => lang("App.permisos_paises"),
|
||||
|
||||
'Presupuestos' => lang("App.permisos_presupuestos"),
|
||||
'Presupuesto' => lang("App.permisos_presupuestos"),
|
||||
|
||||
153
ci4/app/Helpers/go_common_helper.php
Normal file
153
ci4/app/Helpers/go_common_helper.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
function goSanitize($var, bool $nullIfEmpty = false, bool $allowTags = false, bool $allowJs = false, bool $onlyAlphaNumeric = false, bool $fromGetRequest = false) {
|
||||
|
||||
$malScore = 0;
|
||||
|
||||
if (is_numeric($var) ) {
|
||||
|
||||
$decimalSeparator = localeconv()['decimal_point'];
|
||||
|
||||
if (strpos($var, $decimalSeparator)===false) {
|
||||
|
||||
$finalVal = intval(filter_var($var, FILTER_SANITIZE_NUMBER_INT));
|
||||
|
||||
} else {
|
||||
|
||||
$finalVal = filter_var($var, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
if (empty($var)) {
|
||||
return [$nullIfEmpty ? null : $var, 0];
|
||||
}
|
||||
$str1 = $allowTags ? $var : strip_tags($var);
|
||||
|
||||
if (!$allowJs) {
|
||||
$badParts = ['<script', 'onchange', 'onmouse', 'onblur', 'onfocus', 'oninput', 'onclick', 'onshow', 'onkey','onload','alert(','</script>'];
|
||||
|
||||
if ($onlyAlphaNumeric) {
|
||||
$badparts[] = "='";
|
||||
$badparts[] = '="';
|
||||
$badparts[] = '=';
|
||||
$badparts[] = '_';
|
||||
$badparts[] = '/';
|
||||
$badparts[] = '"';
|
||||
$badparts[] = "'";
|
||||
$badparts[] = ">";
|
||||
$badparts[] = "<";
|
||||
$badparts[] = "()";
|
||||
}
|
||||
|
||||
foreach ($badParts as $bp) {
|
||||
if (strpos($str1, $bp)!==false) {
|
||||
$malScore += 1;
|
||||
$str1 = str_replace($bp, '', $str1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($fromGetRequest) {
|
||||
$str1 = urldecode ($str1);
|
||||
}
|
||||
|
||||
// $finalVal = filter_var($str1, FILTER_SANITIZE_FULL_SPECIAL_CHARS); // doesn't play well with esc() and old() as well as form_textarea() functions of CI 4
|
||||
$finalVal = $str1;
|
||||
}
|
||||
return [trim($finalVal),$malScore];
|
||||
}
|
||||
|
||||
|
||||
function convertTurkishCharacters($text) {
|
||||
$text = trim($text);
|
||||
$search = array('Ç','ç','Ğ','ğ','ı','İ','Ö','ö','Ş','ş','Ü','ü',' ');
|
||||
$replace = array('c','c','g','g','i','i','o','o','s','s','u','u','-');
|
||||
$new_text = str_replace($search,$replace,$text);
|
||||
return $new_text;
|
||||
}
|
||||
|
||||
function convertPhpDateToMomentFormat($format)
|
||||
{
|
||||
$replacements = [
|
||||
'd' => 'DD',
|
||||
'D' => 'ddd',
|
||||
'j' => 'D',
|
||||
'l' => 'dddd',
|
||||
'N' => 'E',
|
||||
'S' => 'o',
|
||||
'w' => 'e',
|
||||
'z' => 'DDD',
|
||||
'W' => 'W',
|
||||
'F' => 'MMMM',
|
||||
'm' => 'MM',
|
||||
'M' => 'MMM',
|
||||
'n' => 'M',
|
||||
't' => '', // no equivalent
|
||||
'L' => '', // no equivalent
|
||||
'o' => 'YYYY',
|
||||
'Y' => 'YYYY',
|
||||
'y' => 'YY',
|
||||
'a' => 'a',
|
||||
'A' => 'A',
|
||||
'B' => '', // no equivalent
|
||||
'g' => 'h',
|
||||
'G' => 'H',
|
||||
'h' => 'hh',
|
||||
'H' => 'HH',
|
||||
'i' => 'mm',
|
||||
's' => 'ss',
|
||||
'u' => 'SSS',
|
||||
'e' => 'zz', // deprecated since version 1.6.0 of moment.js
|
||||
'I' => '', // no equivalent
|
||||
'O' => '', // no equivalent
|
||||
'P' => '', // no equivalent
|
||||
'T' => '', // no equivalent
|
||||
'Z' => '', // no equivalent
|
||||
'c' => '', // no equivalent
|
||||
'r' => '', // no equivalent
|
||||
'U' => 'X',
|
||||
];
|
||||
$momentFormat = strtr($format, $replacements);
|
||||
return $momentFormat;
|
||||
}
|
||||
|
||||
// Check if the function does not exists
|
||||
if ( ! function_exists('slugify')) {
|
||||
// Slugify a string
|
||||
function slugify($string)
|
||||
{
|
||||
helper('text');
|
||||
|
||||
// Replace unsupported characters (add your owns if necessary)
|
||||
$string = str_replace("'", '-', $string);
|
||||
$string = str_replace(".", '-', $string);
|
||||
$string = str_replace("²", '2', $string);
|
||||
|
||||
// Slugify and return the string
|
||||
return url_title(convert_accented_characters(convertTurkishCharacters($string)), '-', true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('convertToSnakeCase')) {
|
||||
function convertToSnakeCase($strInput) {
|
||||
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $strInput, $matches);
|
||||
$ret = $matches[0];
|
||||
foreach ($ret as &$match) {
|
||||
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
|
||||
}
|
||||
return implode('_', $ret);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('newUUID')) {
|
||||
|
||||
function newUUID() {
|
||||
if (function_exists('com_create_guid') === true) {
|
||||
return trim(com_create_guid(), '{}');
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use Firebase\JWT\JWT;
|
||||
|
||||
/**
|
||||
|
||||
@ -639,6 +639,7 @@ return [
|
||||
"permisos_serviciocliente" => "Customer service",
|
||||
"permisos_calendario" => "Calendar",
|
||||
"permisos_correo" => "Mail",
|
||||
"permisos_paises" => "Countries",
|
||||
|
||||
"permisos_presupuestos" => "Budgets",
|
||||
"permisos_presupuestomaquetacion" => "Layout",
|
||||
@ -675,6 +676,7 @@ return [
|
||||
|
||||
"menu_configuration" => "Settings",
|
||||
"menu_calendario" => "Calendar",
|
||||
"menu_paises" => "Countries",
|
||||
"menu_correo" => "Mail",
|
||||
"menu_formaspago" => "Payment methods",
|
||||
"menu_imposiciones" => "Impositions",
|
||||
|
||||
@ -8,11 +8,11 @@ return [
|
||||
'id' => 'ID',
|
||||
'keyErp' => 'Key Erp',
|
||||
'moduleTitle' => 'Paises',
|
||||
'moneda' => 'Moneda',
|
||||
'nombre' => 'Nombre',
|
||||
'pais' => 'Pais',
|
||||
'paisList' => 'Pais List',
|
||||
'paises' => 'Paises',
|
||||
'moneda' => 'Currency',
|
||||
'nombre' => 'Name',
|
||||
'pais' => 'Country',
|
||||
'paisList' => 'Country List',
|
||||
'paises' => 'Countries',
|
||||
'showErp' => 'Show Erp',
|
||||
'urlErp' => 'URL Erp',
|
||||
'userErp' => 'User Erp',
|
||||
|
||||
@ -639,6 +639,7 @@ return [
|
||||
"permisos_serviciocliente" => "Servicio cliente",
|
||||
"permisos_calendario" => "Calendario",
|
||||
"permisos_correo" => "Correo",
|
||||
"permisos_paises" => "Paises",
|
||||
|
||||
"permisos_presupuestos" => "Presupuestos",
|
||||
"permisos_presupuestomaquetacion" => "Maquetación",
|
||||
@ -675,6 +676,7 @@ return [
|
||||
|
||||
"menu_configuration" => "Configuracion",
|
||||
"menu_calendario" => "Calendario",
|
||||
"menu_paises" => "Paises",
|
||||
"menu_correo" => "Correo",
|
||||
"menu_formaspago" => "Metodos de pago",
|
||||
"menu_imposiciones" => "Imposiciones",
|
||||
|
||||
@ -3,20 +3,52 @@
|
||||
|
||||
|
||||
return [
|
||||
'code' => 'Code',
|
||||
'code3' => 'Code3',
|
||||
'code' => 'Código',
|
||||
'code3' => 'Código33',
|
||||
'id' => 'ID',
|
||||
'keyErp' => 'Key Erp',
|
||||
'moduleTitle' => 'Paises',
|
||||
'moneda' => 'Moneda',
|
||||
'nombre' => 'Nombre',
|
||||
'pais' => 'Pais',
|
||||
'paisList' => 'Pais List',
|
||||
'pais' => 'País',
|
||||
'paisList' => 'Lista Paises',
|
||||
'paises' => 'Paises',
|
||||
'showErp' => 'Show Erp',
|
||||
'showErp' => 'Mostrar Erp',
|
||||
'urlErp' => 'URL Erp',
|
||||
'userErp' => 'User Erp',
|
||||
'validation' => [
|
||||
'code3' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'key_erp' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'url_erp' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'user_erp' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
'moneda' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'nombre' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'code' => [
|
||||
'is_unique' => 'The {field} field must contain a unique value',
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
@ -27,61 +59,5 @@ return [
|
||||
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'code3' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'key_erp' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'moneda' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'nombre' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'url_erp' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'user_erp' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
78
ci4/app/Models/Configuracion/PaisModel.php
Normal file
78
ci4/app/Models/Configuracion/PaisModel.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class PaisModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_paises";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $allowedFields = ["nombre", "code", "code3", "moneda", "url_erp", "user_erp", "key_erp", "show_erp"];
|
||||
protected $returnType = "App\Entities\Configuracion\Pais";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"code" => [
|
||||
"label" => "Paises.code",
|
||||
"rules" => "trim|required|max_length[2]|is_unique[lg_paises.code,id,{id}]",
|
||||
],
|
||||
"code3" => [
|
||||
"label" => "Paises.code3",
|
||||
"rules" => "trim|max_length[3]",
|
||||
],
|
||||
"key_erp" => [
|
||||
"label" => "Paises.keyErp",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
"moneda" => [
|
||||
"label" => "Paises.moneda",
|
||||
"rules" => "trim|required|max_length[3]",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "Paises.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"url_erp" => [
|
||||
"label" => "Paises.urlErp",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
"user_erp" => [
|
||||
"label" => "Paises.userErp",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"code" => [
|
||||
"is_unique" => "Paises.validation.code.is_unique",
|
||||
"max_length" => "Paises.validation.code.max_length",
|
||||
"required" => "Paises.validation.code.required",
|
||||
],
|
||||
"code3" => [
|
||||
"max_length" => "Paises.validation.code3.max_length",
|
||||
],
|
||||
"key_erp" => [
|
||||
"max_length" => "Paises.validation.key_erp.max_length",
|
||||
],
|
||||
"moneda" => [
|
||||
"max_length" => "Paises.validation.moneda.max_length",
|
||||
"required" => "Paises.validation.moneda.required",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "Paises.validation.nombre.max_length",
|
||||
"required" => "Paises.validation.nombre.required",
|
||||
],
|
||||
"url_erp" => [
|
||||
"max_length" => "Paises.validation.url_erp.max_length",
|
||||
],
|
||||
"user_erp" => [
|
||||
"max_length" => "Paises.validation.user_erp.max_length",
|
||||
],
|
||||
];
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
class UserGroupModel extends BaseModel
|
||||
{
|
||||
protected $table = 'auth_user_group';
|
||||
protected $primaryKey = 'id_group';
|
||||
protected $allowedFields = [
|
||||
'title',
|
||||
'dashboard',
|
||||
'rules',
|
||||
'token'
|
||||
];
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
class UserModel extends BaseModel
|
||||
{
|
||||
protected $table = 'auth_user';
|
||||
protected $primaryKey = 'id_user';
|
||||
protected $allowedFields = [
|
||||
'group',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'date_birth',
|
||||
'address',
|
||||
'city',
|
||||
'state',
|
||||
'country',
|
||||
'zip_code',
|
||||
'mobile',
|
||||
'email',
|
||||
'password',
|
||||
'last_ip',
|
||||
'last_access',
|
||||
'picture',
|
||||
'language',
|
||||
'tfa',
|
||||
'tfa_secret',
|
||||
'tfa_code',
|
||||
'blocked',
|
||||
'email_confirmed',
|
||||
'token',
|
||||
'status'
|
||||
];
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
namespace App\Models\Usuarios;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class GroupUserModel extends BaseModel
|
||||
{
|
||||
117
ci4/app/Models/Usuarios/UserGroupModel.php
Normal file
117
ci4/app/Models/Usuarios/UserGroupModel.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
namespace App\Models\Usuarios;
|
||||
|
||||
class UserGroupModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "auth_user_group";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $primaryKey = "id_group";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "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" => "trim|required|max_length[50]",
|
||||
],
|
||||
"id_group" => [
|
||||
"label" => "UserGroups.idGroup",
|
||||
"rules" => "max_length[31]",
|
||||
],
|
||||
"rules" => [
|
||||
"label" => "UserGroups.rules",
|
||||
"rules" => "trim|required|max_length[4194192]",
|
||||
],
|
||||
"title" => [
|
||||
"label" => "UserGroups.title",
|
||||
"rules" => "trim|required|max_length[150]",
|
||||
],
|
||||
"token" => [
|
||||
"label" => "UserGroups.token",
|
||||
"rules" => "trim|required|max_length[35]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"dashboard" => [
|
||||
"max_length" => "UserGroups.validation.dashboard.max_length",
|
||||
"required" => "UserGroups.validation.dashboard.required",
|
||||
],
|
||||
"id_group" => [
|
||||
"max_length" => "UserGroups.validation.id_group.max_length",
|
||||
],
|
||||
"rules" => [
|
||||
"max_length" => "UserGroups.validation.rules.max_length",
|
||||
"required" => "UserGroups.validation.rules.required",
|
||||
],
|
||||
"title" => [
|
||||
"max_length" => "UserGroups.validation.title.max_length",
|
||||
"required" => "UserGroups.validation.title.required",
|
||||
],
|
||||
"token" => [
|
||||
"max_length" => "UserGroups.validation.token.max_length",
|
||||
"required" => "UserGroups.validation.token.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();
|
||||
}
|
||||
}
|
||||
207
ci4/app/Models/Usuarios/UserModel.php
Normal file
207
ci4/app/Models/Usuarios/UserModel.php
Normal file
@ -0,0 +1,207 @@
|
||||
<?php
|
||||
namespace App\Models\Usuarios;
|
||||
|
||||
class UserModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "auth_user";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
protected $primaryKey = "id_user";
|
||||
|
||||
protected $allowedFields = [
|
||||
"group",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"date_birth",
|
||||
"address",
|
||||
"city",
|
||||
"state",
|
||||
"country",
|
||||
"zip_code",
|
||||
"mobile",
|
||||
"email",
|
||||
"password",
|
||||
"last_ip",
|
||||
"last_access",
|
||||
"picture",
|
||||
"language",
|
||||
"blocked",
|
||||
"email_confirmed",
|
||||
"status",
|
||||
"token",
|
||||
];
|
||||
protected $returnType = "App\Entities\Usuarios\UserEntity";
|
||||
|
||||
public static $labelField = "first_name";
|
||||
|
||||
|
||||
protected $validationRules = [
|
||||
"address" => [
|
||||
"label" => "Users.address",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
"blocked" => [
|
||||
"label" => "Users.blocked",
|
||||
"rules" => "required|permit_empty",
|
||||
],
|
||||
"city" => [
|
||||
"label" => "Users.city",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
"country" => [
|
||||
"label" => "Users.country",
|
||||
"rules" => "trim|required|max_length[2]",
|
||||
],
|
||||
"date_birth" => [
|
||||
"label" => "Users.dateBirth",
|
||||
"rules" => "valid_date|permit_empty",
|
||||
],
|
||||
"email" => [
|
||||
"label" => "Users.email",
|
||||
"rules" => "trim|required|max_length[150]|valid_email",
|
||||
],
|
||||
"email_confirmed" => [
|
||||
"label" => "Users.emailConfirmed",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"first_name" => [
|
||||
"label" => "Users.firstName",
|
||||
"rules" => "trim|required|max_length[150]",
|
||||
],
|
||||
"language" => [
|
||||
"label" => "Users.language",
|
||||
"rules" => "trim|required|max_length[10]",
|
||||
],/*
|
||||
"last_access" => [
|
||||
"label" => "Users.lastAccess",
|
||||
"rules" => "valid_date",
|
||||
],*/
|
||||
"last_ip" => [
|
||||
"label" => "Users.lastIp",
|
||||
"rules" => "max_length[50]",
|
||||
],
|
||||
"last_name" => [
|
||||
"label" => "Users.lastName",
|
||||
"rules" => "trim|required|max_length[150]",
|
||||
],
|
||||
"mobile" => [
|
||||
"label" => "Users.mobile",
|
||||
"rules" => "trim|required|max_length[50]",
|
||||
],
|
||||
"password" => [
|
||||
"label" => "Users.password",
|
||||
"rules" => "required|max_length[35]",
|
||||
],
|
||||
"picture" => [
|
||||
"label" => "Users.picture",
|
||||
"rules" => "trim|required|max_length[150]",
|
||||
],
|
||||
"state" => [
|
||||
"label" => "Users.state",
|
||||
"rules" => "trim|max_length[255]",
|
||||
],
|
||||
"zip_code" => [
|
||||
"label" => "Users.zipCode",
|
||||
"rules" => "trim|max_length[50]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"address" => [
|
||||
"max_length" => "Users.validation.address.max_length",
|
||||
],
|
||||
|
||||
"blocked" => [
|
||||
"required" => "Users.validation.email_confirmed.required",
|
||||
],
|
||||
"city" => [
|
||||
"max_length" => "Users.validation.city.max_length",
|
||||
],
|
||||
"country" => [
|
||||
"max_length" => "Users.validation.country.max_length",
|
||||
"required" => "Users.validation.country.required",
|
||||
],
|
||||
"date_birth" => [
|
||||
"valid_date" => "Users.validation.date_birth.valid_date",
|
||||
],
|
||||
"email" => [
|
||||
"max_length" => "Users.validation.email.max_length",
|
||||
"required" => "Users.validation.email.required",
|
||||
"valid_email" => "Users.validation.email.valid_email",
|
||||
],
|
||||
"email_confirmed" => [
|
||||
"integer" => "Users.validation.email_confirmed.integer",
|
||||
"required" => "Users.validation.email_confirmed.required",
|
||||
],
|
||||
"first_name" => [
|
||||
"max_length" => "Users.validation.first_name.max_length",
|
||||
"required" => "Users.validation.first_name.required",
|
||||
],
|
||||
|
||||
"language" => [
|
||||
"max_length" => "Users.validation.language.max_length",
|
||||
"required" => "Users.validation.language.required",
|
||||
],
|
||||
"last_access" => [
|
||||
"required" => "Users.validation.last_access.required",
|
||||
"valid_date" => "Users.validation.last_access.valid_date",
|
||||
],
|
||||
"last_ip" => [
|
||||
"max_length" => "Users.validation.last_ip.max_length",
|
||||
"required" => "Users.validation.last_ip.required",
|
||||
],
|
||||
"last_name" => [
|
||||
"max_length" => "Users.validation.last_name.max_length",
|
||||
"required" => "Users.validation.last_name.required",
|
||||
],
|
||||
"mobile" => [
|
||||
"max_length" => "Users.validation.mobile.max_length",
|
||||
"required" => "Users.validation.mobile.required",
|
||||
],
|
||||
"password" => [
|
||||
"max_length" => "Users.validation.password.max_length",
|
||||
"required" => "Users.validation.password.required",
|
||||
],
|
||||
"picture" => [
|
||||
"max_length" => "Users.validation.picture.max_length",
|
||||
"required" => "Users.validation.picture.required",
|
||||
],
|
||||
"state" => [
|
||||
"max_length" => "Users.validation.state.max_length",
|
||||
"required" => "Users.validation.state.required",
|
||||
],
|
||||
"zip_code" => [
|
||||
"max_length" => "Users.validation.zip_code.max_length",
|
||||
],
|
||||
];
|
||||
|
||||
public function getGroupsTitles($user_token){
|
||||
|
||||
$sql = 'SELECT `auth_user_group`.`title` FROM `auth_user_group`
|
||||
JOIN `group_user` ON `auth_user_group`.`token` = `group_user`.`token_group`
|
||||
JOIN `auth_user` ON `auth_user`.`token` = `group_user`.`token_user`
|
||||
WHERE `auth_user`.`token` = \''. $user_token . '\'';
|
||||
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
$data = [];
|
||||
foreach($result as $r){
|
||||
array_push($data, $r->title);
|
||||
}
|
||||
return implode(',', $data);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ namespace App\Validation;
|
||||
|
||||
use App\Libraries\PasswordHash;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use Exception;
|
||||
|
||||
class ApiAuthRules
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
<?php if (config('Basics')->theme['name'] == 'Bootstrap5') { ?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
||||
<symbol id="exclamation-triangle-fill" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
||||
@ -18,18 +17,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-dismissible alert-warning">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fas fa-exclamation-triangle"></i> Please correct the errors below:</h4>
|
||||
<ul>
|
||||
<?php foreach ($errors as $error) : ?>
|
||||
<li><?= esc($error) ?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div><!--//.alert-->
|
||||
</div><!--//.col-->
|
||||
</div><!--//.row -->
|
||||
<?php } ?>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.0 KiB |
@ -0,0 +1,66 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="nombre" class="form-label">
|
||||
<?=lang('Paises.nombre') ?>*
|
||||
</label>
|
||||
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $pais->nombre) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="code" class="form-label">
|
||||
<?=lang('Paises.code') ?>*
|
||||
</label>
|
||||
<input type="text" id="code" name="code" required maxLength="2" class="form-control" value="<?=old('code', $pais->code) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="code3" class="form-label">
|
||||
<?=lang('Paises.code3') ?>
|
||||
</label>
|
||||
<input type="text" id="code3" name="code3" maxLength="3" class="form-control" value="<?=old('code3', $pais->code3) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="moneda" class="form-label">
|
||||
<?=lang('Paises.moneda') ?>*
|
||||
</label>
|
||||
<input type="text" id="moneda" name="moneda" required maxLength="3" class="form-control" value="<?=old('moneda', $pais->moneda) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="urlErp" class="form-label">
|
||||
<?=lang('Paises.urlErp') ?>
|
||||
</label>
|
||||
<input type="url" id="urlErp" name="url_erp" maxLength="255" class="form-control" value="<?=old('url_erp', $pais->url_erp) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="userErp" class="form-label">
|
||||
<?=lang('Paises.userErp') ?>
|
||||
</label>
|
||||
<input type="text" id="userErp" name="user_erp" maxLength="255" class="form-control" value="<?=old('user_erp', $pais->user_erp) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="keyErp" class="form-label">
|
||||
<?=lang('Paises.keyErp') ?>
|
||||
</label>
|
||||
<input type="text" id="keyErp" name="key_erp" maxLength="255" class="form-control" value="<?=old('key_erp', $pais->key_erp) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
|
||||
<label for="showErp" class="form-check-label">
|
||||
<input type="checkbox" id="showErp" name="show_erp" value="1" class="form-check-input"<?=$pais->show_erp== true ? 'checked' : ''; ?>>
|
||||
<?=lang('Paises.showErp') ?>
|
||||
</label>
|
||||
</div><!--//.form-check -->
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -0,0 +1,26 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?=$this->extend('themes/backend/focus2/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section("content") ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<form id="paisForm" method="post" action="<?= $formAction ?>">
|
||||
<?= csrf_field() ?>
|
||||
<div class="card-body">
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<?= view("themes/backend/focus2/form/configuracion/paises/_paisFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<?= anchor(route_to("paisList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,84 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->extend('themes/backend/focus2/main/defaultlayout') ?>
|
||||
|
||||
<?=$this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?=lang('Paises.paisList') ?></h3>
|
||||
<?=anchor(route_to('newPais'), lang('Basic.global.addNew').' '.lang('Paises.pais'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfPaises" class="table table-striped table-hover using-data-table" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Paises.id') ?></th>
|
||||
<th><?= lang('Paises.nombre') ?></th>
|
||||
<th><?= lang('Paises.code') ?></th>
|
||||
<th><?= lang('Paises.code3') ?></th>
|
||||
<th><?= lang('Paises.moneda') ?></th>
|
||||
<th><?= lang('Paises.urlErp') ?></th>
|
||||
<th><?= lang('Paises.userErp') ?></th>
|
||||
<th><?= lang('Paises.keyErp') ?></th>
|
||||
<th><?= lang('Paises.showErp') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($paisList as $item ) : ?>
|
||||
<tr>
|
||||
<td class="align-middle text-center">
|
||||
<?=$item->id ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->code) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->code3) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->moneda) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->url_erp) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->user_erp) || strlen($item->user_erp) < 51 ? esc($item->user_erp) : character_limiter(esc($item->user_erp), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->key_erp) || strlen($item->key_erp) < 51 ? esc($item->key_erp) : character_limiter(esc($item->key_erp), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle text-center text-green">
|
||||
|
||||
<?php if ( $item->show_erp ) { ?>
|
||||
|
||||
<i class="text-success bi bi-check-lg"></i>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</td>
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editPais', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
|
||||
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deletePais', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
@ -0,0 +1,111 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?=$this->extend('themes/backend/focus2/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section("content") ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= formAlert() ?>
|
||||
<form id="groupForm" method="post" action="<?= $formAction ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id_group" value="<?= (isset($obj)) ? $obj['id_group'] : set_value('id_group') ?>">
|
||||
<input type="hidden" name="token" value="<?= (isset($obj)) ? $obj['token'] : set_value('token') ?>">
|
||||
<div class="form-body">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label for="title" class="text-dark"><?=lang("App.group_field_title")?></label>
|
||||
<input type="text" name="title" id="title" class="form-control" value="<?= old('title', $group->title) ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="dashboard" class="text-dark"><?=lang("App.group_field_dashboard")?></label>
|
||||
<?php $id_select = (isset($group)) ? $group->dashboard : set_value('dashboard');?>
|
||||
<select name="dashboard" id="dashboard" class="form-control">
|
||||
<option value="user" <?= $id_select == "user" ? 'selected' : '' ?>><?=lang("App.group_label_user")?></option>
|
||||
<option value="admin" <?= $id_select == "admin" ? 'selected' : '' ?>><?=lang("App.group_label_admin")?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 right">
|
||||
<div class="form-group">
|
||||
<button type="button" name="select_all" id="select_all" class="btn btn-primary round"><i class="la la-toggle-on"></i> <?=lang("App.group_btn_select")?></button>
|
||||
<button type="button" name="remove_all" id="remove_all" class="btn btn-primary round ml-1"><i class="la la-toggle-off"></i> <?=lang("App.group_btn_remove")?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 right">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4 class="card-title"><?= lang("App.permisos_general") ?></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<?php foreach(getAllClass() as $item): ?>
|
||||
<?php if (empty($item['path'])): ?>
|
||||
<div class="col-md-3 col-lg-2">
|
||||
<h4 class="danger"><?=getDictionary($item['name'])?></h4>
|
||||
<?php foreach($item['methods'] as $subitem): ?>
|
||||
<?php if(!getIgnoreMethod($subitem)): ?>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" id="<?=$item['name'].'_'.$subitem?>" name="<?=$item['name'].'_'.$subitem?>" class="custom-control-input">
|
||||
<label for="<?=$item['name'].'_'.$subitem?>" class="custom-control-label"><?=getDictionary($subitem)?></label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php foreach(getAllFolder() as $folder): ?>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4 class="card-title"><?= getDictionary($folder)??'' ?></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<?php foreach(getAllClass() as $item): ?>
|
||||
<?php if (str_contains($item['path'], $folder)): ?>
|
||||
<div class="col-md-3 col-lg-2">
|
||||
<h4 class="danger"><?=getDictionary($item['name'])?></h4>
|
||||
<?php foreach($item['methods'] as $subitem): ?>
|
||||
<?php if(!getIgnoreMethod($subitem)): ?>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" id="<?=$item['name'].'_'.$subitem?>" name="<?=$item['name'].'_'.$subitem?>" class="custom-control-input">
|
||||
<label for="<?=$item['name'].'_'.$subitem?>" class="custom-control-label"><?=getDictionary($subitem)?></label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions mt-2">
|
||||
<?= anchor(route_to("groupIndex"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</div><!-- /.card-body -->
|
||||
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,66 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->extend('themes/backend/focus2/main/defaultlayout') ?>
|
||||
<?=$this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?=lang('Group.grouplist') ?></h3>
|
||||
<?=anchor(route_to('newGroup'), lang('Basic.global.addNew').' '.lang('Group.group'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfGroups" class="table table-striped table-hover using-data-table" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?=lang("Group.id")?></th>
|
||||
<th><?=lang("Group.group_grid_title")?></th>
|
||||
<th><?=lang("Group.group_grid_dashboard")?></th>
|
||||
<th><?= lang('UserGroups.token') ?></th>
|
||||
<th><?= lang('UserGroups.createdAt') ?></th>
|
||||
<th><?= lang('UserGroups.updatedAt') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($userGroupList as $item ) : ?>
|
||||
<tr>
|
||||
<td class="align-middle text-center">
|
||||
<?=$item->id_group ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->title) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->dashboard) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->token) ?>
|
||||
</td>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editGroup', $item->id_group), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id_group,]); ?>
|
||||
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteGroup', $item->id_group), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
@ -1,5 +1,5 @@
|
||||
<?= $this->include("Themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->extend("themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?>
|
||||
<?= $this->section("content") ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@ -10,7 +10,7 @@
|
||||
<form id="tarifaacabadoForm" method="post" action="<?= $formAction ?>">
|
||||
<?= csrf_field() ?>
|
||||
<div class="card-body">
|
||||
<?= view("Themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<?= view("admin/acabadoViews/_tarifaacabadoFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
|
||||
174
ci4/app/Views/themes/backend/focus2/form/user/_userFormItems.php
Normal file
174
ci4/app/Views/themes/backend/focus2/form/user/_userFormItems.php
Normal file
@ -0,0 +1,174 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="firstName" class="form-label">
|
||||
<?=lang('Users.firstName') ?>*
|
||||
</label>
|
||||
<input type="text" id="firstName" name="first_name" required maxLength="150" class="form-control" value="<?=old('first_name', $user->first_name) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="address" class="form-label">
|
||||
<?=lang('Users.address') ?>
|
||||
</label>
|
||||
<input type="text" id="address" name="address" maxLength="255" class="form-control" value="<?=old('address', $user->address) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="state" class="form-label">
|
||||
<?=lang('Users.state') ?>*
|
||||
</label>
|
||||
<input type="text" id="state" name="state" maxLength="255" class="form-control" value="<?=old('state', $user->state) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="country" class="form-label">
|
||||
<?=lang('Users.country') ?>*
|
||||
</label>
|
||||
|
||||
<select id="country" name="country" required class="form-control " style="width: 100%;" >
|
||||
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('Users.country')]) ?></option>
|
||||
|
||||
<?php foreach ($paisList as $item) : ?>
|
||||
<option value="<?=$item->code ?>"<?=$item->code==$user->country ? ' selected':'' ?> >
|
||||
<?=$item->nombre ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="dateBirth" class="form-label">
|
||||
<?=lang('Users.dateBirth') ?>
|
||||
</label>
|
||||
<input type="date" id="dateBirth" name="date_birth" maxLength="10" class="form-control" value="<?=old('date_birth', $user->date_birth) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="mobile" class="form-label">
|
||||
<?=lang('Users.mobile') ?>*
|
||||
</label>
|
||||
<input type="text" id="mobile" name="mobile" maxLength="50" class="form-control" value="<?=old('mobile', $user->mobile) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">
|
||||
<?=lang('Users.email') ?>*
|
||||
</label>
|
||||
<input type="email" id="email" name="email" required maxLength="150" class="form-control" value="<?=old('email', $user->email) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">
|
||||
<?=lang('Users.password') ?>*
|
||||
</label>
|
||||
<input type="password" id="password" name="password" maxLength="35" class="form-control" value="<?=old('password', $user->password) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-group">
|
||||
<label for="group" class="form-label"> <?=lang('Users.group') ?></label>
|
||||
<select name="group[]" id="group" multiple="multiple">
|
||||
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('Users.group')]) ?></option>
|
||||
<?php foreach ($groups as $item) : ?>
|
||||
<?php if (isset($selectedGroups) && sizeof($selectedGroups)>=1): ?>
|
||||
<?php foreach ($selectedGroups as $selItem) : ?>
|
||||
<option value="<?=$item->token ?>" data-select2-id=<?=$item->token ?> <?=$item->token==$selItem['token_group']?'selected':'' ?>> <?= $item->title ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<option value="<?=$item->token ?>" data-select2-id=<?=$item->token ?> > <?= $item->title ?>
|
||||
</option>
|
||||
<?php endif ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="lastName" class="form-label">
|
||||
<?=lang('Users.lastName') ?>*
|
||||
</label>
|
||||
<input type="text" id="lastName" name="last_name" required maxLength="150" class="form-control" value="<?=old('last_name', $user->last_name) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="city" class="form-label">
|
||||
<?=lang('Users.city') ?>
|
||||
</label>
|
||||
<input type="text" id="city" name="city" maxLength="255" class="form-control" value="<?=old('city', $user->city) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="zipCode" class="form-label">
|
||||
<?=lang('Users.zipCode') ?>
|
||||
</label>
|
||||
<input type="text" id="zipCode" name="zip_code" maxLength="50" class="form-control" value="<?=old('zip_code', $user->zip_code) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-group">
|
||||
<label for="language" class="text-dark"><?=lang("Users.language")?></label>
|
||||
<?php $id_select = old('language', $user->language);?>
|
||||
<select name="language" id="language" class="form-control">
|
||||
<option value=""><?=lang("App.global_select")?></option>
|
||||
<option value="en" <?= $id_select == "en" ? 'selected' : '' ?>><?=lang("App.lang_en")?></option>
|
||||
<option value="es" <?= $id_select == "es" ? 'selected' : '' ?>><?=lang("App.lang_es")?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="picture" class="form-label">
|
||||
<?=lang('Users.picture') ?>*
|
||||
</label>
|
||||
<input type="text" id="picture" name="picture" required placeholder="/assets/img/default-user.png" maxLength="150" class="form-control" value="<?=old('picture', $user->picture) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="blocked" class="form-label">
|
||||
<?=lang('Users.blocked') ?>*
|
||||
</label>
|
||||
<?php $id_select = old('blocked', $user->blocked);?>
|
||||
<select name="blocked" id="blocked" class="form-control">
|
||||
<option value="0" <?= $id_select == "0" ? 'selected' : '' ?>><?=lang("User.user_non_blocked")?></option>
|
||||
<option value="1" <?= $id_select == "1" ? 'selected' : '' ?>><?=lang("User.user_blocked")?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="emailConfirmed" class="form-label">
|
||||
<?=lang('Users.emailConfirmed') ?>*
|
||||
</label>
|
||||
<?php $id_select = old('email_confirmed', $user->email_confirmed);?>
|
||||
<select name="email_confirmed" id="email_confirmed" class="form-control">
|
||||
<option value="0" <?= $id_select == "0" ? 'selected' : '' ?>><?=lang("User.user_alert_not_confirmed")?></option>
|
||||
<option value="1" <?= $id_select == "1" ? 'selected' : '' ?>><?=lang("User.user_alert_confirmed")?></option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="status" class="form-label">
|
||||
<?=lang('Users.status') ?>*
|
||||
</label>
|
||||
<?php $id_select = old('status', $user->status);?>
|
||||
<select name="status" id="status" class="form-control">
|
||||
<option value="1" <?= $id_select == "1" ? 'selected' : '' ?>><?=lang("User.global_active")?></option>
|
||||
<option value="0" <?= $id_select == "0" ? 'selected' : '' ?>><?=lang("User.global_inactive")?></option>
|
||||
</select>
|
||||
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -1,219 +0,0 @@
|
||||
<!--Style-->
|
||||
<link href="<?=site_url("themes/focus2/vendor/bootstrap-material-datetimepicker/css/bootstrap-material-datetimepicker.css")?>" rel="stylesheet">
|
||||
<!--Content Body-->
|
||||
<div class="content-body">
|
||||
<div class="container-fluid">
|
||||
<div class="row page-titles mx-0">
|
||||
<div class="col-sm-6 p-md-0">
|
||||
<div class="welcome-text">
|
||||
<h4><i class="<?= $title['icon']??'' ?>"></i> <?= $title['module']??'' ?></h4>
|
||||
<span class="ml-1"><?= $title['page']??'' ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
|
||||
<ol class="breadcrumb">
|
||||
<?php foreach ($breadcrumb??[] as $item) : ?>
|
||||
<?php if (!$item['active']) : ?>
|
||||
<li class="breadcrumb-item"><a href="<?= site_url($item['route']) ?>"><?= $item['title'] ?></a></li>
|
||||
<?php else : ?>
|
||||
<li class="breadcrumb-item active"><?= $item['title'] ?></li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4 class="card-title"><?= $title['page']??'' ?></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?= formAlert() ?>
|
||||
<form class="form" action="<?=site_url("user/store")?>" method="post">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id_user" value="<?= (isset($obj)) ? $obj['id_user'] : set_value('id_user') ?>">
|
||||
<div class="form-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<label class="text-primary"><?=lang("App.user_msg_desc_1")?></label>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label class="text-dark"><?=lang("App.user_field_first_name")?></label>
|
||||
<input type="text" id="first_name" name="first_name" class="form-control" placeholder="<?=lang("App.user_field_first_name_ph")?>" value="<?= (isset($obj)) ? $obj['first_name'] : set_value('first_name');?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label class="text-dark"><?=lang("App.user_field_last_name")?></label>
|
||||
<input type="text" id="last_name" name="last_name" class="form-control" placeholder="<?=lang("App.user_field_last_name_ph")?>" value="<?= (isset($obj)) ? $obj['last_name'] : set_value('last_name');?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label class="text-dark"><?=lang("App.user_field_email")?></label>
|
||||
<input type="text" id="email" name="email" class="form-control" placeholder="<?=lang("App.user_field_email_ph")?>" value="<?= (isset($obj)) ? $obj['email'] : set_value('email');?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label class="text-dark"><?=lang("App.user_field_date_birth")?></label>
|
||||
<input type="text" class="form-control" placeholder="<?=lang("App.user_field_date_birth_ph")?>" id="date_birth" name="date_birth" value="<?= (isset($obj)) ? $obj['date_birth'] : set_value('date_birth');?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label for="mobile" class="text-dark"><?=lang("App.user_field_cell")?></label>
|
||||
<input type="text" id="mobile" name="mobile" class="form-control" placeholder="<?=lang("App.user_field_cell_ph")?>" value="<?= (isset($obj)) ? $obj['mobile'] : set_value('mobile');?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label for="password" class="text-dark"><?=lang("App.user_field_password")?></label>
|
||||
<input type="password" id="password" name="password" class="form-control" placeholder="<?=lang("App.user_field_password_ph")?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label for="confirm_password" class="text-dark"><?=lang("App.user_field_password_confirm")?></label>
|
||||
<input type="password" id="confirm_password" name="confirm_password" class="form-control" placeholder="<?=lang("App.user_field_password_confirm_ph")?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label for="id_group" class="text-dark"><?=lang("App.user_field_group")?></label>
|
||||
<?php $select = (isset($selected_groups)) ? $selected_groups??[] : [];?>
|
||||
<select name="group[]" id="group" multiple="multiple">
|
||||
<?php foreach ($group??[] as $item) : ?>
|
||||
<?php foreach ($select??[] as $id_select) : ?>
|
||||
<?php
|
||||
if ($id_select['token_group'] == $item['token']){
|
||||
$selItem = 'selected';
|
||||
break;
|
||||
}
|
||||
else{
|
||||
$selItem = '';
|
||||
}
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
<option value="<?=$item['token']??''?>" <?= isset($selItem)?$selItem:"" ?>> <?=$item['title']??''?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label for="email_confirmed" class="text-dark"><?=lang("App.user_field_email_confirmed")?></label>
|
||||
<?php $id_select = (isset($obj)) ? $obj['email_confirmed']??[] : set_value('email_confirmed');?>
|
||||
<select name="email_confirmed" id="email_confirmed" class="form-control">
|
||||
<option value="0" <?= $id_select == "0" ? 'selected' : '' ?>><?=lang("App.user_alert_not_confirmed")?></option>
|
||||
<option value="1" <?= $id_select == "1" ? 'selected' : '' ?>><?=lang("App.user_alert_confirmed")?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label for="status" class="text-dark"><?=lang("App.user_field_status")?></label>
|
||||
<?php $id_select = (isset($obj)) ? $obj['status']??[] : set_value('status');?>
|
||||
<select name="status" id="status" class="form-control">
|
||||
<option value="1" <?= $id_select == "1" ? 'selected' : '' ?>><?=lang("App.global_active")?></option>
|
||||
<option value="0" <?= $id_select == "0" ? 'selected' : '' ?>><?=lang("App.global_inactive")?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<label class="text-primary"><?=lang("App.user_msg_desc_2")?></label>
|
||||
</div>
|
||||
<div class="col-lg-9">
|
||||
<div class="form-group">
|
||||
<label class="text-dark"><?=lang("App.user_field_address")?></label>
|
||||
<input type="text" id="address" name="address" class="form-control" placeholder="<?=lang("App.user_field_address_ph")?>" value="<?= (isset($obj)) ? $obj['address'] : set_value('address');?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label for="city" class="text-dark"><?=lang("App.user_field_city")?></label>
|
||||
<input type="text" id="city" name="city" class="form-control" placeholder="<?=lang("App.user_field_city_ph")?>" value="<?= (isset($obj)) ? $obj['city'] : set_value('city');?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="state" class="text-dark"><?=lang("App.user_field_state")?></label>
|
||||
<input type="text" id="state" name="state" class="form-control" placeholder="<?=lang("App.user_field_state_ph")?>" value="<?= (isset($obj)) ? $obj['state'] : set_value('state');?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="country" class="text-dark"><?=lang("App.user_field_country")?></label>
|
||||
<?php $id_select = (isset($obj)) ? $obj['country']??[] : set_value('country');?>
|
||||
<select name="country" id="country" class="form-control">
|
||||
<option value=""><?=lang("App.global_select")?></option>
|
||||
<?php foreach ($country??[] as $item) : ?>
|
||||
<option value="<?=$item['code']??''?>" <?= $id_select == $item['code'] ? 'selected' : '' ?>><?=$item['name']??''?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="language" class="text-dark"><?=lang("App.user_field_language")?></label>
|
||||
<?php $id_select = (isset($obj)) ? $obj['language']??[] : set_value('language');?>
|
||||
<select name="language" id="language" class="form-control">
|
||||
<option value=""><?=lang("App.global_select")?></option>
|
||||
<option value="en" <?= $id_select == "en" ? 'selected' : '' ?>><?=lang("App.lang_en")?></option>
|
||||
<option value="es" <?= $id_select == "es" ? 'selected' : '' ?>><?=lang("App.lang_es")?></option>
|
||||
<option value="pt" <?= $id_select == "pt" ? 'selected' : '' ?>><?=lang("App.lang_pt")?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<a href="<?= site_url($btn_return['route']??'#') ?>" class="<?= $btn_return['class']??''?>">
|
||||
<i class="<?= $btn_return['icon']??'' ?>"></i> <?= $btn_return['title']??'' ?>
|
||||
</a>
|
||||
<button type="submit" class="<?= $btn_submit['class']??''?>">
|
||||
<i class="<?= $btn_submit['icon']??'' ?>"></i> <?= $btn_submit['title']??'' ?>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Required vendors -->
|
||||
<script src="<?=site_url("themes/focus2/vendor/global/global.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/js/quixnav-init.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/js/custom.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/select2/js/select2.full.min.js")?>"></script>
|
||||
<!-- Date Range Picker -->
|
||||
<!-- momment js is must -->
|
||||
<script src="<?=site_url("themes/focus2/vendor/moment/moment.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/bootstrap-daterangepicker/daterangepicker.js")?>"></script>
|
||||
<!-- Material color picker -->
|
||||
<script src="<?=site_url("themes/focus2/vendor/bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker.js")?>"></script>
|
||||
<!-- Form -->
|
||||
<script>
|
||||
"use strict";
|
||||
$(document).ready(function () {
|
||||
$('#first_name').focus();
|
||||
$("#group").select2();
|
||||
$("#status").select2();
|
||||
$("#country").select2();
|
||||
$("#language").select2();
|
||||
$("#email_confirmed").select2();
|
||||
$('#date_birth').bootstrapMaterialDatePicker({
|
||||
format: '<?=momentDateJS()?>',
|
||||
time: false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -1,120 +0,0 @@
|
||||
<!--Content Body-->
|
||||
<div class="content-body">
|
||||
<div class="container-fluid">
|
||||
<div class="row page-titles mx-0">
|
||||
<div class="col-sm-6 p-md-0">
|
||||
<div class="welcome-text">
|
||||
<h4><i class="<?= $title['icon']??'' ?>"></i> <?= $title['module']??'' ?></h4>
|
||||
<span class="ml-1"><?= $title['page']??'' ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
|
||||
<ol class="breadcrumb">
|
||||
<?php foreach ($breadcrumb??[] as $item) : ?>
|
||||
<?php if (!$item['active']) : ?>
|
||||
<li class="breadcrumb-item"><a href="<?= site_url($item['route']) ?>"><?= $item['title'] ?></a></li>
|
||||
<?php else : ?>
|
||||
<li class="breadcrumb-item active"><?= $item['title'] ?></li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header row">
|
||||
<div class="col-sm-6">
|
||||
<h4 class="card-title"><?= $title['page']??'' ?></h4>
|
||||
</div>
|
||||
<div class="col-sm-6 justify-content-sm-end mt-2 mt-sm-0 d-flex">
|
||||
<a href="<?= site_url($btn_add['route']??'#')?>" class="<?= $btn_add['class']??''?>">
|
||||
<i class="<?= $btn_add['icon']??'' ?>"></i> <?= $btn_add['title']??'' ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<!-- CSRF token -->
|
||||
<input type="hidden" class="txt_csrfname" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>" />
|
||||
<!-- Table -->
|
||||
<div class="table-responsive">
|
||||
<table id='table-grid' class="table table-striped nowrap" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?=lang("App.user_grid_name")?></th>
|
||||
<th><?=lang("App.user_grid_email")?></th>
|
||||
<th><?=lang("App.user_grid_group")?></th>
|
||||
<th><?=lang("App.user_grid_mobile")?></th>
|
||||
<th><?=lang("App.user_grid_last_access")?></th>
|
||||
<th><?=lang("App.user_grid_last_ip")?></th>
|
||||
<th><?=lang("App.user_grid_created")?></th>
|
||||
<th><?=lang("App.user_grid_options")?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Required vendors -->
|
||||
<script src="<?=site_url("themes/focus2/vendor/global/global.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/js/quixnav-init.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/js/custom.min.js")?>"></script>
|
||||
<!-- Datatable -->
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/jquery.dataTables.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/pickers/daterange/moment.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/dataTables.datetime.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/dataTables.buttons.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/buttons.bootstrap4.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/jszip.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/pdfmake.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/vfs_fonts.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/buttons.html5.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/buttons.print.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/datatables/js/buttons.colVis.min.js")?>"></script>
|
||||
<!-- Alert -->
|
||||
<script src="<?=site_url("themes/focus2/vendor/sweetalert2/dist/sweetalert2.min.js")?>"></script>
|
||||
<script src="<?=site_url("themes/focus2/vendor/toastr/js/toastr.min.js")?>"></script>
|
||||
<!-- Custom -->
|
||||
<script src="<?=site_url("assets/js/main.js")?>"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
$(document).ready(function () {
|
||||
let dataFormat = [
|
||||
{
|
||||
targets: 4,
|
||||
render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss','<?=momentDateTimeJS()?>')
|
||||
},
|
||||
{
|
||||
targets: 6,
|
||||
render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss','<?=momentDateTimeJS()?>')
|
||||
}
|
||||
];
|
||||
let order = [[0, "asc"]];
|
||||
let translate = '/themes/focus2/vendor/datatables/locales/<?=langJS()?>.json';
|
||||
let button = ["<?=lang("App.global_copy")?>","<?=lang("App.global_print")?>","<?=lang("App.global_excel")?>","<?=lang("App.global_pdf")?>"];
|
||||
let columns = [{ data: 'first_name' },{ data: 'email' },{ data: 'group' },{ data: 'mobile' },{ data: 'last_access' },{ data: 'last_ip' },{ data: 'created_at' },{ data: 'options' }];
|
||||
loadDataTableAjax('table-grid', '<?=site_url('ajax/getUsers')?>', translate, true, true, order, columns,dataFormat, button);
|
||||
});
|
||||
function delete_user(id){
|
||||
swal({
|
||||
title: "<?=lang("App.user_delete_title")?>",
|
||||
text: "<?=lang("App.user_delete_subtitle")?>",
|
||||
type: "warning",
|
||||
showCancelButton: !0,
|
||||
confirmButtonColor: "#f34141",
|
||||
confirmButtonText: "<?=lang("App.user_delete_btn_ok")?>",
|
||||
cancelButtonText: "<?=lang("App.user_delete_btn_cancel")?>",
|
||||
closeOnConfirm: !1
|
||||
}).then(function(isConfirm) {
|
||||
console.log(isConfirm);
|
||||
if (isConfirm.value) {
|
||||
window.location.href = '<?=site_url("usuarios/user/delete/")?>'+id;
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<?= sweetAlert() ?>
|
||||
@ -0,0 +1,25 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?=$this->extend('themes/backend/focus2/main/defaultlayout') ?>
|
||||
<?= $this->section("content") ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<form id="userForm" method="post" action="<?= $formAction ?>">
|
||||
<?= csrf_field() ?>
|
||||
<div class="card-body">
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<?= view("themes/backend/focus2/form/user/_userFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<?= anchor(route_to("userIndex"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
135
ci4/app/Views/themes/backend/focus2/form/user/viewUserList.php
Normal file
135
ci4/app/Views/themes/backend/focus2/form/user/viewUserList.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->extend('themes/backend/focus2/main/defaultlayout') ?>
|
||||
<?=$this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?=lang('Users.userList') ?></h3>
|
||||
<?=anchor(route_to('newUser'), lang('Basic.global.addNew').' '.lang('Users.user'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfUsers" class="table table-striped table-hover using-data-table" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Users.idUser') ?></th>
|
||||
<th><?= lang('Users.firstName') ?></th>
|
||||
<th><?= lang('Users.lastName') ?></th>
|
||||
<th><?= lang('Users.group') ?></th>
|
||||
<th><?= lang('Users.mobile') ?></th>
|
||||
<th><?= lang('Users.email') ?></th>
|
||||
<th><?= lang('Users.address') ?></th>
|
||||
<th><?= lang('Users.city') ?></th>
|
||||
<th><?= lang('Users.state') ?></th>
|
||||
<th><?= lang('Users.country') ?></th>
|
||||
<th><?= lang('Users.zipCode') ?></th>
|
||||
<th><?= lang('Users.lastIp') ?></th>
|
||||
<th><?= lang('Users.lastAccess') ?></th>
|
||||
<th><?= lang('Users.picture') ?></th>
|
||||
<th><?= lang('Users.language') ?></th>
|
||||
<th><?= lang('Users.blocked') ?></th>
|
||||
<th><?= lang('Users.emailConfirmed') ?></th>
|
||||
<th><?= lang('Users.token') ?></th>
|
||||
<th><?= lang('Users.status') ?></th>
|
||||
<th><?= lang('Users.createdAt') ?></th>
|
||||
<th><?= lang('Users.updatedAt') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($userList as $item ) : ?>
|
||||
<tr>
|
||||
<td class="align-middle text-center">
|
||||
<?=$item->id_user ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->first_name) || strlen($item->first_name) < 51 ? esc($item->first_name) : character_limiter(esc($item->first_name), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->last_name) || strlen($item->last_name) < 51 ? esc($item->last_name) : character_limiter(esc($item->last_name), 50) ?>
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
<?= empty($user_model->getGroupsTitles($item->token)) || strlen($user_model->getGroupsTitles($item->token)) < 51 ? esc($user_model->getGroupsTitles($item->token)) : character_limiter($user_model->getGroupsTitles($item->token), 50) ?>
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
<?= empty($item->mobile) || strlen($item->mobile) < 51 ? esc($item->mobile) : character_limiter(esc($item->mobile), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->email) ?>
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
<?= empty($item->address) || strlen($item->address) < 51 ? esc($item->address) : character_limiter(esc($item->address), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->city) || strlen($item->city) < 51 ? esc($item->city) : character_limiter(esc($item->city), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->state) || strlen($item->state) < 51 ? esc($item->state) : character_limiter(esc($item->state), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->country) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->zip_code) || strlen($item->zip_code) < 51 ? esc($item->zip_code) : character_limiter(esc($item->zip_code), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->last_ip) || strlen($item->last_ip) < 51 ? esc($item->last_ip) : character_limiter(esc($item->last_ip), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->last_access) ? '' : date('d/m/Y H:m:s', strtotime($item->last_access)) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->picture) || strlen($item->picture) < 51 ? esc($item->picture) : character_limiter(esc($item->picture), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->language) ?>
|
||||
</td>
|
||||
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->blocked) ? '' : date('d/m/Y H:m:s', strtotime($item->blocked)) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->email_confirmed) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->token) ?>
|
||||
</td>
|
||||
<td class="align-middle text-center text-green">
|
||||
|
||||
<?php if ( $item->status ) { ?>
|
||||
|
||||
<i class="text-success bi bi-check-lg"></i>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editUser', $item->id_user), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id_user,]); ?>
|
||||
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteUser', $item->id_user), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
@ -151,6 +151,14 @@ $notification = session()->get('notification');
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
||||
|
||||
<?= $this->renderSection('additionalExternalJs') ?>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
$(document).ready(function () {
|
||||
$('#first_name').focus();
|
||||
$("#group").select2();
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if(allowMenuSection($menus, ['Calendario', 'Correo', 'Formaspago', 'Imposiciones', 'Maquina', 'Papelgenerico', 'Seriefactura', 'Serviciocliente', 'Tamanioformatos', 'Tamaniolibros', 'Tareaservicio', 'Tiposimpresion', 'Trabajo'], 'index')): ?>
|
||||
<?php if(allowMenuSection($menus, ['Paises', 'Calendario', 'Correo', 'Formaspago', 'Imposiciones', 'Maquina', 'Papelgenerico', 'Seriefactura', 'Serviciocliente', 'Tamanioformatos', 'Tamaniolibros', 'Tareaservicio', 'Tiposimpresion', 'Trabajo'], 'index')): ?>
|
||||
<li><a class="has-arrow" href="Javascript:void()" aria-expanded="false"><i class="icon-arrow-down"></i><span class="nav-text"><?= lang("App.menu_configuration") ?></span></a>
|
||||
<ul aria-expanded="false">
|
||||
<?php if (count($temp=getArrayItem($menus,'name','Calendario')) > 0): ?>
|
||||
@ -32,6 +32,11 @@
|
||||
<li><a href="<?= site_url("configuracion/calendario")?>" aria-expanded="false"><i class="icon-list"></i><span class="nav-text"><?= lang("App.menu_calendario") ?></span></a></li>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (count($temp=getArrayItem($menus,'name','Paises')) > 0): ?>
|
||||
<?php if (count(getArrayItem($temp,'methods','index',true)) > 0): ?>
|
||||
<li><a href="<?= site_url("configuracion/paises")?>" aria-expanded="false"><i class="icon-list"></i><span class="nav-text"><?= lang("App.menu_paises") ?></span></a></li>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (count($temp=getArrayItem($menus,'name','Correo')) > 0): ?>
|
||||
<?php if (count(getArrayItem($temp,'methods','index',true)) > 0): ?>
|
||||
<li><a href="<?= site_url("configuracion/correo")?>" aria-expanded="false"><i class="icon-list"></i><span class="nav-text"><?= lang("App.menu_correo") ?></span></a></li>
|
||||
@ -214,12 +219,12 @@
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(allowMenuSection($menus, ['User', 'Group'], 'index')): ?>
|
||||
<?php if(allowMenuSection($menus, ['Users', 'Group'], 'index')): ?>
|
||||
<li><a class="has-arrow" href="Javascript:void()" aria-expanded="false"><i class="icon-arrow-down"></i><span class="nav-text"><?= lang("App.menu_users") ?></span></a>
|
||||
<ul aria-expanded="false">
|
||||
<?php if (count($temp=getArrayItem($menus,'name','User')) > 0): ?>
|
||||
<?php if (count($temp=getArrayItem($menus,'name','Users')) > 0): ?>
|
||||
<?php if (count(getArrayItem($temp,'methods','index',true)) > 0): ?>
|
||||
<li><a href="<?= site_url("usuarios/user")?>" aria-expanded="false"><i class="icon-list"></i><span class="nav-text"><?= lang("App.menu_users") ?></span></a></li>
|
||||
<li><a href="<?= site_url("usuarios/users")?>" aria-expanded="false"><i class="icon-list"></i><span class="nav-text"><?= lang("App.menu_users") ?></span></a></li>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (count($temp=getArrayItem($menus,'name','Group')) > 0): ?>
|
||||
|
||||
Reference in New Issue
Block a user