Merge branch 'bud/tarifas_extras' into 'main'

Bud/tarifas extras

See merge request jjimenez/safekat!280
This commit is contained in:
Ignacio Martinez Navajas
2024-07-02 11:34:05 +00:00
25 changed files with 178 additions and 242 deletions

View File

@ -21,10 +21,6 @@ const SK_PERMISSION_MATRIX = [
"presupuesto-cliente.edit", "presupuesto-cliente.edit",
"presupuesto-cliente.delete", "presupuesto-cliente.delete",
"presupuesto-cliente.menu", "presupuesto-cliente.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
"tarifa-preimpresion.menu",
"tarifa-manipulado.create", "tarifa-manipulado.create",
"tarifa-manipulado.edit", "tarifa-manipulado.edit",
"tarifa-manipulado.delete", "tarifa-manipulado.delete",
@ -41,6 +37,10 @@ const SK_PERMISSION_MATRIX = [
"tarifa-envio.edit", "tarifa-envio.edit",
"tarifa-envio.delete", "tarifa-envio.delete",
"tarifa-envio.menu", "tarifa-envio.menu",
"tarifa-extra.create",
"tarifa-extra.edit",
"tarifa-extra.delete",
"tarifa-extra.menu",
"proveedores.create", "proveedores.create",
"proveedores.edit", "proveedores.edit",
"proveedores.delete", "proveedores.delete",

View File

@ -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"
]
];

View File

@ -41,6 +41,10 @@ const SK_PERMISSIONS = [
'tarifa-envio.edit' => 'Can edit', 'tarifa-envio.edit' => 'Can edit',
'tarifa-envio.delete' => 'Can delete', 'tarifa-envio.delete' => 'Can delete',
'tarifa-envio.menu' => 'Menu shall be visualize', '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.create' => 'Can create',
'proveedores.edit' => 'Can edit', 'proveedores.edit' => 'Can edit',
'proveedores.delete' => 'Can delete', 'proveedores.delete' => 'Can delete',

View File

@ -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',
];

View File

@ -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.',
],
];

View File

