diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 25fd341d..a974f2ad 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -122,13 +122,14 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $routes->get('datatable', 'ConfigErrores::datatable', ['as' => 'erroresPresupuestoDatatable']); $routes->post('edit/(:num)', 'ConfigErrores::update_error_presupuesto/$1', ['as' => 'erroresPresupuestoUpdate']); }); - $routes->group("servicios", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) { - $routes->get('', 'ServicioCliente::index', ['as' => 'servicioClienteList']); - $routes->get('(:num)', 'ServicioCliente::show/$1', ['as' => 'servicioClienteShow']); - $routes->post('(:num)', 'ServicioCliente::store/$1', ['as' => 'servicioClienteStore']); - $routes->post('update/(:num)', 'ServicioCliente::update_servicio_cliente/$1', ['as' => 'updateServicioCliente']); - $routes->get('edit/(:num)', 'ServicioCliente::viewForm/$1', ['as' => 'servicioClienteViewForm']); - $routes->get('datatable', 'ServicioCliente::datatable', ['as' => 'servicioClienteDatatable']); + $routes->group("maquina-tareas", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'MaquinaTarea::index', ['as' => 'maquinaTareaList']); + $routes->get('(:num)', 'MaquinaTarea::show/$1', ['as' => 'maquinaTareaShow']); + $routes->delete('(:num)', 'MaquinaTarea::delete/$1', ['as' => 'maquinaTareaDelete']); + $routes->post('', 'MaquinaTarea::store/$1', ['as' => 'maquinaTareaStore']); + $routes->post('update/(:num)', 'MaquinaTarea::update_servicio_cliente/$1', ['as' => 'maquinaTareaUpdate']); + $routes->get('edit/(:num)', 'MaquinaTarea::viewForm/$1', ['as' => 'maquinaTareaViewForm']); + $routes->get('datatable', 'MaquinaTarea::datatable', ['as' => 'maquinaTareaDatatable']); }); }); diff --git a/ci4/app/Controllers/Configuracion/MaquinaTarea.php b/ci4/app/Controllers/Configuracion/MaquinaTarea.php new file mode 100644 index 00000000..4115850d --- /dev/null +++ b/ci4/app/Controllers/Configuracion/MaquinaTarea.php @@ -0,0 +1,86 @@ +maquinaTareaModel = model(MaquinaTareaModel::class); + } + + + public function index() + { + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_maquina_tareas"), 'route' => site_url('configuracion/maquina-tareas'), 'active' => true] + ]; + return view(static::$viewPath . $this->indexRoute, $this->viewData); + } + public function viewForm(int $maquina_tarea_id) + { + $maquinaTarea = $this->maquinaTareaModel->find($maquina_tarea_id); + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_maquina_tareas"), 'route' => site_url('configuracion/maquina-tareas'), 'active' => false], + ['title' => $maquinaTarea->name, 'route' => site_url('configuracion/maquina-tareas/edit/' . $maquina_tarea_id), 'active' => true] + ]; + $this->viewData["model"] = $maquinaTarea; + + return view(static::$viewPath . $this->editRoute, $this->viewData); + } + public function show(int $id) + { + $data = $this->maquinaTareaModel->find($id); + return $this->response->setJSON($data); + } + public function update_servicio_cliente(int $id) + { + $data = $this->request->getPost(); + $status = $this->maquinaTareaModel->update($id, [ + "name" => $data["name"], + "description" => $data["description"] + ]); + + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status]); + } + public function store() + { + $bodyData = $this->request->getPost(); + $r = $this->maquinaTareaModel->insert($bodyData); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r,"data" => $bodyData]); + } + public function delete(int $maquina_tarea_id){ + $r = $this->maquinaTareaModel->delete($maquina_tarea_id); + return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => $r]); + } + public function datatable() + { + $query = $this->maquinaTareaModel->getQueryDatatable()->orderBy("created_at", "DESC"); + return DataTable::of($query) + ->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "") + ->add("action", fn($q) => $q->id) + ->toJson(true); + } +} diff --git a/ci4/app/Controllers/Configuracion/ServicioCliente.php b/ci4/app/Controllers/Configuracion/ServicioCliente.php deleted file mode 100644 index bc282142..00000000 --- a/ci4/app/Controllers/Configuracion/ServicioCliente.php +++ /dev/null @@ -1,89 +0,0 @@ -servicioClienteModel = model(ServicioClienteModel::class); - } - - - public function index() - { - $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], - ['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => true] - ]; - return view(static::$viewPath . $this->indexRoute, $this->viewData); - } - public function viewForm(int $servicio_cliente_id) - { - $servicioCliente = $this->servicioClienteModel->find($servicio_cliente_id); - $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], - ['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => false], - ['title' => $servicioCliente->nombre, 'route' => site_url('configuracion/servicios/edit/' . $servicio_cliente_id), 'active' => true] - ]; - $this->viewData["model"] = $servicioCliente; - - return view(static::$viewPath . 'ServicioClienteEdit', $this->viewData); - } - public function show(int $id) - { - $data = $this->servicioClienteModel->find($id)->withAllTarifas(); - return $this->response->setJSON($data); - } - public function update_servicio_cliente(int $id) - { - $data = $this->request->getPost(); - $status = $this->servicioClienteModel->update($id, [ - "nombre" => $data["nombre"], - "code" => $data["code"] - ]); - if (isset($data["tarifa_manipulado_id"])) { - $this->servicioClienteModel->upsertTarifaManipulado($id, $data["tarifa_manipulado_id"]); - }else if(isset($data["tarifa_acabado_id"])) { - - $this->servicioClienteModel->upsertTarifaAcabado($id, $data["tarifa_acabado_id"]); - }else{ - $this->servicioClienteModel->detachTarifas($id); - } - - return $this->response->setJSON(["message" => lang("App.global_success"), "status" => $status]); - } - public function store() - { - // $this->servicioClienteModel->update($id,[$this->request->getPost()]); - return $this->response->setJSON([]); - } - public function datatable() - { - $query = $this->servicioClienteModel->getQueryDatatable()->orderBy("created_at", "DESC"); - return DataTable::of($query) - ->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "") - ->add("action", fn($q) => $q->id) - ->toJson(true); - } -} diff --git a/ci4/app/Entities/Configuracion/TareaMaquinaEntity.php b/ci4/app/Entities/Tarifas/Maquinas/TareaMaquinaEntity.php similarity index 100% rename from ci4/app/Entities/Configuracion/TareaMaquinaEntity.php rename to ci4/app/Entities/Tarifas/Maquinas/TareaMaquinaEntity.php diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index f2f5f26f..846ff301 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -695,7 +695,7 @@ return [ "menu_papelgenerico" => "Papel generico", "menu_papelimpresion" => "Papel impresión", "menu_series_facturas" => "Series facturas", - "menu_servicios_cliente" => "Servicios cliente", + "menu_maquina_tareas" => "Tareas máquinas", "menu_ubicaciones" => "Ubicaciones", "menu_serviciocliente" => "Servicio cliente", "menu_tamanioformatos" => "Tamaño formatos", diff --git a/ci4/app/Language/es/ServicioCliente.php b/ci4/app/Language/es/MaquinaTarea.php similarity index 71% rename from ci4/app/Language/es/ServicioCliente.php rename to ci4/app/Language/es/MaquinaTarea.php index 5218a72b..4e259c7e 100644 --- a/ci4/app/Language/es/ServicioCliente.php +++ b/ci4/app/Language/es/MaquinaTarea.php @@ -2,13 +2,14 @@ return [ - "cardTitle" => "Servicios cliente", + "cardTitle" => "Máquina tareas", + "tarea_new" => "Crear tarea", "infoTarifaManipulado" => "La tarifa seleccionada estará asociada al servicio.", "infoTarifaAcabado" => "La tarifa seleccionada estará asociada al servicio.", "datatable" => [ "nombre" => "Nombre", - "code" => "Código", + "description" => "Descripción", "created_at" => "Fecha creación", ] ]; \ No newline at end of file diff --git a/ci4/app/Models/Configuracion/MaquinaTareaModel.php b/ci4/app/Models/Configuracion/MaquinaTareaModel.php index 536b7fd9..b1f44991 100644 --- a/ci4/app/Models/Configuracion/MaquinaTareaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaTareaModel.php @@ -3,6 +3,9 @@ namespace App\Models\Configuracion; use App\Entities\Tarifas\Maquinas\TareaMaquinaEntity; +use CodeIgniter\Database\BaseBuilder; +use CodeIgniter\Database\MySQLi\Builder; +use CodeIgniter\Database\Query; use CodeIgniter\Model; class MaquinaTareaModel extends Model @@ -55,14 +58,19 @@ class MaquinaTareaModel extends Model * @return array * */ - public function getSelectQuery(?string $q = null) : array + public function getSelectQuery(?string $q = null): array { - $query = $this->builder()->select(["id","name","description"]) - ->where("deleted_at",null); - if($q){ - $query->like("nombre",$q); + $query = $this->builder()->select(["id", "name", "description"]) + ->where("deleted_at", null); + if ($q) { + $query->like("nombre", $q); } return $query->get()->getResultArray(); } + public function getQueryDatatable(): BaseBuilder + { + return $this->builder()->select(["id","name","description","created_at"]) + ->where("deleted_at", null); + } } diff --git a/ci4/app/Views/themes/vuexy/components/forms/maquina_tarea.php b/ci4/app/Views/themes/vuexy/components/forms/maquina_tarea.php new file mode 100644 index 00000000..9bbd34d4 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/forms/maquina_tarea.php @@ -0,0 +1,23 @@ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/forms/servicio_cliente.php b/ci4/app/Views/themes/vuexy/components/forms/servicio_cliente.php deleted file mode 100644 index a90d9058..00000000 --- a/ci4/app/Views/themes/vuexy/components/forms/servicio_cliente.php +++ /dev/null @@ -1,61 +0,0 @@ - \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/tables/servicios_cliente_table.php b/ci4/app/Views/themes/vuexy/components/tables/maquina_tarea_table.php similarity index 54% rename from ci4/app/Views/themes/vuexy/components/tables/servicios_cliente_table.php rename to ci4/app/Views/themes/vuexy/components/tables/maquina_tarea_table.php index 1631175b..5fa49f48 100644 --- a/ci4/app/Views/themes/vuexy/components/tables/servicios_cliente_table.php +++ b/ci4/app/Views/themes/vuexy/components/tables/maquina_tarea_table.php @@ -2,9 +2,9 @@