Creado mecanismo de generacion de alertas tipo Boostrap (defecto) y ToastR. Aplicado a los controladores existentes

This commit is contained in:
imnavajas
2023-07-26 22:36:57 +02:00
parent 47a6c3b62a
commit d25ff9666c
28 changed files with 2214 additions and 2195 deletions

View File

@ -19,7 +19,8 @@ use App\Models\Configuracion\FormaPagoModel;
use App\Models\Configuracion\PaisModel;
class Cliente extends \App\Controllers\GoBaseResourceController {
class Cliente extends \App\Controllers\GoBaseResourceController
{
protected $modelName = ClienteModel::class;
protected $format = 'json';
@ -36,8 +37,8 @@ class Cliente extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'clienteList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Clientes.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
@ -57,7 +58,8 @@ class Cliente extends \App\Controllers\GoBaseResourceController {
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -69,11 +71,12 @@ class Cliente extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewClienteList', $viewData);
return view(static::$viewPath . 'viewClienteList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -99,7 +102,7 @@ class Cliente extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Clientes.cliente'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -109,13 +112,11 @@ class Cliente extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Clientes.cliente'))]).'.';
$message .= anchor( "admin/cliente/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -137,13 +138,14 @@ class Cliente extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createCliente');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Clientes.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -165,32 +167,30 @@ class Cliente extends \App\Controllers\GoBaseResourceController {
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
if ($this->request->getPost('credito_asegurado') == null ) {
if ($this->request->getPost('credito_asegurado') == null) {
$sanitizedData['credito_asegurado'] = false;
}
if ($this->request->getPost('disponible_fe') == null ) {
if ($this->request->getPost('disponible_fe') == null) {
$sanitizedData['disponible_fe'] = false;
}
if ($this->request->getPost('message_tracking') == null ) {
if ($this->request->getPost('message_tracking') == null) {
$sanitizedData['message_tracking'] = false;
}
if ($this->request->getPost('message_production_start') == null ) {
if ($this->request->getPost('message_production_start') == null) {
$sanitizedData['message_production_start'] = false;
}
if ($this->request->getPost('tirada_flexible') == null ) {
if ($this->request->getPost('tirada_flexible') == null) {
$sanitizedData['tirada_flexible'] = false;
}
if ($this->request->getPost('lineasEnvioFactura') == null ) {
if ($this->request->getPost('lineasEnvioFactura') == null) {
$sanitizedData['lineasEnvioFactura'] = 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);
@ -210,13 +210,11 @@ if ($this->request->getPost('lineasEnvioFactura') == null ) {
endif;
if ($noException && $successfulResult) :
$id = $clienteEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Clientes.cliente'))]).'.';
$message .= anchor( "admin/cliente/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -239,20 +237,20 @@ if ($this->request->getPost('lineasEnvioFactura') == null ) {
$this->viewData['formAction'] = route_to('updateCliente', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Clientes.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -264,15 +262,18 @@ if ($this->request->getPost('lineasEnvioFactura') == null ) {
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
foreach ($resourceData as $item) :
if (isset($item->direccion) && strlen($item->direccion) > 100) :
if (isset($item->direccion) && strlen($item->direccion) > 100) :
$item->direccion = character_limiter($item->direccion, 100);
endif;if (isset($item->comentarios_tirada_flexible) && strlen($item->comentarios_tirada_flexible) > 100) :
endif;
if (isset($item->comentarios_tirada_flexible) && strlen($item->comentarios_tirada_flexible) > 100) :
$item->comentarios_tirada_flexible = character_limiter($item->comentarios_tirada_flexible, 100);
endif;if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100) :
endif;
if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100) :
$item->comentarios_produccion = character_limiter($item->comentarios_produccion, 100);
endif;if (isset($item->comentarios) && strlen($item->comentarios) > 100) :
endif;
if (isset($item->comentarios) && strlen($item->comentarios) > 100) :
$item->comentarios = character_limiter($item->comentarios, 100);
endif;
endif;
endforeach;
return $this->respond(Collection::datatable(
@ -285,15 +286,16 @@ endif;
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -307,7 +309,8 @@ endif;
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -318,8 +321,8 @@ endif;
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -334,8 +337,9 @@ endif;
}
protected function getPaisListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
protected function getPaisListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
if (!empty($selId)) :
$paisModel = model('App\Models\Configuracion\PaisModel');
@ -348,8 +352,9 @@ endif;
}
protected function getUserListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])];
protected function getUserListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])];
if (!empty($selId)) :
$userModel = model('App\Models\Usuarios\UserModel');
@ -362,8 +367,9 @@ endif;
}
protected function getComunidadAutonomaListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])];
protected function getComunidadAutonomaListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])];
if (!empty($selId)) :
$comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel');
@ -376,8 +382,9 @@ endif;
}
protected function getUserListItems2($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])];
protected function getUserListItems2($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])];
if (!empty($selId)) :
$userModel = model('App\Models\Configuracion\UserModel');
@ -390,8 +397,9 @@ endif;
}
protected function getFormaDePagoListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('FormasPagoes.formaDePago'))])];
protected function getFormaDePagoListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('FormasPagoes.formaDePago'))])];
if (!empty($selId)) :
$formaPagoModel = model('App\Models\Configuracion\FormaPagoModel');
@ -404,8 +412,9 @@ endif;
}
protected function getProvinciaListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])];
protected function getProvinciaListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])];
if (!empty($selId)) :
$provinciaModel = model('App\Models\Configuracion\ProvinciaModel');

View File

@ -11,7 +11,8 @@ use App\Models\Clientes\ClienteModel;
use App\Models\Clientes\ClienteContactoModel;
class Clientecontactos extends \App\Controllers\GoBaseResourceController {
class Clientecontactos extends \App\Controllers\GoBaseResourceController
{
protected $modelName = ClienteContactoModel::class;
protected $format = 'json';
@ -28,15 +29,16 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'contactoDeClienteList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('ClienteContactos.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -48,12 +50,12 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewContactoDeClienteList', $viewData);
return view(static::$viewPath . 'viewContactoDeClienteList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -79,7 +81,7 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -89,13 +91,11 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]).'.';
$message .= anchor( "admin/cliente-contactos/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -112,13 +112,14 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createContactoDeCliente');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ClienteContactos.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('ClienteContactos.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -142,12 +143,10 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController {
$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);
@ -167,13 +166,11 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $clienteContactoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]).'.';
$message .= anchor( "admin/cliente-contactos/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -189,20 +186,20 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateContactoDeCliente', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ClienteContactos.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('ClienteContactos.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -214,9 +211,9 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController {
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
foreach ($resourceData as $item) :
if (isset($item->apellidos) && strlen($item->apellidos) > 100) :
if (isset($item->apellidos) && strlen($item->apellidos) > 100) :
$item->apellidos = character_limiter($item->apellidos, 100);
endif;
endif;
endforeach;
return $this->respond(Collection::datatable(
@ -229,15 +226,16 @@ endif;
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -251,7 +249,8 @@ endif;
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -262,8 +261,8 @@ endif;
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -278,8 +277,9 @@ endif;
}
protected function getClienteListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])];
protected function getClienteListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])];
if (!empty($selId)) :
$clienteModel = model('App\Models\Clientes\ClienteModel');

View File