@ -37,7 +37,7 @@ class BaseController extends Controller
* *
* @var array * @var array
*/ */
protected $helpers = ['general', 'go_common']; protected $helpers = ['general', 'go_common', 'rbac'];
/** /**
* Constructor. * Constructor.

View File

@ -43,23 +43,23 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
*/ */
protected static $pluralObjectName; protected static $pluralObjectName;
/** /**
* Path for the views directory for the extending view controller * Path for the views directory for the extending view controller
* *
* @var string * @var string
*/ */
protected static $viewPath; protected static $viewPath;
/** /**
* JJO: Variable para indicar si el controlador hace soft_delete o no * JJO: Variable para indicar si el controlador hace soft_delete o no
* *
* @var bool * @var bool
*/ */
public $soft_delete = false; public $soft_delete = false;
/** /**
* JJO: Variable quién puede ver los registros borrados * JJO: Variable quién puede ver los registros borrados
* *
* 0 -> Not Deleted * 0 -> Not Deleted
* 1 -> Soft Deleted, shows up in lists of deleted items for management users * 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 * 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 * @var array
*/ */
protected $helpers = ['session', 'go_common', 'form', 'text', 'general']; //JJO protected $helpers = ['session', 'go_common', 'form', 'text', 'general', 'rbac']; //JJO
/** /**
* Initializer method. * Initializer method.
@ -123,7 +123,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
$this->viewData['usingSweetAlert'] = true; $this->viewData['usingSweetAlert'] = true;
$this->viewData['viewPath'] = static::$viewPath; $this->viewData['viewPath'] = static::$viewPath;
$this->viewData['currentLocale'] = $this->request->getLocale(); $this->viewData['currentLocale'] = $this->request->getLocale();
/* IMN */ /* IMN */
@ -159,7 +159,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
} }
if (!isset($this->viewData['formAction'])) { 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)) { 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) public function delete($id = null)
{ {
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) { 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 { } else {
$objName = lang('Basic.global.record'); $objName = lang('Basic.global.record');
} }
if (!$this->soft_delete){ if (!$this->soft_delete) {
if (!$this->model->delete($id)) { if (!$this->model->delete($id)) {
return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
} }
} } else {
else{
$datetime = (new \CodeIgniter\I18n\Time("now")); $datetime = (new \CodeIgniter\I18n\Time("now"));
$rawResult = $this->model->where('id',$id) $rawResult = $this->model->where('id', $id)
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'), ->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
'is_deleted' => $this->delete_flag]) 'is_deleted' => $this->delete_flag])
->update(); ->update();
if (!$rawResult) { if (!$rawResult) {
return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
} }
} }
// $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented // $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]); $message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
$response = $this->respondDeleted(['id' => $id, 'msg' => $message]); $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) protected function canValidate($customValidationRules = null, $customValidationMessages = null)
{ {
if($customValidationRules == null){ if ($customValidationRules == null) {
$validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null; $validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null;
} } else {
else{
$validationRules = $customValidationRules; $validationRules = $customValidationRules;
} }
if ($validationRules == null) { if ($validationRules == null) {
return true; return true;
} }
if($customValidationMessages == null){ if ($customValidationMessages == null) {
$validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;; $validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;;
} } else {
else{
$validationErrorMessages = $customValidationMessages; $validationErrorMessages = $customValidationMessages;
} }
@ -283,7 +280,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
} else { } else {
$valid = $this->validate($validationRules); $valid = $this->validate($validationRules);
} }
$this->validationErrors = $valid ? '' : $this->validator->getErrors(); $this->validationErrors = $valid ? '' : $this->validator->getErrors();
/* /*
@ -303,7 +300,8 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
* @param array|null $postData * @param array|null $postData
* @return array * @return array
*/ */
protected function sanitized(array $postData = null, bool $nullIfEmpty = false) { protected function sanitized(array $postData = null, bool $nullIfEmpty = false)
{
if ($postData == null) { if ($postData == null) {
$postData = $this->request->getPost(); $postData = $this->request->getPost();
} }
@ -317,7 +315,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
} }
return $sanitizedData; return $sanitizedData;
} }
/** /**
* Custom fail method needed when CSRF token regeneration is on in security settings * Custom fail method needed when CSRF token regeneration is on in security settings
* @param string|array $messages * @param string|array $messages
@ -326,15 +324,15 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
* @param string $customMessage * @param string $customMessage
* @return mixed * @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]; $messages = ['error' => $messages];
} }
$response = [ $response = [
'status' => $status, 'status' => $status,
'error' => $status, 'error' => $status,
'messages' => $messages, 'messages' => $messages,
csrf_token() => csrf_hash() csrf_token() => csrf_hash()
]; ];
@ -360,7 +358,8 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
* Convenience method for common exception handling * Convenience method for common exception handling
* @param \Exception $e * @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 // using another try / catch block to prevent to avoid CodeIgniter bug throwing trivial exceptions for querying DB errors
try { try {
$query = $this->model->db->getLastQuery(); $query = $this->model->db->getLastQuery();
@ -368,16 +367,16 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
$dbError = $this->model->db->error(); $dbError = $this->model->db->error();
$userFriendlyErrMsg = lang('Basic.global.persistErr1', [static::$singularObjectNameCc]); $userFriendlyErrMsg = lang('Basic.global.persistErr1', [static::$singularObjectNameCc]);
if (isset($dbError['code']) && $dbError['code'] == 1062) : 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; endif;
// $userFriendlyErrMsg = str_replace("'", "\'", $userFriendlyErrMsg); // Uncomment if experiencing unescaped single quote errors // $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'])) : if (isset($dbError['message']) && !empty($dbError['message'])) :
log_message('error', $dbError['code'].' : '.$dbError['message']); log_message('error', $dbError['code'] . ' : ' . $dbError['message']);
endif; endif;
$this->viewData['errorMessage'] = $userFriendlyErrMsg; $this->viewData['errorMessage'] = $userFriendlyErrMsg;
} catch (\Exception $e2) { } 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());
} }
} }
} }

View File

@ -139,7 +139,7 @@ abstract class GoBaseController extends Controller {
* *
* @var array * @var array
*/ */
protected $helpers = ['session', 'go_common', 'text', 'general','jwt']; //JJO protected $helpers = ['session', 'go_common', 'text', 'general','jwt', 'rbac']; //JJO
public static $queries = []; public static $queries = [];

