diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 270b9103..2ee527dd 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -391,6 +391,10 @@ $routes->group('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers }); $routes->resource('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'clienteplantillaprecioslineas', 'except' => 'show,new,create,update']); +$routes->group('clienteusuarios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) { + $routes->post('datatable', 'Clienteusuarios::datatable', ['as' => 'dataTableOfClienteUsuarios']); +}); + $routes->group('formas-pagos', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'Formaspagos::index', ['as' => 'formaDePagoList']); diff --git a/ci4/app/Controllers/Clientes/Clienteusuarios.php b/ci4/app/Controllers/Clientes/Clienteusuarios.php new file mode 100644 index 00000000..1324b513 --- /dev/null +++ b/ci4/app/Controllers/Clientes/Clienteusuarios.php @@ -0,0 +1,77 @@ +viewData['pageTitle'] = lang('ClienteContactos.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + + public function datatable() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + 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); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = ClienteUsuariosModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $id_C = $reqData['id_cliente'] ?? -1; + + $resourceData = $this->model->getResource("", $id_C)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource("", $id_C)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + +} diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index ed5cb4c1..653da4cf 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -130,8 +130,8 @@ return [ "profile_subtitle_tfa" => "Autenticación de dos factores (2FA)", "profile_first_name" => "Nombre", "profile_first_name_ph" => "Escriba su nombre", - "profile_last_name" => "Apellido", - "profile_last_name_ph" => "Escriba su apellido", + "profile_last_name" => "Apellidos", + "profile_last_name_ph" => "Escriba sus apellidos", "profile_email" => "Correo Electrónico", "profile_email_ph" => "Escriba su correo electrónico", "profile_mobile" => "Teléfono Móvil", diff --git a/ci4/app/Models/Clientes/ClienteUsuariosModel.php b/ci4/app/Models/Clientes/ClienteUsuariosModel.php new file mode 100644 index 00000000..6bec17a9 --- /dev/null +++ b/ci4/app/Models/Clientes/ClienteUsuariosModel.php @@ -0,0 +1,110 @@ + "t1.first_name", + 1 => "t1.last_name", + 2 => "t1.email", + ]; + + protected $allowedFields = ["id", "first_name", "last_name", "email"]; + protected $returnType = "App\Entities\Usuarios\UserEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "last_name" => [ + "label" => "ClienteContactos.apellidos", + "rules" => "trim|max_length[500]", + ], + "email" => [ + "label" => "ClienteContactos.email", + "rules" => "trim|max_length[150]|valid_email|permit_empty", + ], + "first_name" => [ + "label" => "ClienteContactos.nombre", + "rules" => "trim|max_length[100]", + ], + ]; + + protected $validationMessages = [ + "last_name" => [ + "max_length" => "ClienteContactos.validation.apellidos.max_length", + ], + + "email" => [ + "max_length" => "ClienteContactos.validation.email.max_length", + "valid_email" => "ClienteContactos.validation.email.valid_email", + ], + "first_name" => [ + "max_length" => "ClienteContactos.validation.nombre.max_length", + ], + ]; + + public function findAllWithClientes(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS cliente_id FROM " . + $this->table . + " t1 LEFT JOIN clientes t2 ON t1.cliente_id = t2.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . $limit; + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . $offset; + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "", $cliente_id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id_user AS id, t1.first_name AS nombre, t1.last_name AS apellidos, t1.email AS email" + ); + + $builder->where('t1.id_user', $cliente_id); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.first_name", $search) + ->orLike("t1.last_name", $search) + ->orLike("t1.email", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteFormItems.php index 396da491..93a16106 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteFormItems.php @@ -659,7 +659,20 @@
| ID | += lang('App.profile_first_name') ?> | += lang('App.profile_last_name') ?> | += lang('App.profile_email') ?> | += lang('Basic.global.Action') ?> | +
|---|