From 04d157f5728402e920f7dcb4224a1e5505ec0c01 Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Thu, 2 Oct 2025 08:09:11 +0200 Subject: [PATCH 1/3] =?UTF-8?q?fix(UI):=20movido=20ajuste=20de=20codificac?= =?UTF-8?q?i=C3=B3n=20para=20evitar=20confusi=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/Backup.php | 14 +++++ Translation/en_EN.json | 6 +- Translation/es_ES.json | 6 +- View/Backup.html.twig | 132 ++++++++++++++++++++++++++++------------- 4 files changed, 113 insertions(+), 45 deletions(-) diff --git a/Controller/Backup.php b/Controller/Backup.php index 0a9ff9d..f0f6b4b 100644 --- a/Controller/Backup.php +++ b/Controller/Backup.php @@ -41,6 +41,9 @@ class Backup extends Controller /** @var string */ public $active_tab = 'download'; + /** @var string */ + public $download_tab = 'general'; + /** @var array */ public $backup_list = []; @@ -50,6 +53,9 @@ class Backup extends Controller /** @var string */ public $zip_file_name = ''; + /** @var string */ + public $db_charset = 'utf8'; + /** * Return the max file size that can be uploaded. * @@ -80,7 +86,11 @@ public function privateCore(&$response, $user, $permissions) { parent::privateCore($response, $user, $permissions); + // track charset for the download tab selector + $this->db_charset = Tools::config('mysql_charset', 'utf8'); + $this->active_tab = $this->request->get('active_tab', 'download'); + $this->download_tab = $this->request->get('download_tab', 'general'); $action = $this->request->get('action', ''); switch ($action) { @@ -685,6 +695,10 @@ private function switchDbCharsetAction(): void return; } + $this->db_charset = $selectedCharset; + $this->active_tab = 'download'; + $this->download_tab = 'advanced'; + Tools::log()->notice('record-updated-correctly'); } diff --git a/Translation/en_EN.json b/Translation/en_EN.json index 7d9bbc7..d66a725 100644 --- a/Translation/en_EN.json +++ b/Translation/en_EN.json @@ -1,6 +1,6 @@ { "backup": "Backup", - "backup-charset-error": "The backup encoding is %db-charset%, while in config.php it is %config-charset%. Press the change encoding button before restoring.", + "backup-charset-error": "The backup encoding is %db-charset%, while config.php uses %config-charset%. Adjust the encoding before restoring.", "backup-file-too-big": "The backup file is too large to upload to the server. The maximum size is %size% MB", "backup-memory-warning": "Warning: the backup takes %size% MB, but you only have %memory% MB of memory available. Insufficient to perform the backup.", "backup-port-warning": "The MySQL port should be 3306, but you are using %port%", @@ -15,5 +15,7 @@ "restore-backup-warning": "Warning: restoring FacturaScripts data is like going back in time. Everything that was not in the backup will be deleted, that is, the invoices that you have made later and are not in the copy, will be lost.", "restore-files": "Restore files", "restore-files-p": "If you have the backup of the files, select that zip file and press the restore button.", - "switch-db-charset": "Change encoding" + "switch-db-charset": "Database encoding", + "general": "General", + "advanced": "Advanced" } \ No newline at end of file diff --git a/Translation/es_ES.json b/Translation/es_ES.json index 0fa202f..9500bc7 100644 --- a/Translation/es_ES.json +++ b/Translation/es_ES.json @@ -1,6 +1,6 @@ { "backup": "Copia de seguridad", - "backup-charset-error": "La codificación de la copia de seguridad es %db-charset%, mientras que en el config.php es %config-charset%. Pulsa el botón cambiar codificación antes de restaurar.", + "backup-charset-error": "La codificación de la copia de seguridad es %db-charset%, mientras que en el config.php es %config-charset%. Ajusta la codificación antes de restaurar.", "backup-file-too-big": "El archivo de copia de seguridad es demasiado grande para subirlo al servidor. El tamaño máximo es %size% MB", "backup-memory-warning": "Advertencia: la copia de seguridad ocupa %size% MB, pero solamente tienes %memory% MB de memoria RAM disponible. Insuficiente para realizar la copia de seguridad. Como alternativa puedes comprimir la carpeta de FacturaScripts, que es equivalente a una copia de los archivos.", "backup-port-warning": "El puerto de MySQL debe ser el 3306, pero estás usando el %port%", @@ -15,5 +15,7 @@ "restore-backup-warning": "Advertencia: restaurar los datos de FacturaScripts es como volver al pasado. Se eliminará todo lo que no estuviese en la copia de seguridad, es decir, las facturas que hayas realizado después y no estén en la copia, se perderán.", "restore-files": "Restaurar archivos", "restore-files-p": "Si tienes la copia de seguridad de los archivos, selecciona ese archivo zip y pulsa el botón restaurar.", - "switch-db-charset": "Cambiar codificación" + "switch-db-charset": "Codificación de la base de datos", + "general": "General", + "advanced": "Avanzado" } \ No newline at end of file diff --git a/View/Backup.html.twig b/View/Backup.html.twig index dec8665..d24da40 100644 --- a/View/Backup.html.twig +++ b/View/Backup.html.twig @@ -40,6 +40,7 @@ {{ formToken() }} +

@@ -47,29 +48,91 @@

{{ trans('download-backup-p') }}

-
@@ -169,24 +232,6 @@ -
- -
@@ -260,6 +305,11 @@ } $(document).ready(function () { + let downloadTabInput = $('#f_download').find('input[name="download_tab"]'); + $('#download-options-tab button[data-download-tab]').on('shown.bs.tab', function (event) { + downloadTabInput.val($(event.target).data('download-tab')); + }); + $('#f_restore_db').on('submit', function (e) { animateSpinner('add'); let fileInput = $(this).find('input[type=file]'); From ee5f9bfd8b0b9ed0a93f6cc075f5fd4cf610091b Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Thu, 2 Oct 2025 11:27:37 +0200 Subject: [PATCH 2/3] fix(UI): created extra pannel for database charset --- Controller/Backup.php | 3 +- View/Backup.html.twig | 154 ++++++++++++++++++------------------------ 2 files changed, 67 insertions(+), 90 deletions(-) diff --git a/Controller/Backup.php b/Controller/Backup.php index f0f6b4b..e8bd304 100644 --- a/Controller/Backup.php +++ b/Controller/Backup.php @@ -696,8 +696,7 @@ private function switchDbCharsetAction(): void } $this->db_charset = $selectedCharset; - $this->active_tab = 'download'; - $this->download_tab = 'advanced'; + $this->active_tab = 'advanced'; Tools::log()->notice('record-updated-correctly'); } diff --git a/View/Backup.html.twig b/View/Backup.html.twig index d24da40..659fc99 100644 --- a/View/Backup.html.twig +++ b/View/Backup.html.twig @@ -20,6 +20,14 @@ {{ trans('restore') }} +
@@ -40,7 +48,6 @@ {{ formToken() }} -

@@ -48,90 +55,32 @@

{{ trans('download-backup-p') }}

-
@@ -265,6 +214,40 @@
+ {% set tabClass = fsc.active_tab == 'advanced' ? 'tab-pane fade show active' : 'tab-pane fade' %} +
+
+
+

+ {{ trans('switch-db-charset') }} +

+ +
+
+
@@ -305,11 +288,6 @@ } $(document).ready(function () { - let downloadTabInput = $('#f_download').find('input[name="download_tab"]'); - $('#download-options-tab button[data-download-tab]').on('shown.bs.tab', function (event) { - downloadTabInput.val($(event.target).data('download-tab')); - }); - $('#f_restore_db').on('submit', function (e) { animateSpinner('add'); let fileInput = $(this).find('input[type=file]'); @@ -334,4 +312,4 @@ }); }); -{% endblock %} \ No newline at end of file +{% endblock %} From b9b26e68dc63cf74d08d8ca6de87076e2500f60d Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Thu, 2 Oct 2025 12:08:43 +0200 Subject: [PATCH 3/3] feat(ui): texto informativo --- Translation/en_EN.json | 1 + Translation/es_ES.json | 1 + View/Backup.html.twig | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/Translation/en_EN.json b/Translation/en_EN.json index d66a725..08cc607 100644 --- a/Translation/en_EN.json +++ b/Translation/en_EN.json @@ -16,6 +16,7 @@ "restore-files": "Restore files", "restore-files-p": "If you have the backup of the files, select that zip file and press the restore button.", "switch-db-charset": "Database encoding", + "switch-db-charset-info": "The encoding must match the backup. If you receive a warning that it is different, change it from here.", "general": "General", "advanced": "Advanced" } \ No newline at end of file diff --git a/Translation/es_ES.json b/Translation/es_ES.json index 9500bc7..7154f25 100644 --- a/Translation/es_ES.json +++ b/Translation/es_ES.json @@ -16,6 +16,7 @@ "restore-files": "Restaurar archivos", "restore-files-p": "Si tienes la copia de seguridad de los archivos, selecciona ese archivo zip y pulsa el botón restaurar.", "switch-db-charset": "Codificación de la base de datos", + "switch-db-charset-info": "La codificación debe ser la misma que la de la copia de seguridad. Si recibe aviso de que no es la misma, cámbiela desde aquí.", "general": "General", "advanced": "Avanzado" } \ No newline at end of file diff --git a/View/Backup.html.twig b/View/Backup.html.twig index 659fc99..931e30f 100644 --- a/View/Backup.html.twig +++ b/View/Backup.html.twig @@ -221,6 +221,11 @@

{{ trans('switch-db-charset') }}

+

+ {{ trans('switch-db-charset-info') }} +

+ +