diff --git a/ci4/app/Config/Routes/ConfiguracionRoutes.php b/ci4/app/Config/Routes/ConfiguracionRoutes.php index 1dd58f89..058ae817 100755 --- a/ci4/app/Config/Routes/ConfiguracionRoutes.php +++ b/ci4/app/Config/Routes/ConfiguracionRoutes.php @@ -53,7 +53,6 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $routes->post('duplicate/(:num)', 'Papelesimpresion::duplicate/$1', ['as' => 'duplicatePapelImpresion']); $routes->get('select', 'Papelesimpresion::papel_impresion_select', ['as' => 'papelImpresionSelect']); $routes->get('show/(:num)', 'Papelesimpresion::papel_impresion_find/$1', ['as' => 'showPapelImpresion']); - }); /* Maquinas */ @@ -149,5 +148,15 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $routes->group("messages", ["namespace" => 'App\Controllers\Chat'], function ($routes) { $routes->get('', 'ChatController::config_view', ['as' => 'configMessagesIndex']); }); -}); + + /* Festivos */ + $routes->group("festivos", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'FestivoController::index', ['as' => 'festivosList']); + $routes->post('', 'FestivoController::store_festivo_date', ['as' => 'storeFestivoDate']); + $routes->delete('(:num)', 'FestivoController::delete_festivo_date/$1', ['as' => 'deleteFestivoDate']); + $routes->get('all', 'FestivoController::find_all', ['as' => 'getFindAllFestivos']); + + }); + +}); diff --git a/ci4/app/Controllers/Configuracion/FestivoController.php b/ci4/app/Controllers/Configuracion/FestivoController.php new file mode 100644 index 00000000..bf43337b --- /dev/null +++ b/ci4/app/Controllers/Configuracion/FestivoController.php @@ -0,0 +1,103 @@ +viewData['pageTitle'] = lang('Festivos.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + $this->model = model($this->modelName); + $this->validation = service("validation"); + parent::initController($request, $response, $logger); + } + + public function index() + { + return view($this->viewPath . $this->indexRoute); + } + + public function store_festivo_date() + { + $bodyData = $this->request->getPost(); + $date = $bodyData['date']; + $count = $this->model->where('date',$date)->countAllResults(); + if ($count) { + $status = $this->model->where('date', $date)->delete(purge: true); + return $this->response->setJSON([ + "message" => lang("App.user_alert_delete"), + "status" => $status, + ]); + } else { + + $status = $this->model->insert($bodyData); + if ($status) { + $festivoEntity = $this->model->find($status); + return $this->response->setJSON([ + "message" => lang("App.global_alert_save_success"), + "status" => $status, + "data" => $festivoEntity + ]); + } else { + return $this->response->setJSON([ + "message" => lang("App.global_alert_save_error"), + "errors" => $this->model->errors(), + "status" => true + ])->setStatusCode(400); + } + } + } + public function delete_festivo_date($id) + { + $status = $this->model->delete($id, true); + if ($status) { + return $this->response->setJSON([ + "message" => lang("App.user_alert_delete"), + "status" => $status, + ]); + } else { + return $this->response->setJSON([ + "message" => lang("App.global_alert_save_error"), + "errors" => $this->model->errors(), + "status" => true + ])->setStatusCode(400); + } + } + public function find_all() + { + $festivos = $this->model->findAll(); + return $this->response->setJSON([ + "message" => lang("App.global_alert_fetch_success"), + "status" => true, + "data" => $festivos + ]); + } +} diff --git a/ci4/app/Database/Migrations/2025-04-27-193500_CreateTableFestivos.php b/ci4/app/Database/Migrations/2025-04-27-193500_CreateTableFestivos.php new file mode 100644 index 00000000..48d47d33 --- /dev/null +++ b/ci4/app/Database/Migrations/2025-04-27-193500_CreateTableFestivos.php @@ -0,0 +1,49 @@ + [ + "type" => "INT", + "unsigned" => true, + "auto_increment" => true + ], + "date" => [ + "type" => "DATE", + "unique" => true, + ], + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql("CURRENT_TIMESTAMP"); + $this->forge->addField([ + "created_at" => [ + "type" => "TIMESTAMP", + "default" => $currenttime, + ], + "updated_at" => [ + "type" => "TIMESTAMP", + "null" => true, + ], + "deleted_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + ]); + $this->forge->addPrimaryKey('id'); + $this->forge->createTable("festivos", true); + } + + public function down() + { + // + $this->forge->dropTable("festivos", true); + } +} diff --git a/ci4/app/Language/en/App.php b/ci4/app/Language/en/App.php index 147d9dfe..649f02b6 100755 --- a/ci4/app/Language/en/App.php +++ b/ci4/app/Language/en/App.php @@ -676,6 +676,7 @@ return [ "menu_tarifacliente" => "Fees", "menu_configuration" => "Settings", + "menu_config_holidays" => "Holidays", "menu_calendario" => "Calendar", "menu_paises" => "Countries", "menu_correo" => "Mail", diff --git a/ci4/app/Language/en/Festivos.php b/ci4/app/Language/en/Festivos.php new file mode 100644 index 00000000..1f4a58d7 --- /dev/null +++ b/ci4/app/Language/en/Festivos.php @@ -0,0 +1,7 @@ + 'Date', + 'moduleTitle' => 'Holidays' +]; \ No newline at end of file diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index cddbcfc2..1a56b5fa 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -690,6 +690,7 @@ return [ "menu_configuration" => "Configuración", "menu_variables" => "Variables sistema", "menu_config_messages" => "Mensajería", + "menu_config_holidays" => "Festivos", "menu_error_presupuesto" => "Errores presupuesto", "menu_calendario" => "Calendario", "menu_paises" => "Paises", diff --git a/ci4/app/Language/es/Festivos.php b/ci4/app/Language/es/Festivos.php new file mode 100644 index 00000000..cde21cc8 --- /dev/null +++ b/ci4/app/Language/es/Festivos.php @@ -0,0 +1,7 @@ + 'Fecha', + 'moduleTitle' => 'Festivos' +]; \ No newline at end of file diff --git a/ci4/app/Models/Configuracion/FestivoModel.php b/ci4/app/Models/Configuracion/FestivoModel.php index 5af52bab..003e4e01 100755 --- a/ci4/app/Models/Configuracion/FestivoModel.php +++ b/ci4/app/Models/Configuracion/FestivoModel.php @@ -3,130 +3,66 @@ namespace App\Models\Configuracion; use App\Entities\Configuracion\FestivoEntity; -use App\Entities\Configuracion\Imposicion; use App\Models\BaseModel; -class ImposicionModel extends BaseModel +class FestivoModel extends BaseModel { protected $table = "festivos"; - - + protected $primaryKey = 'id'; protected $allowedFields = ["date"]; protected $returnType = FestivoEntity::class; + protected $useAutoIncrement = true; + protected $useSoftDeletes = true; + protected $protectFields = true; + + + protected bool $allowEmptyInserts = false; + protected bool $updateOnlyChanged = true; + + protected array $casts = []; + protected array $castHandlers = []; + + // Dates + protected $useTimestamps = true; + protected $dateFormat = 'datetime'; + protected $createdField = 'created_at'; + protected $updatedField = 'updated_at'; + protected $deletedField = 'deleted_at'; + + // Validation + + protected $skipValidation = false; + protected $cleanValidationRules = true; + + // Callbacks + protected $allowCallbacks = true; + protected $beforeInsert = []; + protected $afterInsert = []; + protected $beforeUpdate = []; + protected $afterUpdate = []; + protected $beforeFind = []; + protected $afterFind = []; + protected $beforeDelete = []; + protected $afterDelete = []; + + - public static $labelField = "ancho"; protected $validationRules = [ "date" => [ - "label" => "Festivos.fecha", - "rules" => "required|datetime", + "label" => "Festivos.date", + "rules" => "required|valid_date[Y-m-d]", ], ]; protected $validationMessages = [ - "alto" => [ - "integer" => "Imposiciones.validation.alto.integer", - "required" => "Imposiciones.validation.alto.required", - ], - "ancho" => [ - "integer" => "Imposiciones.validation.ancho.integer", - "required" => "Imposiciones.validation.ancho.required", - ], - "etiqueta" => [ - "max_length" => "Imposiciones.validation.etiqueta.max_length", - ], - "maquina" => [ - "max_length" => "Imposiciones.validation.maquina.max_length", - ], - "orientacion" => [ - "in_list" => "Imposiciones.validation.orientacion.in_list", - ], - "unidades" => [ - "integer" => "Imposiciones.validation.unidades.integer", - ], - "imposicion_esquema_id" => [ - "integer" => "Imposiciones.validation.unidades.integer", + "date" => [ + "valid_date" => "Validation.valid_date", ], ]; - /** - * Get resource data. - * - * @param string $search - * - * @return \CodeIgniter\Database\BaseBuilder - */ - public function getResource(string $search = "") - { - $builder = $this->db - ->table($this->table . " t1") - ->select( - "t1.id AS id, t1.ancho AS ancho, t1.alto AS alto, t1.unidades AS unidades, t1.orientacion AS orientacion, t1.maquina AS maquina, t1.etiqueta AS etiqueta" - ); - - return empty($search) - ? $builder - : $builder - ->groupStart() - ->like("t1.id", $search) - ->orlike("t1.ancho", $search) - ->orLike("t1.alto", $search) - ->orLike("t1.unidades", $search) - ->orLike("t1.orientacion", $search) - ->orLike("t1.maquina", $search) - ->orLike("t1.etiqueta", $search) - ->orlike("t1.id", $search) - ->orLike("t1.ancho", $search) - ->orLike("t1.alto", $search) - ->orLike("t1.unidades", $search) - ->orLike("t1.orientacion", $search) - ->orLike("t1.maquina", $search) - ->orLike("t1.etiqueta", $search) - ->groupEnd(); - } - - public function querySelect(?string $q) - { - $query = $this->builder()->select([ - "id", - "CONCAT(lg_imposiciones.ancho,'x',lg_imposiciones.alto,'_',COALESCE(lg_imposiciones.unidades,'NULL'),'_',COALESCE(lg_imposiciones.orientacion,'NULL')) as name", - "COALESCE(lg_imposiciones.etiqueta,'" . lang("Produccion.imposicion_no_label") . "') as description" - ]); - if ($q) { - $query->orLike("CONCAT(lg_imposiciones.ancho,'x',lg_imposiciones.alto)", $q); - $query->orLike("lg_imposiciones.etiqueta", $q); - } - return $query - ->orderBy('id', 'ASC') - ->get()->getResultArray(); - } - public function queryDatatable() - { - return $this->builder() - ->select([ - "lg_imposiciones.id", - "lg_imposiciones.ancho", - "lg_imposiciones.alto", - "lg_imposiciones.unidades", - "lg_imposiciones.maquina", - "lg_imposiciones.orientacion", - "lg_imposiciones.etiqueta", - "imposicion_esquemas.id as esquemaId", - "imposicion_esquemas.name as esquemaName" - ]) - ->join("imposicion_esquemas","imposicion_esquemas.id = lg_imposiciones.imposicion_esquema_id","left") - ->where('lg_imposiciones.deleted_at', null); - } - public static function datatable_buttons(int $id) - { - $btn = ""; - if(auth()->user()->inGroup("admin")){ - $btn.=""; - $btn.=""; - } - return $btn; - } + } diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 89babdd5..f39bf921 100755 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -1759,7 +1759,7 @@ class ProductionService extends BaseService ->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") ->join("lg_papel_impresion", "lg_papel_impresion.id = presupuesto_linea.papel_impresion_id", "left") ->groupStart() - ->orWhere('orden_trabajo_tareas.maquina_id', $maquina_id) + ->orWhere('orden_trabajo_tareas.maquina_id', $maquina_id) //!TODO ->orWhere('presupuesto_linea.maquina_id', $maquina_id) ->groupEnd() // ->where('pedidos.fecha_impresion IS NOT NULL', null, false) diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/festivos/festivoList.php b/ci4/app/Views/themes/vuexy/form/configuracion/festivos/festivoList.php new file mode 100644 index 00000000..425071af --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/configuracion/festivos/festivoList.php @@ -0,0 +1,64 @@ += $this->include('themes/_commonPartialsBs/select2bs5') ?> += $this->include('themes/_commonPartialsBs/datatables') ?> += $this->include('themes/_commonPartialsBs/sweetalert') ?> += $this->include('themes/_commonPartialsBs/_confirm2delete') ?> += $this->extend('themes/vuexy/main/defaultlayout') ?> += $this->section('content'); ?> +
| IDSK | - + |
|---|---|