diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index e86e221bbb7..af115c3aab2 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2024 Frédéric France * * 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 @@ -930,14 +931,15 @@ class Invoices extends DolibarrApi * "notrigger": 0 * } * - * @param int $id Invoice ID - * @param int $idwarehouse Warehouse ID - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return Object|false Object with cleaned properties + * @param int $id Invoice ID + * @param string $force_number force ref invoice + * @param int $idwarehouse Warehouse ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return Object|false Object with cleaned properties * * @url POST {id}/validate */ - public function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $force_number = '', $idwarehouse = 0, $notrigger = 0) { if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); @@ -951,7 +953,7 @@ class Invoices extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); + $result = $this->invoice->validate(DolibarrApiAccess::$user, $force_number, $idwarehouse, $notrigger); if ($result == 0) { throw new RestException(304, 'Error nothing done. May be object is already validated'); } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index a518ec79f9d..f82a0fccd6e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2620,7 +2620,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @return array Array with properties (full path, date, ...) of to most recent file */ -function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(\.meta|_preview.*\.png)$', '^\.'), $nohook = 0, $mode = '') +function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(\.meta|_preview.*\.png)$', '^\.'), $nohook = 0, $mode = 0) { $tmparray = dol_dir_list($dir, 'files', 0, $regexfilter, $excludefilter, 'date', SORT_DESC, $mode, $nohook); return isset($tmparray[0]) ? $tmparray[0] : null; diff --git a/htdocs/product/dynamic_price/class/price_global_variable.class.php b/htdocs/product/dynamic_price/class/price_global_variable.class.php index e14075cfd48..13cf5233342 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ion Agorria + * Copyright (C) 2024 Frédéric France * * 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 @@ -169,11 +170,11 @@ class PriceGlobalVariable /** * Update object into database * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User|null $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ - public function update($user = 0, $notrigger = 0) + public function update($user = null, $notrigger = 0) { $error = 0; diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index 5097d8ac7ba..d36c0477bf4 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ion Agorria + * Copyright (C) 2024 Frédéric France * * 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 @@ -189,11 +190,11 @@ class PriceGlobalVariableUpdater /** * Update object into database * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User|null $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ - public function update($user = 0, $notrigger = 0) + public function update($user = null, $notrigger = 0) { $error = 0; @@ -557,12 +558,12 @@ class PriceGlobalVariableUpdater /** * Update next_update into database * - * @param string $next_update Next update to write - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param string $next_update Next update to write + * @param User|null $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ - public function update_next_update($next_update, $user = 0, $notrigger = 0) + public function update_next_update($next_update, $user = null, $notrigger = 0) { // phpcs:enable $error = 0; @@ -602,12 +603,12 @@ class PriceGlobalVariableUpdater /** * Update last_status into database * - * @param string $last_status Status to write - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param string $last_status Status to write + * @param User|null $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ - public function update_status($last_status, $user = 0, $notrigger = 0) + public function update_status($last_status, $user = null, $notrigger = 0) { // phpcs:enable $error = 0;