View File

@ -17,7 +17,7 @@ class Home extends BaseController
public function index() public function index()
{ {
echo view(getenv('theme.path') . 'main/defaultlayout'); echo view(getenv('theme.path') . 'form/home/viewHome');
} }

View File

@ -48,6 +48,8 @@ class TarifaAcabados extends BaseResourceController
public function index() public function index()
{ {
checkPermission('tarifa-acabado.menu');
$viewData = [ $viewData = [
'currentModule' => static::$controllerSlug, 'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifaacabado.tarifaacabado')]), 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifaacabado.tarifaacabado')]),
@ -64,6 +66,8 @@ class TarifaAcabados extends BaseResourceController
public function add() public function add()
{ {
checkPermission('tarifa-acabado.create', $this->indexRoute);
if ($this->request->getPost()) : if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1'); $nullIfEmpty = true; // !(phpversion() >= '8.1');
@ -133,8 +137,10 @@ class TarifaAcabados extends BaseResourceController
return $this->displayForm(__METHOD__); return $this->displayForm(__METHOD__);
} // end function add() } // end function add()
public function edit($requestedId = null) { public function edit($requestedId = null)
{
checkPermission('tarifa-acabado.edit', $this->indexRoute);
if ($requestedId == null) : if ($requestedId == null) :
return $this->redirect2listView(); return $this->redirect2listView();

View File

@ -40,6 +40,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
public function index() public function index()
{ {
checkPermission('tarifa-extra.menu');
$this->viewData['usingClientSideDataTable'] = true; $this->viewData['usingClientSideDataTable'] = true;
@ -51,8 +52,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
public function add() public function add()
{ {
checkPermission('tarifa-extra.create', $this->indexRoute);
if ($this->request->getPost()) : if ($this->request->getPost()) :
@ -117,6 +117,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
public function edit($requestedId = null) public function edit($requestedId = null)
{ {
checkPermission('tarifa-extra.edit', $this->indexRoute);
if ($requestedId == null) : if ($requestedId == null) :
return $this->redirect2listView(); return $this->redirect2listView();
@ -129,14 +130,10 @@ class Tarifaextra extends \App\Controllers\GoBaseController
return $this->redirect2listView('errorMessage', $message); return $this->redirect2listView('errorMessage', $message);
endif; endif;
if ($this->request->getPost()) : if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost(); $postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty); $sanitizedData = $this->sanitized($postData, true);
// JJO // JJO
if (isset($this->model->user_updated_id)) { if (isset($this->model->user_updated_id)) {
@ -192,7 +189,6 @@ class Tarifaextra extends \App\Controllers\GoBaseController
return $this->displayForm(__METHOD__, $id); return $this->displayForm(__METHOD__, $id);
} // end function edit(...) } // end function edit(...)
public function allItemsSelect() public function allItemsSelect()
{ {
if ($this->request->isAJAX()) { if ($this->request->isAJAX()) {

View File

@ -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()
{
}
}

View File

@ -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()
{
}
}

View File

@ -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()
{
}
}

View File

@ -40,19 +40,17 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
public function index() public function index()
{ {
checkPermission('tarifa-preimpresion.menu');
$this->viewData['usingClientSideDataTable'] = true; $this->viewData['usingClientSideDataTable'] = true;
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifapreimpresion.tarifapreimpresion')]); $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifapreimpresion.tarifapreimpresion')]);
parent::index(); parent::index();
} }
public function add() public function add()
{ {
checkPermission('tarifa-preimpresion.create', $this->indexRoute);
if ($this->request->getPost()) : if ($this->request->getPost()) :
@ -117,6 +115,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
public function edit($requestedId = null) public function edit($requestedId = null)
{ {
checkPermission('tarifa-preimpresion.edit', $this->indexRoute);
if ($requestedId == null) : if ($requestedId == null) :
return $this->redirect2listView(); return $this->redirect2listView();

View File

@ -55,6 +55,8 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
public function index() public function index()
{ {
// Check if the user is allowed to list items
checkPermission('tarifa-encuadernacion.menu');
$viewData = [ $viewData = [
'currentModule' => static::$controllerSlug, 'currentModule' => static::$controllerSlug,
@ -73,8 +75,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
public function add() public function add()
{ {
checkPermission('tarifa-encuadernacion.create', $this->indexRoute);
if ($this->request->getPost()) : if ($this->request->getPost()) :
@ -157,6 +158,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
public function edit($requestedId = null) public function edit($requestedId = null)
{ {
checkPermission('tarifa-encuadernacion.edit', $this->indexRoute);
if ($requestedId == null) : if ($requestedId == null) :
return $this->redirect2listView(); return $this->redirect2listView();
@ -248,6 +250,12 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
return $this->displayForm(__METHOD__, $id); return $this->displayForm(__METHOD__, $id);
} // end function edit(...) } // 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() public function datatable()
{ {

View File

@ -55,7 +55,10 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
public function index() { public function index() {
// Check if the user is allowed to list items
checkPermission('tarifa-envio.menu');
$viewData = [ $viewData = [
'currentModule' => static::$controllerSlug, 'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifasEnvios.tarifaEnvio')]), 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifasEnvios.tarifaEnvio')]),
@ -71,9 +74,8 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
public function add() { public function add() {
checkPermission('tarifa-envio.create', $this->indexRoute);
if ($this->request->getPost()) : if ($this->request->getPost()) :
@ -142,6 +144,8 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
public function edit($requestedId = null) { public function edit($requestedId = null) {
checkPermission('tarifa-envio.edit', $this->indexRoute);
if ($requestedId == null) : if ($requestedId == null) :
return $this->redirect2listView(); return $this->redirect2listView();
@ -227,6 +231,10 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
// JJO // JJO
public function delete($id = null) public function delete($id = null)
{ {
/*if (!auth()->user()->can('tarifa-envio.delete')) {
return $this->fail('Error');
}*/
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) { 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 { } else {
@ -242,7 +250,6 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
else{ else{
$datetime = (new \CodeIgniter\I18n\Time("now")); $datetime = (new \CodeIgniter\I18n\Time("now"));
$zonaModel = new TarifaEnvioZonaModel(); $zonaModel = new TarifaEnvioZonaModel();
$zonaResult = $zonaModel->removeAllZonasLineas($id, $datetime, $this->delete_flag); $zonaResult = $zonaModel->removeAllZonasLineas($id, $datetime, $this->delete_flag);

View File

@ -51,6 +51,8 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
public function index() public function index()
{ {
// Check if the user is allowed to list items
checkPermission('tarifa-manipulado.menu');
$viewData = [ $viewData = [
'currentModule' => static::$controllerSlug, 'currentModule' => static::$controllerSlug,
@ -69,8 +71,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
public function add() public function add()
{ {
checkPermission('tarifa-manipulado.create', $this->indexRoute);
if ($this->request->getPost()) : if ($this->request->getPost()) :
@ -140,6 +141,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
public function edit($requestedId = null) public function edit($requestedId = null)
{ {
checkPermission('tarifa-manipulado.edit', $this->indexRoute);
if ($requestedId == null) : if ($requestedId == null) :
return $this->redirect2listView(); return $this->redirect2listView();
@ -151,16 +153,13 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado')), $id]); $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado')), $id]);
return $this->redirect2listView('sweet-error', $message); return $this->redirect2listView('sweet-error', $message);
endif; endif;
if ($this->request->getPost()) : if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost(); $postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty); $sanitizedData = $this->sanitized($postData, true);
// JJO // JJO
if (isset($this->model->user_updated_id)) { if (isset($this->model->user_updated_id)) {

View File

@ -2,6 +2,7 @@
use App\Models\Usuarios\GroupModel; use App\Models\Usuarios\GroupModel;
use App\Models\Usuarios\PermisosModel; use App\Models\Usuarios\PermisosModel;
use CodeIgniter\HTTP\RedirectResponse;
if (!function_exists('generate_php_roles_constant')) { if (!function_exists('generate_php_roles_constant')) {
function 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;
}
}

View File

@ -742,6 +742,7 @@ return [
"menu_pedidos_todos" => "Todos", "menu_pedidos_todos" => "Todos",
"menu_presupuestos" => "Presupuestos", "menu_presupuestos" => "Presupuestos",
"menu_presupuestos_clientes" => "Presupuestos (Clientes)",
"menu_presupuesto" => "Libros", "menu_presupuesto" => "Libros",
"menu_presupuesto_buscador" => "Buscador", "menu_presupuesto_buscador" => "Buscador",
"menu_libros" => "Libros", "menu_libros" => "Libros",

View File

@ -34,6 +34,7 @@ return [
'tarifaAcabadoSection' => 'Tarifas de acabado', 'tarifaAcabadoSection' => 'Tarifas de acabado',
'tarifaEncuadernacionSection' => 'Tarifas de encuadernación', 'tarifaEncuadernacionSection' => 'Tarifas de encuadernación',
'tarifaEnvioSection' => 'Tarifas de envio', 'tarifaEnvioSection' => 'Tarifas de envio',
'tarifaExtraSection' => 'Tarifas extra',
'proveedoresSection' => 'Proveedores', 'proveedoresSection' => 'Proveedores',
'paisesSection' => 'Países', 'paisesSection' => 'Países',
'maquinasSection' => 'Máquinas', 'maquinasSection' => 'Máquinas',

View 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() ?>

View File

@ -77,7 +77,7 @@ if (
<?php if (auth()->user()->can('series-facturas.menu')) { ?> <?php if (auth()->user()->can('series-facturas.menu')) { ?>
<li class="menu-item"> <li class="menu-item">
<a href="<?= route_to("seriesFacturasList") ?>" class="menu-link"> <a href="<?= route_to("seriesFacturasList") ?>" class="menu-link">
<?= lang("App.menu_series_factura") ?> <?= lang("App.menu_series_facturas") ?>
</a> </a>
</li> </li>
<?php } ?> <?php } ?>

View File

@ -3,14 +3,22 @@
* MENU PRESUPUESTOS VISTA CLIENTES * MENU PRESUPUESTOS VISTA CLIENTES
*/ */
if (auth()->user()->inGroup('cliente-admin') 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"> <li class="menu-item">
<a href="javascript:void(0);" class="menu-link menu-toggle"> <a href="javascript:void(0);" class="menu-link menu-toggle">
<i class="menu-icon tf-icons ti ti-currency-dollar"></i> <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> </a>
<ul class="menu-sub"> <ul class="menu-sub">
<li class="menu-item"> <li class="menu-item">

View File

@ -7,7 +7,8 @@ if (
auth()->user()->can('tarifa-manipulado.menu') || auth()->user()->can('tarifa-manipulado.menu') ||
auth()->user()->can('tarifa-acabado.menu') || auth()->user()->can('tarifa-acabado.menu') ||
auth()->user()->can('tarifa-encuadernacion.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 --> <!-- Prices -->
@ -52,6 +53,13 @@ if (
</a> </a>
</li> </li>
<?php } ?> <?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> </ul>
</li> </li>
<?php } ?> <?php } ?>