@ -15,7 +15,8 @@ use App\Models\Configuracion\ProvinciaModel;
use App\Models\Configuracion\ComunidadAutonomaModel;
class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
class Clientedistribuidores extends \App\Controllers\GoBaseResourceController
{
protected $modelName = ClienteDistribuidorModel::class;
protected $format = 'json';
@ -32,15 +33,16 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'distribuidorDeClienteList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('ClienteDistribuidores.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -52,12 +54,12 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewDistribuidorDeClienteList', $viewData);
return view(static::$viewPath . 'viewDistribuidorDeClienteList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -83,7 +85,7 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -93,13 +95,11 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]).'.';
$message .= anchor( "admin/cliente-distribuidores/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -118,13 +118,14 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createDistribuidorDeCliente');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ClienteDistribuidores.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('ClienteDistribuidores.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -148,12 +149,10 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
$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);
@ -173,13 +172,11 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $clienteDistribuidorEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]).'.';
$message .= anchor( "admin/cliente-distribuidores/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -197,20 +194,20 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateDistribuidorDeCliente', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ClienteDistribuidores.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('ClienteDistribuidores.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -222,11 +219,12 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController {
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
foreach ($resourceData as $item) :
if (isset($item->direccion) && strlen($item->direccion) > 100) :
if (isset($item->direccion) && strlen($item->direccion) > 100) :
$item->direccion = character_limiter($item->direccion, 100);
endif;if (isset($item->horarios_entrega) && strlen($item->horarios_entrega) > 100) :
endif;
if (isset($item->horarios_entrega) && strlen($item->horarios_entrega) > 100) :
$item->horarios_entrega = character_limiter($item->horarios_entrega, 100);
endif;
endif;
endforeach;
return $this->respond(Collection::datatable(
@ -239,15 +237,16 @@ endif;
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -261,7 +260,8 @@ endif;
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -272,8 +272,8 @@ endif;
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -288,8 +288,9 @@ endif;
}
protected function getComunidadAutonomaListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])];
protected function getComunidadAutonomaListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])];
if (!empty($selId)) :
$comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel');
@ -302,8 +303,9 @@ endif;
}
protected function getPaisListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
protected function getPaisListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
if (!empty($selId)) :
$paisModel = model('App\Models\Configuracion\PaisModel');
@ -316,8 +318,9 @@ endif;
}
protected function getProvinciaListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])];
protected function getProvinciaListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])];
if (!empty($selId)) :
$provinciaModel = model('App\Models\Configuracion\ProvinciaModel');

View File

@ -11,7 +11,8 @@ use App\Models\Configuracion\PaisModel;
use App\Models\Configuracion\ComunidadAutonomaModel;
class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController
{
protected $modelName = ComunidadAutonomaModel::class;
protected $format = 'json';
@ -28,15 +29,16 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'comunidadAutonomaList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('ComunidadesAutonomas.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -48,12 +50,12 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewComunidadAutonomaList', $viewData);
return view(static::$viewPath . 'viewComunidadAutonomaList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -79,7 +81,7 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -89,13 +91,11 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))]).'.';
$message .= anchor( "admin/comunidades-autonomas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -112,13 +112,14 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createComunidadAutonoma');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ComunidadesAutonomas.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('ComunidadesAutonomas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -142,12 +143,10 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
$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);
@ -167,13 +166,11 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $comunidadAutonomaEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))]).'.';
$message .= anchor( "admin/comunidades-autonomas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -189,20 +186,20 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateComunidadAutonoma', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ComunidadesAutonomas.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('ComunidadesAutonomas.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -224,15 +221,16 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -246,7 +244,8 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -257,8 +256,8 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -273,8 +272,9 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController {
}
protected function getPaisListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
protected function getPaisListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
if (!empty($selId)) :
$paisModel = model('App\Models\Configuracion\PaisModel');

View File

