diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index cb04d31acbf..ba785b3bf5c 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2025 Alexandre Spangaro + * Copyright (C) 2013-2026 Alexandre Spangaro * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2025 Frédéric France @@ -869,7 +869,7 @@ if ($action == 'export_file') { ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").'...', '', 'export_fileconfirm', $form_question, '', 1, 390, 700); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").'...', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 500, 700); } // Print form confirm diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 3a6b76e40c5..9984056beae 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -1161,7 +1161,7 @@ class BlockedLog { $aaa = null; try { - $aaa = (object) jsonOrUnserialize($data); + $aaa = (object) jsonOrUnserialize($data, false); } catch (Exception $e) { // print $e->getErrs); } diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 717e18ac061..9c43f104b4f 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -54,7 +54,7 @@ $date_endyear = GETPOSTINT('date_endyear'); $nbofyear = 4; -// Change this to test different cases of setup +// Change this to test different cases of setup. //$conf->global->SOCIETE_FISCAL_MONTH_START = 7; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ea233483aae..f50011bee9e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4943,6 +4943,8 @@ abstract class CommonObject $this->context = array_merge($this->context, array('newstatus' => $status)); if ($trigkey && $trigkey != 'none') { + $this->oldcopy = dol_clone($this); + // Call trigger $result = $this->call_trigger($trigkey, $user); if ($result < 0) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4cfaf896aef..a988c197ce0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -15,7 +15,7 @@ * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2012-2015 Raphaël Doursenaud - * Copyright (C) 2014-2023 Alexandre Spangaro + * Copyright (C) 2014-2026 Alexandre Spangaro * Copyright (C) 2018-2022 Ferran Marcet * Copyright (C) 2018-2026 Frédéric France * Copyright (C) 2018 Nicolas ZABOURI @@ -7387,7 +7387,7 @@ class Form if (!empty($user) && $user->admin && preg_match('/\'(..)\'/', $country_code, $reg)) { $langs->load("errors"); $new_country_code = $reg[1]; - $country_id = dol_getIdFromCode($this->db, $new_country_code, 'c_pays', 'code', 'rowid'); + $country_id = dol_getIdFromCode($this->db, $new_country_code, 'c_country', 'code', 'rowid'); $this->error .= '
'.$langs->trans("ErrorFixThisHere", DOL_URL_ROOT.'/admin/dict.php?id=10'.($country_id > 0 ? '&countryidforinsert='.$country_id : '')); } $this->error .= ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bf21c1f6da3..c47581339b4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1937,11 +1937,12 @@ function dol_size($size, $type = '') * @param string $newstr String to replace bad chars with. * @param int $unaccent 1=Remove also accent (default), 0 do not remove them * @param int $includequotes 1=Include simple quotes (double is already included by default) + * @param int $allowdash 1=Allow dash char after a space and before a string, 0 do not allow * @return string String cleaned * * @see dol_string_nospecial(), dol_string_unaccent(), dol_sanitizePathName() */ -function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1, $includequotes = 0) +function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1, $includequotes = 0, $allowdash = 0) { $str = (string) $str; @@ -1955,9 +1956,13 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1, $includequotes } $tmp = dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars); $tmp = preg_replace('/\-\-+/', '_', $tmp); - $tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp); - $tmp = preg_replace('/\s+\-$/', '', $tmp); + if (empty($allowdash)) { + $tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp); + $tmp = preg_replace('/\s+\-$/', '', $tmp); + } $tmp = str_replace('..', '', $tmp); + $tmp = str_replace('~', $newstr, $tmp); + $tmp = preg_replace('/\s{2,}/', ' ', $tmp); return $tmp; } @@ -1998,6 +2003,8 @@ function dol_sanitizePathName($str, $newstr = '_', $unaccent = 0, $allowdash = 0 } $tmp = str_replace('..', $newstr, $tmp); $tmp = str_replace('~', $newstr, $tmp); + $tmp = preg_replace('/\s{2,}/', ' ', $tmp); + return $tmp; } @@ -15703,11 +15710,12 @@ function showValueWithClipboardCPButton($valuetocopy, $showonlyonhover = 1, $tex * Decode an encoded string. The string can be encoded in json format (recommended) or with serialize (avoid this) * * @param string $stringtodecode String to decode (json or serialize coded) + * @param boolean $assoc true=Return is converted into associative array * @return mixed The decoded object. */ -function jsonOrUnserialize($stringtodecode) +function jsonOrUnserialize($stringtodecode, $assoc = true) { - $result = json_decode($stringtodecode); + $result = json_decode($stringtodecode, $assoc); if ($result === null) { $result = unserialize($stringtodecode); // For backward compatibility. Is no more used in recent versions. } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 0be4d164c0f..5c2b03dc3ee 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3214,13 +3214,7 @@ class CommandeFournisseur extends CommonOrder if ($qty < $this->line->packaging) { $qty = $this->line->packaging; } else { - // Ensure packaging is numeric, positive, and use fmod instead of %, to prevent error with decimal packaging values (resulting in division by zero) - if ( - !empty($this->line->packaging) - && is_numeric($this->line->packaging) - && (float) $this->line->packaging > 0 - && fmod((float) $qty, (float) $this->line->packaging) > 0 - ) { + if (!empty($this->line->packaging) && is_numeric($this->line->packaging) && (float) $this->line->packaging > 0 && (fmod((float) $qty, (float) $this->line->packaging) > 0)) { $coeff = intval($qty / $this->line->packaging) + 1; $qty = $this->line->packaging * $coeff; setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 33b999f1127..697fb9c7aa4 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1598,6 +1598,11 @@ if (empty($reshook)) { dol_syslog("Try to find source object origin=".$object->origin_type." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) { + if (empty($object->delivery_date)) { + $tmpdate = $srcobject->delivery_date; + $object->setDeliveryDate($user, $tmpdate); + } + $object->set_id_projet($user, $srcobject->fk_project); $lines = $srcobject->lines; diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 7f99eb8f9ed..5e3deaaacfb 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -207,7 +207,7 @@ insert into llx_c_tva(fk_pays,taux,recuperableonly,note,active,entity) values (1 insert into llx_c_tva(fk_pays,taux,recuperableonly,note,active,entity) values (140, '14','0','VAT rate - intermediary',1,__ENTITY__); insert into llx_c_tva(fk_pays,taux,recuperableonly,note,active,entity) values (140, '8','0','VAT rate - reduced', 1,__ENTITY__); insert into llx_c_tva(fk_pays,taux,recuperableonly,note,active,entity) values (140, '3','0','VAT rate - super-reduced', 1,__ENTITY__); -insert into llx_c_tva(fk_pays,taux,recuperableonly,note,active,entity) values (140, '16','0','VAT rate - standard',1,__ENTITY__); +insert into llx_c_tva(fk_pays,taux,recuperableonly,note,active,entity) values (140, '17','0','VAT rate - standard',1,__ENTITY__); -- MALI (id country=147) insert into llx_c_tva(fk_pays,taux,recuperableonly,note,active,entity) values (147, '0','0','VAT rate 0', 1,__ENTITY__); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 9ce4ccb76c5..c1e62959e8a 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1135,8 +1135,9 @@ class Thirdparties extends DolibarrApi $sql = ''; if ($mode === 'customer') { $sql = "SELECT f.ref, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture, re.fk_facture_line"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f"; - $sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".((int) $id); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = re.fk_facture_source"; + $sql .= " WHERE re.fk_soc = ".((int) $id); if ($filter == "available") { $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL"; } @@ -1145,7 +1146,8 @@ class Thirdparties extends DolibarrApi } } elseif ($mode === 'supplier') { $sql = "SELECT f.ref, f.type as factype, re.fk_invoice_supplier_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_invoice_supplier, re.fk_invoice_supplier_line"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = re.fk_invoice_supplier_source"; $sql .= " WHERE f.rowid = re.fk_invoice_supplier_source AND re.fk_soc = ".((int) $id); if ($filter == "available") { $sql .= " AND re.fk_invoice_supplier IS NULL AND re.fk_invoice_supplier_line IS NULL"; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a043494c693..fa7e2fde877 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1506,9 +1506,9 @@ class Societe extends CommonObject $this->order_min_amount = price2num($this->order_min_amount); $this->supplier_order_min_amount = price2num($this->supplier_order_min_amount); - $this->tva_assuj = (is_numeric($this->tva_assuj)) ? (int) trim((string) $this->tva_assuj) : 0; - $this->tva_intra = dol_sanitizeFileName($this->tva_intra ?? '', ''); - $this->vat_reverse_charge = empty($this->vat_reverse_charge) ? 0 : 1; + $this->tva_assuj = (is_numeric($this->tva_assuj)) ? (int) trim((string) $this->tva_assuj) : 0; + $this->tva_intra = trim($this->tva_intra); + $this->vat_reverse_charge = empty($this->vat_reverse_charge) ? 0 : 1; if (empty($this->status)) { $this->status = 0; } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index d5ac4c886f8..75776878340 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -634,7 +634,7 @@ if (empty($reshook)) { // Reopen ticket if ($object->fetch(GETPOSTINT('id'), GETPOST('track_id', 'alpha')) >= 0) { $new_status = GETPOSTINT('new_status'); - //$old_status = $object->status; + $res = $object->setStatut($new_status, null, '', $triggermodname); if ($res) { $url = 'card.php?track_id=' . $object->track_id; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 21a3cea83b9..8be726ba18d 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1717,7 +1717,7 @@ class Ticket extends CommonObject $this->status = Ticket::STATUS_READ; $sql = "UPDATE ".MAIN_DB_PREFIX."ticket"; - $sql .= " SET fk_statut = ".Ticket::STATUS_READ.", date_read = '".$this->db->idate(dol_now())."'"; + $sql .= " SET fk_statut = ".((int) $this->status) .", date_read = '".$this->db->idate(dol_now())."'"; $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::markAsRead"); @@ -1742,7 +1742,9 @@ class Ticket extends CommonObject $this->status = $this->oldcopy->status; $this->db->rollback(); + $this->error = implode(',', $this->errors); + dol_syslog(get_class($this)."::markAsRead ".$this->error, LOG_ERR); return -1; } @@ -2009,8 +2011,11 @@ class Ticket extends CommonObject if ($this->status != Ticket::STATUS_CLOSED && $this->status != Ticket::STATUS_CANCELED) { // not closed $this->db->begin(); + $this->oldcopy = dol_clone($this); + $this->status = ($mode ? Ticket::STATUS_CANCELED : Ticket::STATUS_CLOSED); + $sql = "UPDATE ".MAIN_DB_PREFIX."ticket"; - $sql .= " SET fk_statut=".($mode ? Ticket::STATUS_CANCELED : Ticket::STATUS_CLOSED).", progress=100, date_close='".$this->db->idate(dol_now())."'"; + $sql .= " SET fk_statut = ".((int) $this->status).", progress=100, date_close='".$this->db->idate(dol_now())."'"; $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::close mode=".$mode); @@ -3068,8 +3073,10 @@ class Ticket extends CommonObject if ((getDolGlobalInt('TICKET_SET_STATUS_ON_ANSWER', -1) < 0 && ($object->status < self::STATUS_IN_PROGRESS && !$user->socid && !$private)) || ($object->status > self::STATUS_IN_PROGRESS && $public_area)) { + // Set status $object->setStatut($object::STATUS_IN_PROGRESS, null, '', 'TICKET_MODIFY'); } elseif (getDolGlobalInt('TICKET_SET_STATUS_ON_ANSWER', -1) >= 0 && empty($user->socid) && empty($private)) { + // Set status $object->setStatut(getDolGlobalInt('TICKET_SET_STATUS_ON_ANSWER'), null, '', 'TICKET_MODIFY'); } diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 178b97b2417..1a39504ad93 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -298,7 +298,9 @@ if (empty($reshook)) { $result = $objecttmp->fetch($toselectid); if ($result > 0) { if ($objecttmp->status == Ticket::STATUS_CLOSED || $objecttmp->status == Ticket::STATUS_CANCELED) { + // Set status $result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED, null, '', 'TICKET_MODIFY'); + if ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++;