From 077f5b7e00bcf2766e0cd395d0f6aa15b550b011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 14 Oct 2024 16:46:19 +0200 Subject: [PATCH 1/2] NEW can delete a category translation (#31396) * can delete a category translation * Update traduction.php --- htdocs/categories/traduction.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 4b487ff07c5..f09da3130a8 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -41,6 +41,7 @@ $id = GETPOSTINT('id'); $label = GETPOST('label', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); +$langtodelete = GETPOST('langtodelete', 'alpha'); if ($id == '' && $label == '') { dol_print_error(null, 'Missing parameter id'); @@ -76,6 +77,17 @@ if ($cancel == $langs->trans("Cancel")) { $action = ''; } +// delete a translation +if ($action == 'delete' && $langtodelete && $user->hasRight('categorie', 'creer')) { + $res = $object->delMultiLangs($langtodelete, $user); + if ($res < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + unset($object->multilangs[$langtodelete]); + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + } + $action = ''; +} // validation of addition if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $permissiontoadd) { From 4146c0df892c0fbfdb2db7d312c3898ecbd00109 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Mon, 14 Oct 2024 16:50:32 +0200 Subject: [PATCH 2/2] accountancysystem: fix object create() method (#31390) The accountancysystem::create() method is not used in the code, and thus was not updated, especially after the introduction of the whole new accountancy system. The method is at least useful for the tests so fix it to create values like in every other tests. --- htdocs/accountancy/class/accountancysystem.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 0858179253f..bfdee1331b3 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2023 Frédéric France + * Copyright (C) 2024 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -170,8 +171,13 @@ class AccountancySystem $now = dol_now(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system"; - $sql .= " (date_creation, fk_user_author, numero, label)"; - $sql .= " VALUES ('".$this->db->idate($now)."',".((int) $user->id).",'".$this->db->escape($this->numero)."','".$this->db->escape($this->label)."')"; + $sql .= " (date_creation, fk_user_author, label, pcg_version, active)"; + $sql .= " VALUES ('" + . $this->db->idate($now) ."'," + . ((int) $user->id) .",'" + . $this->db->escape($this->label) ."','" + . $this->db->escape($this->pcg_version) ."'," + . ((int) $this->active) .")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql);