diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 262c1436..fec21e00 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -344,7 +344,7 @@ $routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function $routes->post('add', 'Cliente::add', ['as' => 'createCliente']); $routes->post('create', 'Cliente::create', ['as' => 'ajaxCreateCliente']); $routes->put('(:num)/update', 'Cliente::update/$1', ['as' => 'ajaxUpdateCliente']); - $routes->post('(:num)/edit', 'Cliente::edit/$1', ['as' => 'updateCliente']); + $routes->post('edit/(:num)', 'Cliente::edit/$1', ['as' => 'updateCliente']); $routes->get('delete/(:num)', 'Cliente::delete/$1', ['as' => 'deleteCliente']); $routes->post('datatable', 'Cliente::datatable', ['as' => 'dataTableOfClientes']); $routes->post('allmenuitems', 'Cliente::allItemsSelect', ['as' => 'select2ItemsOfClientes']); diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index f91714e1..cffc7991 100755 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -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; } diff --git a/ci4/app/Controllers/Clientes/Clientedirecciones.php b/ci4/app/Controllers/Clientes/Clientedirecciones.php old mode 100644 new mode 100755 index b01eb994..872fd5a1 --- a/ci4/app/Controllers/Clientes/Clientedirecciones.php +++ b/ci4/app/Controllers/Clientes/Clientedirecciones.php @@ -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); + } + } } diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index 48f741c8..c8c55f09 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -265,7 +265,6 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); $this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo')); - $this->viewData['paisList'] = $this->getPaisListItems(); $this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); $this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro(); $this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ(); diff --git a/ci4/app/Entities/Clientes/ClienteDireccionesEntity.php b/ci4/app/Entities/Clientes/ClienteDireccionesEntity.php old mode 100644 new mode 100755 index 7e28a6fc..87e06cac --- a/ci4/app/Entities/Clientes/ClienteDireccionesEntity.php +++ b/ci4/app/Entities/Clientes/ClienteDireccionesEntity.php @@ -8,13 +8,14 @@ class ClienteDireccionesEntity extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "cliente_id" => null, + "alias" => null, "att" => null, "email" => null, "direccion" => null, "pais_id" => null, "ccaa_id" => null, - "provincia_id" => null, - "municipio_id" => null, + "provincia" => null, + "municipio" => null, "cp" => null, "telefono" => null, ]; @@ -22,8 +23,6 @@ class ClienteDireccionesEntity extends \CodeIgniter\Entity\Entity "cliente_id" => "int", "pais_id" => "int", "ccaa_id" => "int", - "provincia_id" => "int", - "municipio_id" => "int", "cp" => "int", ]; } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php old mode 100644 new mode 100755 diff --git a/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity copy.php b/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity copy.php old mode 100644 new mode 100755 diff --git a/ci4/app/Language/en/ClienteDirecciones.php b/ci4/app/Language/en/ClienteDirecciones.php old mode 100644 new mode 100755 index a60e5c7c..a0329961 --- a/ci4/app/Language/en/ClienteDirecciones.php +++ b/ci4/app/Language/en/ClienteDirecciones.php @@ -3,6 +3,8 @@ return [ + 'nuevaTitle' => 'New address', + 'alias' => 'Alias', 'att' => 'Attn.', 'email' => 'Email', 'direccion' => 'Address', @@ -13,8 +15,12 @@ return [ 'pais' => 'Country', 'telefono' => 'Phone', 'validation' => [ - 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'max_length' => 'Max. length ', + 'required' => 'Field required' 'valid_email' => 'The email is not valid', ], + + 'selectPais' => 'Select a country', + ]; \ No newline at end of file diff --git a/ci4/app/Language/es/ClienteDirecciones.php b/ci4/app/Language/es/ClienteDirecciones.php old mode 100644 new mode 100755 index 1c0e0380..fdffc131 --- a/ci4/app/Language/es/ClienteDirecciones.php +++ b/ci4/app/Language/es/ClienteDirecciones.php @@ -3,6 +3,8 @@ return [ + 'nuevaTitle' => 'Añadir nueva dirección', + 'alias' => 'Alias', 'att' => 'Att.', 'email' => 'Email', 'direccion' => 'Direccion', @@ -13,7 +15,13 @@ return [ 'pais' => 'País', 'telefono' => 'Teléfono', 'validation' => [ - 'max_length' => 'El campo {field} no puede exceder los {param} caracteres de longitud.', + 'max_length' => 'Max. valor caracteres alcanzado', + 'required' => 'Campo obligatorio', 'valid_email' => 'El email introducido no es válido', ], + + 'selectPais' => 'Seleccione País', + 'selectCcaa' => 'Seleccione CCAA', + 'selectProvincia' => 'Seleccione Provincia', + 'selectMunicipio' => 'Seleccione Municipio', ]; \ No newline at end of file diff --git a/ci4/app/Models/Clientes/ClienteDireccionesModel.php b/ci4/app/Models/Clientes/ClienteDireccionesModel.php old mode 100644 new mode 100755 index 13e32564..50a4b90e --- a/ci4/app/Models/Clientes/ClienteDireccionesModel.php +++ b/ci4/app/Models/Clientes/ClienteDireccionesModel.php @@ -14,25 +14,27 @@ class ClienteDireccionesModel extends \App\Models\GoBaseModel protected $useAutoIncrement = true; const SORTABLE = [ - 0 => "t1.att", - 1 => "t1.email", - 2 => "t1.direccion", - 3 => "t1.cp", - 4 => "t5.municipio_nombre", - 5 => "t4.nombre", - 6 => "t3.nombre", - 7 => "t1.telefono", + 0 => "t1.alias", + 1 => "t1.att", + 2 => "t1.email", + 3 => "t1.direccion", + 4 => "t1.cp", + 5 => "t5.municipio_nombre", + 6 => "t4.nombre", + 7 => "t3.nombre", + 8 => "t1.telefono", ]; protected $allowedFields = [ + "alias", "cliente_id", "att", "email", "direccion", "pais_id", "ccaa_id", - "provincia_id", - "municipio_id", + "provincia", + "municipio", "cp", "telefono", ]; @@ -46,6 +48,10 @@ class ClienteDireccionesModel extends \App\Models\GoBaseModel "label" => "ClienteDirecciones.att", "rules" => "trim|max_length[100]", ], + "alias" => [ + "label" => "ClienteDirecciones.att", + "rules" => "trim|max_length[100]", + ], "email" => [ "label" => "ClienteDirecciones.email", "rules" => "trim|max_length[100]|valid_email", @@ -64,6 +70,9 @@ class ClienteDireccionesModel extends \App\Models\GoBaseModel "att" => [ "max_length" => "ClienteDirecciones.validation.max_length", ], + "alias" => [ + "max_length" => "ClienteDirecciones.validation.max_length", + ], "email" => [ "max_length" => "ClienteDirecciones.validation.max_length", ], @@ -89,17 +98,17 @@ class ClienteDireccionesModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.cliente_id AS cliente_id, t2.nombre as cliente_nombre, t1.att AS att, + "t1.id AS id, t1.cliente_id AS cliente_id, t2.nombre as cliente_nombre, t1.att AS att, t1.alias AS alias, t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t3.nombre AS pais, t1.ccaa_id AS ccaa_id, t4.nombre AS ccaa_nombre, - t1.municipio_id AS municipio_id, t5.municipio_nombre AS municipio_nombre, t1.cp AS cp, t1.telefono AS telefono" + t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono" ); $builder->where('t1.cliente_id', $cliente_id); $builder->join("clientes t2", "t1.cliente_id = t2.id", "left"); $builder->join("lg_paises t3", "t1.pais_id = t3.id", "left"); $builder->join("lg_comunidades_autonomas t4", "t1.ccaa_id = t4.id", "left"); - $builder->join("municipios t5", "t1.municipio_id = t5.id", "left"); + return empty($search) ? $builder @@ -110,7 +119,8 @@ class ClienteDireccionesModel extends \App\Models\GoBaseModel ->orLike("t1.direccion", $search) ->orLike("t3.nombre", $search) ->orLike("t4.nombre", $search) - ->orLike("t5.municipio_nombre", $search) + ->orLike("t1.municipio", $search) + ->orLike("t1.provincia", $search) ->orLike("t1.cp", $search) ->orLike("t1.telefono", $search) ->groupEnd(); diff --git a/ci4/app/Models/Clientes/ClienteModel.php b/ci4/app/Models/Clientes/ClienteModel.php index 836fcb62..5b6508b8 100755 --- a/ci4/app/Models/Clientes/ClienteModel.php +++ b/ci4/app/Models/Clientes/ClienteModel.php @@ -93,7 +93,7 @@ class ClienteModel extends \App\Models\GoBaseModel ], "comentarios_tirada_flexible" => [ "label" => "Clientes.comentariosTiradaFlexible", - "rules" => "trim|required|max_length[16313]", + "rules" => "trim|max_length[16313]", ], "cp" => [ "label" => "Clientes.cp", @@ -119,22 +119,10 @@ class ClienteModel extends \App\Models\GoBaseModel "label" => "Clientes.fechaVencimiento", "rules" => "trim|max_length[100]", ], - "is_deleted" => [ - "label" => "Clientes.isDeleted", - "rules" => "required|integer", - ], "limite_credito" => [ "label" => "Clientes.limiteCredito", "rules" => "required|decimal", ], - "limite_credito_change_at" => [ - "label" => "Clientes.limiteCreditoChangeAt", - "rules" => "required|valid_date", - ], - "limite_credito_user_id" => [ - "label" => "Clientes.limiteCreditoUserId", - "rules" => "required|integer", - ], "margen" => [ "label" => "Clientes.margen", "rules" => "required|decimal", @@ -155,14 +143,6 @@ class ClienteModel extends \App\Models\GoBaseModel "label" => "Clientes.telefono", "rules" => "trim|max_length[60]", ], - "user_created_id" => [ - "label" => "Clientes.userCreatedId", - "rules" => "required|integer", - ], - "user_update_id" => [ - "label" => "Clientes.userUpdateId", - "rules" => "required|integer", - ], "vencimiento" => [ "label" => "Clientes.vencimiento", "rules" => "required|integer", diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteDireccionesForm.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteDireccionesForm.php old mode 100644 new mode 100755 index 5fab13af..f5903ad9 --- a/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteDireccionesForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteDireccionesForm.php @@ -1,7 +1,171 @@ -