@ -3,7 +3,8 @@
use App\Entities\Configuracion\FormasPagoEntity;
class Formaspago extends \App\Controllers\GoBaseController {
class Formaspago extends \App\Controllers\GoBaseController
{
use \CodeIgniter\API\ResponseTrait;
@ -19,8 +20,8 @@ class Formaspago extends \App\Controllers\GoBaseController {
protected $indexRoute = 'formaPagoList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('FormasPagoes.moduleTitle');
parent::initController($request, $response, $logger);
$this->viewData['usingSweetAlert'] = true;
@ -33,7 +34,8 @@ class Formaspago extends \App\Controllers\GoBaseController {
}
}
public function index() {
public function index()
{
$this->viewData['usingClientSideDataTable'] = true;
@ -42,7 +44,8 @@ class Formaspago extends \App\Controllers\GoBaseController {
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -67,7 +70,7 @@ class Formaspago extends \App\Controllers\GoBaseController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('FormasPagoes.formaPago'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -77,9 +80,7 @@ class Formaspago extends \App\Controllers\GoBaseController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('FormasPagoes.formaPago'))]).'.';
$message .= anchor(route_to('editFormaPago', $id), lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -99,13 +100,14 @@ class Formaspago extends \App\Controllers\GoBaseController {
$this->viewData['formAction'] = route_to('createFormaPago');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('FormasPagoes.formaPago').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPagoes.formaPago') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -128,7 +130,6 @@ class Formaspago extends \App\Controllers\GoBaseController {
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
@ -152,9 +153,7 @@ class Formaspago extends \App\Controllers\GoBaseController {
endif;
if ($noException && $successfulResult) :
$id = $formasPagoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('FormasPagoes.formaPago'))]).'.';
$message .= anchor(route_to('editFormaPago', $id), lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -173,23 +172,23 @@ class Formaspago extends \App\Controllers\GoBaseController {
$this->viewData['formAction'] = route_to('updateFormaPago', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('FormasPagoes.formaPago').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPagoes.formaPago') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -203,7 +202,8 @@ class Formaspago extends \App\Controllers\GoBaseController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -214,8 +214,8 @@ class Formaspago extends \App\Controllers\GoBaseController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -9,7 +9,8 @@ use App\Entities\Configuracion\FormaPagoEntity;
use App\Models\Configuracion\FormaPagoModel;
class Formaspagos extends \App\Controllers\GoBaseResourceController {
class Formaspagos extends \App\Controllers\GoBaseResourceController
{
protected $modelName = FormaPagoModel::class;
protected $format = 'json';
@ -26,15 +27,16 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'formaDePagoList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('FormasPagoes.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -46,12 +48,12 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewFormaDePagoList', $viewData);
return view(static::$viewPath . 'viewFormaDePagoList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -77,7 +79,7 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('FormasPagoes.formaDePago'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -87,13 +89,11 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('FormasPagoes.formaDePago'))]).'.';
$message .= anchor( "admin/formas-pagos/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -109,13 +109,14 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createFormaDePago');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('FormasPagoes.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPagoes.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -139,12 +140,10 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
$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);
@ -164,13 +163,11 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $formaPagoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('FormasPagoes.formaDePago'))]).'.';
$message .= anchor( "admin/formas-pagos/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -185,20 +182,20 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateFormaDePago', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('FormasPagoes.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPagoes.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -220,15 +217,16 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -242,7 +240,8 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -253,8 +252,8 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -24,9 +24,10 @@ class Group extends \App\Controllers\GoBaseController
private $group_user_model;
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
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/';
self::$viewPath = getenv('theme.path') . 'form/group/';
parent::initController($request, $response, $logger);
@ -55,7 +56,6 @@ class Group extends \App\Controllers\GoBaseController
$postData = $this->request->getPost();
$title = $postData['title'];
$dashboard = $postData['dashboard'];
unset($postData['title']);
@ -66,27 +66,26 @@ class Group extends \App\Controllers\GoBaseController
$controller = null;
$rules_access = null;
foreach ($postData as $key=>$value){
$exp = explode('_',$key);
foreach ($postData as $key => $value) {
$exp = explode('_', $key);
$controller[] = $exp[0];
}
if($controller != null){
foreach (array_unique($controller) as $item){
if ($controller != null) {
foreach (array_unique($controller) as $item) {
$rules_access[$item] = [];
foreach ($postData as $key=>$value){
$exp = explode('_',$key);
if($exp[0] == $item){
array_push($rules_access[$item],str_replace($exp[0].'_','',$key)) ;
foreach ($postData as $key => $value) {
$exp = explode('_', $key);
if ($exp[0] == $item) {
array_push($rules_access[$item], str_replace($exp[0] . '_', '', $key));
}
}
}
}
$temp_data['rules'] = json_encode($rules_access??'{}');
$temp_data['rules'] = json_encode($rules_access ?? '{}');
$temp_data['token'] = md5(uniqid(rand(), true));;
$temp_data['title'] = $title;
$temp_data['dashboard'] = $dashboard;
@ -105,7 +104,7 @@ class Group extends \App\Controllers\GoBaseController
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Group.userGroup'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -115,13 +114,11 @@ class Group extends \App\Controllers\GoBaseController
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Group.userGroup'))]).'.';
$message .= anchor( "admin/user-groups/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -137,14 +134,15 @@ class Group extends \App\Controllers\GoBaseController
$this->viewData['formAction'] = route_to('createGroup');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Group.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Group.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
}
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
helper('general');
$session = session();
@ -180,26 +178,26 @@ class Group extends \App\Controllers\GoBaseController
$controller = null;
$rules_access = null;
foreach ($postData as $key=>$value){
$exp = explode('_',$key);
foreach ($postData as $key => $value) {
$exp = explode('_', $key);
$controller[] = $exp[0];
}
if($controller != null){
foreach (array_unique($controller) as $item){
if ($controller != null) {
foreach (array_unique($controller) as $item) {
$rules_access[$item] = [];
foreach ($postData as $key=>$value){
$exp = explode('_',$key);
if($exp[0] == $item){
array_push($rules_access[$item],str_replace($exp[0].'_','',$key)) ;
foreach ($postData as $key => $value) {
$exp = explode('_', $key);
if ($exp[0] == $item) {
array_push($rules_access[$item], str_replace($exp[0] . '_', '', $key));
}
}
}
}
$temp_data['id_group'] = $id_group;
$temp_data['rules'] = json_encode($rules_access??'{}');
$temp_data['rules'] = json_encode($rules_access ?? '{}');
$temp_data['token'] = $token;
$temp_data['title'] = $title;
$temp_data['dashboard'] = $dashboard;
@ -211,7 +209,6 @@ class Group extends \App\Controllers\GoBaseController
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
@ -231,11 +228,9 @@ class Group extends \App\Controllers\GoBaseController
endif;
if ($noException && $successfulResult) :
$id = $groupEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Group.userGroup'))]).'.';
$message .= anchor(route_to('editGroup', $id), lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if($session->get('group') == $this->request->getPost('token')){
if ($session->get('group') == $this->request->getPost('token')) {
$session->set('rules', $temp_data['rules']);
}
if ($thenRedirect) :
@ -255,23 +250,23 @@ class Group extends \App\Controllers\GoBaseController
$this->viewData['formAction'] = route_to('updateGroup', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Group.userGroup').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Group.userGroup') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -285,7 +280,8 @@ class Group extends \App\Controllers\GoBaseController
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -296,8 +292,8 @@ class Group extends \App\Controllers\GoBaseController
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -9,7 +9,8 @@ use App\Entities\Configuracion\Imposicion;
use App\Models\Configuracion\ImposicionModel;
class Imposiciones extends \App\Controllers\GoBaseResourceController {
class Imposiciones extends \App\Controllers\GoBaseResourceController
{
protected $modelName = ImposicionModel::class;
protected $format = 'json';
@ -26,15 +27,16 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'imposicionList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Imposiciones.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -46,12 +48,12 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewImposicionList', $viewData);
return view(static::$viewPath . 'viewImposicionList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -77,7 +79,7 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Imposiciones.imposicion'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -87,13 +89,11 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Imposiciones.imposicion'))]).'.';
$message .= anchor( "admin/imposiciones/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -110,13 +110,14 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createImposicion');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Imposiciones.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Imposiciones.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -140,12 +141,10 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
$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);
@ -165,13 +164,11 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $imposicion->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Imposiciones.imposicion'))]).'.';
$message .= anchor( "admin/imposiciones/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -187,20 +184,20 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateImposicion', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Imposiciones.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Imposiciones.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -222,15 +219,16 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', ancho', 'ancho', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', ancho', 'ancho', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->ancho = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->ancho = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -244,7 +242,8 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -255,8 +254,8 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -271,7 +270,8 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController {
}
protected function getOrientacionOptions() {
protected function getOrientacionOptions()
{
$orientacionOptions = [
'' => lang('Basic.global.pleaseSelect'),
'H' => 'H',

View File

@ -9,7 +9,8 @@ use App\Entities\Configuracion\Maquina;
use App\Models\Configuracion\MaquinaModel;
class Maquinas extends \App\Controllers\GoBaseResourceController {
class Maquinas extends \App\Controllers\GoBaseResourceController
{
protected $modelName = MaquinaModel::class;
protected $format = 'json';
@ -26,8 +27,8 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'maquinaList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Maquinas.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
@ -48,7 +49,8 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -60,11 +62,12 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewMaquinaList', $viewData);
return view(static::$viewPath . 'viewMaquinaList', $viewData);
}
public function add() {
public function add()
{
// JJO
$session = session();
@ -94,7 +97,7 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Maquinas.maquina'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -104,14 +107,12 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Maquinas.maquina'))]).'.';
$message .= anchor( "maquinas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
return redirect()->to(site_url('configuracion/maquinas/edit/'.$id))->with('sweet-success', $message);
return redirect()->to(site_url('configuracion/maquinas/edit/' . $id))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -129,13 +130,14 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createMaquina');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Maquinas.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Maquinas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
// JJO
$session = session();
@ -160,13 +162,13 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
if ($this->request->getPost('is_padre') == null ) {
if ($this->request->getPost('is_padre') == null) {
$sanitizedData['is_padre'] = false;
}
if ($this->request->getPost('is_rotativa') == null ) {
if ($this->request->getPost('is_rotativa') == null) {
$sanitizedData['is_rotativa'] = false;
}
if ($this->request->getPost('is_tinta') == null ) {
if ($this->request->getPost('is_tinta') == null) {
$sanitizedData['is_tinta'] = false;
}
@ -177,17 +179,15 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
if ($this->canValidate()) :
//JJO: comprobar alto y ancho impresion < alto y ancho
if($sanitizedData['alto'] < $sanitizedData['alto_impresion']){
if ($sanitizedData['alto'] < $sanitizedData['alto_impresion']) {
$successfulResult = false;
$this->viewData['errorMessage'] = lang('Maquinas.validation.alto_menor_alto_impresion');;
$this->session->setFlashdata('formErrors', $this->model->errors());
}
else if ($sanitizedData['ancho'] < $sanitizedData['ancho_impresion']){
} else if ($sanitizedData['ancho'] < $sanitizedData['ancho_impresion']) {
$successfulResult = false;
$this->viewData['errorMessage'] = lang('Maquinas.validation.ancho_menor_ancho_impresion');;
$this->session->setFlashdata('formErrors', $this->model->errors());
}
else{
} else {
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
@ -208,9 +208,7 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $maquina->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Maquinas.maquina'))]).'.';
$message .= anchor( "maquinas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -231,20 +229,20 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateMaquina', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Maquinas.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Maquinas.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -271,15 +269,16 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -293,7 +292,8 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -304,8 +304,8 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -320,8 +320,9 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
}
protected function getMaquinaListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
protected function getMaquinaListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
if (!empty($selId)) :
$maquinaModel = model('App\Models\Configuracion\MaquinaModel');
@ -334,7 +335,8 @@ class Maquinas extends \App\Controllers\GoBaseResourceController {
}
protected function getTipoOptions() {
protected function getTipoOptions()
{
$tipoOptions = [
'' => lang('Basic.global.pleaseSelect'),
'impresion' => 'impresion',

View File

@ -11,7 +11,8 @@ use App\Models\Configuracion\MaquinaModel;
use App\Models\Configuracion\MaquinasDefectoModel;
class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
class Maquinasdefecto extends \App\Controllers\GoBaseResourceController
{
protected $modelName = MaquinasDefectoModel::class;
protected $format = 'json';
@ -28,8 +29,8 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'maquinaPorDefectoList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('MaquinasPorDefecto.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
@ -42,7 +43,8 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -54,11 +56,12 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewMaquinaPorDefectoList', $viewData);
return view(static::$viewPath . 'viewMaquinaPorDefectoList', $viewData);
}
public function add() {
public function add()
{
// JJO
$session = session();
@ -84,10 +87,9 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
// En caso de error se devuelve un mensaje.
try {
$error = $this->model->checkIntervals($sanitizedData);
if(empty($error)){
if (empty($error)) {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
}
else{
} else {
$successfulResult = false;
$this->viewData['errorMessage'] = $error;
$this->session->setFlashdata('formErrors', $this->model->errors());
@ -97,7 +99,7 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -107,9 +109,7 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]).'.';
$message .= anchor( "configuracion/maquinasdefecto/edit/{$id}" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -131,13 +131,14 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createMaquinaPorDefecto');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('MaquinasPorDefecto.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('MaquinasPorDefecto.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
// JJO
$session = session();
@ -174,10 +175,9 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
// En caso de error se devuelve un mensaje.
try {
$error = $this->model->checkIntervals($sanitizedData, $id);
if(empty($error)){
if (empty($error)) {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
}
else{
} else {
$successfulResult = false;
$this->viewData['errorMessage'] = $error;
$this->session->setFlashdata('formErrors', $this->model->errors());
@ -198,9 +198,7 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $maquinasDefectoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]).'.';
$message .= anchor( "maquinasdefecto/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -221,20 +219,20 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateMaquinaPorDefecto', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('MaquinasPorDefecto.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('MaquinasPorDefecto.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -259,15 +257,16 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', tipo', 'tipo', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', tipo', 'tipo', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->tipo = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->tipo = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -281,7 +280,8 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -292,8 +292,8 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -308,8 +308,9 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
}
protected function getMaquinaListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
protected function getMaquinaListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
if (!empty($selId)) :
$maquinaModel = model('App\Models\Configuracion\MaquinaModel');
@ -322,7 +323,8 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController {
}
protected function getTipoOptions() {
protected function getTipoOptions()
{
$tipoOptions = [
'' => lang('Basic.global.pleaseSelect'),
'bn' => 'bn',

View File

@ -22,7 +22,8 @@ use
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController {
class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
{
protected $modelName = MaquinasTarifasImpresionModel::class;
protected $format = 'json';
@ -39,15 +40,16 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
protected $indexRoute = 'maquinasTarifaImpresionList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('MaquinasTarifasImpresions.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -59,12 +61,12 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewMaquinasTarifaImpresionList', $viewData);
return view(static::$viewPath . 'viewMaquinasTarifaImpresionList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -90,7 +92,7 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -100,9 +102,7 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]).'.';
$message .= anchor( "maquinastarifasimpresion/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -124,13 +124,14 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
$this->viewData['formAction'] = route_to('createMaquinasTarifaImpresion');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('MaquinasTarifasImpresions.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('MaquinasTarifasImpresions.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -152,17 +153,15 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
if ($this->request->getPost('predeterminado') == null ) {
if ($this->request->getPost('predeterminado') == null) {
$sanitizedData['predeterminado'] = 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);
@ -182,9 +181,7 @@ if ($this->request->getPost('predeterminado') == null ) {
endif;
if ($noException && $successfulResult) :
$id = $maquinasTarifasImpresion->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]).'.';
$message .= anchor( "maquinastarifasimpresion/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -205,67 +202,67 @@ if ($this->request->getPost('predeterminado') == null ) {
$this->viewData['formAction'] = route_to('updateMaquinasTarifaImpresion', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('MaquinasTarifasImpresions.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('MaquinasTarifasImpresions.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable_editor() {
public function datatable_editor()
{
if ($this->request->isAJAX()) {
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
// Build our Editor instance and process the data coming from _POST
$response = Editor::inst( $db, 'lg_maquinas_tarifas_impresion' )
$response = Editor::inst($db, 'lg_maquinas_tarifas_impresion')
->fields(
Field::inst( 'uso' )
->validator( 'Validate::notEmpty',array(
'message' => lang('MaquinasTarifasImpresions.validation.uso.required') )
Field::inst('uso')
->validator('Validate::notEmpty', array(
'message' => lang('MaquinasTarifasImpresions.validation.uso.required'))
),
Field::inst( 'tipo' )
->validator( 'Validate::notEmpty',array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required') )
Field::inst('tipo')
->validator('Validate::notEmpty', array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
),
Field::inst( 'precio' )
->validator( 'Validate::numeric', array(
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal') )
Field::inst('precio')
->validator('Validate::numeric', array(
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required') )
->validator('Validate::notEmpty', array(
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
),
Field::inst( 'maquina_id' ),
Field::inst( 'user_created_id' ),
Field::inst( 'created_at' ),
Field::inst( 'user_updated_id' ),
Field::inst( 'updated_at' ),
Field::inst( 'is_deleted' ),
Field::inst( 'deleted_at' ),
Field::inst('maquina_id'),
Field::inst('user_created_id'),
Field::inst('created_at'),
Field::inst('user_updated_id'),
Field::inst('updated_at'),
Field::inst('is_deleted'),
Field::inst('deleted_at'),
)
->validator( function($editor, $action, $data){
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
foreach ($data['data'] as $pkey => $values ){
->validator(function ($editor, $action, $data) {
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) {
foreach ($data['data'] as $pkey => $values) {
// Si no se quiere borrar...
if($data['data'][$pkey]['is_deleted'] != 1)
{
if ($data['data'][$pkey]['is_deleted'] != 1) {
// Cubierta y sobrecubierta sólo pueden ser en color
if($values['uso'] != 'interior' && $values['tipo'] != 'color'){
if ($values['uso'] != 'interior' && $values['tipo'] != 'color') {
return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color');
}
$builder = $this->model->select('*')
->where(array(
'maquina_id'=> $values['maquina_id'],
'tipo'=> $values['tipo'],
'uso'=> $values['uso'],
'is_deleted'=> 0));
'maquina_id' => $values['maquina_id'],
'tipo' => $values['tipo'],
'uso' => $values['uso'],
'is_deleted' => 0));
// No se pueden duplicar valores al crear o al editar
if ($builder->countAllResults() >= 1){
if(($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey)
|| $action === Editor::ACTION_CREATE){
if ($builder->countAllResults() >= 1) {
if (($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey)
|| $action === Editor::ACTION_CREATE) {
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
}
@ -274,28 +271,28 @@ if ($this->request->getPost('predeterminado') == null ) {
}
}
})
->on( 'preCreate', function ( $editor, &$values ) {
->on('preCreate', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field( 'user_created_id' )
->setValue( $session->id_user );
->field('user_created_id')
->setValue($session->id_user);
$editor
->field( 'created_at' )
->setValue( $datetime->format('Y-m-d H:i:s') );
} )
->on( 'preEdit', function ( $editor, &$values ) {
->field('created_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->on('preEdit', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field( 'user_updated_id' )
->setValue( $session->id_user );
->field('user_updated_id')
->setValue($session->id_user);
$editor
->field( 'updated_at' )
->setValue( $datetime->format('Y-m-d H:i:s') );
} )
->field('updated_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->debug(true)
->process( $_POST )
->process($_POST)
->data();
@ -318,12 +315,13 @@ if ($this->request->getPost('predeterminado') == null ) {
}
}
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -347,15 +345,16 @@ if ($this->request->getPost('predeterminado') == null ) {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', maquina_id', 'maquina_id', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', maquina_id', 'maquina_id', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->maquina_id = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->maquina_id = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -369,7 +368,8 @@ if ($this->request->getPost('predeterminado') == null ) {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -380,8 +380,8 @@ if ($this->request->getPost('predeterminado') == null ) {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -396,8 +396,9 @@ if ($this->request->getPost('predeterminado') == null ) {
}
protected function getMaquinaListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
protected function getMaquinaListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
if (!empty($selId)) :
$maquinaModel = model('App\Models\Configuracion\MaquinaModel');
@ -410,7 +411,8 @@ if ($this->request->getPost('predeterminado') == null ) {
}
protected function getTipoOptions() {
protected function getTipoOptions()
{
$tipoOptions = [
'' => lang('Basic.global.pleaseSelect'),
'negro' => 'negro',

View File

@ -9,7 +9,8 @@ use App\Entities\Configuracion\PaisEntity;
use App\Models\Configuracion\PaisModel;
class Paises extends \App\Controllers\GoBaseResourceController {
class Paises extends \App\Controllers\GoBaseResourceController
{
protected $modelName = PaisModel::class;
protected $format = 'json';
@ -26,15 +27,16 @@ class Paises extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'paisList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Paises.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -46,12 +48,12 @@ class Paises extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewPaisList', $viewData);
return view(static::$viewPath . 'viewPaisList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -77,7 +79,7 @@ class Paises extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Paises.pais'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -87,13 +89,11 @@ class Paises extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Paises.pais'))]).'.';
$message .= anchor( "admin/paises/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -109,13 +109,14 @@ class Paises extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createPais');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Paises.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Paises.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -137,17 +138,15 @@ class Paises extends \App\Controllers\GoBaseResourceController {
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
if ($this->request->getPost('show_erp') == null ) {
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);
@ -167,13 +166,11 @@ if ($this->request->getPost('show_erp') == null ) {
endif;
if ($noException && $successfulResult) :
$id = $paisEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Paises.pais'))]).'.';
$message .= anchor( "admin/paises/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -188,20 +185,20 @@ if ($this->request->getPost('show_erp') == null ) {
$this->viewData['formAction'] = route_to('updatePais', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Paises.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Paises.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -223,15 +220,16 @@ if ($this->request->getPost('show_erp') == null ) {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -245,7 +243,8 @@ if ($this->request->getPost('show_erp') == null ) {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -256,8 +255,8 @@ if ($this->request->getPost('show_erp') == null ) {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -95,7 +95,7 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController
$this->dealWithException($e);
}
else :
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -105,9 +105,7 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]) . '.';
$message .= anchor("papelesgenericos/{$id}/edit", lang('Basic.global.continueEditing') . '?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -185,9 +183,7 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController
endif;
if ($noException && $successfulResult) :
$id = $papelGenerico->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]) . '.';
$message .= anchor("papelesgenericos/{$id}/edit", lang('Basic.global.continueEditing') . '?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :

View File

@ -118,7 +118,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
$this->dealWithException($e);
}
else :
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelImpresion.papelImpresion'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -128,9 +128,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('PapelImpresion.papelImpresion'))]) . '.';
$message .= anchor("papelesimpresion/{$id}/edit", lang('Basic.global.continueEditing') . '?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -232,9 +230,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
endif;
if ($noException && $successfulResult) :
$id = $papelImpresion->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('PapelImpresion.papelImpresion'))]) . '.';
$message .= anchor("papelesimpresion/{$id}/edit", lang('Basic.global.continueEditing') . '?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :

View File

@ -78,7 +78,7 @@ class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -88,9 +88,7 @@ class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]).'.';
$message .= anchor( "papelimpresiontipologias/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -177,9 +175,7 @@ class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController
if ($noException && $successfulResult) :
$id = $papelImpresionTipologia->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]).'.';
$message .= anchor( "papelimpresiontipologias/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :

View File

@ -11,7 +11,8 @@ use App\Models\Configuracion\PaisModel;
use App\Models\Configuracion\ProvinciaModel;
class Provincias extends \App\Controllers\GoBaseResourceController {
class Provincias extends \App\Controllers\GoBaseResourceController
{
protected $modelName = ProvinciaModel::class;
protected $format = 'json';
@ -28,15 +29,16 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'provinciaList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Provincias.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -48,12 +50,12 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewProvinciaList', $viewData);
return view(static::$viewPath . 'viewProvinciaList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -79,7 +81,7 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Provincias.provincia'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -89,13 +91,11 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Provincias.provincia'))]).'.';
$message .= anchor( "admin/provincias/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -112,13 +112,14 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createProvincia');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Provincias.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Provincias.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -142,12 +143,10 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
$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);
@ -167,13 +166,11 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $provinciaEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Provincias.provincia'))]).'.';
$message .= anchor( "admin/provincias/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
@ -189,20 +186,20 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateProvincia', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Provincias.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Provincias.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -224,15 +221,16 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -246,7 +244,8 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -257,8 +256,8 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -273,8 +272,9 @@ class Provincias extends \App\Controllers\GoBaseResourceController {
}
protected function getPaisListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
protected function getPaisListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
if (!empty($selId)) :
$paisModel = model('App\Models\Configuracion\PaisModel');

View File

@ -3,7 +3,8 @@
use App\Entities\Configuracion\TipologiasEntity;
class Tipologias extends \App\Controllers\GoBaseController {
class Tipologias extends \App\Controllers\GoBaseController
{
use \CodeIgniter\API\ResponseTrait;
@ -19,14 +20,15 @@ class Tipologias extends \App\Controllers\GoBaseController {
protected $indexRoute = 'tipologiaLibrosList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('TipologiasLibros.moduleTitle');
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$this->viewData['usingClientSideDataTable'] = true;
@ -35,8 +37,8 @@ class Tipologias extends \App\Controllers\GoBaseController {
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -61,7 +63,7 @@ class Tipologias extends \App\Controllers\GoBaseController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TipologiasLibros.tipologiaLibros'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -71,9 +73,7 @@ class Tipologias extends \App\Controllers\GoBaseController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('TipologiasLibros.tipologiaLibros'))]).'.';
$message .= anchor(route_to('editTipologiaLibros', $id), lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -93,13 +93,14 @@ class Tipologias extends \App\Controllers\GoBaseController {
$this->viewData['formAction'] = route_to('createTipologiaLibros');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TipologiasLibros.tipologiaLibros').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('TipologiasLibros.tipologiaLibros') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -122,12 +123,10 @@ class Tipologias extends \App\Controllers\GoBaseController {
$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);
@ -147,9 +146,7 @@ class Tipologias extends \App\Controllers\GoBaseController {
endif;
if ($noException && $successfulResult) :
$id = $tipologiasEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TipologiasLibros.tipologiaLibros'))]).'.';
$message .= anchor(route_to('editTipologiaLibros', $id), lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -168,23 +165,23 @@ class Tipologias extends \App\Controllers\GoBaseController {
$this->viewData['formAction'] = route_to('updateTipologiaLibros', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TipologiasLibros.tipologiaLibros').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('TipologiasLibros.tipologiaLibros') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -198,7 +195,8 @@ class Tipologias extends \App\Controllers\GoBaseController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -209,8 +207,8 @@ class Tipologias extends \App\Controllers\GoBaseController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -68,6 +68,15 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon
*/
public $delete_flag = 0;
/**
* IMN: Variable para seleccionar el tipo de mensajeria que usa una clase
*
* 'alerts' -> Boostrap 5 default alerts
* 'toastr' -> Javascript ToastR library
* @var string
*/
public $alertStyle = 'alerts';
/**
* An array of helpers to be loaded automatically upon
@ -116,6 +125,9 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon
$this->viewData['viewPath'] = static::$viewPath;
$this->viewData['currentLocale'] = $this->request->getLocale();
/* IMN */
$this->viewData['alertStyle'] = $this->alertStyle;
}
/**

View File

@ -98,7 +98,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -108,9 +108,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]) . '.';
$message .= anchor("tarifasacabado/{$id}/edit", lang('Basic.global.continueEditing') . '?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -120,9 +118,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
return $this->redirect2listView('sweet-success', $message);
endif;
else:
//JJO
$this->viewData['successMessage'] = $message;
//$this->session->setFlashData('sweet-success', $message);
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
@ -194,9 +190,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
if ($noException && $successfulResult) :
$id = $tarifaacabadoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]) . '.';
//$message .= anchor("tarifasacabado/{$id}/edit", lang('Basic.global.continueEditing') . '?');
//$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -205,8 +199,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
return $this->redirect2listView('sweet-success', $message);
endif;
else:
//JJO
$this->viewData['successMessage'] = $message;
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult

View File

@ -24,7 +24,8 @@ use
use function PHPUnit\Framework\isEmpty;
class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController
{
protected $modelName = TarifaAcabadoLineaModel::class;
protected $format = 'json';
@ -41,15 +42,16 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'tarifaAcabadoLineaList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('TarifaAcabadoLineas.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -61,12 +63,12 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewTarifaAcabadoLineaList', $viewData);
return view(static::$viewPath . 'viewTarifaAcabadoLineaList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -92,7 +94,7 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaAcabadoLineas.tarifaAcabadoLinea'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -102,9 +104,7 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('TarifaAcabadoLineas.tarifaAcabadoLinea'))]).'.';
$message .= anchor( "tarifa-acabado-lineas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -125,13 +125,14 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createTarifaAcabadoLinea');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaAcabadoLineas.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('TarifaAcabadoLineas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -155,12 +156,10 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
$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);
@ -180,9 +179,7 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $tarifaAcabadoLinea->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaAcabadoLineas.tarifaAcabadoLinea'))]).'.';
$message .= anchor( "tarifa-acabado-lineas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -202,20 +199,20 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateTarifaAcabadoLinea', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaAcabadoLineas.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('TarifaAcabadoLineas.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
@ -242,97 +239,98 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
}
}
public function datatable_editor() {
public function datatable_editor()
{
if ($this->request->isAJAX()) {
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
// Build our Editor instance and process the data coming from _POST
$response = Editor::inst( $db, 'tarifa_acabado_lineas' )
$response = Editor::inst($db, 'tarifa_acabado_lineas')
->fields(
Field::inst( 'paginas_min' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal') )
Field::inst('paginas_min')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required'))
),
Field::inst( 'paginas_max' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal') )
Field::inst('paginas_max')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required'))
),
Field::inst( 'precio_min' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') )
Field::inst('precio_min')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required'))
),
Field::inst( 'precio_max' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') )
Field::inst('precio_max')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required'))
),
Field::inst( 'margen' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') )
Field::inst('margen')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.margen.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
),
Field::inst( 'tarifa_acabado_id' ),
Field::inst( 'user_created_id' ),
Field::inst( 'created_at' ),
Field::inst( 'user_updated_id' ),
Field::inst( 'updated_at' ),
Field::inst( 'is_deleted' ),
Field::inst( 'deleted_at' ),
Field::inst('tarifa_acabado_id'),
Field::inst('user_created_id'),
Field::inst('created_at'),
Field::inst('user_updated_id'),
Field::inst('updated_at'),
Field::inst('is_deleted'),
Field::inst('deleted_at'),
)
->validator( function($editor, $action, $data){
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
foreach ($data['data'] as $pkey => $values ){
->validator(function ($editor, $action, $data) {
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) {
foreach ($data['data'] as $pkey => $values) {
// Si no se quiere borrar...
if($data['data'][$pkey]['is_deleted'] != 1){
if ($data['data'][$pkey]['is_deleted'] != 1) {
$process_data['paginas_min'] = $data['data'][$pkey]['paginas_min'];
$process_data['paginas_max'] = $data['data'][$pkey]['paginas_max'];
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_acabado_id']);
// No se pueden duplicar valores al crear o al editar
if (!empty($response)){
if (!empty($response)) {
return $response;
}
}
}
}
})
->on( 'preCreate', function ( $editor, &$values ) {
->on('preCreate', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field( 'user_created_id' )
->setValue( $session->id_user );
->field('user_created_id')
->setValue($session->id_user);
$editor
->field( 'created_at' )
->setValue( $datetime->format('Y-m-d H:i:s') );
} )
->on( 'preEdit', function ( $editor, &$values ) {
->field('created_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->on('preEdit', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field( 'user_updated_id' )
->setValue( $session->id_user );
->field('user_updated_id')
->setValue($session->id_user);
$editor
->field( 'updated_at' )
->setValue( $datetime->format('Y-m-d H:i:s') );
} )
->field('updated_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->debug(true)
->process( $_POST )
->process($_POST)
->data();
// if unique key is set in DB
@ -354,15 +352,16 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', tarifa_acabado_id', 'tarifa_acabado_id', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', tarifa_acabado_id', 'tarifa_acabado_id', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->tarifa_acabado_id = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->tarifa_acabado_id = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -376,7 +375,8 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -387,8 +387,8 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -403,8 +403,9 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
}
protected function getTarifaAcabadoListItems($selId = null) {
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Tarifaacabado.tarifaAcabado'))])];
protected function getTarifaAcabadoListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Tarifaacabado.tarifaAcabado'))])];
if (!empty($selId)) :
$tarifaacabadoModel = model('App\Models\tarifas\TarifaacabadoModel');

View File

@ -21,7 +21,8 @@ use
DataTables\Editor\ValidateOptions;
class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceController {
class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceController
{
protected $modelName = TarifaEncuadernacionLineaModel::class;
protected $format = 'json';
@ -38,15 +39,16 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
protected $indexRoute = 'tarifaEncuadernacionLineaList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('TarifaEncuadernacionLineas.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -58,12 +60,12 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewTarifaEncuadernacionLineaList', $viewData);
return view(static::$viewPath . 'viewTarifaEncuadernacionLineaList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -89,7 +91,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -99,9 +101,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]).'.';
$message .= anchor( "tarifaencuadernacionlineas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -121,13 +121,14 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
$this->viewData['formAction'] = route_to('createTarifaEncuadernacionLinea');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaEncuadernacionLineas.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('TarifaEncuadernacionLineas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -151,12 +152,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
$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);
@ -176,9 +175,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
endif;
if ($noException && $successfulResult) :
$id = $tarifaEncuadernacionLinea->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]).'.';
$message .= anchor( "tarifaencuadernacionlineas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -197,104 +194,104 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
$this->viewData['formAction'] = route_to('updateTarifaEncuadernacionLinea', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaEncuadernacionLineas.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('TarifaEncuadernacionLineas.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable_editor() {
public function datatable_editor()
{
if ($this->request->isAJAX()) {
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
// Build our Editor instance and process the data coming from _POST
$response = Editor::inst( $db, 'tarifa_encuadernacion_lineas' )
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas')
->fields(
Field::inst( 'paginas_min' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal') )
Field::inst('paginas_min')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required'))
),
Field::inst( 'paginas_max' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal') )
Field::inst('paginas_max')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required'))
),
Field::inst( 'precio_min' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') )
Field::inst('precio_min')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required'))
),
Field::inst( 'precio_max' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') )
Field::inst('precio_max')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required'))
),
Field::inst( 'margen' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') )
Field::inst('margen')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.margen.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
),
Field::inst( 'tarifa_encuadernacion_id' ),
Field::inst( 'user_created_id' ),
Field::inst( 'created_at' ),
Field::inst( 'user_updated_id' ),
Field::inst( 'updated_at' ),
Field::inst( 'is_deleted' ),
Field::inst( 'deleted_at' ),
Field::inst('tarifa_encuadernacion_id'),
Field::inst('user_created_id'),
Field::inst('created_at'),
Field::inst('user_updated_id'),
Field::inst('updated_at'),
Field::inst('is_deleted'),
Field::inst('deleted_at'),
)
->validator( function($editor, $action, $data){
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
foreach ($data['data'] as $pkey => $values ){
->validator(function ($editor, $action, $data) {
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) {
foreach ($data['data'] as $pkey => $values) {
// Si no se quiere borrar...
if($data['data'][$pkey]['is_deleted'] != 1)
{
if ($data['data'][$pkey]['is_deleted'] != 1) {
$process_data['paginas_min'] = $data['data'][$pkey]['paginas_min'];
$process_data['paginas_max'] = $data['data'][$pkey]['paginas_max'];
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_encuadernacion_id']);
// No se pueden duplicar valores al crear o al editar
if (!empty($response)){
if (!empty($response)) {
return $response;
}
}
}
}
})
->on( 'preCreate', function ( $editor, &$values ) {
->on('preCreate', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field( 'user_created_id' )
->setValue( $session->id_user );
->field('user_created_id')
->setValue($session->id_user);
$editor
->field( 'created_at' )
->setValue( $datetime->format('Y-m-d H:i:s') );
} )
->on( 'preEdit', function ( $editor, &$values ) {
->field('created_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->on('preEdit', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field( 'user_updated_id' )
->setValue( $session->id_user );
->field('user_updated_id')
->setValue($session->id_user);
$editor
->field( 'updated_at' )
->setValue( $datetime->format('Y-m-d H:i:s') );
} )
->field('updated_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->debug(true)
->process( $_POST )
->process($_POST)
->data();
$newTokenHash = csrf_hash();
@ -309,12 +306,13 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
}
}
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -338,15 +336,16 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', tarifa_encuadernacion_id', 'tarifa_encuadernacion_id', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', tarifa_encuadernacion_id', 'tarifa_encuadernacion_id', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->tarifa_encuadernacion_id = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->tarifa_encuadernacion_id = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -360,7 +359,8 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -371,8 +371,8 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -21,7 +21,8 @@ use
DataTables\Editor\ValidateOptions;
class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController
{
protected $modelName = TarifaManipuladoLineaModel::class;
protected $format = 'json';
@ -38,15 +39,16 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'tarifaManipuladoLineaList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('TarifaManipuladoLineas.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -58,12 +60,12 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewTarifaManipuladoLineaList', $viewData);
return view(static::$viewPath . 'viewTarifaManipuladoLineaList', $viewData);
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -89,7 +91,7 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -99,9 +101,7 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]).'.';
$message .= anchor( "tarifamanipuladolineas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -121,13 +121,14 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('createTarifaManipuladoLinea');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaManipuladoLineas.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('TarifaManipuladoLineas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
if ($requestedId == null) :
return $this->redirect2listView();
@ -151,12 +152,10 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
$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);
@ -176,9 +175,7 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $tarifaManipuladoLinea->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]).'.';
$message .= anchor( "tarifamanipuladolineas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -197,104 +194,104 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateTarifaManipuladoLinea', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaManipuladoLineas.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('TarifaManipuladoLineas.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable_editor() {
public function datatable_editor()
{
if ($this->request->isAJAX()) {
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
// Build our Editor instance and process the data coming from _POST
$response = Editor::inst( $db, 'tarifa_manipulado_lineas' )
$response = Editor::inst($db, 'tarifa_manipulado_lineas')
->fields(
Field::inst( 'paginas_min' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal') )
Field::inst('paginas_min')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required'))
),
Field::inst( 'paginas_max' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal') )
Field::inst('paginas_max')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required'))
),
Field::inst( 'precio_min' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') )
Field::inst('precio_min')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required'))
),
Field::inst( 'precio_max' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') )
Field::inst('precio_max')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required'))
),
Field::inst( 'margen' )
->validator( 'Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') )
Field::inst('margen')
->validator('Validate::numeric', array(
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal'))
)
->validator( 'Validate::notEmpty',array(
'message' => lang('TarifaAcabadoLineas.validation.margen.required') )
->validator('Validate::notEmpty', array(
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
),
Field::inst( 'tarifa_manipulado_id' ),
Field::inst( 'user_created_id' ),
Field::inst( 'created_at' ),
Field::inst( 'user_updated_id' ),
Field::inst( 'updated_at' ),
Field::inst( 'is_deleted' ),
Field::inst( 'deleted_at' ),
Field::inst('tarifa_manipulado_id'),
Field::inst('user_created_id'),
Field::inst('created_at'),
Field::inst('user_updated_id'),
Field::inst('updated_at'),
Field::inst('is_deleted'),
Field::inst('deleted_at'),
)
->validator( function($editor, $action, $data){
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
foreach ($data['data'] as $pkey => $values ){
->validator(function ($editor, $action, $data) {
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) {
foreach ($data['data'] as $pkey => $values) {
// Si no se quiere borrar...
if($data['data'][$pkey]['is_deleted'] != 1)
{
if ($data['data'][$pkey]['is_deleted'] != 1) {
$process_data['paginas_min'] = $data['data'][$pkey]['paginas_min'];
$process_data['paginas_max'] = $data['data'][$pkey]['paginas_max'];
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_manipulado_id']);
// No se pueden duplicar valores al crear o al editar
if (!empty($response)){
if (!empty($response)) {
return $response;
}
}
}
}
})
->on( 'preCreate', function ( $editor, &$values ) {
->on('preCreate', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field( 'user_created_id' )
->setValue( $session->id_user );
->field('user_created_id')
->setValue($session->id_user);
$editor
->field( 'created_at' )
->setValue( $datetime->format('Y-m-d H:i:s') );
} )
->on( 'preEdit', function ( $editor, &$values ) {
->field('created_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->on('preEdit', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field( 'user_updated_id' )
->setValue( $session->id_user );
->field('user_updated_id')
->setValue($session->id_user);
$editor
->field( 'updated_at' )
->setValue( $datetime->format('Y-m-d H:i:s') );
} )
->field('updated_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->debug(true)
->process( $_POST )
->process($_POST)
->data();
$newTokenHash = csrf_hash();
@ -309,12 +306,13 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
}
}
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -338,15 +336,16 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', tarifa_manipulado_id', 'tarifa_manipulado_id', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', tarifa_manipulado_id', 'tarifa_manipulado_id', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->tarifa_manipulado_id = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->tarifa_manipulado_id = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -360,7 +359,8 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -371,8 +371,8 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -3,7 +3,8 @@
use App\Entities\Tarifas\TarifapreimpresionEntity;
class Tarifapreimpresion extends \App\Controllers\GoBaseController {
class Tarifapreimpresion extends \App\Controllers\GoBaseController
{
use \CodeIgniter\API\ResponseTrait;
@ -19,8 +20,8 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
protected $indexRoute = 'tarifapreimpresionList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Tarifapreimpresion.moduleTitle');
// Se indica que este controlador trabaja con soft_delete
$this->soft_delete = true;
@ -37,7 +38,8 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
}
public function index() {
public function index()
{
$this->viewData['usingClientSideDataTable'] = true;
@ -46,8 +48,8 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
}
public function add() {
public function add()
{
$requestMethod = $this->request->getMethod();
@ -72,7 +74,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifapreimpresion.tarifapreimpresion'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -82,9 +84,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifapreimpresion.tarifapreimpresion'))]).'.';
$message .= anchor(route_to('editTarifapreimpresion', $id), lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -93,7 +93,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
return $this->redirect2listView('successMessage', $message);
endif;
else:
$this->viewData['successMessage'] = $message;
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
@ -104,13 +104,14 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
$this->viewData['formAction'] = route_to('createTarifapreimpresion');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifapreimpresion.tarifapreimpresion').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifapreimpresion.tarifapreimpresion') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
// JJO
$session = session();
@ -136,7 +137,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
if(isset($this->model->user_updated_id)){
if (isset($this->model->user_updated_id)) {
$sanitizedData['user_updated_id'] = $session->id_user;
}
@ -161,9 +162,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
endif;
if ($noException && $successfulResult) :
$id = $tarifapreimpresionEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifapreimpresion.tarifapreimpresion'))]).'.';
//$message .= anchor(route_to('editTarifapreimpresion', $id), lang('Basic.global.continueEditing').'?');
//$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -172,8 +171,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
return $this->redirect2listView('successMessage', $message);
endif;
else:
//JJO
$this->viewData['successMessage'] = $message;
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
@ -183,23 +181,23 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
$this->viewData['formAction'] = route_to('updateTarifapreimpresion', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifapreimpresion.tarifapreimpresion').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifapreimpresion.tarifapreimpresion') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -213,7 +211,8 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -224,8 +223,8 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -9,7 +9,8 @@ use App\Entities\Tarifas\TarifaEncuadernacionEntity;
use App\Models\Tarifas\TarifaEncuadernacionModel;
class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
{
protected $modelName = TarifaEncuadernacionModel::class;
protected $format = 'json';
@ -26,8 +27,8 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'tarifaEncuadernacionList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Tarifaencuadernacion.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
@ -48,7 +49,8 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -60,11 +62,12 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewTarifaEncuadernacionList', $viewData);
return view(static::$viewPath . 'viewTarifaEncuadernacionList', $viewData);
}
public function add() {
public function add()
{
// JJO
$session = session();
@ -80,7 +83,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
if(isset($this->model->user_updated_id)){
if (isset($this->model->user_updated_id)) {
$sanitizedData['user_created_id'] = $session->id_user;
}
@ -96,7 +99,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -106,21 +109,17 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]).'.';
//$message .= anchor( "tarifaencuadernacion/{$id}/edit" , lang('Basic.global.continueEditing').'?');
//$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(site_url('tarifas/tarifasencuadernacion/edit/'.$id))->with('sweet-success', $message);
return redirect()->to(site_url('tarifas/tarifasencuadernacion/edit/' . $id))->with('sweet-success', $message);
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
else:
//JJO
$this->viewData['successMessage'] = $message;
//$this->session->setFlashData('sweet-success', $message);
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
@ -131,13 +130,14 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = site_url('tarifas/tarifasencuadernacion/add');//route_to('createTarifaEncuadernacion');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifaencuadernacion.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
// JJO
$session = session();
@ -149,7 +149,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$tarifaEncuadernacionEntity = $this->model->find($id);
if ($tarifaEncuadernacionEntity == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion')), $id]);
$message = lang('Basic.global.notFoundWithIdErr', [lang('Basic.global.record'), $id]);
return $this->redirect2listView('sweet-error', $message);
endif;
@ -164,7 +164,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
if(isset($this->model->user_updated_id)){
if (isset($this->model->user_updated_id)) {
$sanitizedData['user_updated_id'] = $session->id_user;
}
@ -178,7 +178,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]);
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -189,9 +189,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $tarifaEncuadernacionEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]).'.';
//$message .= anchor( "tarifa ulado/{$id}/edit" , lang('Basic.global.continueEditing').'?');
//$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -210,20 +208,20 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateTarifaEncuadernacion', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifaencuadernacion.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -245,15 +243,16 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -267,7 +266,8 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -278,8 +278,8 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -9,7 +9,8 @@ use App\Entities\Tarifas\TarifaManipuladoEntity;
use App\Models\Tarifas\TarifaManipuladoModel;
class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController
{
protected $modelName = TarifaManipuladoModel::class;
protected $format = 'json';
@ -26,8 +27,8 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
protected $indexRoute = 'tarifaManipuladoList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Tarifamanipulado.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
@ -48,7 +49,8 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
}
public function index() {
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
@ -60,11 +62,12 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewTarifaManipuladoList', $viewData);
return view(static::$viewPath . 'viewTarifaManipuladoList', $viewData);
}
public function add() {
public function add()
{
// JJO
$session = session();
@ -80,7 +83,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
if(isset($this->model->user_updated_id)){
if (isset($this->model->user_updated_id)) {
$sanitizedData['user_created_id'] = $session->id_user;
}
@ -96,7 +99,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]);
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
@ -106,21 +109,17 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]).'.';
$message .= anchor( "tarifamanipulado/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(site_url('tarifas/tarifasmanipulado/edit/'.$id))->with('sweet-success', $message);
return redirect()->to(site_url('tarifas/tarifasmanipulado/edit/' . $id))->with('sweet-success', $message);
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
else:
//JJO
$this->viewData['successMessage'] = $message;
//$this->session->setFlashData('sweet-success', $message);
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
@ -131,13 +130,14 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = site_url('tarifas/tarifasmanipulado/add');//route_to('createTarifaManipulado');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifamanipulado.moduleTitle').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifamanipulado.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
public function edit($requestedId = null)
{
// JJO
$session = session();
@ -164,7 +164,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
if(isset($this->model->user_updated_id)){
if (isset($this->model->user_updated_id)) {
$sanitizedData['user_updated_id'] = $session->id_user;
}
@ -189,9 +189,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
endif;
if ($noException && $successfulResult) :
$id = $tarifaManipuladoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]).'.';
//$message .= anchor( "tarifamanipulado/{$id}/edit" , lang('Basic.global.continueEditing').'?');
//$message = ucfirst(str_replace("'", "\'", $message));
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
@ -210,20 +208,20 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
$this->viewData['formAction'] = route_to('updateTarifaManipulado', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifamanipulado.moduleTitle').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifamanipulado.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -245,15 +243,16 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
}
}
public function allItemsSelect() {
public function allItemsSelect()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -267,7 +266,8 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
}
}
public function menuItems() {
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
@ -278,8 +278,8 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -63,7 +63,7 @@ return [
'pleaseSelect' => 'Por favor seleccione...',
'pleaseSelectA' => 'Por favor seleccione un {0}... ',
'pleaseSelectOne' => 'Por favor seleccione un...',
'record' => 'el registro',
'record' => 'registro',
'saveSuccess' => 'El {0} se ha guardado satisfactoriamente',
'saveSuccess1' => 'El {0} ',
'saveSuccess2' => ' se ha guardado satisfactoriamente',

View File

@ -10,32 +10,49 @@
<?= $this->section('additionalInlineJs') ?>
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-right",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-right",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
<?php if (session('sweet-success')) { ?>
<?php if (session('sweet-success')) {
if (isset($alertStyle) && ($alertStyle == 'toastr')) { ?>
toastr.success(`<?= session('sweet-success') ?>`);
<?php } ?>
<?php if (session('sweet-warning')) { ?>
toastr.success(`<?= session('sweet-warning') ?>`);
<?php } ?>
<?php if (session('sweet-error')) { ?>
toastr.success(`<?= session('sweet-error') ?>`);
<?php } ?>
<?php } else { ?>
popSuccessAlert(`<?= session('sweet-success') ?>`);
<?php }
}
?>
<?php if (session('sweet-warning')) {
if (isset($alertStyle) && ($alertStyle == 'toastr')) { ?>
toastr.warning(`<?= session('sweet-warning') ?>`);
<?php } else { ?>
popWarningAlert(`<?= session('sweet-warning') ?>`);
<?php }
}
?>
<?php if (session('sweet-error')) {
if (isset($alertStyle) && ($alertStyle == 'toastr')) { ?>
toastr.error(`<?= session('sweet-error') ?>`);
<?php } else { ?>
popErrorgAlert(`<?= session('sweet-error') ?>`);
<?php }
}
?>
<?= $this->endSection() ?>

View File

@ -134,7 +134,6 @@ if (!empty($token) && $tfa == false) {
aria-expanded="false"
>
<i class="ti ti-bell ti-md"></i>
<span class="badge bg-danger rounded-pill badge-notifications">5</span>
</a>
</li>
<!--/ Notification -->