mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'bud/tarifas_extras' into 'main'
Bud/tarifas extras See merge request jjimenez/safekat!280
This commit is contained in:
@ -21,10 +21,6 @@ const SK_PERMISSION_MATRIX = [
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
"tarifa-preimpresion.create",
|
||||
"tarifa-preimpresion.edit",
|
||||
"tarifa-preimpresion.delete",
|
||||
"tarifa-preimpresion.menu",
|
||||
"tarifa-manipulado.create",
|
||||
"tarifa-manipulado.edit",
|
||||
"tarifa-manipulado.delete",
|
||||
@ -41,6 +37,10 @@ const SK_PERMISSION_MATRIX = [
|
||||
"tarifa-envio.edit",
|
||||
"tarifa-envio.delete",
|
||||
"tarifa-envio.menu",
|
||||
"tarifa-extra.create",
|
||||
"tarifa-extra.edit",
|
||||
"tarifa-extra.delete",
|
||||
"tarifa-extra.menu",
|
||||
"proveedores.create",
|
||||
"proveedores.edit",
|
||||
"proveedores.delete",
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
const SK_PERMISSION_MATRIX = [
|
||||
"superadmin"=> [
|
||||
"admin.*",
|
||||
"users.*",
|
||||
"beta.*"
|
||||
],
|
||||
"admin"=> [
|
||||
"admin.access",
|
||||
"users.create",
|
||||
"users.edit",
|
||||
"users.delete",
|
||||
"beta.access"
|
||||
],
|
||||
"developer"=> [
|
||||
"admin.access",
|
||||
"admin.settings",
|
||||
"users.create",
|
||||
"users.edit",
|
||||
"beta.access"
|
||||
],
|
||||
"user"=> [
|
||||
"users.list"
|
||||
],
|
||||
"beta"=> [
|
||||
"beta.access"
|
||||
]
|
||||
];
|
||||
@ -41,6 +41,10 @@ const SK_PERMISSIONS = [
|
||||
'tarifa-envio.edit' => 'Can edit',
|
||||
'tarifa-envio.delete' => 'Can delete',
|
||||
'tarifa-envio.menu' => 'Menu shall be visualize',
|
||||
'tarifa-extra.create' => 'Can create',
|
||||
'tarifa-extra.edit' => 'Can edit',
|
||||
'tarifa-extra.delete' => 'Can delete',
|
||||
'tarifa-extra.menu' => 'Menu shall be visualize',
|
||||
'proveedores.create' => 'Can create',
|
||||
'proveedores.edit' => 'Can edit',
|
||||
'proveedores.delete' => 'Can delete',
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
const SK_PERMISSIONS = [
|
||||
'admin.access' => 'Can access the sites admin area',
|
||||
'admin.settings' => 'Can access the main site settings',
|
||||
'users.manage-admins' => 'Can manage other admins',
|
||||
'users.list' => 'Can list user stuff',
|
||||
'users.create' => 'Can create new non-admin users',
|
||||
'users.edit' => 'Can edit existing non-admin users',
|
||||
'users.delete' => 'Can delete existing non-admin users',
|
||||
'beta.access' => 'Can access beta-level features',
|
||||
];
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
const SK_ROLES = [
|
||||
'superadmin' => [
|
||||
'title' => 'Super Admin',
|
||||
'description' => 'Complete control of the site.',
|
||||
],
|
||||
'admin' => [
|
||||
'title' => 'Admin',
|
||||
'description' => 'Day to day administrators of the site.',
|
||||
],
|
||||
'developer' => [
|
||||
'title' => 'Developer',
|
||||
'description' => 'Site programmers.',
|
||||
],
|
||||
'user' => [
|
||||
'title' => 'User',
|
||||
'description' => 'General users of the site. Often customers.',
|
||||
],
|
||||
'beta' => [
|
||||
'title' => 'Beta User',
|
||||
'description' => 'Has access to beta-level features.',
|
||||
],
|
||||
];
|
||||
@ -37,7 +37,7 @@ class BaseController extends Controller
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['general', 'go_common'];
|
||||
protected $helpers = ['general', 'go_common', 'rbac'];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
||||
@ -43,23 +43,23 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
*/
|
||||
protected static $pluralObjectName;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Path for the views directory for the extending view controller
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $viewPath;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* JJO: Variable para indicar si el controlador hace soft_delete o no
|
||||
*
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $soft_delete = false;
|
||||
/**
|
||||
* JJO: Variable quién puede ver los registros borrados
|
||||
*
|
||||
*
|
||||
* 0 -> Not Deleted
|
||||
* 1 -> Soft Deleted, shows up in lists of deleted items for management users
|
||||
* 2 -> Soft Deleted, does not show up for any user except admin users
|
||||
@ -85,7 +85,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['session', 'go_common', 'form', 'text', 'general']; //JJO
|
||||
protected $helpers = ['session', 'go_common', 'form', 'text', 'general', 'rbac']; //JJO
|
||||
|
||||
/**
|
||||
* Initializer method.
|
||||
@ -123,7 +123,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
$this->viewData['viewPath'] = static::$viewPath;
|
||||
|
||||
|
||||
$this->viewData['currentLocale'] = $this->request->getLocale();
|
||||
|
||||
/* IMN */
|
||||
@ -159,7 +159,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
}
|
||||
|
||||
if (!isset($this->viewData['formAction'])) {
|
||||
$this->viewData['formAction'] = base_url(strtolower($this->viewData['currentModule']) . '/' . $formActionSuffix . '/' . $action );
|
||||
$this->viewData['formAction'] = base_url(strtolower($this->viewData['currentModule']) . '/' . $formActionSuffix . '/' . $action);
|
||||
}
|
||||
|
||||
if ((!isset($this->viewData['boxTitle']) || empty($this->viewData['boxTitle'])) && isset(static::$singularObjectName) && !empty(static::$singularObjectName)) {
|
||||
@ -223,29 +223,28 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
public function delete($id = null)
|
||||
{
|
||||
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc) . '.' . static::$singularObjectNameCc));
|
||||
} else {
|
||||
$objName = lang('Basic.global.record');
|
||||
}
|
||||
|
||||
if (!$this->soft_delete){
|
||||
|
||||
if (!$this->soft_delete) {
|
||||
|
||||
if (!$this->model->delete($id)) {
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$rawResult = $this->model->where('id',$id)
|
||||
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
|
||||
'is_deleted' => $this->delete_flag])
|
||||
$rawResult = $this->model->where('id', $id)
|
||||
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
|
||||
'is_deleted' => $this->delete_flag])
|
||||
->update();
|
||||
if (!$rawResult) {
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented
|
||||
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
|
||||
$response = $this->respondDeleted(['id' => $id, 'msg' => $message]);
|
||||
@ -261,20 +260,18 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
protected function canValidate($customValidationRules = null, $customValidationMessages = null)
|
||||
{
|
||||
|
||||
if($customValidationRules == null){
|
||||
if ($customValidationRules == null) {
|
||||
$validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$validationRules = $customValidationRules;
|
||||
}
|
||||
if ($validationRules == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($customValidationMessages == null){
|
||||
$validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;;
|
||||
}
|
||||
else{
|
||||
if ($customValidationMessages == null) {
|
||||
$validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;;
|
||||
} else {
|
||||
$validationErrorMessages = $customValidationMessages;
|
||||
}
|
||||
|
||||
@ -283,7 +280,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
} else {
|
||||
$valid = $this->validate($validationRules);
|
||||
}
|
||||
|
||||
|
||||
$this->validationErrors = $valid ? '' : $this->validator->getErrors();
|
||||
|
||||
/*
|
||||
@ -303,7 +300,8 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
* @param array|null $postData
|
||||
* @return array
|
||||
*/
|
||||
protected function sanitized(array $postData = null, bool $nullIfEmpty = false) {
|
||||
protected function sanitized(array $postData = null, bool $nullIfEmpty = false)
|
||||
{
|
||||
if ($postData == null) {
|
||||
$postData = $this->request->getPost();
|
||||
}
|
||||
@ -317,7 +315,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
}
|
||||
return $sanitizedData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom fail method needed when CSRF token regeneration is on in security settings
|
||||
* @param string|array $messages
|
||||
@ -326,15 +324,15 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
* @param string $customMessage
|
||||
* @return mixed
|
||||
*/
|
||||
protected function failWithNewToken($messages, int $status = 400, string $code = null, string $customMessage = '') {
|
||||
protected function failWithNewToken($messages, int $status = 400, string $code = null, string $customMessage = '')
|
||||
{
|
||||
|
||||
if (! is_array($messages))
|
||||
{
|
||||
if (!is_array($messages)) {
|
||||
$messages = ['error' => $messages];
|
||||
}
|
||||
$response = [
|
||||
'status' => $status,
|
||||
'error' => $status,
|
||||
'status' => $status,
|
||||
'error' => $status,
|
||||
'messages' => $messages,
|
||||
csrf_token() => csrf_hash()
|
||||
];
|
||||
@ -360,7 +358,8 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
* Convenience method for common exception handling
|
||||
* @param \Exception $e
|
||||
*/
|
||||
protected function dealWithException(\Exception $e) {
|
||||
protected function dealWithException(\Exception $e)
|
||||
{
|
||||
// using another try / catch block to prevent to avoid CodeIgniter bug throwing trivial exceptions for querying DB errors
|
||||
try {
|
||||
$query = $this->model->db->getLastQuery();
|
||||
@ -368,16 +367,16 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
$dbError = $this->model->db->error();
|
||||
$userFriendlyErrMsg = lang('Basic.global.persistErr1', [static::$singularObjectNameCc]);
|
||||
if (isset($dbError['code']) && $dbError['code'] == 1062) :
|
||||
$userFriendlyErrMsg .= PHP_EOL.lang('Basic.global.persistDuplErr', [static::$singularObjectNameCc]);
|
||||
$userFriendlyErrMsg .= PHP_EOL . lang('Basic.global.persistDuplErr', [static::$singularObjectNameCc]);
|
||||
endif;
|
||||
// $userFriendlyErrMsg = str_replace("'", "\'", $userFriendlyErrMsg); // Uncomment if experiencing unescaped single quote errors
|
||||
log_message('error', $userFriendlyErrMsg.PHP_EOL.$e->getMessage().PHP_EOL.$queryStr);
|
||||
log_message('error', $userFriendlyErrMsg . PHP_EOL . $e->getMessage() . PHP_EOL . $queryStr);
|
||||
if (isset($dbError['message']) && !empty($dbError['message'])) :
|
||||
log_message('error', $dbError['code'].' : '.$dbError['message']);
|
||||
log_message('error', $dbError['code'] . ' : ' . $dbError['message']);
|
||||
endif;
|
||||
$this->viewData['errorMessage'] = $userFriendlyErrMsg;
|
||||
} catch (\Exception $e2) {
|
||||
log_message('debug', 'You can probably safely ignore this: In attempt to check DB errors, CodeIgniter threw: '.PHP_EOL.$e2->getMessage());
|
||||
log_message('debug', 'You can probably safely ignore this: In attempt to check DB errors, CodeIgniter threw: ' . PHP_EOL . $e2->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,7 @@ abstract class GoBaseController extends Controller {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['session', 'go_common', 'text', 'general','jwt']; //JJO
|
||||
protected $helpers = ['session', 'go_common', 'text', 'general','jwt', 'rbac']; //JJO
|
||||
|
||||
public static $queries = [];
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ class Home extends BaseController
|
||||
public function index()
|
||||
{
|
||||
|
||||
echo view(getenv('theme.path') . 'main/defaultlayout');
|
||||
echo view(getenv('theme.path') . 'form/home/viewHome');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +48,8 @@ class TarifaAcabados extends BaseResourceController
|
||||
public function index()
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifaacabado.tarifaacabado')]),
|
||||
@ -64,6 +66,8 @@ class TarifaAcabados extends BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
@ -133,8 +137,10 @@ class TarifaAcabados extends BaseResourceController
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
|
||||
@ -40,6 +40,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
checkPermission('tarifa-extra.menu');
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
@ -51,8 +52,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-extra.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -117,6 +117,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-extra.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -129,14 +130,10 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
// JJO
|
||||
if (isset($this->model->user_updated_id)) {
|
||||
@ -192,7 +189,6 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Tarifaimpresion extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Tarifa impresion';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Tarifapapelcompra extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Tarifa papel compra';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Tarifapapeldefecto extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Tarifa papel defecto';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -40,19 +40,17 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
checkPermission('tarifa-preimpresion.menu');
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifapreimpresion.tarifapreimpresion')]);
|
||||
parent::index();
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-preimpresion.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -117,6 +115,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-preimpresion.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
|
||||
@ -55,6 +55,8 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Check if the user is allowed to list items
|
||||
checkPermission('tarifa-encuadernacion.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
@ -73,8 +75,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-encuadernacion.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -157,6 +158,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-encuadernacion.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -248,6 +250,12 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
/*public function delete($id =null){
|
||||
if (!auth()->user()->can('tarifa-encuadernacion.delete')) {
|
||||
return $this->fail('No tiene permisos');
|
||||
}
|
||||
parent::delete($id);
|
||||
}*/
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
@ -55,7 +55,10 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
|
||||
// Check if the user is allowed to list items
|
||||
checkPermission('tarifa-envio.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifasEnvios.tarifaEnvio')]),
|
||||
@ -71,9 +74,8 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
|
||||
|
||||
public function add() {
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-envio.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -142,6 +144,8 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
checkPermission('tarifa-envio.edit', $this->indexRoute);
|
||||
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -227,6 +231,10 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
// JJO
|
||||
public function delete($id = null)
|
||||
{
|
||||
/*if (!auth()->user()->can('tarifa-envio.delete')) {
|
||||
return $this->fail('Error');
|
||||
}*/
|
||||
|
||||
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
|
||||
} else {
|
||||
@ -242,7 +250,6 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
else{
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
|
||||
|
||||
$zonaModel = new TarifaEnvioZonaModel();
|
||||
$zonaResult = $zonaModel->removeAllZonasLineas($id, $datetime, $this->delete_flag);
|
||||
|
||||
|
||||
@ -51,6 +51,8 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Check if the user is allowed to list items
|
||||
checkPermission('tarifa-manipulado.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
@ -69,8 +71,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-manipulado.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -140,6 +141,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-manipulado.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -151,16 +153,13 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
// JJO
|
||||
if (isset($this->model->user_updated_id)) {
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
use App\Models\Usuarios\GroupModel;
|
||||
use App\Models\Usuarios\PermisosModel;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
|
||||
if (!function_exists('generate_php_roles_constant')) {
|
||||
function generate_php_roles_constant()
|
||||
@ -94,3 +95,28 @@ if (!function_exists('generate_php_permissions_matrix_constant')) {
|
||||
|
||||
|
||||
|
||||
|
||||
if (!function_exists('checkPermission')) {
|
||||
/**
|
||||
* Checks if the user has the required permission and redirects accordingly.
|
||||
*
|
||||
* @param string $sectionPermission The permission to check.
|
||||
* @param string|null $redirectRoute The route to redirect to if the permission is not granted.
|
||||
* @return RedirectResponse|null Redirect response if the user does not have permission, null otherwise.
|
||||
*/
|
||||
function checkPermission(string $sectionPermission, string $redirectRoute = null)
|
||||
{
|
||||
$session = \Config\Services::session();
|
||||
$response = \Config\Services::response();
|
||||
|
||||
if (!auth()->user()->can($sectionPermission)) {
|
||||
$session->setFlashdata('errorMessage', "No tiene permisos de acceso");
|
||||
|
||||
$route = $redirectRoute ?? 'home';
|
||||
return $response->redirect(route_to($route));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -742,6 +742,7 @@ return [
|
||||
"menu_pedidos_todos" => "Todos",
|
||||
|
||||
"menu_presupuestos" => "Presupuestos",
|
||||
"menu_presupuestos_clientes" => "Presupuestos (Clientes)",
|
||||
"menu_presupuesto" => "Libros",
|
||||
"menu_presupuesto_buscador" => "Buscador",
|
||||
"menu_libros" => "Libros",
|
||||
|
||||
@ -34,6 +34,7 @@ return [
|
||||
'tarifaAcabadoSection' => 'Tarifas de acabado',
|
||||
'tarifaEncuadernacionSection' => 'Tarifas de encuadernación',
|
||||
'tarifaEnvioSection' => 'Tarifas de envio',
|
||||
'tarifaExtraSection' => 'Tarifas extra',
|
||||
'proveedoresSection' => 'Proveedores',
|
||||
'paisesSection' => 'Países',
|
||||
'maquinasSection' => 'Máquinas',
|
||||
|
||||
41
ci4/app/Views/themes/vuexy/form/home/viewHome.php
Normal file
41
ci4/app/Views/themes/vuexy/form/home/viewHome.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/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">Inicio</h3>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('additionalInlineJs') ?>
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
@ -77,7 +77,7 @@ if (
|
||||
<?php if (auth()->user()->can('series-facturas.menu')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to("seriesFacturasList") ?>" class="menu-link">
|
||||
<?= lang("App.menu_series_factura") ?>
|
||||
<?= lang("App.menu_series_facturas") ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
@ -3,14 +3,22 @@
|
||||
* MENU PRESUPUESTOS VISTA CLIENTES
|
||||
*/
|
||||
if (auth()->user()->inGroup('cliente-admin')
|
||||
|| auth()->user()->inGroup('cliente-editor')) {
|
||||
|| auth()->user()->inGroup('cliente-editor')
|
||||
|| auth()->user()->inGroup('admin')
|
||||
) {
|
||||
|
||||
if (auth()->user()->can('presupuesto-cliente.menu')) {
|
||||
if (auth()->user()->can('presupuesto-cliente.menu') || auth()->user()->inGroup('admin')) {
|
||||
?>
|
||||
<li class="menu-item">
|
||||
<a href="javascript:void(0);" class="menu-link menu-toggle">
|
||||
<i class="menu-icon tf-icons ti ti-currency-dollar"></i>
|
||||
<?= lang("App.menu_presupuestos") ?>
|
||||
<?php
|
||||
echo(
|
||||
auth()->user()->inGroup('admin') ?
|
||||
lang("App.menu_presupuestos_clientes") :
|
||||
lang("App.menu_presupuestos")
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
<ul class="menu-sub">
|
||||
<li class="menu-item">
|
||||
|
||||
@ -7,7 +7,8 @@ if (
|
||||
auth()->user()->can('tarifa-manipulado.menu') ||
|
||||
auth()->user()->can('tarifa-acabado.menu') ||
|
||||
auth()->user()->can('tarifa-encuadernacion.menu') ||
|
||||
auth()->user()->can('tarifa-envio.menu')
|
||||
auth()->user()->can('tarifa-envio.menu') ||
|
||||
auth()->user()->can('tarifa-extra.menu')
|
||||
) {
|
||||
?>
|
||||
<!-- Prices -->
|
||||
@ -52,6 +53,13 @@ if (
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if (auth()->user()->can('tarifa-extra.menu')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("tarifas/tarifaextra") ?>" class="menu-link">
|
||||
<?= lang("App.menu_tarifaextra") ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
Reference in New Issue
Block a user