terminando form de clientes direcciones

This commit is contained in:
2023-12-17 08:58:26 +01:00
parent d4246ca99b
commit d9083aac2d
15 changed files with 350 additions and 79 deletions

View File

@ -78,7 +78,8 @@ class Cliente extends \App\Controllers\GoBaseResourceController
public function add()
{
// JJO
$session = session();
$requestMethod = $this->request->getMethod();
@ -90,6 +91,8 @@ class Cliente extends \App\Controllers\GoBaseResourceController
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
$sanitizedData['user_created_id'] = $session->id_user;
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
@ -148,6 +151,9 @@ class Cliente extends \App\Controllers\GoBaseResourceController
public function edit($requestedId = null)
{
// JJO
$session = session();
if ($requestedId == null) :
return $this->redirect2listView();
endif;
@ -181,6 +187,9 @@ class Cliente extends \App\Controllers\GoBaseResourceController
$sanitizedData['tirada_flexible'] = false;
}
// JJO
$sanitizedData['user_updated_id'] = $session->id_user;
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
@ -338,15 +347,10 @@ class Cliente extends \App\Controllers\GoBaseResourceController
protected function getPaisListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])];
if (!empty($selId)) :
$paisModel = model('App\Models\Configuracion\PaisModel');
$paisModel = model('App\Models\Configuracion\PaisModel');
$onlyActiveOnes = true;
$data = $paisModel->getAllForMenu('id, nombre', 'nombre', $onlyActiveOnes);
$selOption = $paisModel->where('id', $selId)->findColumn('nombre');
if (!empty($selOption)) :
$data[$selId] = $selOption[0];
endif;
endif;
return $data;
}

50
ci4/app/Controllers/Clientes/Clientedirecciones.php Normal file → Executable file
View File

@ -53,4 +53,54 @@ class Clientedirecciones extends \App\Controllers\GoBaseResourceController
return $this->failUnauthorized('Invalid request', 403);
}
}
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, 'clientes_direcciones')
->fields(
Field::inst('att')
->validator('Validate::notEmpty', array(
'message' => lang('ClienteDirecciones.validation.required'))
)
->validator( Validate::maxLen( 100 ) , array(
'message' => lang('ClienteDirecciones.validation.max_length'))
),
)
/*->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) {
$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]['papel_impresion_id']);
// No se pueden duplicar valores al crear o al editar
if (!empty($response)) {
return $response;
}
}
}
}
})*/
->debug(true)
->process($_POST)
->data();
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$response[$csrfTokenName] = $newTokenHash;
echo json_encode($response);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}