diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2f8f3266009..7554f5e5851 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13931,3 +13931,71 @@ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto' return '&' . http_build_query($TParam); } + +/** + * Displays an error page when a record is not found. It allows customization of the message, + * whether to include the header and footer, and if only the message should be shown without additional details. + * The function also supports executing additional hooks for customized handling of error pages. + * + * @param string $message Custom error message to display. If empty, a default "Record Not Found" message is shown. + * @param int $printheader Determines if the page header should be printed (1 = yes, 0 = no). + * @param int $printfooter Determines if the page footer should be printed (1 = yes, 0 = no). + * @param int $showonlymessage If set to 1, only the error message is displayed without any additional information or hooks. + * @param mixed $params Optional parameters to pass to hooks for further processing or customization. + * @global object $conf Dolibarr configuration object (global) + * @global object $db Database connection object (global) + * @global object $user Current user object (global) + * @global Translate $langs Language translation object, initialized within the function if not already. + * @global object $hookmanager Hook manager object, initialized within the function if not already for executing hooks. + * @global string $action Current action, can be modified by hooks. + * @global object $object Current object, can be modified by hooks. + * @return void This function terminates script execution after outputting the error page. + */ +function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) +{ + global $conf, $db, $user, $langs, $hookmanager; + global $action, $object; + + if (!is_object($langs)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; + $langs = new Translate('', $conf); + $langs->setDefaultLang(); + } + + $langs->load("errors"); + + if ($printheader) { + if (function_exists("llxHeader")) { + llxHeader(''); + } elseif (function_exists("llxHeaderVierge")) { + llxHeaderVierge(''); + } + } + + print '