54if (!function_exists(
'utf8_encode')) {
62 function utf8_encode($elements)
64 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
68if (!function_exists(
'utf8_decode')) {
76 function utf8_decode($elements)
78 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
81if (!function_exists(
'str_starts_with')) {
90 function str_starts_with($haystack, $needle)
92 return (
string) $needle !==
'' && strncmp($haystack, $needle, strlen($needle)) === 0;
95if (!function_exists(
'str_ends_with')) {
104 function str_ends_with($haystack, $needle)
106 return $needle !==
'' && substr($haystack, -strlen($needle)) === (string) $needle;
109if (!function_exists(
'str_contains')) {
118 function str_contains($haystack, $needle)
120 return $needle !==
'' && mb_strpos($haystack, $needle) !==
false;
140 if (!is_object(
$object) && empty($module)) {
143 if (empty($module) && !empty(
$object->element)) {
148 if ($module ==
'fichinter') {
149 $module =
'ficheinter';
150 } elseif ($module ==
'invoice_supplier') {
151 $module =
'supplier_invoice';
152 } elseif ($module ==
'order_supplier') {
153 $module =
'supplier_order';
157 if ($mode ==
'output' || $mode ==
'outputrel' || $mode ==
'version') {
158 if (isset(
$conf->$module) && property_exists(
$conf->$module,
'multidir_output')) {
160 if ($mode !=
'outputrel') {
163 if ($forobject &&
$object->id > 0) {
167 } elseif (isset(
$conf->$module) && property_exists(
$conf->$module,
'dir_output')) {
169 if ($mode !=
'outputrel') {
170 $s =
$conf->$module->dir_output;
172 if ($forobject &&
$object->id > 0) {
177 return 'error-diroutput-not-defined-for-this-object='.$module;
179 } elseif ($mode ==
'temp') {
180 if (isset(
$conf->$module) && property_exists(
$conf->$module,
'multidir_temp')) {
182 } elseif (isset(
$conf->$module) && property_exists(
$conf->$module,
'dir_temp')) {
183 return $conf->$module->dir_temp;
185 return 'error-dirtemp-not-defined-for-this-object='.$module;
188 return 'error-bad-value-for-mode';
232 return (
string) (isset(
$conf->global->$key) ?
$conf->global->$key : $default);
247 return (
int) (isset(
$conf->global->$key) ?
$conf->global->$key : $default);
262 return (
float) (isset(
$conf->global->$key) ?
$conf->global->$key : $default);
276 return (
bool) (
$conf->global->$key ?? $default);
290 if (empty($tmpuser)) {
295 return (
string) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
308 if (empty($tmpuser)) {
313 return (
int) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
330 'adherent' =>
'member',
331 'member_type' =>
'adherent_type',
333 'contrat' =>
'contract',
334 'entrepot' =>
'stock',
335 'projet' =>
'project',
336 'categorie' =>
'category',
337 'commande' =>
'order',
338 'expedition' =>
'shipping',
339 'facture' =>
'invoice',
340 'fichinter' =>
'intervention',
341 'ficheinter' =>
'intervention',
342 'propale' =>
'propal',
343 'socpeople' =>
'contact',
344 'fournisseur' =>
'supplier',
346 'actioncomm' =>
'agenda',
347 'product_price' =>
'productprice',
348 'product_fournisseur_price' =>
'productsupplierprice',
358function isModEnabled($module)
368 $arrayconv[
'supplier_order'] =
'fournisseur';
369 $arrayconv[
'supplier_invoice'] =
'fournisseur';
374 if ($module ==
'delivery_note') {
378 $module =
'shipping';
382 $module_alt = $module;
383 if (!empty($arrayconv[$module])) {
384 $module_alt = $arrayconv[$module];
386 $module_bis = $module;
387 if (!empty($arrayconvbis[$module])) {
388 $module_bis = $arrayconvbis[$module];
391 return !empty(
$conf->modules[$module]) || !empty(
$conf->modules[$module_alt]) || !empty(
$conf->modules[$module_bis]);
410 $moduletomoduletouse = array(
411 'invoice' =>
'facture',
413 $moduleParmsMapping = array(
414 'product' =>
'produit',
417 if (!empty($moduletomoduletouse[$module])) {
418 $module = $moduletomoduletouse[$module];
421 $warningDelayPath = $parmlevel1;
422 if (!empty($moduleParmsMapping[$warningDelayPath])) {
423 $warningDelayPath = $moduleParmsMapping[$warningDelayPath];
427 if (!empty(
$conf->$module->$warningDelayPath->warning_delay)) {
428 if (!empty(
$conf->$module->$warningDelayPath->$parmlevel2->warning_delay)) {
429 return (
int)
$conf->$module->$warningDelayPath->$parmlevel2->warning_delay;
433 if (!empty(
$conf->$module->$warningDelayPath->warning_delay)) {
434 return (
int)
$conf->$module->$warningDelayPath->$parmlevel1->warning_delay;
449 if ($timestamp ===
'') {
450 dol_syslog(
'Using empty string for a timestamp is deprecated, prefer use of null when calling page '.$_SERVER[
"PHP_SELF"] .
getCallerInfoString(), LOG_NOTICE);
453 if (is_null($timestamp) || !is_numeric($timestamp)) {
473 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
475 $class =
'DoliDB'.ucfirst($type);
476 $db =
new $class($type, $host, $user, $pass, $name, $port);
497function getEntity($element, $shared = 1, $currentobject =
null)
501 if (!is_object($hookmanager)) {
502 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
509 $element =
'project';
512 $element =
'contract';
514 case 'order_supplier':
515 $element =
'supplier_order';
517 case 'invoice_supplier':
518 $element =
'supplier_invoice';
522 if (is_object($mc)) {
523 $out = $mc->getEntity($element, $shared, $currentobject);
526 $addzero = array(
'user',
'usergroup',
'cronjob',
'c_email_templates',
'email_template',
'default_values',
'overwrite_trans');
528 $addzero[] =
'c_holiday_types';
530 if (in_array($element, $addzero)) {
533 $out .= ((int)
$conf->entity);
538 'element' => $element,
541 'currentobject' => $currentobject,
545 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
547 if (is_numeric($reshook)) {
548 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
549 $out .=
','.$hookmanager->resPrint;
550 } elseif ($reshook == 1) {
551 $out = $hookmanager->resPrint;
568 if (is_object($mc) && method_exists($mc,
'setEntity')) {
569 return $mc->setEntity($currentobject);
571 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity :
$conf->entity);
583 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
595 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1) {
596 $r = chr($n % 26 + 0x41) . $r;
620 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
627 $user_agent = substr($user_agent, 0, 512);
629 $detectmobile =
new Mobile_Detect(
null, $user_agent);
630 $tablet = $detectmobile->isTablet();
632 if ($detectmobile->isMobile()) {
636 if ($detectmobile->is(
'AndroidOS')) {
637 $os = $phone =
'android';
638 } elseif ($detectmobile->is(
'BlackBerryOS')) {
639 $os = $phone =
'blackberry';
640 } elseif ($detectmobile->is(
'iOS')) {
643 } elseif ($detectmobile->is(
'PalmOS')) {
644 $os = $phone =
'palm';
645 } elseif ($detectmobile->is(
'SymbianOS')) {
647 } elseif ($detectmobile->is(
'webOS')) {
649 } elseif ($detectmobile->is(
'MaemoOS')) {
651 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
657 if (preg_match(
'/linux/i', $user_agent)) {
659 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
661 } elseif (preg_match(
'/windows/i', $user_agent)) {
667 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
669 $version = empty($reg[2]) ?
'' : $reg[2];
670 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
672 $version = empty($reg[2]) ?
'' : $reg[2];
673 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
675 $version = empty($reg[2]) ?
'' : $reg[2];
676 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
679 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
681 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
683 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
685 $version = empty($reg[2]) ?
'' : $reg[2];
686 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
689 $version = empty($reg[2]) ?
'' : $reg[2];
690 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
692 $version = end($reg);
693 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
696 $version = end($reg);
697 } elseif (preg_match(
'/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
699 $name =
'textbrowser';
700 $version = empty($reg[3]) ?
'' : $reg[3];
701 } elseif (preg_match(
'/w3m\/([\d\.]+)/i', $user_agent, $reg)) {
703 $name =
'textbrowser';
704 $version = empty($reg[1]) ?
'' : $reg[1];
716 'browsername' => $name,
717 'browserversion' => $version,
719 'browserua' => $user_agent,
734 $disconnectdone =
false;
736 if (is_object($db) && !empty($db->connected)) {
737 $depth = $db->transaction_opened;
738 $disconnectdone = $db->close();
740 dol_syslog(
"--- End access to ".(empty($_SERVER[
"PHP_SELF"]) ?
'unknown' : $_SERVER[
"PHP_SELF"]).(($disconnectdone && $depth) ?
' (Warn: db disconnection forced, transaction depth was '.$depth.
')' :
''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
752function GETPOSTISSET($paramname)
756 $relativepathstring = $_SERVER[
"PHP_SELF"];
758 if (constant(
'DOL_URL_ROOT')) {
759 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
761 $relativepathstring = ltrim($relativepathstring,
'/');
762 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
768 if (!empty($_GET[
'restore_lastsearch_values'])) {
769 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
770 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
771 if (is_array($tmp)) {
772 foreach ($tmp as $key => $val) {
773 if ($key == $paramname) {
781 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
783 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
785 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
787 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
791 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
808 if (empty($method)) {
809 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
810 } elseif ($method == 1) {
811 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
812 } elseif ($method == 2) {
813 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
814 } elseif ($method == 3) {
815 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
817 $val =
'BadFirstParameterForGETPOST';
820 return is_array($val);
853function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
855 global $mysoc, $user,
$conf;
857 if (empty($paramname)) {
858 return 'BadFirstParameterForGETPOST';
861 dol_syslog(
"Deprecated use of GETPOST, called with 1st param = ".$paramname.
" and a 2nd param that is '', when calling page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
866 if (empty($method)) {
867 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
868 } elseif ($method == 1) {
869 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
870 } elseif ($method == 2) {
871 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
872 } elseif ($method == 3) {
873 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
875 return 'BadThirdParameterForGETPOST';
878 $relativepathstring =
'';
880 if (empty($method) || $method == 3 || $method == 4) {
881 $relativepathstring = (empty($_SERVER[
"PHP_SELF"]) ?
'' : $_SERVER[
"PHP_SELF"]);
883 if (constant(
'DOL_URL_ROOT')) {
884 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
886 $relativepathstring = ltrim($relativepathstring,
'/');
887 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
893 if (!empty($_GET[
'restore_lastsearch_values'])) {
894 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
895 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
896 if (is_array($tmp)) {
897 foreach ($tmp as $key => $val) {
898 if ($key == $paramname) {
906 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
907 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
908 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
909 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
910 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
911 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
912 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
913 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
915 } elseif (!isset($_GET[
'sortfield'])) {
918 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
921 '@phan-var-force CommonObject $object';
922 if (is_object(
$object) && isset(
$object->fields[$paramname][
'default'])) {
924 $out =
$object->fields[$paramname][
'default'];
928 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
930 if (!empty($user->default_values)) {
931 if (isset($user->default_values[$relativepathstring][
'createform'])) {
932 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
934 if ($defkey !=
'_noquery_') {
935 $tmpqueryarraytohave = explode(
'&', $defkey);
938 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
939 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
952 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
953 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
960 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
962 if (!empty($user->default_values)) {
965 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
967 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
969 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
971 if ($defkey !=
'_noquery_') {
972 $tmpqueryarraytohave = explode(
'&', $defkey);
975 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
976 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
989 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
990 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
994 if ($paramname ==
'sortfield') {
997 if ($paramname ==
'sortorder') {
1005 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
1006 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
1007 if (!empty($_GET[
'disabledefaultvalues'])) {
1011 if ($defkey !=
'_noquery_') {
1012 $tmpqueryarraytohave = explode(
'&', $defkey);
1015 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
1016 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
1028 if ($qualified && isset($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname])) {
1030 if (isset($_POST[
'search_all']) || isset($_GET[
'search_all'])) {
1033 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
1034 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
1037 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
1038 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
1053 '@phan-var-force string $paramname';
1054 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
1056 $regreplace = array();
1060 while (preg_match(
'/__([A-Z0-9]+(?:_[A-Z0-9]+){0,3})__/i', $out, $reg) && ($loopnb < $maxloop)) {
1064 if ($reg[1] ==
'DAY') {
1066 $newout = $tmp[
'mday'];
1067 } elseif ($reg[1] ==
'MONTH') {
1069 $newout = $tmp[
'mon'];
1070 } elseif ($reg[1] ==
'YEAR') {
1072 $newout = $tmp[
'year'];
1073 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
1076 $newout = $tmp2[
'day'];
1077 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
1080 $newout = $tmp2[
'month'];
1081 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
1083 $newout = ($tmp[
'year'] - 1);
1084 } elseif ($reg[1] ==
'NEXT_DAY') {
1087 $newout = $tmp2[
'day'];
1088 } elseif ($reg[1] ==
'NEXT_MONTH') {
1091 $newout = $tmp2[
'month'];
1092 } elseif ($reg[1] ==
'NEXT_YEAR') {
1094 $newout = ($tmp[
'year'] + 1);
1095 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
1096 $newout = $mysoc->country_id;
1097 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
1098 $newout = $user->id;
1099 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
1100 $newout = $user->fk_user;
1101 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
1102 $newout =
$conf->entity;
1103 } elseif ($reg[1] ==
'ID') {
1106 $newout =
'REGREPLACE_'.$loopnb;
1107 $regreplace[$loopnb] = $reg[0];
1110 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
1112 if (!empty($regreplace)) {
1113 foreach ($regreplace as $key => $value) {
1114 $out = preg_replace(
'/REGREPLACE_'.$key.
'/', $value, $out);
1120 if (preg_match(
'/^array/', $check)) {
1121 $tmpcheck =
'alphanohtml';
1124 } elseif (!is_array($out)) {
1125 $out = explode(
',', $out);
1127 $tmparray = explode(
':', $check);
1128 if (!empty($tmparray[1])) {
1129 $tmpcheck = $tmparray[1];
1132 foreach ($out as $outkey => $outval) {
1133 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
1138 if (strpos($paramname,
'search_') === 0) {
1139 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
1143 $out =
sanitizeVal($out, $check, $filter, $options);
1150 if (preg_match(
'/^backto/i', $paramname)) {
1151 $out = str_replace(
'\\',
'/', $out);
1152 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
1154 $oldstringtoclean = $out;
1155 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
1156 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
1157 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
1158 }
while ($oldstringtoclean != $out);
1163 if (empty($method) || $method == 3 || $method == 4) {
1164 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
1171 if ($out !=
'' && isset($user)) {
1172 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
1177 if ($paramname ==
'hashp' && $out ==
'shared') {
1195 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
1227function GETPOSTDATE($prefix, $hourTime =
'', $gm =
'auto', $saverestore =
'')
1230 if ($hourTime ===
'getpost' || $hourTime ===
'getpostend') {
1231 $hour = (GETPOSTISSET($prefix .
'hour') &&
GETPOSTINT($prefix .
'hour') >= 0) ?
GETPOSTINT($prefix .
'hour') : ($hourTime ===
'getpostend' ? 23 : 0);
1232 $minute = (GETPOSTISSET($prefix .
'min') &&
GETPOSTINT($prefix .
'min') >= 0) ?
GETPOSTINT($prefix .
'min') : ($hourTime ===
'getpostend' ? 59 : 0);
1233 $second = (GETPOSTISSET($prefix .
'sec') &&
GETPOSTINT($prefix .
'sec') >= 0) ?
GETPOSTINT($prefix .
'sec') : ($hourTime ===
'getpostend' ? 59 : 0);
1234 } elseif (preg_match(
'/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) {
1235 $hour = intval($m[1]);
1236 $minute = intval($m[2]);
1237 $second = intval($m[3]);
1238 } elseif ($hourTime ===
'end') {
1243 $hour = $minute = $second = 0;
1248 && !GETPOSTISSET($prefix .
'day')
1249 && !GETPOSTISSET($prefix .
'month')
1250 && !GETPOSTISSET($prefix .
'year')
1251 && isset($_SESSION[
'DOLDATE_' . $saverestore .
'_day'])
1252 && isset($_SESSION[
'DOLDATE_' . $saverestore .
'_month'])
1253 && isset($_SESSION[
'DOLDATE_' . $saverestore .
'_year'])
1255 $day = $_SESSION[
'DOLDATE_'.$saverestore.
'_day'];
1256 $month = $_SESSION[
'DOLDATE_'.$saverestore.
'_month'];
1257 $year = $_SESSION[
'DOLDATE_'.$saverestore.
'_year'];
1265 $hour = (int) min($hour, 23);
1266 $minute = (int) min($minute, 59);
1267 $second = (int) min($second, 59);
1270 $_SESSION[
'DOLDATE_'.$saverestore.
'_day'] = $day;
1271 $_SESSION[
'DOLDATE_'.$saverestore.
'_month'] = $month;
1272 $_SESSION[
'DOLDATE_'.$saverestore.
'_year'] = $year;
1276 return dol_mktime($hour, $minute, $second, $month, $day, $year, $gm);
1290function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1292 return sanitizeVal($out, $check, $filter, $options);
1304function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1308 if ($out ===
null) {
1316 if (!is_numeric($out)) {
1321 if (is_array($out)) {
1322 $out = implode(
',', $out);
1324 if (preg_match(
'/[^0-9,-]+/i', $out)) {
1329 $out = filter_var($out, FILTER_SANITIZE_STRING);
1332 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
1336 $out = preg_replace(
'/[^:\/\[\]a-z0-9@\$\'\*\~\.\-_,;\?\!=%&+#]+/i',
'', $out);
1340 if (!is_array($out)) {
1342 if (preg_match(
'/[^a-z]+/i', $out)) {
1348 if (!is_array($out)) {
1350 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
1356 if (!is_array($out)) {
1358 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1364 if (!is_array($out)) {
1366 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1373 if (!is_array($out)) {
1376 $oldstringtoclean = $out;
1380 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1387 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1388 }
while ($oldstringtoclean != $out);
1392 case 'alphawithlgt':
1393 if (!is_array($out)) {
1396 $oldstringtoclean = $out;
1400 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1407 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1408 }
while ($oldstringtoclean != $out);
1414 case 'restricthtmlnolink':
1415 case 'restricthtml':
1416 case 'restricthtmlallowclass':
1417 case 'restricthtmlallowiframe':
1418 case 'restricthtmlallowlinkscript':
1419 case 'restricthtmlallowunvalid':
1424 if (empty($filter)) {
1425 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1427 if (is_null($options)) {
1430 $out = filter_var($out, $filter, $options);
1434 dol_syslog(
"Error, you call sanitizeVal() with a bad value for the check type. Data will be sanitized with alphanohtml.", LOG_ERR);
1435 $out =
GETPOST($out,
'alphanohtml');
1450function dolSetCookie(
string $cookiename,
string $cookievalue,
int $expire = -1)
1452 global $dolibarr_main_force_https;
1454 if ($expire == -1) {
1455 $expire = (time() + (86400 * 354));
1458 if (PHP_VERSION_ID < 70300) {
1459 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, empty($cookievalue) ? 0 : $expire,
'/',
'', !(empty($dolibarr_main_force_https) &&
isHTTPS() === false), true);
1462 $cookieparams = array(
1463 'expires' => empty($cookievalue) ? 0 : $expire,
1466 'secure' => !(empty($dolibarr_main_force_https) &&
isHTTPS() === false),
1470 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, $cookieparams);
1472 if (empty($cookievalue)) {
1473 unset($_COOKIE[$cookiename]);
1477if (!function_exists(
'dol_getprefix')) {
1488 function dol_getprefix($mode =
'')
1491 if ($mode ==
'email') {
1497 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1498 return $_SERVER[
"SERVER_NAME"];
1503 if (!empty(
$conf->file->instance_unique_id)) {
1504 return sha1(
'dolibarr'.
$conf->file->instance_unique_id);
1508 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1512 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1513 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1516 if (!empty($tmp_instance_unique_id)) {
1517 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1521 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1522 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1524 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1541 global
$conf, $langs, $user, $mysoc;
1545 if (!file_exists($fullpath)) {
1546 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1549 if (!empty($classname) && !class_exists($classname)) {
1550 return include $fullpath;
1552 return include_once $fullpath;
1570function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
1574 $path = preg_replace(
'/^\//',
'', $path);
1577 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1578 if (is_array(
$conf->file->dol_document_root)) {
1579 foreach (
$conf->file->dol_document_root as $key => $dirroot) {
1580 if ($key ==
'main') {
1584 if (@file_exists($dirroot.
'/'.$path)) {
1585 $res = $dirroot.
'/'.$path;
1590 if ($returnemptyifnotfound) {
1592 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1604 $res = DOL_URL_ROOT.
'/'.$path;
1607 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1610 $res = DOL_URL_ROOT.
'/'.$path;
1613 foreach (
$conf->file->dol_document_root as $key => $dirroot) {
1614 if ($key ==
'main') {
1619 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$conf->file->dol_main_url_root));
1620 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1623 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1628 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1629 if (!empty($regs[1])) {
1632 if (@file_exists($dirroot.
'/'.$regs[1])) {
1634 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).
$conf->file->dol_url_root[$key].
'/'.$path;
1635 } elseif ($type == 2) {
1636 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).
$conf->file->dol_url_root[$key].
'/'.$path;
1637 } elseif ($type == 3) {
1641 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$conf->file->dol_main_url_root));
1642 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1645 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
$conf->file->dol_url_root[$key].
'/'.$path;
1669 if (empty($properties)) {
1670 return get_object_vars($obj);
1673 $existingProperties = [];
1674 $realProperties = get_object_vars($obj);
1677 foreach ($properties as $property) {
1678 if (array_key_exists($property, $realProperties)) {
1680 $existingProperties[$property] = $obj->{$property};
1681 } elseif (property_exists($obj, $property)) {
1683 $existingProperties[$property] = $obj->{$property};
1687 return $existingProperties;
1716 $myclone = unserialize(serialize(
$object));
1718 if (!empty($tmpsavdb)) {
1721 } elseif ($native == 2) {
1724 $tmparray = get_object_vars(
$object);
1726 if (is_array($tmparray)) {
1727 foreach ($tmparray as $propertykey => $propertyval) {
1728 if (is_scalar($propertyval) || is_array($propertyval)) {
1729 $myclone->$propertykey = $propertyval;
1749function dol_size($size, $type =
'')
1752 if (empty(
$conf->dol_optimize_smallscreen)) {
1755 if ($type ==
'width' && $size > 250) {
1781 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1782 if ($includequotes) {
1783 $filesystem_forbidden_chars[] =
"'";
1786 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1787 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1788 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1789 $tmp = str_replace(
'..',
'', $tmp);
1790 $tmp = preg_replace(
'/\s{2,}/',
' ', $tmp);
1812 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1819 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1820 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1821 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1822 $tmp = str_replace(
'..',
'', $tmp);
1823 $tmp = preg_replace(
'/\s{2,}/',
' ', $tmp);
1839 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1841 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1843 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1847 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1851 $oldstringtoclean = $stringtoclean;
1854 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1855 }
while ($oldstringtoclean != $stringtoclean);
1859 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1862 return $stringtoclean;
1874 $oldstringtoclean = $stringtoclean;
1875 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1876 }
while ($oldstringtoclean != $stringtoclean);
1878 return $stringtoclean;
1891 return preg_replace(
'/[^\w]+/',
'', $str);
1905 if (is_null($str)) {
1910 if (extension_loaded(
'intl') &&
getDolGlobalString(
'MAIN_UNACCENT_USE_TRANSLITERATOR')) {
1911 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1912 return $transliterator->transliterate($str);
1915 $string = rawurlencode($str);
1916 $replacements = array(
1917 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1919 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1920 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1922 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
'%C5%90' =>
'O',
1924 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
'%C5%B0' =>
'U',
1925 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1926 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1928 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1929 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1931 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
'%C5%91' =>
'o',
1933 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
'%C5%B1' =>
'u',
1934 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1936 $string = strtr($string, $replacements);
1937 return rawurldecode($string);
1942 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1943 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1944 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1945 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1946 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1947 \xF9\xFA\xFB\xFC\xFD\xFF",
1955 $string = strtr($string, array(
"\xC4" =>
"Ae",
"\xC6" =>
"AE",
"\xD6" =>
"Oe",
"\xDC" =>
"Ue",
"\xDE" =>
"TH",
"\xDF" =>
"ss",
"\xE4" =>
"ae",
"\xE6" =>
"ae",
"\xF6" =>
"oe",
"\xFC" =>
"ue",
"\xFE" =>
"th"));
1973function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1975 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1976 if (empty($keepspaces)) {
1977 $forbidden_chars_to_replace[] =
" ";
1979 $forbidden_chars_to_remove = array();
1982 if (is_array($badcharstoreplace)) {
1983 $forbidden_chars_to_replace = $badcharstoreplace;
1985 if (is_array($badcharstoremove)) {
1986 $forbidden_chars_to_remove = $badcharstoremove;
1990 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
2009 if ($removetabcrlf) {
2010 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
2012 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
2027 if (function_exists(
'iconv')) {
2028 $slug = iconv(
'UTF-8',
'ASCII//TRANSLIT//IGNORE', $slug);
2032 $slug = strtolower($slug);
2035 $slug = preg_replace(
'/[^a-z0-9]+/',
'-', $slug);
2038 $slug = trim($slug,
'-');
2051function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
2053 if (is_null($stringtoescape)) {
2058 $substitjs = array(
"'" =>
"\\'",
"\r" =>
'\\r');
2060 if (empty($noescapebackslashn)) {
2061 $substitjs[
"\n"] =
'\\n';
2062 $substitjs[
'\\'] =
'\\\\';
2065 $substitjs[
"'"] =
"\\'";
2066 $substitjs[
'"'] =
"\\'";
2067 } elseif ($mode == 1) {
2068 $substitjs[
"'"] =
"\\'";
2069 } elseif ($mode == 2) {
2070 $substitjs[
'"'] =
'\\"';
2071 } elseif ($mode == 3) {
2072 $substitjs[
"'"] =
"\\'";
2073 $substitjs[
'"'] =
"\\\"";
2075 return strtr((
string) $stringtoescape, $substitjs);
2089 return rawurlencode($stringtoescape);
2100 return str_replace(
'"',
'\"', $stringtoescape);
2112 if (is_null($stringtoescape)) {
2116 if ($stringforquotes == 2) {
2117 return str_replace(
'"',
"'", $stringtoescape);
2118 } elseif ($stringforquotes == 1) {
2124 $stringtoescape = str_replace(
'\\',
'', $stringtoescape);
2125 return str_replace(
"'",
"\'", str_replace(
'"',
"'", $stringtoescape));
2128 return 'Bad parameter for stringforquotes in dol_escape_php';
2139 return preg_replace(
'/[^a-z0-9_]/i',
'', $stringtoescape);
2150 return $stringtoescape;
2214 $allowedtags = array(
'br',
'b',
'font',
'hr',
'span');
2215 if (!empty($allowothertags) && is_array($allowothertags)) {
2216 $allowedtags = array_merge($allowedtags, $allowothertags);
2220 if ($escapeonlyhtmltags) {
2221 return dol_escape_htmltag(
dol_string_onlythesehtmltags($s, 1, 0, 0, 0, $allowedtags), 1, -1,
'', 1, 1);
2223 return dol_escape_htmltag(
dol_string_onlythesehtmltags(
dol_htmlentitiesbr($s), 1, 0, 0, 0, $allowedtags), 1, -1,
'', 0, 1);
2239 $escapeonlyhtmltags = 1;
2240 return dol_escape_htmltag(
dol_string_onlythesehtmltags($s, 1, 1, 1, 0, array()), 0, 0,
'', $escapeonlyhtmltags, 1);
2265 return htmlspecialchars($s, ENT_HTML5,
'UTF-8');
2285function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
2287 if ($noescapetags ==
'common') {
2288 $noescapetags =
'html,body,a,b,em,hr,i,u,ul,ol,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody,h1,h2,h3,h4,h5,h6,h7,h8,h9';
2290 $noescapetags .=
',header,footer,nav,section,menu,menuitem';
2292 if ($cleanalsojavascript) {
2297 if ($escapeonlyhtmltags) {
2298 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
2305 $tmp = (string) $stringtoescape;
2308 $tmp = str_ireplace(
'<',
'__DONOTDECODELT', $tmp);
2309 $tmp = str_ireplace(
'>',
'__DONOTDECODEGT', $tmp);
2310 $tmp = str_ireplace(
'&',
'__DONOTDECODEAMP', $tmp);
2311 $tmp = str_ireplace(
'"',
'__DONOTDECODEQUOT', $tmp);
2312 $tmp = str_ireplace(
'&apos',
'__DONOTDECODEAPOS', $tmp);
2313 $tmp = str_ireplace(
''',
'__DONOTDECODE39', $tmp);
2315 $tmp = html_entity_decode((
string) $tmp, ENT_COMPAT,
'UTF-8');
2318 $tmp = str_ireplace(
'__DONOTDECODELT',
'<', $tmp);
2319 $tmp = str_ireplace(
'__DONOTDECODEGT',
'>', $tmp);
2320 $tmp = str_ireplace(
'__DONOTDECODEAMP',
'&', $tmp);
2321 $tmp = str_ireplace(
'__DONOTDECODEQUOT',
'"', $tmp);
2322 $tmp = str_ireplace(
'__DONOTDECODEAPOS',
'&apos', $tmp);
2323 $tmp = str_ireplace(
'__DONOTDECODE39',
''', $tmp);
2325 $tmp = str_ireplace(
''',
'__SIMPLEQUOTE__', $tmp);
2328 $tmp = strtr($tmp, array(
"<b>" =>
'',
'</b>' =>
'',
'<strong>' =>
'',
'</strong>' =>
''));
2331 $tmp = strtr($tmp, array(
"\r" =>
'\\r',
"\n" =>
'\\n'));
2332 } elseif ($keepn == -1) {
2333 $tmp = strtr($tmp, array(
"\r" =>
'',
"\n" =>
''));
2336 if ($escapeonlyhtmltags) {
2337 $tmp = htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
2341 $tmparrayoftags = array();
2342 if ($noescapetags) {
2343 $tmparrayoftags = explode(
',', $noescapetags);
2346 if (count($tmparrayoftags)) {
2351 $tmp = str_ireplace(array(
'__DOUBLEQUOTE',
'__BEGINTAGTOREPLACE',
'__ENDTAGTOREPLACE',
'__BEGINENDTAGTOREPLACE'),
'', $tmp);
2353 foreach ($tmparrayoftags as $tagtoreplace) {
2355 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2356 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2357 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
' \/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2363 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'(\s+)([^>]+)>/', $tmp, $reg)) {
2365 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[2]);
2366 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE__', $tmpattributes);
2367 $tmpattributes = preg_replace(
'/[^a-z0-9_%,\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2369 $tmp = str_replace(
'<'.$tagtoreplace.$reg[1].$reg[2].
'>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2372 $diff = strcmp($tmpold, $tmp);
2376 $tmp = str_ireplace(
'&',
'__ANDNOSEMICOLON__', $tmp);
2377 $tmp = str_ireplace(
'"',
'__DOUBLEQUOTENOSEMICOLON__', $tmp);
2378 $tmp = str_ireplace(
'<',
'__LESSTHAN__', $tmp);
2379 $tmp = str_ireplace(
'>',
'__GREATERTHAN__', $tmp);
2383 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
2387 if (count($tmparrayoftags)) {
2389 foreach ($tmparrayoftags as $tagtoreplace) {
2390 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
2391 $result = preg_replace(
'/__BEGINTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1>', $result);
2392 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
2393 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
2394 $result = preg_replace(
'/__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1 />', $result);
2397 $result = str_ireplace(
'__DOUBLEQUOTE__',
'"', $result);
2399 $result = str_ireplace(
'__ANDNOSEMICOLON__',
'&', $result);
2400 $result = str_ireplace(
'__DOUBLEQUOTENOSEMICOLON__',
'"', $result);
2401 $result = str_ireplace(
'__LESSTHAN__',
'<', $result);
2402 $result = str_ireplace(
'__GREATERTHAN__',
'>', $result);
2405 $result = str_ireplace(
'__SIMPLEQUOTE__',
''', $result);
2422 if (function_exists(
'mb_strtolower')) {
2423 return mb_strtolower($string, $encoding);
2425 return strtolower($string);
2439 if (function_exists(
'mb_strtoupper')) {
2440 return mb_strtoupper($string, $encoding);
2442 return strtoupper($string);
2456 if (function_exists(
'mb_substr')) {
2457 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
2459 return ucfirst($string);
2473 if (function_exists(
'mb_convert_case')) {
2474 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
2476 return ucwords($string);
2488 $backtrace = debug_backtrace();
2490 if (count($backtrace) >= 1) {
2492 if (count($backtrace) == 1) {
2495 $trace = $backtrace[$pos];
2496 if (isset($trace[
'file'], $trace[
'line'])) {
2497 $msg =
" From {$trace['file']}:{$trace['line']}.";
2525function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
2527 global
$conf, $user, $debugbar;
2530 if (!isModEnabled(
'syslog')) {
2535 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
2536 global $website, $websitekey;
2537 if (is_object($website) && !empty($website->ref)) {
2538 $suffixinfilename .=
'_website_'.$website->ref;
2539 } elseif (!empty($websitekey)) {
2540 $suffixinfilename .=
'_website_'.$websitekey;
2545 if (defined(
'USESUFFIXINLOG')) {
2546 $suffixinfilename .= constant(
'USESUFFIXINLOG');
2550 foreach (
$conf->loghandlers as $loghandlerinstance) {
2551 $loghandlerinstance->setIdent($ident);
2555 if (!empty($message)) {
2558 $logLevels = array(LOG_EMERG =>
'EMERG', LOG_ALERT =>
'ALERT', LOG_CRIT =>
'CRITICAL', LOG_ERR =>
'ERR', LOG_WARNING =>
'WARN', LOG_NOTICE =>
'NOTICE', LOG_INFO =>
'INFO', LOG_DEBUG =>
'DEBUG');
2560 if (!array_key_exists($level, $logLevels)) {
2561 dol_syslog(
'Error Bad Log Level '.$level, LOG_ERR);
2569 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
2573 if ((!empty($_REQUEST[
'logtohtml']) &&
getDolGlobalString(
'MAIN_ENABLE_LOG_TO_HTML'))
2574 || (is_object($user) && $user->hasRight(
'debugbar',
'read') && is_object($debugbar))) {
2575 $ospid = sprintf(
"%7s",
dol_trunc((
string) getmypid(), 7,
'right',
'UTF-8', 1));
2576 $osuser =
" ".sprintf(
"%6s",
dol_trunc(function_exists(
'posix_getuid') ? posix_getuid() :
'', 6,
'right',
'UTF-8', 1));
2578 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".sprintf(
"%-7s", $logLevels[$level]).
" ".$ospid.
" ".$osuser.
" ".$message;
2584 print
"\n\n<!-- Log start\n";
2586 print
"Log end -->\n";
2590 'message' => $message,
2591 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') :
''),
2593 'user' => ((is_object($user) && $user->id) ? $user->login :
''),
2595 'osuser' => function_exists(
'posix_getuid') ? (string) posix_getuid() :
'',
2596 'ospid' => (string) getmypid()
2601 if (!empty($remoteip)) {
2602 $data[
'ip'] = $remoteip;
2606 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
2607 $tmpips = explode(
',', $_SERVER[
'HTTP_X_FORWARDED_FOR']);
2611 foreach ($tmpips as $tmpip) {
2612 $tmpip = trim($tmpip);
2613 if (strtolower($tmpip) == strtolower($remoteip)) {
2616 if (empty($data[
'ip'])) {
2617 $data[
'ip'] = $tmpip;
2620 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$tmpip;
2623 if (!$foundremoteip) {
2625 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$remoteip;
2627 $data[
'ip'] .= (($j > 0) ?
']' :
'');
2628 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP'])) {
2629 $tmpips = explode(
',', $_SERVER[
'HTTP_CLIENT_IP']);
2633 foreach ($tmpips as $tmpip) {
2634 $tmpip = trim($tmpip);
2635 if (strtolower($tmpip) == strtolower($remoteip)) {
2638 if (empty($data[
'ip'])) {
2639 $data[
'ip'] = $tmpip;
2642 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$tmpip;
2645 if (!$foundremoteip) {
2647 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$remoteip;
2649 $data[
'ip'] .= (($j > 0) ?
']' :
'');
2651 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
2653 $data[
'ip'] = (string) $_SERVER[
'SERVER_ADDR'];
2654 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
2656 $data[
'ip'] = (string) $_SERVER[
'COMPUTERNAME'];
2658 $data[
'ip'] =
'???';
2661 if (!empty($_SERVER[
'USERNAME'])) {
2663 $data[
'osuser'] = (string) $_SERVER[
'USERNAME'];
2664 } elseif (!empty($_SERVER[
'LOGNAME'])) {
2666 $data[
'osuser'] = (string) $_SERVER[
'LOGNAME'];
2670 foreach (
$conf->loghandlers as $loghandlerinstance) {
2671 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
2674 $loghandlerinstance->export($data, $suffixinfilename);
2680 foreach (
$conf->loghandlers as $loghandlerinstance) {
2681 $loghandlerinstance->setIdent($ident);
2701 $form =
new Form($db);
2703 $templatenameforexport = $website->name_template;
2704 if (empty($templatenameforexport)) {
2705 $templatenameforexport =
'website_'.$website->ref;
2709 $out .=
'<input type="button" class="cursorpointer button bordertransp" id="open-dialog-' . $name .
'" value="'.dol_escape_htmltag($buttonstring).
'"/>';
2712 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">';
2713 $out .=
'jQuery(document).ready(function () {';
2714 $out .=
' jQuery("#open-dialog-' . $name .
'").click(function () {';
2715 $out .=
' var dialogHtml = \'';
2717 $dialogcontent =
' <div id="custom-dialog-' . $name .
'">';
2718 $dialogcontent .=
' <div style="margin-top: 20px;">';
2719 $dialogcontent .=
' <label for="export-site-' . $name .
'"><strong>'.$langs->trans(
"ExportSiteLabel").
'...</label><br>';
2720 $dialogcontent .=
' <button class="button smallpaddingimp" id="export-site-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"DownloadZip")) .
'</button>';
2721 $dialogcontent .=
' </div>';
2722 $dialogcontent .=
' <br>';
2723 $dialogcontent .=
' <div style="margin-top: 20px;">';
2724 $dialogcontent .=
' <strong>'.$langs->trans(
"ExportSiteGitLabel").
' '.$form->textwithpicto(
'', $langs->trans(
"SourceFiles"), 1,
'help',
'', 0, 3,
'').
'</strong><br>';
2725 $dialogcontent .=
' <form action="'.dol_escape_htmltag($overwriteGitUrl).
'" method="POST">';
2726 $dialogcontent .=
' <input type="hidden" name="action" value="overwritesite">';
2727 $dialogcontent .=
' <input type="hidden" name="token" value="'.newToken().
'">';
2728 $dialogcontent .=
' <input type="text" autofocus name="export_path" id="export-path-'.$name.
'" placeholder="'.$langs->trans(
'ExportPath').
'" style="width:400px " value="'.
dol_escape_htmltag($templatenameforexport).
'"/><br>';
2729 $dialogcontent .=
' <button type="submit" class="button smallpaddingimp" id="overwrite-git-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"ExportIntoGIT")) .
'</button>';
2730 $dialogcontent .=
' </form>';
2731 $dialogcontent .=
' </div>';
2732 $dialogcontent .=
' </div>';
2739 // Add the content of the dialog to the body of the page
2740 $out .= ' var $dialog = jQuery(
"#custom-dialog-' . $name . '");
';
2741 $out .= ' if ($dialog.length > 0) {
2744 jQuery(
"body").append(dialogHtml);
';
2746 // Configuration of popup
2747 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog({
';
2748 $out .= ' autoOpen:
false,
';
2749 $out .= ' modal:
true,
';
2750 $out .= ' height: 290,
';
2751 $out .= ' width:
"40%",
';
2752 $out .= ' title:
"' . dol_escape_js($label) . '",
';
2755 // Simulate a click on the original "submit" input to export the site.
2756 $out .= ' jQuery(
"#export-site-' . $name . '").click(
function () {
';
2757 $out .= ' console.log(
"Clic on exportsite.");
';
2758 $out .= ' var target = jQuery(
"input[name=\'' . dol_escape_js($exportSiteName) . '\']");
';
2759 $out .= ' console.log(
"element founded:", target.length > 0);
';
2760 $out .= ' if (target.length > 0) { target.click(); }
';
2761 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"close");
';
2765 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"open");
';
2766 $out .= ' return false;
';
2769 $out .= '</script>
';
2791function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '
', $morecss = 'classlink
button bordertransp
', $jsonopen = '', $jsonclose = '', $accesskey = '')
2795 if (strpos($url, '?
') > 0) {
2796 $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2798 $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2803 //print '<input
type=
"submit" class=
"button bordertransp"'.$disabled.' value=
"'.dol_escape_htmltag($langs->trans("MediaFiles
")).'" name=
"file_manager">
';
2804 $out .= '<!-- a link
for button to open url into a dialog popup -->
';
2805 $out .= '<a
'.($accesskey ? ' accesskey=
"'.$accesskey.'"' : '').' class=
"cursorpointer reposition button_'.$name.($morecss ? ' '.$morecss : '').'"'.$disabled.' title=
"'.dol_escape_htmltag($label).'"';
2806 if (empty($conf->use_javascript_ajax)) {
2807 $out .= ' href=
"'.DOL_URL_ROOT.$url.'" target=
"_blank"';
2808 } elseif ($jsonopen) {
2809 $out .= ' href=
"#" onclick=
"'.$jsonopen.'"';
2811 $out .= ' href=
"#"';
2813 $out .= '>
'.$buttonstring.'</a>
';
2815 if (!empty($conf->use_javascript_ajax)) {
2816 // Add code to open url using the popup.
2817 $out .= '<!-- code to open popup and variables to retrieve returned variables -->
';
2818 $out .= '<div
id=
"idfordialog'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for dialog
' : '').'</div>
';
2820 $out .= '<!-- Add js code to open dialog popup on dialog -->
';
2821 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
2822 jQuery(document).ready(
function () {
2823 jQuery(
".button_'.$name.'").click(
function () {
2824 console.log(\
'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
2825 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
2826 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
2830 height: (window.innerHeight - 150),
2833 open: function (event, ui) {
2834 console.log(
"open popup name='.$name.'");
2836 close:
function (event, ui) {
2837 console.log(
"Popup is closed, run jsonclose = '.$jsonclose.'");
2838 '.(empty($jsonclose) ? '' : $jsonclose.';
').'
2842 $tmpdialog.dialog(\
'open\');
2867function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
2869 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
2889function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0, $morecssdiv =
'')
2891 global
$conf, $langs, $hookmanager;
2895 if (!empty(
$conf->dol_optimize_smallscreen)) {
2899 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
2901 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2902 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
2906 if ($morehtmlright) {
2907 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2914 if (is_array($links) && !empty($links)) {
2915 $keys = array_keys($links);
2917 $maxkey = max($keys);
2923 if (empty($limittoshow)) {
2926 if (!empty(
$conf->dol_optimize_smallscreen)) {
2934 for ($i = 0; $i <= $maxkey; $i++) {
2935 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2937 if ($i >= $limittoshow) {
2943 for ($i = 0; $i <= $maxkey; $i++) {
2944 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2950 if ($i < $limittoshow || $isactive) {
2952 $out .=
'<div class="inline-block tabsElem'.($isactive ?
' tabsElemActive' :
'').((!$isactive &&
getDolGlobalString(
'MAIN_HIDE_INACTIVETAB_ON_PRINT')) ?
' hideonprint' :
'').
'"><!-- id tab = '.(empty($links[$i][2]) ?
'' :
dol_escape_htmltag($links[$i][2])).
' -->';
2954 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2955 if (!empty($links[$i][0])) {
2956 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2958 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2960 } elseif (!empty($links[$i][1])) {
2962 $out .=
'<div class="tab tab'.($isactive ?
'active' :
'unactive').
'" style="margin: 0 !important">';
2964 if (!empty($links[$i][0])) {
2965 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2966 $out .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="tab inline-block valignmiddle'.($morecss ?
' '.$morecss :
'').(!empty($links[$i][5]) ?
' '.$links[$i][5] :
'').
'" href="'.$links[$i][0].
'" title="'.
dol_escape_htmltag($titletoshow).
'">';
2969 if ($displaytab == 0 && $picto) {
2970 $out .=
img_picto($title, $picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle paddingright marginrightonlyshort');
2973 $out .= $links[$i][1];
2974 if (!empty($links[$i][0])) {
2975 $out .=
'</a>'.
"\n";
2977 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2986 $outmore .=
'<div class="popuptabset wordwrap">';
2988 $outmore_content =
'';
2990 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2991 if (!empty($links[$i][0])) {
2992 $outmore_content .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2994 $outmore_content .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2996 } elseif (!empty($links[$i][1])) {
2997 $outmore_content .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2998 $outmore_content .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2999 $outmore_content .=
'</a>'.
"\n";
3001 if ($outmore_content !==
'') {
3002 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">' . $outmore_content .
'</div>';
3008 $displaytab = $i + 1;
3011 $outmore .=
'</div>';
3015 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
3016 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
3017 $widthofpopup = 240;
3019 $tabsname = $moretabssuffix;
3020 if (empty($tabsname)) {
3021 $tabsname = str_replace(
"@",
"", $picto);
3023 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
3025 $out .=
'<div class="tab valignmiddle"><a href="#" class="tab moretab inline-block tabunactive valignmiddle"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
3027 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
3030 $out .=
'<div></div>';
3033 $out .=
'<script nonce="'.getNonce().
'">';
3034 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
3035 var x = this.offsetLeft, y = this.offsetTop;
3036 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
3037 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
3038 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
3040 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
3043 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
3044 $out .=
"</script>";
3047 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
3051 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3 || $notab == -4) {
3052 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : ((($notab == -3 || $notab == -4) ?
' noborderbottom' :
'').($notab == -4 ?
'' :
' tabBarWithBottom'))));
3053 $out .= ($morecssdiv ?
' '.$morecssdiv :
'');
3056 if (!empty($dragdropfile)) {
3057 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
3060 $parameters = array(
'tabname' => $active,
'out' => $out);
3061 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
3063 $out = $hookmanager->resPrint;
3089 if (!$notab || $notab == -1) {
3090 return "\n</div>\n";
3115function dol_banner_tab(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
3117 global
$conf, $form, $user, $langs, $hookmanager, $action;
3121 $maxvisiblephotos = 1;
3125 $showbarcode = !isModEnabled(
'barcode') ? 0 : (empty(
$object->barcode) ? 0 : 1);
3126 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
3129 $modulepart =
'unknown';
3131 if (in_array(
$object->element, [
'societe',
'contact',
'product',
'ticket',
'bom'])) {
3132 $modulepart =
$object->element;
3133 } elseif (
$object->element ==
'member') {
3134 $modulepart =
'memberphoto';
3135 } elseif (
$object->element ==
'user') {
3136 $modulepart =
'userphoto';
3139 if (class_exists(
"Imagick")) {
3140 if (
$object->element ==
'expensereport' ||
$object->element ==
'propal' ||
$object->element ==
'commande' ||
$object->element ==
'facture' ||
$object->element ==
'supplier_proposal') {
3141 $modulepart =
$object->element;
3142 } elseif (
$object->element ==
'fichinter' ||
$object->element ==
'intervention') {
3143 $modulepart =
'ficheinter';
3144 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3145 $modulepart =
'contract';
3146 } elseif (
$object->element ==
'order_supplier') {
3147 $modulepart =
'supplier_order';
3148 } elseif (
$object->element ==
'invoice_supplier') {
3149 $modulepart =
'supplier_invoice';
3153 if (
$object->element ==
'product') {
3155 '@phan-var-force Product $object';
3157 $cssclass =
'photowithmargin photoref';
3158 $showimage =
$object->is_photo_available(
$conf->product->multidir_output[$entity]);
3160 if (
$conf->browser->layout ==
'phone') {
3161 $maxvisiblephotos = 1;
3164 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos(
'product',
$conf->product->multidir_output[$entity], 1, $maxvisiblephotos, 0, 0, 0, 0, $width, 0,
'').
'</div>';
3168 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3170 $nophoto =
'/public/theme/common/nophoto.png';
3171 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" title="'.
dol_escape_htmltag($langs->trans(
"UploadAnImageToSeeAPhotoHere", $langs->transnoentitiesnoconv(
"Documents"))).
'" alt="No photo"'.($width ?
' style="width: '.$width.
'px"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'"></div>';
3174 } elseif (
$object->element ==
'category') {
3176 '@phan-var-force Categorie $object';
3178 $cssclass =
'photowithmargin photoref';
3179 $showimage =
$object->isAnyPhotoAvailable(
$conf->categorie->multidir_output[$entity]);
3181 if (
$conf->browser->layout ==
'phone') {
3182 $maxvisiblephotos = 1;
3185 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos(
'category',
$conf->categorie->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, 0, $width, 0,
'').
'</div>';
3189 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3191 $nophoto =
'/public/theme/common/nophoto.png';
3192 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" title="'.
dol_escape_htmltag($langs->trans(
"UploadAnImageToSeeAPhotoHere", $langs->transnoentitiesnoconv(
"Documents"))).
'" alt="No photo"'.($width ?
' style="width: '.$width.
'px"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'"></div>';
3195 } elseif (
$object->element ==
'bom') {
3197 '@phan-var-force Bom $object';
3199 $cssclass =
'photowithmargin photoref';
3200 $showimage =
$object->is_photo_available(
$conf->bom->multidir_output[$entity]);
3202 if (
$conf->browser->layout ==
'phone') {
3203 $maxvisiblephotos = 1;
3206 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos(
'bom',
$conf->bom->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, 0, $width, 0,
'').
'</div>';
3210 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3212 $nophoto =
'/public/theme/common/nophoto.png';
3213 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" title="'.
dol_escape_htmltag($langs->trans(
"UploadAnImageToSeeAPhotoHere", $langs->transnoentitiesnoconv(
"Documents"))).
'" alt="No photo"'.($width ?
' style="width: '.$width.
'px"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'"></div>';
3216 } elseif (
$object->element ==
'ticket') {
3218 $cssclass =
'photoref';
3220 '@phan-var-force Ticket $object';
3221 $showimage =
$object->is_photo_available(
$conf->ticket->multidir_output[$entity].
'/'.
$object->ref);
3223 if (
$conf->browser->layout ==
'phone') {
3224 $maxvisiblephotos = 1;
3228 $showphoto =
$object->show_photos(
'ticket',
$conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
3230 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
3238 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3240 $nophoto =
img_picto(
'No photo',
'object_ticket');
3241 $morehtmlleft .=
'<!-- No photo to show -->';
3242 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
3243 $morehtmlleft .= $nophoto;
3244 $morehtmlleft .=
'</div></div>';
3249 if ($modulepart !=
'unknown' || method_exists(
$object,
'getDataToShowPhoto')) {
3252 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
3254 $dir_output = (empty(
$conf->$modulepart->multidir_output[$entity]) ?
$conf->$modulepart->dir_output :
$conf->$modulepart->multidir_output[$entity]).
"/";
3255 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
3257 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
3261 if (empty($subdir)) {
3262 $subdir =
'errorgettingsubdirofobject';
3265 $filepath = $dir_output.$subdir.
"/";
3267 $filepdf = $filepath.$objectref.
".pdf";
3268 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
3271 $fileimage = $filepdf.
'_preview.png';
3272 $relativepathimage = $relativepath.
'_preview.png';
3274 $pdfexists = file_exists($filepdf);
3279 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
3281 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
3290 if ($pdfexists && !$error) {
3291 $heightforphotref = 80;
3292 if (!empty(
$conf->dol_optimize_smallscreen)) {
3293 $heightforphotref = 60;
3296 if (file_exists($fileimage)) {
3297 $phototoshow =
'<div class="photoref">';
3298 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
3299 $phototoshow .=
'</div>';
3302 } elseif (!$phototoshow) {
3303 $phototoshow .= $form->showphoto($modulepart,
$object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0);
3307 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
3308 $morehtmlleft .= $phototoshow;
3309 $morehtmlleft .=
'</div>';
3313 if (empty($phototoshow)) {
3314 if (
$object->element ==
'action') {
3316 $cssclass =
'photorefcenter';
3317 $nophoto =
img_picto(
'No photo',
'title_agenda');
3320 $cssclass =
'photorefcenter';
3322 $prefix =
'object_';
3326 if (strpos($picto,
'fontawesome_') !==
false) {
3329 $nophoto =
img_picto(
'No photo', $prefix.$picto);
3331 $morehtmlleft .=
'<!-- No photo to show -->';
3332 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
3333 $morehtmlleft .= $nophoto;
3334 $morehtmlleft .=
'</div></div>';
3341 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode(
$object, 100,
'photoref valignmiddle').
'</div>';
3344 if (
$object->element ==
'societe') {
3345 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3348 $morehtmlstatus .=
$object->getLibStatut(6);
3350 } elseif (
$object->element ==
'product') {
3352 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3353 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
3355 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
3357 $morehtmlstatus .=
' ';
3359 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3360 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
3362 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
3364 } elseif (in_array(
$object->element, array(
'salary'))) {
3365 '@phan-var-force Salary $object';
3367 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3370 $morehtmlstatus .= $tmptxt;
3371 } elseif (in_array(
$object->element, array(
'facture',
'invoice',
'invoice_supplier'))) {
3372 '@phan-var-force Facture|FactureFournisseur|CommonInvoice $object';
3373 $totalallpayments =
$object->getSommePaiement(0);
3374 $totalallpayments +=
$object->getSumCreditNotesUsed(0);
3375 $totalallpayments +=
$object->getSumDepositsUsed(0);
3376 $tmptxt =
$object->getLibStatut(6, $totalallpayments);
3377 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3378 $tmptxt =
$object->getLibStatut(5, $totalallpayments);
3380 $morehtmlstatus .= $tmptxt;
3381 } elseif (in_array(
$object->element, array(
'chargesociales',
'loan',
'tva'))) {
3382 '@phan-var-force ChargeSociales|Loan|Tva $object';
3384 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3387 $morehtmlstatus .= $tmptxt;
3388 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3390 $morehtmlstatus .=
$object->getLibStatut(5);
3392 $morehtmlstatus .=
$object->getLibStatut(4);
3394 } elseif (
$object->element ==
'facturerec') {
3395 '@phan-var-force FactureRec $object';
3396 if (
$object->frequency == 0) {
3397 $morehtmlstatus .=
$object->getLibStatut(2);
3399 $morehtmlstatus .=
$object->getLibStatut(5);
3401 } elseif (
$object->element ==
'project_task') {
3402 $tmptxt =
$object->getLibStatut(4);
3403 $morehtmlstatus .= $tmptxt;
3404 } elseif (method_exists(
$object,
'getLibStatut')) {
3405 $tmptxt =
$object->getLibStatut(6);
3406 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3407 $tmptxt =
$object->getLibStatut(5);
3409 $morehtmlstatus .= $tmptxt;
3413 if (isModEnabled(
'accounting') && in_array(
$object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
3415 if (method_exists(
$object,
'getVentilExportCompta')) {
3416 $accounted =
$object->getVentilExportCompta(1);
3417 $langs->load(
"accountancy");
3418 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ?
'<a href="'.DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?search_mvt_num='.((int) $accounted).
'">'.$langs->trans(
"Accounted").
'</a>' : $langs->trans(
"NotYetAccounted")).
'</span>';
3423 if (!empty(
$object->name_alias)) {
3424 '@phan-var-force Societe $object';
3425 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag(
$object->name_alias).
'</div>';
3429 if (in_array(
$object->element, array(
'product',
'bank_account',
'project_task'))) {
3431 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
3435 if (method_exists(
$object,
'getBannerAddress') && !in_array(
$object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
3438 $morehtmlref .=
'<div class="refidno refaddress">';
3439 $morehtmlref .= $moreaddress;
3440 $morehtmlref .=
'</div>';
3444 $morehtmlref .=
'<div style="clear: both;"></div>';
3445 $morehtmlref .=
'<div class="refidno opacitymedium">';
3446 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int)
$object->id);
3447 $morehtmlref .=
'</div>';
3450 $parameters = array(
'morehtmlref' => &$morehtmlref,
'moreparam' => &$moreparam,
'morehtmlleft' => &$morehtmlleft,
'morehtmlstatus' => &$morehtmlstatus,
'morehtmlright' => &$morehtmlright);
3451 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters,
$object, $action);
3454 } elseif (empty($reshook)) {
3455 $morehtmlref .= $hookmanager->resPrint;
3456 } elseif ($reshook > 0) {
3457 $morehtmlref = $hookmanager->resPrint;
3465 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
3466 print $form->showrefnav(
$object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
3468 print
'<div class="underrefbanner clearboth"></div>';
3480function fieldLabel($langkey, $fieldkey, $fieldrequired = 0)
3484 if ($fieldrequired) {
3485 $ret .=
'<span class="fieldrequired">';
3487 $ret .=
'<label for="'.$fieldkey.
'">';
3488 $ret .= $langs->trans($langkey);
3490 if ($fieldrequired) {
3511 global $langs, $hookmanager;
3514 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
3519 $ret .= (($extralangcode && !empty(
$object->array_languages[
'address'][$extralangcode])) ?
$object->array_languages[
'address'][$extralangcode] : (empty(
$object->
address) ?
'' : preg_replace(
'/(\r\n|\r|\n)+/', $sep,
$object->
address)));
3522 if (isset(
$object->country_code) && in_array(
$object->country_code, array(
'AU',
'CA',
'US',
'CN')) ||
getDolGlobalString(
'MAIN_FORCE_STATE_INTO_ADDRESS')) {
3524 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3525 $ret .= (($ret && $town) ? $sep :
'').$town;
3528 $ret .= ($ret ? ($town ?
", " : $sep) :
'').
$object->state;
3531 $ret .= ($ret ? (($town ||
$object->state) ?
", " : $sep) :
'').
$object->zip;
3533 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'GB',
'UK'))) {
3535 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3536 $ret .= ($ret ? $sep :
'').$town;
3538 $ret .= ($ret ?
", " :
'').
$object->state;
3541 $ret .= ($ret ? $sep :
'').
$object->zip;
3543 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'ES',
'TR'))) {
3545 $ret .= ($ret ? $sep :
'').
$object->zip;
3546 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3547 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3549 $ret .= $sep.$object->state;
3551 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'JP'))) {
3554 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3556 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'IT'))) {
3558 $ret .= ($ret ? $sep :
'').
$object->zip;
3559 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3560 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3561 $ret .= (empty(
$object->state_code) ?
'' : (
' '.$object->state_code));
3564 $town = (($extralangcode && !empty(
$object->array_languages[
'address'][$extralangcode])) ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3565 $ret .= !empty(
$object->zip) ? (($ret ? $sep :
'').
$object->zip) :
'';
3566 $ret .= ($town ? ((
$object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
3567 if (!empty(
$object->state) && in_array(
$object->country_code, $countriesusingstate)) {
3568 $ret .= ($ret ?
", " :
'').
$object->state;
3572 if (!is_object($outputlangs)) {
3573 $outputlangs = $langs;
3576 $langs->load(
"dict");
3577 $ret .= (empty(
$object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
3580 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
3581 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters,
$object);
3585 $ret .= $hookmanager->resPrint;
3602function dol_strftime($fmt, $ts =
false, $is_gmt =
false)
3604 if ((abs($ts) <= 0x7FFFFFFF)) {
3607 return 'Error date outside supported range';
3632function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
null, $encodetooutput =
false)
3634 global
$conf, $langs;
3641 if ($tzoutput ===
'auto') {
3642 $tzoutput = (empty(
$conf) ?
'tzserver' : (isset(
$conf->tzuserinputkey) ?
$conf->tzuserinputkey :
'tzserver'));
3647 $offsettz = $offsetdst = 0;
3650 if (is_string($tzoutput)) {
3651 if ($tzoutput ==
'tzserver') {
3653 $offsettzstring = @date_default_timezone_get();
3658 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
3660 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
3662 if (class_exists(
'DateTimeZone')) {
3663 $user_date_tz =
new DateTimeZone($offsettzstring);
3664 $user_dt =
new DateTime();
3665 $user_dt->setTimezone($user_date_tz);
3666 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (int) $time);
3667 $offsettz = $user_dt->getOffset();
3669 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3670 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3675 if (!is_object($outputlangs)) {
3676 $outputlangs = $langs;
3679 $format =
'daytextshort';
3684 $reduceformat = (!empty(
$conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour',
'dayhoursec'))) ? 1 : 0;
3685 $format = preg_replace(
'/inputnoreduce/',
'', $format);
3686 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
3687 if ($formatwithoutreduce != $format) {
3688 $format = $formatwithoutreduce;
3694 if ($format ==
'day') {
3695 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") :
$conf->format_date_short);
3696 } elseif ($format ==
'hour') {
3697 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") :
$conf->format_hour_short);
3698 } elseif ($format ==
'hourduration') {
3699 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") :
$conf->format_hour_short_duration);
3700 } elseif ($format ==
'daytext') {
3701 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") :
$conf->format_date_text);
3702 } elseif ($format ==
'daytextshort') {
3703 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") :
$conf->format_date_text_short);
3704 } elseif ($format ==
'dayhour') {
3705 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") :
$conf->format_date_hour_short);
3706 } elseif ($format ==
'dayhoursec') {
3707 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") :
$conf->format_date_hour_sec_short);
3708 } elseif ($format ==
'dayhourtext') {
3709 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") :
$conf->format_date_hour_text);
3710 } elseif ($format ==
'dayhourtextshort') {
3711 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") :
$conf->format_date_hour_text_short);
3712 } elseif ($format ==
'dayhourlog') {
3714 $format =
'%Y%m%d%H%M%S';
3715 } elseif ($format ==
'dayhourlogsmall') {
3717 $format =
'%y%m%d%H%M';
3718 } elseif ($format ==
'dayhourldap') {
3719 $format =
'%Y%m%d%H%M%SZ';
3720 } elseif ($format ==
'dayhourxcard') {
3721 $format =
'%Y%m%dT%H%M%SZ';
3722 } elseif ($format ==
'dayxcard') {
3724 } elseif ($format ==
'dayrfc') {
3725 $format =
'%Y-%m-%d';
3726 } elseif ($format ==
'dayhourrfc') {
3727 $format =
'%Y-%m-%dT%H:%M:%SZ';
3728 } elseif ($format ==
'standard') {
3729 $format =
'%Y-%m-%d %H:%M:%S';
3732 if ($reduceformat) {
3733 $format = str_replace(
'%Y',
'%y', $format);
3734 $format = str_replace(
'yyyy',
'yy', $format);
3738 if (preg_match(
'/%b/i', $format)) {
3740 $format = str_replace(
'%b',
'__b__', $format);
3741 $format = str_replace(
'%B',
'__B__', $format);
3743 if (preg_match(
'/%a/i', $format)) {
3745 $format = str_replace(
'%a',
'__a__', $format);
3746 $format = str_replace(
'%A',
'__A__', $format);
3751 if (preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', (
string) $time, $reg)) {
3752 dol_print_error(
null,
"Functions.lib::dol_print_date function called with a bad value from page ".(empty($_SERVER[
"PHP_SELF"]) ?
'unknown' : $_SERVER[
"PHP_SELF"]));
3754 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', (
string) $time, $reg)) {
3756 dol_syslog(
"Functions.lib::dol_print_date function called with a bad value from page ".(empty($_SERVER[
"PHP_SELF"]) ?
'unknown' : $_SERVER[
"PHP_SELF"]), LOG_WARNING);
3759 $syear = (!empty($reg[1]) ? $reg[1] :
'');
3760 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
3761 $sday = (!empty($reg[3]) ? $reg[3] :
'');
3762 $shour = (!empty($reg[4]) ? $reg[4] :
'');
3763 $smin = (!empty($reg[5]) ? $reg[5] :
'');
3764 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
3766 $time =
dol_mktime((
int) $shour, (
int) $smin, (
int) $ssec, (
int) $smonth, (
int) $sday, (
int) $syear,
true);
3769 $tzo =
new DateTimeZone(
'UTC');
3771 $tzo =
new DateTimeZone(date_default_timezone_get());
3773 $dtts =
new DateTime();
3774 $dtts->setTimestamp($time);
3775 $dtts->setTimezone($tzo);
3776 $newformat = str_replace(
3777 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3778 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3781 $ret = $dtts->format($newformat);
3783 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3784 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3789 if ($time < 100000000000) {
3790 $timetouse = $time + $offsettz + $offsetdst;
3793 $tzo =
new DateTimeZone(
'UTC');
3795 $tzo =
new DateTimeZone(date_default_timezone_get());
3797 $dtts =
new DateTime();
3798 $dtts->setTimestamp($timetouse);
3799 $dtts->setTimezone($tzo);
3800 $newformat = str_replace(
3801 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3802 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3805 $ret = $dtts->format($newformat);
3807 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3808 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3813 $ret =
'Bad value '.$time.
' for date';
3817 if (preg_match(
'/__b__/i', $format)) {
3818 $timetouse = $time + $offsettz + $offsetdst;
3821 $tzo =
new DateTimeZone(
'UTC');
3823 $tzo =
new DateTimeZone(date_default_timezone_get());
3825 $dtts =
new DateTime();
3826 $dtts->setTimestamp($timetouse);
3827 $dtts->setTimezone($tzo);
3828 $month = (int) $dtts->format(
"m");
3829 $month = sprintf(
"%02d", $month);
3830 if ($encodetooutput) {
3831 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
3832 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
3834 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
3835 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
3838 $ret = str_replace(
'__b__', $monthtextshort, $ret);
3839 $ret = str_replace(
'__B__', $monthtext, $ret);
3843 if (preg_match(
'/__a__/i', $format)) {
3845 $timetouse = $time + $offsettz + $offsetdst;
3848 $tzo =
new DateTimeZone(
'UTC');
3850 $tzo =
new DateTimeZone(date_default_timezone_get());
3852 $dtts =
new DateTime();
3853 $dtts->setTimestamp($timetouse);
3854 $dtts->setTimezone($tzo);
3855 $w = $dtts->format(
"w");
3856 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
3858 $ret = str_replace(
'__A__', $dayweek, $ret);
3859 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
3886function dol_getdate($timestamp, $fast =
false, $forcetimezone =
'')
3888 if ($timestamp ===
'') {
3892 $datetimeobj =
new DateTime();
3893 $datetimeobj->setTimestamp($timestamp);
3894 if ($forcetimezone) {
3895 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
3898 'year' => ((
int) date_format($datetimeobj,
'Y')),
3899 'mon' => ((
int) date_format($datetimeobj,
'm')),
3900 'mday' => ((
int) date_format($datetimeobj,
'd')),
3901 'wday' => ((
int) date_format($datetimeobj,
'w')),
3902 'yday' => ((
int) date_format($datetimeobj,
'z')),
3903 'hours' => ((
int) date_format($datetimeobj,
'H')),
3904 'minutes' => ((
int) date_format($datetimeobj,
'i')),
3905 'seconds' => ((
int) date_format($datetimeobj,
's')),
3933function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
3938 if ($gm ===
'auto') {
3939 $gm = (empty(
$conf) ?
'tzserver' :
$conf->tzuserinputkey);
3944 if ($hour == -1 || empty($hour)) {
3947 if ($minute == -1 || empty($minute)) {
3950 if ($second == -1 || empty($second)) {
3956 if (!$month || !$day) {
3965 if ($hour < 0 || $hour > 24) {
3968 if ($minute < 0 || $minute > 60) {
3971 if ($second < 0 || $second > 60) {
3976 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3977 $default_timezone = @date_default_timezone_get();
3978 $localtz =
new DateTimeZone($default_timezone);
3979 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3981 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3983 $localtz =
new DateTimeZone($default_timezone);
3985 dol_syslog(
"Warning dol_tz_string contains an invalid value ".json_encode($_SESSION[
"dol_tz_string"] ??
null), LOG_WARNING);
3986 $default_timezone = @date_default_timezone_get();
3988 } elseif (strrpos($gm,
"tz,") !==
false) {
3989 $timezone = str_replace(
"tz,",
"", $gm);
3991 $localtz =
new DateTimeZone($timezone);
3993 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3997 if (empty($localtz)) {
3998 $localtz =
new DateTimeZone(
'UTC');
4002 $dt =
new DateTime(
'now', $localtz);
4003 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
4004 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
4005 $date = $dt->getTimestamp();
4021function dol_now($mode =
'auto')
4025 if ($mode ===
'auto') {
4029 if ($mode ==
'gmt') {
4031 } elseif ($mode ==
'tzserver') {
4032 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
4034 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
4040 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
4043 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
4044 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
4045 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
4062 global
$conf, $langs;
4065 if (!empty(
$conf->dol_optimize_smallscreen)) {
4070 if (empty($shortvalue) || $size < ($level * 10)) {
4072 $textunitshort = $langs->trans(
"b");
4073 $textunitlong = $langs->trans(
"Bytes");
4075 $ret = round($size / $level, 0);
4076 $textunitshort = $langs->trans(
"Kb");
4077 $textunitlong = $langs->trans(
"KiloBytes");
4080 if (empty($shortunit)) {
4081 $ret .=
' '.$textunitlong;
4083 $ret .=
' '.$textunitshort;
4099function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'')
4107 $linkstart =
'<a href="';
4108 if (!preg_match(
'/^http/i', $url)) {
4109 $linkstart .=
'http://';
4114 $linkstart .=
' target="'.$target.
'"';
4116 $linkstart .=
' title="'.$langs->trans(
"URL").
': '.$url.
'"';
4120 if (!preg_match(
'/^http/i', $url)) {
4127 if ($morecss ==
'float') {
4128 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe',
'class="paddingrightonly"') :
'').$link.
'</div>';
4130 return $linkstart.
'<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto(
'',
'globe',
'class="paddingrightonly"') :
'').$link.
'</span>'.$linkend;
4147function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0, $morecss =
'paddingrightonly')
4149 global $user, $langs, $hookmanager;
4160 if (empty($email)) {
4164 if ($addlink == 1) {
4165 $newemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="';
4166 if (!preg_match(
'/^mailto:/i', $email)) {
4167 $newemail .=
'mailto:';
4169 $newemail .= $email;
4170 $newemail .=
'" target="_blank">';
4172 $newemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
4177 $newemail .= $email;
4179 $newemail .=
'</a>';
4181 $langs->load(
"errors");
4182 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email),
'',
'paddingrightonly');
4185 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4187 $linktoaddaction =
'';
4189 $linktoaddaction =
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&backtopage=1&actioncode='.urlencode($type).
'&contactid='.((int) $cid).
'&socid='.((int) $socid).
'">'.
img_object($langs->trans(
"AddAction"),
"calendar").
'</a>';
4191 if ($linktoaddaction) {
4192 $newemail =
'<div>'.$newemail.
' '.$linktoaddaction.
'</div>';
4195 } elseif ($addlink ===
'thirdparty') {
4196 $tmpnewemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="'.DOL_URL_ROOT.
'/societe/card.php?socid='.$socid.
'&action=presend&mode=init#formmailbeforetitle">';
4197 $tmpnewemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
4198 if ($withpicto == 1) {
4199 $tmpnewemail .= $newemail;
4201 $tmpnewemail .=
'</a>';
4203 $newemail = $tmpnewemail;
4205 $newemail = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'').$newemail;
4208 $langs->load(
"errors");
4209 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
4219 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
4221 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
4225 $rep .= $hookmanager->resPrint;
4240 $socialnetworks = array();
4242 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
4243 $cachekey =
'socialnetworks_' .
$conf->entity;
4245 if (!is_null($dataretrieved)) {
4246 $socialnetworks = $dataretrieved;
4248 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
4249 $sql .=
" WHERE entity=".$conf->entity;
4250 $resql = $db->query($sql);
4252 while ($obj = $db->fetch_object($resql)) {
4253 $socialnetworks[$obj->code] = array(
4254 'rowid' => $obj->rowid,
4255 'label' => $obj->label,
4257 'icon' => $obj->icon,
4258 'active' => $obj->active,
4264 return $socialnetworks;
4279 global $hookmanager, $langs, $user;
4283 if (empty($value)) {
4287 if (!empty($type)) {
4288 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
4290 $htmllink .=
'<span class="fab pictofixedwidth ' . ($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link') .
'"></span>';
4291 if ($type ==
'skype') {
4293 $htmllink .=
' <a href="skype:';
4295 $htmllink .=
'?call" alt="' . $langs->trans(
"Call") .
' ' . $value .
'" title="' .
dol_escape_htmltag($langs->trans(
"Call") .
' ' . $value) .
'">';
4296 $htmllink .=
'<img src="' . DOL_URL_ROOT .
'/theme/common/skype_callbutton.png" border="0">';
4297 $htmllink .=
'</a><a href="skype:';
4299 $htmllink .=
'?chat" alt="' . $langs->trans(
"Chat") .
' ' . $value .
'" title="' .
dol_escape_htmltag($langs->trans(
"Chat") .
' ' . $value) .
'">';
4300 $htmllink .=
'<img class="paddingleft" src="' . DOL_URL_ROOT .
'/theme/common/skype_chatbutton.png" border="0">';
4301 $htmllink .=
'</a>';
4302 if (($contactid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
4303 $addlink =
'AC_SKYPE';
4306 $link =
'<a href="' . DOL_URL_ROOT .
'/comm/action/card.php?action=create&backtopage=1&actioncode=' . $addlink .
'&contactid=' . $contactid .
'&socid=' . $socid .
'">' .
img_object($langs->trans(
"AddAction"),
"calendar") .
'</a>';
4308 $htmllink .= ($link ?
' ' . $link :
'');
4311 if (!empty($dictsocialnetworks[$type][
'url'])) {
4312 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
4313 if ($tmpvirginurl) {
4314 $value = preg_replace(
'/^www\.' . preg_quote($tmpvirginurl,
'/') .
'\/?/',
'', $value);
4315 $value = preg_replace(
'/^' . preg_quote($tmpvirginurl,
'/') .
'\/?/',
'', $value);
4317 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
4318 if ($tmpvirginurl3) {
4319 $value = preg_replace(
'/^www\.' . preg_quote($tmpvirginurl3,
'/') .
'\/?/',
'', $value);
4320 $value = preg_replace(
'/^' . preg_quote($tmpvirginurl3,
'/') .
'\/?/',
'', $value);
4323 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
4324 if ($tmpvirginurl2) {
4325 $value = preg_replace(
'/^www\.' . preg_quote($tmpvirginurl2,
'/') .
'\/?/',
'', $value);
4326 $value = preg_replace(
'/^' . preg_quote($tmpvirginurl2,
'/') .
'\/?/',
'', $value);
4329 if (preg_match(
'/^https?:\/\//i', $value)) {
4332 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
4334 $valuetoshow = $value;
4335 $valuetoshow = preg_replace(
'/https:\/\/www\.(twitter|x|linkedin)\.com\/?/',
'', $valuetoshow);
4336 if (preg_match(
'/^https?:\/\//i', $link)) {
4345 $htmllink .=
'</div>';
4347 $langs->load(
"errors");
4348 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
4352 $parameters = array(
4354 'cid' => $contactid,
4357 'dictsocialnetworks' => $dictsocialnetworks,
4360 $reshook = $hookmanager->executeHooks(
'printSocialNetworks', $parameters);
4364 $htmllink .= $hookmanager->resPrint;
4379function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1)
4383 if (empty($profID) || empty($profIDtype)) {
4386 if (empty($countrycode)) {
4387 $countrycode = $mysoc->country_code;
4389 $newProfID = $profID;
4390 $id = substr($profIDtype, -1);
4392 if (strtoupper($countrycode) ==
'FR') {
4398 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3);
4402 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3).
' '.substr($newProfID, 9, 5);
4406 $newProfID = substr($newProfID, 0, 2).
'.'.substr($newProfID, 2, 3);
4408 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) {
4410 $newProfID = substr($newProfID, 0, 4).
' '.substr($newProfID, 4, 3).
' '.substr($newProfID, 7, 3).
' '.substr($newProfID, 10, 3);
4413 if (!empty($addcpButton)) {
4436function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0, $morecss =
'paddingright')
4438 global
$conf, $user, $langs, $mysoc, $hookmanager;
4441 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
4442 if (empty($phone)) {
4448 if (empty($countrycode) && is_object($mysoc)) {
4449 $countrycode = $mysoc->country_code;
4453 if (!empty(
$conf->dol_optimize_smallscreen) && $separ !=
'hidenum') {
4458 $newphonewa = $phone;
4459 if (strtoupper($countrycode) ==
"FR") {
4462 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 2).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
4464 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
4466 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
4468 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4470 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4472 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 2);
4474 } elseif (strtoupper($countrycode) ==
"CA") {
4476 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
4478 } elseif (strtoupper($countrycode) ==
"PT") {
4480 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4482 } elseif (strtoupper($countrycode) ==
"SR") {
4484 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
4486 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
4488 } elseif (strtoupper($countrycode) ==
"DE") {
4490 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
4492 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
4494 } elseif (strtoupper($countrycode) ==
"ES") {
4496 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4498 } elseif (strtoupper($countrycode) ==
"BF") {
4500 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4502 } elseif (strtoupper($countrycode) ==
"RO") {
4504 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4506 } elseif (strtoupper($countrycode) ==
"TR") {
4508 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4510 } elseif (strtoupper($countrycode) ==
"US") {
4512 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4514 } elseif (strtoupper($countrycode) ==
"MX") {
4516 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4518 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4520 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4522 } elseif (strtoupper($countrycode) ==
"ML") {
4524 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4526 } elseif (strtoupper($countrycode) ==
"TH") {
4528 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4530 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 3);
4532 } elseif (strtoupper($countrycode) ==
"MU") {
4535 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4537 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4539 } elseif (strtoupper($countrycode) ==
"ZA") {
4541 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4543 } elseif (strtoupper($countrycode) ==
"SY") {
4545 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4547 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3);
4549 } elseif (strtoupper($countrycode) ==
"AE") {
4551 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4553 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4555 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
4557 } elseif (strtoupper($countrycode) ==
"DZ") {
4559 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4561 } elseif (strtoupper($countrycode) ==
"BE") {
4563 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4565 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4567 } elseif (strtoupper($countrycode) ==
"PF") {
4569 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4571 } elseif (strtoupper($countrycode) ==
"CO") {
4573 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
4575 } elseif (strtoupper($countrycode) ==
"JO") {
4577 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4579 } elseif (strtoupper($countrycode) ==
"JM") {
4581 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4583 } elseif (strtoupper($countrycode) ==
"MG") {
4585 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 2);
4587 } elseif (strtoupper($countrycode) ==
"GB") {
4589 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4591 } elseif (strtoupper($countrycode) ==
"CH") {
4593 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4595 $newphone = $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 4);
4597 } elseif (strtoupper($countrycode) ==
"TN") {
4599 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4601 } elseif (strtoupper($countrycode) ==
"GF") {
4603 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
4605 } elseif (strtoupper($countrycode) ==
"GP") {
4607 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
4609 } elseif (strtoupper($countrycode) ==
"MQ") {
4611 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
4613 } elseif (strtoupper($countrycode) ==
"IT") {
4615 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4617 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
4619 } elseif (strtoupper($countrycode) ==
"AU") {
4623 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
4625 } elseif (strtoupper($countrycode) ==
"LU") {
4628 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
4630 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 1);
4632 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4634 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
4636 } elseif (strtoupper($countrycode) ==
"PE") {
4639 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4);
4641 $newphonewa =
'+51'.$newphone;
4642 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3);
4644 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
4646 $newphonewa = $newphone;
4647 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4649 } elseif (strtoupper($countrycode) ==
"IN") {
4651 if ($withpicto ==
'phone') {
4652 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 4).$separ.substr($newphone, 9, 4);
4654 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 5).$separ.substr($newphone, 8, 5);
4659 $newphoneastart = $newphoneaend =
'';
4660 if (!empty($addlink)) {
4661 if ($addlink ==
'tel' ||
$conf->browser->layout ==
'phone' || (isModEnabled(
'clicktodial') &&
getDolGlobalString(
'CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'))) {
4662 $newphoneastart =
'<a href="tel:'.urlencode($phone).
'">';
4663 $newphoneaend .=
'</a>';
4664 } elseif (isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
4665 if (empty($user->clicktodial_loaded)) {
4666 $user->fetch_clicktodial();
4670 $urlmask =
getDolGlobalString(
'CLICKTODIAL_URL',
'ErrorClickToDialModuleNotConfigured');
4671 if (!empty($user->clicktodial_url)) {
4672 $urlmask = $user->clicktodial_url;
4675 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) :
'');
4676 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) :
'');
4677 $clicktodial_password = (!empty($user->clicktodial_password) ? urlencode($user->clicktodial_password) :
'');
4679 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
4681 $substitarray = array(
'__PHONEFROM__' => $clicktodial_poste,
4682 '__PHONETO__' => urlencode($phone),
4683 '__LOGIN__' => $clicktodial_login,
4684 '__PASS__' => $clicktodial_password);
4688 $newphoneastart =
'<a href="'.$url.
'" class="cssforclicktodial">';
4689 $newphoneaend =
'</a>';
4692 $newphoneastart =
'<a href="'.$url.
'"';
4694 $newphoneastart .=
' target="_blank" rel="noopener noreferrer"';
4696 $newphoneastart .=
'>';
4697 $newphoneaend .=
'</a>';
4702 if (isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4704 $addlinktoagenda =
'';
4705 if ($addlink ==
'AC_FAX') {
4709 $addlinktoagenda =
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&backtopage='. urlencode($_SERVER[
'REQUEST_URI']) .
'&actioncode='.$type.($cid ?
'&contactid='.$cid :
'').($socid ?
'&socid='.$socid :
'').
'">'.
img_object($langs->trans(
"AddAction"),
"calendar").
'</a>';
4711 if ($addlinktoagenda) {
4712 $newphone =
'<span>'.$newphone.
' '.$addlinktoagenda.
'</span>';
4717 if (
getDolGlobalString(
'CONTACT_PHONEMOBILE_SHOW_LINK_TO_WHATSAPP') && $withpicto ==
'mobile') {
4719 $newphone .=
' <a href="https://wa.me/'.$newphonewa.
'" target="_blank"';
4720 $newphone .=
'><span class="paddingright fab fa-whatsapp" style="color:#25D366;" title="WhatsApp"></span></a>';
4723 if (empty($titlealt)) {
4724 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
4729 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
4730 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
4731 $rep .= $hookmanager->resPrint;
4733 if (empty($reshook)) {
4736 if ($withpicto ==
'fax') {
4737 $picto =
'phoning_fax';
4738 } elseif ($withpicto ==
'phone') {
4740 } elseif ($withpicto ==
'mobile') {
4741 $picto =
'phoning_mobile';
4746 if ($adddivfloat == 1) {
4747 $rep .=
'<div class="nospan float'.($morecss ?
' '.$morecss :
'').
'">';
4748 } elseif (empty($adddivfloat)) {
4749 $rep .=
'<span'.($morecss ?
' class="'.$morecss.
'"' :
'').
'>';
4752 $rep .= $newphoneastart;
4753 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png') :
'');
4754 if ($separ !=
'hidenum') {
4755 $rep .= ($withpicto ?
' ' :
'').$newphone;
4757 $rep .= $newphoneaend;
4759 if ($adddivfloat == 1) {
4761 } elseif (empty($adddivfloat)) {
4782 if (!isset(
$conf->cache[
'resolveips'])) {
4783 $conf->cache[
'resolveips'] = array();
4789 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
4793 $ret .=
'('.$countrycode.
')';
4801 if (in_array($mode, [0, 2])) {
4804 if (!array_key_exists($ip,
$conf->cache[
'resolveips'])) {
4805 $domain = gethostbyaddr($ip);
4806 $conf->cache[
'resolveips'][$ip] = $domain;
4808 $domain =
$conf->cache[
'resolveips'][$ip];
4836 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4843 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]\s]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
4844 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]\s]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
4845 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
4846 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4848 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
4851 $ip = preg_replace(
'/,.*$/',
'', $_SERVER[
'HTTP_CLIENT_IP']);
4854 $ip = preg_replace(
'/,.*$/',
'', $_SERVER[
'HTTP_X_FORWARDED_FOR']);
4870 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
4872 } elseif (!empty($_SERVER[
'HTTP_X_FORWARDED_PROTO']) && $_SERVER[
'HTTP_X_FORWARDED_PROTO'] ==
'https' || !empty($_SERVER[
'HTTP_X_FORWARDED_SSL']) && $_SERVER[
'HTTP_X_FORWARDED_SSL'] ==
'on') {
4888 if (isModEnabled(
'geoipmaxmind')) {
4894 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4895 $geoip =
new DolGeoIP(
'country', $datafile);
4897 $countrycode = $geoip->getCountryCodeFromIP($ip);
4904 return $countrycode;
4916 global
$conf, $langs, $user;
4920 if (isModEnabled(
'geoipmaxmind')) {
4925 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4926 $geoip =
new DolGeoIP(
'country', $datafile);
4927 $countrycode = $geoip->getCountryCodeFromIP($ip);
4928 $ret = $countrycode;
4947 global $hookmanager;
4953 $parameters = array(
'element' => $element,
'id' =>
$id);
4954 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
4955 $out .= $hookmanager->resPrint;
4957 if (empty($reshook)) {
4958 if (empty($charfornl)) {
4959 $out .= nl2br((
string) $address);
4961 $out .= preg_replace(
'/[\r\n]+/', $charfornl, (
string) $address);
4965 $showgmap = $showomap = 0;
4966 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS')) {
4969 if ($element ==
'contact' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_CONTACTS')) {
4972 if ($element ==
'member' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_MEMBERS')) {
4975 if ($element ==
'user' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_USERS')) {
4978 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS')) {
4981 if ($element ==
'contact' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_CONTACTS')) {
4984 if ($element ==
'member' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
4987 if ($element ==
'user' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_USERS')) {
4992 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4995 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.
$id, 1);
4996 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
5018function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
5020 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
5023 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
5026 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
5044 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
5045 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
5048 if (function_exists(
'getmxrr')) {
5051 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
5052 if (count($mxhosts) > 1) {
5055 if (count($mxhosts) == 1 && !in_array((
string) $mxhosts[0], array(
'',
'.'))) {
5092 $tmparray = explode(
' ', $s);
5093 foreach ($tmparray as $tmps) {
5108function dol_strlen($string, $stringencoding =
'UTF-8')
5110 if (is_null($string)) {
5114 if (function_exists(
'mb_strlen')) {
5115 return mb_strlen($string, $stringencoding);
5117 return strlen($string);
5131function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
5135 if (empty($stringencoding)) {
5136 $stringencoding = (empty($langs) ?
'UTF-8' : $langs->charset_output);
5140 if (empty($trunconbytes)) {
5141 if (function_exists(
'mb_substr')) {
5142 $ret = mb_substr($string, $start, $length, $stringencoding);
5144 $ret = substr($string, $start, $length);
5147 if (function_exists(
'mb_strcut')) {
5148 $ret = mb_strcut($string, $start, $length, $stringencoding);
5150 $ret = substr($string, $start, $length);
5170function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
5178 if (empty($stringencoding)) {
5179 $stringencoding =
'UTF-8';
5182 if (!empty(
$conf->dol_optimize_smallscreen) &&
$conf->dol_optimize_smallscreen == 1 && $display == 1) {
5183 $size = round($size / 3);
5187 if ($trunc ==
'right') {
5189 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
5191 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
5196 } elseif ($trunc ==
'middle') {
5198 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
5199 $size1 = (int) round($size / 2);
5200 $size2 = (int) round($size / 2);
5201 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
5205 } elseif ($trunc ==
'left') {
5207 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
5209 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
5213 } elseif ($trunc ==
'wrap') {
5215 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
5221 return 'BadParam3CallingDolTrunc';
5235 $type2picto = array(
5236 'varchar' =>
'font',
5239 'int' =>
'sort-numeric-down',
5240 'double' =>
'sort-numeric-down',
5241 'price' =>
'currency',
5242 'pricecy' =>
'multicurrency',
5243 'password' =>
'key',
5244 'boolean' =>
'check-square',
5245 'date' =>
'calendar',
5246 'datetime' =>
'calendar',
5247 'duration' =>
'hourglass',
5253 'sellist' =>
'list',
5254 'stars' =>
'fontawesome_star_fas',
5255 'radio' =>
'check-circle',
5256 'checkbox' =>
'list',
5257 'chkbxlst' =>
'list',
5259 'icon' =>
"question",
5260 'point' =>
"country",
5261 'multipts' =>
'country',
5262 'linestrg' =>
"country",
5263 'polygon' =>
"country",
5264 'separate' =>
'minus'
5267 if (!empty($type2picto[$key])) {
5268 return img_picto(
'', $type2picto[$key],
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
5271 return img_picto(
'',
'generic',
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
5297function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2, $allowothertags = array())
5302 $url = DOL_URL_ROOT;
5303 $theme = isset(
$conf->theme) ?
$conf->theme :
null;
5304 $path =
'theme/'.$theme;
5305 if (empty($picto)) {
5310 if ($pictoisfullpath) {
5312 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5315 $fullpathpicto = $picto;
5317 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5318 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5319 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5324 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
5325 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
5326 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
5329 $pictoconvertkey = array(
'facture' =>
'bill',
'shipping' =>
'shipment',
'fichinter' =>
'intervention',
'agenda' =>
'calendar',
'invoice_supplier' =>
'supplier_invoice',
'order_supplier' =>
'supplier_order');
5330 if (in_array($pictowithouttext, array_keys($pictoconvertkey))) {
5331 $pictowithouttext = $pictoconvertkey[$pictowithouttext];
5334 if (strpos($pictowithouttext,
'fontawesome_') === 0 || strpos($pictowithouttext,
'fa-') === 0) {
5336 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
5337 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
5340 if ($pictowithouttext ==
'file-o') {
5341 $pictowithouttext =
'file';
5344 $pictowithouttextarray = explode(
'_', $pictowithouttext);
5345 $marginleftonlyshort = 0;
5347 if (!empty($pictowithouttextarray[1])) {
5349 $fakey =
'fa-'.$pictowithouttextarray[0];
5350 $faprefix = empty($pictowithouttextarray[1]) ?
'fas' : $pictowithouttextarray[1];
5351 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
5352 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
5354 $fakey =
'fa-'.$pictowithouttext;
5364 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5365 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5366 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5368 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5369 $morestyle = $reg[1];
5370 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5372 $moreatt = trim($moreatt);
5374 $enabledisablehtml =
'<span class="'.$faprefix.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5375 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5376 $enabledisablehtml .=
'</span>';
5378 return $enabledisablehtml;
5382 $fakey = $pictowithouttext;
5386 if (in_array($pictowithouttext, array(
'card',
'bell',
'clock',
'establishment',
'file',
'file-o',
'generic',
'minus-square',
'object_generic',
'pdf',
'plus-square',
'timespent',
'note',
'off',
'on',
'object_bookmark',
'bookmark',
'vcard'))) {
5389 if (in_array($pictowithouttext, array(
'black-tie',
'discord',
'facebook',
'flickr',
'github',
'google',
'google-plus-g',
'instagram',
'linkedin',
'meetup',
'microsoft',
'pinterest',
'skype',
'slack',
'twitter',
'reddit',
'snapchat',
'stripe',
'stripe-s',
'tumblr',
'viadeo',
'whatsapp',
'youtube'))) {
5395 if ($pictowithouttext ==
'off') {
5396 $fakey =
'fa-square';
5398 } elseif ($pictowithouttext ==
'on') {
5399 $fakey =
'fa-check-square';
5401 } elseif ($pictowithouttext ==
'listlight') {
5402 $fakey =
'fa-download';
5403 $marginleftonlyshort = 1;
5404 } elseif ($pictowithouttext ==
'printer') {
5405 $fakey =
'fa-print';
5407 } elseif ($pictowithouttext ==
'note') {
5408 $fakey =
'fa-sticky-note';
5409 $marginleftonlyshort = 1;
5410 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
5411 $convertarray = array(
'1uparrow' =>
'caret-up',
'1downarrow' =>
'caret-down',
'1leftarrow' =>
'caret-left',
'1rightarrow' =>
'caret-right',
'1uparrow_selected' =>
'caret-up',
'1downarrow_selected' =>
'caret-down',
'1leftarrow_selected' =>
'caret-left',
'1rightarrow_selected' =>
'caret-right');
5412 $fakey =
'fa-'.$convertarray[$pictowithouttext];
5413 if (preg_match(
'/selected/', $pictowithouttext)) {
5416 $marginleftonlyshort = 1;
5417 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
5418 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
5420 $fakey =
'fa-'.$pictowithouttext;
5423 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment',
'reception'))) {
5424 $morecss .=
' em092';
5426 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'info_black',
'project',
'workstation'))) {
5427 $morecss .=
' em088';
5429 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
5430 $morecss .=
' em080';
5434 $arrayconvpictotomarginleftonly = array(
5435 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
5436 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_grey',
'switch_on_red',
'switch_off',
5437 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
5439 if (!array_key_exists($pictowithouttext, $arrayconvpictotomarginleftonly)) {
5440 $marginleftonlyshort = 0;
5444 $arrayconvpictotomorcess = array(
5445 'action' =>
'infobox-action',
'account' =>
'infobox-bank_account',
'accounting_account' =>
'infobox-bank_account',
'accountline' =>
'infobox-bank_account',
'accountancy' =>
'infobox-bank_account',
'asset' =>
'infobox-bank_account',
5446 'bank_account' =>
'infobox-bank_account',
5447 'bill' =>
'infobox-commande',
'billa' =>
'infobox-commande',
'billr' =>
'infobox-commande',
'billd' =>
'infobox-commande',
5448 'bookcal' =>
'infobox-action',
5449 'margin' =>
'infobox-bank_account',
'conferenceorbooth' =>
'infobox-project',
5450 'cash-register' =>
'infobox-bank_account',
'contract' =>
'infobox-contrat',
'check' =>
'font-status4',
'collab' =>
'infobox-action',
'conversation' =>
'infobox-contrat',
5451 'donation' =>
'infobox-commande',
'dolly' =>
'infobox-commande',
'dollyrevert' =>
'flip infobox-order_supplier',
5452 'ecm' =>
'infobox-action',
'eventorganization' =>
'infobox-project',
5453 'hrm' =>
'infobox-adherent',
'group' =>
'infobox-adherent',
'intervention' =>
'infobox-contrat',
5454 'incoterm' =>
'infobox-supplier_proposal',
5455 'currency' =>
'infobox-bank_account',
'multicurrency' =>
'infobox-bank_account',
5456 'members' =>
'infobox-adherent',
'member' =>
'infobox-adherent',
'money-bill-alt' =>
'infobox-bank_account',
5457 'order' =>
'infobox-commande',
5458 'user' =>
'infobox-adherent',
'users' =>
'infobox-adherent',
5459 'error' =>
'pictoerror',
'warning' =>
'pictowarning',
'switch_on' =>
'font-status4',
'switch_on_warning' =>
'font-status4 warning',
'switch_on_red' =>
'font-status8',
5460 'holiday' =>
'infobox-holiday',
'info' =>
'opacityhigh',
'info_black' =>
'font-status1',
'invoice' =>
'infobox-commande',
5461 'knowledgemanagement' =>
'infobox-contrat rotate90',
'loan' =>
'infobox-bank_account',
5462 'payment' =>
'infobox-bank_account',
'payment_vat' =>
'infobox-bank_account',
'poll' =>
'infobox-adherent',
'pos' =>
'infobox-bank_account',
'project' =>
'infobox-project',
'projecttask' =>
'infobox-project',
5463 'propal' =>
'infobox-propal',
'proposal' =>
'infobox-propal',
'private' =>
'infobox-project',
5464 'reception' =>
'flip infobox-order_supplier',
'recruitmentjobposition' =>
'infobox-adherent',
'recruitmentcandidature' =>
'infobox-adherent',
5465 'resource' =>
'infobox-action',
5466 'salary' =>
'infobox-bank_account',
'shapes' =>
'infobox-adherent',
'shipment' =>
'infobox-commande',
'stripe' =>
'infobox-bank_account',
'supplier_invoice' =>
'infobox-order_supplier',
'supplier_invoicea' =>
'infobox-order_supplier',
'supplier_invoiced' =>
'infobox-order_supplier',
5467 'supplier' =>
'infobox-order_supplier',
'supplier_order' =>
'infobox-order_supplier',
'supplier_proposal' =>
'infobox-supplier_proposal',
5468 'ticket' =>
'infobox-contrat',
'title_accountancy' =>
'infobox-bank_account',
'title_hrm' =>
'infobox-holiday',
'expensereport' =>
'infobox-expensereport',
'trip' =>
'infobox-expensereport',
'title_agenda' =>
'infobox-action',
5469 'vat' =>
'infobox-bank_account',
5471 'list-alt' =>
'imgforviewmode',
'calendar' =>
'imgforviewmode',
'calendarweek' =>
'imgforviewmode',
'calendarmonth' =>
'imgforviewmode',
'calendarday' =>
'imgforviewmode',
'calendarperuser' =>
'imgforviewmode',
'calendarpertype' =>
'imgforviewmode'
5473 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5474 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
5478 $arrayconvpictotocolor = array(
5479 'address' =>
'#6c6aa8',
'building' =>
'#6c6aa8',
'bom' =>
'#a69944',
5480 'clone' =>
'#999',
'cog' =>
'#999',
'companies' =>
'#6c6aa8',
'company' =>
'#6c6aa8',
'contact' =>
'#6c6aa8',
'cron' =>
'#555',
5481 'dynamicprice' =>
'#a69944',
5482 'edit' =>
'#444',
'note' =>
'#999',
'error' =>
'',
'help' =>
'#bbb',
'listlight' =>
'#999',
'language' =>
'#555',
5484 'lock' =>
'#ddd',
'lot' =>
'#a69944',
5485 'map-marker-alt' =>
'#aaa',
'mrp' =>
'#a69944',
'product' =>
'#a69944',
'service' =>
'#a69944',
'inventory' =>
'#a69944',
'stock' =>
'#a69944',
'movement' =>
'#a69944',
5486 'other' =>
'#ddd',
'world' =>
'#986c6a',
5487 'partnership' =>
'#6c6aa8',
'playdisabled' =>
'#ccc',
'printer' =>
'#444',
'projectpub' =>
'#986c6a',
'resize' =>
'#444',
'rss' =>
'#cba',
5489 'search-plus' =>
'#808080',
'security' =>
'#999',
'square' =>
'#888',
'stop-circle' =>
'#888',
'stats' =>
'#444',
'switch_off' =>
'#999',
5490 'technic' =>
'#999',
'tick' =>
'#282',
'timespent' =>
'#555',
5491 'uncheck' =>
'#800',
'uparrow' =>
'#555',
'user-cog' =>
'#999',
'country' =>
'#aaa',
'globe-americas' =>
'#aaa',
'region' =>
'#aaa',
'state' =>
'#aaa',
5492 'website' =>
'#304',
'workstation' =>
'#a69944'
5494 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5495 $facolor = $arrayconvpictotocolor[$pictowithouttext];
5502 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5503 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5504 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5506 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5507 $morestyle = $reg[1];
5508 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5510 $moreatt = trim($moreatt);
5512 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5513 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5514 $enabledisablehtml .=
'</span>';
5516 return $enabledisablehtml;
5523 } elseif (!empty(
$conf->modules_parts[
'theme']) && array_key_exists($theme,
$conf->modules_parts[
'theme'])) {
5524 $path = $theme.
'/theme/'.$theme;
5529 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
5535 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5540 foreach (
$conf->file->dol_document_root as $type => $dirroot) {
5541 if ($type ==
'main') {
5545 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
5546 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
5552 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
5556 return $fullpathpicto;
5560 return '<img src="'.$fullpathpicto.
'"'.($notitle ?
'' :
' alt="'.dolPrintHTMLForAttribute($alt, 0, $allowothertags).
'"').(($notitle || empty($titlealt)) ?
'' :
' title="'.
dolPrintHTMLForAttribute($titlealt, 0, $allowothertags).
'"').($moreatt ?
' '.$moreatt.($morecss ?
' class="'.$morecss.
'"' :
'') :
' class="inline-block'.($morecss ?
' '.$morecss :
'').
'"').
'>';
5571 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
5572 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'ai',
'angle-double-down',
'angle-double-up',
'asset',
5573 'back',
'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bom',
'bookcal',
'bookmark',
'briefcase-medical',
'bug',
'building',
5574 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
'hourglass',
5575 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'code',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
5576 'check-circle',
'check-square',
'circle',
'stop-circle',
'currency',
'multicurrency',
5577 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-up',
5578 'chevron-double-left',
'chevron-double-right',
'chevron-double-down',
'chevron-double-top',
5579 'commercial',
'companies',
5580 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
5581 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
5582 'filter',
'file',
'file-o',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
'font',
5583 'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
5584 'hands-helping',
'help',
'holiday',
5585 'id-card',
'images',
'incoterm',
'info',
'info_black',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
5586 'key',
'knowledgemanagement',
5587 'label',
'language',
'layout',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
5588 'margin',
'map-marker-alt',
'member',
'meeting',
'minus',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
5589 'off',
'on',
'order',
5590 'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
5591 'resize',
'search',
'service',
'stats',
'stock',
5592 'security',
'setup',
'share-alt',
'sign-out',
'split',
'stripe',
'stripe-s',
'switch_off',
'switch_on',
'switch_on_grey',
'switch_on_warning',
'switch_on_red',
'tools',
'unlink',
'uparrow',
'user',
'user-tie',
'vcard',
'wrench',
5593 'discord',
'facebook',
'flickr',
'instagram',
'linkedin',
'github',
'google',
'jabber',
'meetup',
'microsoft',
'skype',
'slack',
'twitter',
'pinterest',
'reddit',
'snapchat',
'tumblr',
'youtube',
'viadeo',
'google-plus-g',
'whatsapp',
5594 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
5595 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
5596 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
5597 'technic',
'ticket',
5599 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
5600 'search-plus',
'shapes',
'skill',
'square',
'sort-numeric-down',
'status',
'stop-circle',
'store',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
5601 'terminal',
'tick',
'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
'trip',
5602 'uncheck',
'undo',
'url',
'user-cog',
'user-injured',
'user-md',
'upload',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
5603 'conferenceorbooth',
'eventorganization',
5604 'stamp',
'signature',
5621 $arrayconvpictotofa = array(
5622 'account' =>
'university',
'accounting_account' =>
'clipboard-list',
'accountline' =>
'receipt',
'accountancy' =>
'search-dollar',
'action' =>
'calendar-alt',
'add' =>
'plus-circle',
'address' =>
'address-book',
'ai' =>
'magic',
5623 'asset' =>
'money-check-alt',
'autofill' =>
'fill',
5624 'back' =>
'arrow-left',
'bank_account' =>
'university',
5625 'bill' =>
'file-invoice-dollar',
'billa' =>
'file-excel',
'billr' =>
'file-invoice-dollar',
'billd' =>
'file-medical',
5626 'bookcal' =>
'calendar-check',
5627 'supplier_invoice' =>
'file-invoice-dollar',
'supplier_invoicea' =>
'file-excel',
'supplier_invoicer' =>
'file-invoice-dollar',
'supplier_invoiced' =>
'file-medical',
5629 'card' =>
'address-card',
'chart' =>
'chart-line',
'company' =>
'building',
'contact' =>
'address-book',
'contract' =>
'suitcase',
'collab' =>
'people-arrows',
'conversation' =>
'comments',
'country' =>
'globe-americas',
'cron' =>
'business-time',
'cross' =>
'times',
5630 'chevron-double-left' =>
'angle-double-left',
'chevron-double-right' =>
'angle-double-right',
'chevron-double-down' =>
'angle-double-down',
'chevron-double-top' =>
'angle-double-up',
5631 'donation' =>
'file-alt',
'dynamicprice' =>
'hand-holding-usd',
5632 'setup' =>
'cog',
'companies' =>
'building',
'products' =>
'cube',
'commercial' =>
'suitcase',
'invoicing' =>
'coins',
5633 'accounting' =>
'search-dollar',
'category' =>
'tag',
'dollyrevert' =>
'dolly',
5634 'file-o' =>
'file',
'generate' =>
'plus-square',
'hrm' =>
'user-tie',
'incoterm' =>
'truck-loading',
5635 'margin' =>
'calculator',
'members' =>
'user-friends',
'ticket' =>
'ticket-alt',
'globe' =>
'external-link-alt',
'lot' =>
'barcode',
5636 'email' =>
'at',
'establishment' =>
'building',
'edit' =>
'pencil-alt',
'entity' =>
'globe',
5637 'graph' =>
'chart-line',
'grip_title' =>
'arrows-alt',
'grip' =>
'arrows-alt',
'help' =>
'question-circle',
5638 'generic' =>
'file',
'holiday' =>
'umbrella-beach',
5639 'info' =>
'info-circle',
'info_black' =>
'info-circle',
'inventory' =>
'boxes',
'intracommreport' =>
'globe-europe',
'jobprofile' =>
'cogs',
5640 'knowledgemanagement' =>
'ticket-alt',
'label' =>
'layer-group',
'layout' =>
'columns',
'line' =>
'bars',
'loan' =>
'money-bill-alt',
5641 'member' =>
'user-alt',
'meeting' =>
'chalkboard-teacher',
'mrp' =>
'cubes',
'next' =>
'arrow-alt-circle-right',
5642 'trip' =>
'wallet',
'expensereport' =>
'wallet',
'group' =>
'users',
'movement' =>
'people-carry',
5643 'sign-out' =>
'sign-out-alt',
5644 'switch_off' =>
'toggle-off',
'switch_on' =>
'toggle-on',
'switch_on_grey' =>
'toggle-on',
'switch_on_warning' =>
'toggle-on',
'switch_on_red' =>
'toggle-on',
'check' =>
'check',
'bookmark' =>
'star',
5645 'bank' =>
'university',
'close_title' =>
'times',
'delete' =>
'trash',
'filter' =>
'filter',
5646 'list-alt' =>
'list-alt',
'calendarlist' =>
'bars',
'calendar' =>
'calendar-alt',
'calendarmonth' =>
'calendar-alt',
'calendarweek' =>
'calendar-week',
'calendarday' =>
'calendar-day',
'calendarperuser' =>
'table',
'calendarpertype' =>
'table',
5647 'intervention' =>
'ambulance',
'invoice' =>
'file-invoice-dollar',
'order' =>
'file-invoice',
5648 'error' =>
'exclamation-triangle',
'warning' =>
'exclamation-triangle',
5649 'other' =>
'square',
5650 'playdisabled' =>
'play',
'pdf' =>
'file-pdf',
'poll' =>
'check-double',
'pos' =>
'cash-register',
'preview' =>
'binoculars',
'project' =>
'project-diagram',
'projectpub' =>
'project-diagram',
'projecttask' =>
'tasks',
'propal' =>
'file-signature',
'proposal' =>
'file-signature',
5651 'partnership' =>
'handshake',
'payment' =>
'money-check-alt',
'payment_vat' =>
'money-check-alt',
'pictoconfirm' =>
'check-square',
'phoning' =>
'phone',
'phoning_mobile' =>
'mobile-alt',
'phoning_fax' =>
'fax',
'previous' =>
'arrow-alt-circle-left',
'printer' =>
'print',
'product' =>
'cube',
'puce' =>
'angle-right',
5652 'recent' =>
'check-square',
'reception' =>
'dolly',
'recruitmentjobposition' =>
'id-card-alt',
'recruitmentcandidature' =>
'id-badge',
5653 'resize' =>
'crop',
'supplier_order' =>
'dol-order_supplier',
'supplier_proposal' =>
'file-signature',
5654 'refresh' =>
'redo',
'region' =>
'map-marked',
'replacement' =>
'exchange-alt',
'resource' =>
'laptop-house',
'recurring' =>
'history',
5655 'service' =>
'concierge-bell',
5656 'skill' =>
'shapes',
'state' =>
'map-marked-alt',
'security' =>
'key',
'salary' =>
'wallet',
'shipment' =>
'dolly',
'stock' =>
'box-open',
'stats' =>
'chart-bar',
'split' =>
'code-branch',
5657 'status' =>
'stop-circle',
5658 'stripe' =>
'stripe-s',
'supplier' =>
'building',
5659 'technic' =>
'cogs',
'tick' =>
'check',
'timespent' =>
'clock',
'title_setup' =>
'tools',
'title_accountancy' =>
'money-check-alt',
'title_bank' =>
'university',
'title_hrm' =>
'umbrella-beach',
5660 'title_agenda' =>
'calendar-alt',
5661 'uncheck' =>
'times',
'uparrow' =>
'share',
'url' =>
'external-link-alt',
'vat' =>
'money-check-alt',
'vcard' =>
'arrow-alt-circle-down',
5662 'jabber' =>
'comment',
5663 'website' =>
'globe-americas',
'workstation' =>
'pallet',
'webhook' =>
'bullseye',
'world' =>
'globe',
'private' =>
'user-lock',
5664 'conferenceorbooth' =>
'chalkboard-teacher',
'eventorganization' =>
'project-diagram',
5665 'webportal' =>
'door-open'
5668 if (
$conf->currency ==
'EUR') {
5669 $arrayconvpictotofa[
'currency'] =
'euro-sign';
5670 $arrayconvpictotofa[
'multicurrency'] =
'dollar-sign';
5672 $arrayconvpictotofa[
'currency'] =
'dollar-sign';
5673 $arrayconvpictotofa[
'multicurrency'] =
'euro-sign';
5676 return $arrayconvpictotofa;
5694function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $allowothertags = array())
5696 if (strpos($picto,
'^') === 0) {
5697 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle,
'',
'', 2, $allowothertags);
5699 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle,
'',
'', 2, $allowothertags);
5714function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
5718 if (is_numeric($picto)) {
5721 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
5722 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5726 $path = DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/img/weather/'.$picto;
5728 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
5742function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
5746 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5750 if ($pictoisfullpath) {
5753 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
5756 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/img/'.$picto;
5758 if (file_exists($themepath)) {
5764 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
5780function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
5784 if (empty($titlealt) || $titlealt ==
'default') {
5785 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
5787 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
5788 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
5790 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
5791 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
5793 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
5794 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
5796 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
5797 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
5799 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
5801 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
5805 if (!is_numeric($numaction)) {
5809 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
5819function img_pdf($titlealt =
'default', $size = 3)
5823 if ($titlealt ==
'default') {
5824 $titlealt = $langs->trans(
'Show');
5827 return img_picto($titlealt,
'pdf'.$size.
'.png');
5837function img_edit_add($titlealt =
'default', $other =
'')
5841 if ($titlealt ==
'default') {
5842 $titlealt = $langs->trans(
'Add');
5845 return img_picto($titlealt,
'edit_add.png', $other);
5858 if ($titlealt ==
'default') {
5859 $titlealt = $langs->trans(
'Remove');
5862 return img_picto($titlealt,
'edit_remove.png', $other);
5873function img_edit($titlealt =
'default', $float = 0, $other =
'')
5877 if ($titlealt ==
'default') {
5878 $titlealt = $langs->trans(
'Modify');
5881 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
5892function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
5896 if ($titlealt ==
'default') {
5897 $titlealt = $langs->trans(
'View');
5900 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
5902 return img_picto($titlealt,
'eye', $moreatt);
5913function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
5917 if ($titlealt ==
'default') {
5918 $titlealt = $langs->trans(
'Delete');
5921 return img_picto($titlealt,
'delete.png', $other, 0, 0, 0,
'', $morecss);
5931function img_printer($titlealt =
"default", $other =
'')
5934 if ($titlealt ==
"default") {
5935 $titlealt = $langs->trans(
"Print");
5937 return img_picto($titlealt,
'printer.png', $other);
5947function img_split($titlealt =
'default', $other =
'class="pictosplit"')
5951 if ($titlealt ==
'default') {
5952 $titlealt = $langs->trans(
'Split');
5955 return img_picto($titlealt,
'split.png', $other);
5965function img_help($usehelpcursor = 1, $usealttitle = 1)
5970 if (is_string($usealttitle)) {
5973 $usealttitle = $langs->trans(
'Info');
5977 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
5986function img_info($titlealt =
'default')
5990 if ($titlealt ==
'default') {
5991 $titlealt = $langs->trans(
'Informations');
5994 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
6005function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
6009 if ($titlealt ==
'default') {
6010 $titlealt = $langs->trans(
'Warning');
6014 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
6023function img_error($titlealt =
'default')
6027 if ($titlealt ==
'default') {
6028 $titlealt = $langs->trans(
'Error');
6031 return img_picto($titlealt,
'error.png');
6041function img_next($titlealt =
'default', $moreatt =
'')
6045 if ($titlealt ==
'default') {
6046 $titlealt = $langs->trans(
'Next');
6050 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
6060function img_previous($titlealt =
'default', $moreatt =
'')
6064 if ($titlealt ==
'default') {
6065 $titlealt = $langs->trans(
'Previous');
6069 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
6080function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
6084 if ($titlealt ==
'default') {
6085 $titlealt = $langs->trans(
'Down');
6088 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
6099function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
6103 if ($titlealt ==
'default') {
6104 $titlealt = $langs->trans(
'Up');
6107 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
6118function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
6122 if ($titlealt ==
'default') {
6123 $titlealt = $langs->trans(
'Left');
6126 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
6137function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
6141 if ($titlealt ==
'default') {
6142 $titlealt = $langs->trans(
'Right');
6145 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
6155function img_allow($allow, $titlealt =
'default')
6159 if ($titlealt ==
'default') {
6160 $titlealt = $langs->trans(
'Active');
6164 return img_picto($titlealt,
'tick.png');
6179 if (is_null($morecss)) {
6183 if ($brand ==
'visa' || $brand ==
'Visa') {
6185 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
6186 $brand =
'cc-mastercard';
6187 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
6189 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
6190 $brand =
'cc-discover';
6191 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
6193 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
6194 $brand =
'cc-diners-club';
6195 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
6196 $brand =
'credit-card';
6199 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
6210function img_mime($file, $titlealt =
'', $morecss =
'')
6212 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
6218 if (empty($titlealt)) {
6219 $titlealt =
'Mime type: '.$mimetype;
6223 return '<i class="fa fa-'.$mimefa.
' '.(preg_match(
'/pictofixedwidth/', $morecss) ?
'' :
'paddingright ').($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.
dolPrintHTMLForAttribute($titlealt).
'"' :
'').
'></i>';
6234function img_search($titlealt =
'default', $other =
'')
6238 if ($titlealt ==
'default') {
6239 $titlealt = $langs->trans(
'Search');
6242 $img =
img_picto($titlealt,
'search.png', $other, 0, 1);
6244 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
6245 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
6261 if ($titlealt ==
'default') {
6262 $titlealt = $langs->trans(
'Search');
6265 $img =
img_picto($titlealt,
'searchclear.png', $other, 0, 1);
6267 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
6268 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
6285function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'', $picto =
'')
6287 global
$conf, $langs;
6289 if ($infoonimgalt) {
6290 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
6292 if (empty(
$conf->use_javascript_ajax)) {
6293 $textfordropdown =
'';
6296 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
6297 $fa =
'info-circle';
6298 if ($picto ==
'warning') {
6299 $fa =
'exclamation-triangle';
6301 $result = ($nodiv ?
'' :
'<div class="wordbreak '.$class.($morecss ?
' '.$morecss :
'').($textfordropdown ?
' hidden' :
'').
'">').
'<span class="fa fa-'.$fa.
'" title="'.
dol_escape_htmltag($admin ? $langs->trans(
'InfoAdmin') : $langs->trans(
'Note')).
'"></span> ';
6303 $result .= ($nodiv ?
'' :
'</div>');
6305 if ($textfordropdown) {
6306 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
6307 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
6308 jQuery(document).ready(function() {
6309 jQuery(".'.$class.
'text").click(function() {
6310 console.log("toggle text");
6311 jQuery(".'.$class.
'").toggle();
6316 $result = $tmpresult.$result;
6337 global
$conf, $langs, $user, $argv;
6338 global $dolibarr_main_prod;
6345 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
6347 $langs->load(
"main");
6351 $langs->loadLangs(array(
'main',
'errors'));
6353 if ($_SERVER[
'DOCUMENT_ROOT']) {
6354 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
6356 $out .=
"You use an experimental or develop level of features, so please do NOT report any bugs or vulnerability, except if problem is confirmed after moving option MAIN_FEATURES_LEVEL back to 0.<br>\n";
6358 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
6360 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
6361 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
6362 if (isset(
$conf->global->MAIN_FEATURES_LEVEL)) {
6363 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
6365 if ($user instanceof
User) {
6366 $out .=
"<b>".$langs->trans(
"Login").
":</b> ".$user->login.
"<br>\n";
6368 if (function_exists(
"phpversion")) {
6369 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
6371 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
6372 if (function_exists(
"php_uname")) {
6373 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
6375 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
6377 $out .=
"<b>" . $langs->trans(
"RequestedUrl") .
":</b> " . (isset($_SERVER[
"REQUEST_URI"]) ?
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT) :
'') .
"<br>\n";
6378 $out .=
"<b>" . $langs->trans(
"Referer") .
":</b> " . (isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'') .
"<br>\n";
6379 $out .=
"<b>" . $langs->trans(
"MenuManager") .
":</b> " . (isset(
$conf->standard_menu) ?
dol_htmlentities(
$conf->standard_menu, ENT_COMPAT) :
'') .
"<br>\n";
6381 $syslog .=
"url=" . (isset($_SERVER[
"REQUEST_URI"]) ?
dol_escape_htmltag($_SERVER[
"REQUEST_URI"]) :
'');
6382 $syslog .=
", query_string=" . (isset($_SERVER[
"QUERY_STRING"]) ?
dol_escape_htmltag($_SERVER[
"QUERY_STRING"]) :
'');
6384 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
6385 $syslog .=
"pid=".dol_getmypid();
6388 if (!empty(
$conf->modules)) {
6389 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".implode(
', ',
$conf->modules).
"<br>\n";
6392 if (is_object($db)) {
6393 if ($_SERVER[
'DOCUMENT_ROOT']) {
6394 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
6395 $lastqueryerror = $db->lastqueryerror();
6397 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
6399 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6400 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6401 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6405 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
6406 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6407 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6408 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6410 $syslog .=
", sql=".$db->lastquery();
6411 $syslog .=
", db_error=".$db->lasterror();
6414 if ($error || $errors) {
6416 if (is_array($error) && is_array($errors)) {
6417 $errors = array_merge($error, $errors);
6418 } elseif (is_array($error)) {
6420 } elseif (is_array($errors) && !empty($error)) {
6421 $errors = array_merge(array($error), $errors);
6422 } elseif (!empty($error)) {
6423 $errors = array_merge(array($error), array($errors));
6426 $langs->load(
"errors");
6428 foreach ($errors as $msg) {
6432 if ($_SERVER[
'DOCUMENT_ROOT']) {
6435 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
6437 $syslog .=
", msg=".$msg;
6440 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
6441 xdebug_print_function_stack();
6442 $out .=
'<b>XDebug information:</b>'.
"<br>\n";
6443 $out .=
'File: '.xdebug_call_file().
"<br>\n";
6444 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
6445 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
6450 if (!headers_sent()) {
6451 if (function_exists(
'top_httphead')) {
6455 http_response_code(202);
6458 if (empty($dolibarr_main_prod)) {
6461 if (empty($langs->defaultlang)) {
6462 $langs->setDefaultLang();
6464 $langs->loadLangs(array(
"main",
"errors"));
6466 print
'This website or feature is currently temporarily not available or failed after a technical error.<br><br>This may be due to a maintenance operation. Current status of operation ('.dol_print_date(
dol_now(),
'dayhourrfc').
') are on next line...<br><br>'.
"\n";
6467 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
6468 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
6469 if (!defined(
"MAIN_CORE_ERROR")) {
6470 define(
"MAIN_CORE_ERROR", 1);
6487function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
6491 if (empty($email)) {
6495 $langs->load(
"errors");
6498 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
6499 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
6500 if ($errormessage) {
6501 print
'<br><br>'.$errormessage;
6503 if (is_array($errormessages) && count($errormessages)) {
6504 foreach ($errormessages as $mesgtoshow) {
6505 print
'<br><br>'.$mesgtoshow;
6508 print
'</div></div>';
6527function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $param =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
6529 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $param, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
6550function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
6552 global $langs, $form;
6555 if ($moreattrib ==
'class="right"') {
6556 $prefix .=
'right ';
6559 $sortorder = strtoupper((
string) $sortorder);
6568 $tmpsortfield = explode(
',', (
string) $sortfield);
6569 $sortfield1 = trim($tmpsortfield[0]);
6570 $tmpfield = explode(
',', $field);
6571 $field1 = trim($tmpfield[0]);
6573 if (!
getDolGlobalString(
'MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') && empty($forcenowrapcolumntitle)) {
6574 $prefix =
'wrapcolumntitle '.$prefix;
6580 $liste_titre =
'liste_titre';
6581 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
6582 $liste_titre =
'liste_titre_sel';
6585 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
6590 if (empty($thead) && $field && empty($disablesortlink)) {
6591 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6592 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6593 $options = preg_replace(
'/&+/i',
'&', $options);
6594 if (!preg_match(
'/^&/', $options)) {
6595 $options =
'&'.$options;
6598 $sortordertouseinlink =
'';
6599 if ($field1 != $sortfield1) {
6600 if (preg_match(
'/^DESC/i', $sortorder)) {
6601 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6603 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6606 if (preg_match(
'/^ASC/i', $sortorder)) {
6607 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6609 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6612 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
6613 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.urlencode($field).
'&sortorder='.urlencode($sortordertouseinlink).
'&begin='.urlencode($begin).$options.
'"';
6619 if (strpos($tooltip,
':') !==
false) {
6620 $tmptooltip = explode(
':', $tooltip);
6622 $tmptooltip = array($tooltip);
6624 $out .= $form->textwithpicto($langs->trans((
string) $name), $langs->trans($tmptooltip[0]), (empty($tmptooltip[2]) ?
'1' : $tmptooltip[2]),
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
6626 $out .= $langs->trans((
string) $name);
6629 if (empty($thead) && $field && empty($disablesortlink)) {
6633 if (empty($thead) && $field) {
6634 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6635 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6636 $options = preg_replace(
'/&+/i',
'&', $options);
6637 if (!preg_match(
'/^&/', $options)) {
6638 $options =
'&'.$options;
6641 if (!$sortorder || ($field1 != $sortfield1)) {
6644 if (preg_match(
'/^DESC/', $sortorder)) {
6645 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
6647 if (preg_match(
'/^ASC/', $sortorder)) {
6648 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
6653 $tagend =
'</'.$tag.
'>';
6655 $out = $tagstart.$sortimg.$out.$tagend;
6670 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
6672 print
'<div class="titre">'.$title.
'</div>';
6686function print_fiche_titre($title, $mesg =
'', $picto =
'generic', $pictoisfullpath = 0,
$id =
'')
6704function load_fiche_titre($title, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0,
$id =
'', $morecssontable =
'', $morehtmlcenter =
'')
6708 if ($picto ==
'setup') {
6713 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
6714 $return .=
'<tr class="toptitle">';
6716 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
6718 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
6719 $return .=
'<div class="titre inline-block">';
6720 $return .=
'<span class="inline-block valignmiddle">'.$title.
'</span>';
6721 $return .=
'</div>';
6724 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6727 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
6729 $return .=
'</tr></table>'.
"\n";
6757function print_barre_liste($title, $page, $file, $options =
'', $sortfield =
'', $sortorder =
'', $morehtmlcenter =
'', $num = -1, $totalnboflines =
'', $picto =
'generic', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limit = -1, $selectlimitsuffix = 0, $hidenavigation = 0, $pagenavastextinput = 0, $morehtmlrightbeforearrow =
'')
6759 global
$conf, $langs;
6762 $savtotalnboflines = $totalnboflines;
6763 if (is_numeric($totalnboflines)) {
6764 $totalnboflines = abs($totalnboflines);
6769 $tmparray = preg_split(
'/<br>/i', $title, 2);
6770 if (!empty($tmparray[1])) {
6771 $title = $tmparray[0];
6772 $subtitle = $tmparray[1];
6775 $page = (int) $page;
6777 if ($picto ==
'setup') {
6778 $picto =
'title_setup.png';
6780 if ((
$conf->browser->name ==
'ie') && $picto ==
'generic') {
6781 $picto =
'title.gif';
6784 $limit =
$conf->liste_limit;
6787 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
6795 print
"<!-- Begin print_barre_liste -->\n";
6796 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'">';
6797 print
'<tr class="toptitle">';
6801 if ($picto && $title) {
6802 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">';
6803 print
img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath);
6807 print
'<td class="nobordernopadding valignmiddle col-title">';
6808 print
'<div class="titre inline-block">';
6809 print
'<span class="inline-block valignmiddle print-barre-liste">'.$title.
'</span>';
6810 if (!empty($title) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'' && $totalnboflines > 0) {
6811 print
'<span class="opacitymedium colorblack marginleftonly totalnboflines valignmiddle" title="'.$langs->trans(
"NbRecordQualified").
'">('.$totalnboflines.
')</span>';
6814 if (!empty($subtitle)) {
6815 print
'<br><div class="subtitle inline-block hideonsmartphone">'.$subtitle.
'</div>';
6820 if ($morehtmlcenter && empty(
$conf->dol_optimize_smallscreen)) {
6821 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6825 print
'<td class="nobordernopadding valignmiddle right col-right">';
6826 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
6828 $options .=
"&sortfield=".urlencode($sortfield);
6831 $options .=
"&sortorder=".urlencode($sortorder);
6835 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
6836 if ($totalnboflines) {
6838 $maxnbofpage = (empty(
$conf->dol_optimize_smallscreen) ? 4 : 0);
6841 $nbpages = ceil($totalnboflines / $limit);
6845 $cpt = ($page - $maxnbofpage);
6851 if (empty($pagenavastextinput)) {
6852 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=0'.$options.
'">1</a></li>';
6854 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6855 } elseif ($cpt == 2) {
6856 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=1'.$options.
'">2</a></li>';
6862 if ($pagenavastextinput) {
6863 if ($cpt == $page) {
6864 $pagelist .=
'<li class="pagination pageplusone valignmiddle"><input type="text" class="'.($totalnboflines > 100 ?
'width40' :
'width25').
' center pageplusone heightofcombo" name="pageplusone" value="'.($page + 1).
'"></li>';
6868 if ($cpt == $page) {
6869 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
6871 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
6875 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
6877 if (empty($pagenavastextinput)) {
6878 if ($cpt < $nbpages) {
6879 if ($cpt < $nbpages - 2) {
6880 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6881 } elseif ($cpt == $nbpages - 2) {
6882 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
6884 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6888 $pagelist .=
'<li class="pagination paginationlastpage"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6891 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
6895 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
6896 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $selectlimitsuffix, $morehtmlrightbeforearrow, $hidenavigation);
6900 if ($pagenavastextinput) {
6907 print
'</table>'.
"\n";
6910 if ($morehtmlcenter && !empty(
$conf->dol_optimize_smallscreen)) {
6911 print
'<div class="nobordernopadding marginbottomonly center valignmiddle col-center centpercent">'.$morehtmlcenter.
'</div>';
6914 print
"<!-- End title -->\n\n";
6933function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $selectlimitsuffix =
'', $beforearrows =
'', $hidenavigation = 0)
6935 global
$conf, $langs;
6937 print
'<div class="pagination"><ul>';
6938 if ($beforearrows) {
6939 print
'<li class="paginationbeforearrows">';
6940 print $beforearrows;
6944 if (empty($hidenavigation)) {
6945 if ((
int) $limit > 0 && (empty($selectlimitsuffix) || !is_numeric($selectlimitsuffix))) {
6946 $pagesizechoices =
'10:10,15:15,20:20,25:25,50:50,100:100,250:250,500:500,1000:1000';
6947 $pagesizechoices .=
',5000:5000';
6957 print
'<li class="pagination">';
6958 print
'<input onfocus="this.value=null;" onchange="this.blur();" class="flat selectlimit nopadding maxwidth75 right pageplusone" id="limit" name="limit" list="limitlist" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'" value="'.$limit.
'">';
6959 print
'<datalist id="limitlist">';
6961 print
'<li class="paginationcombolimit valignmiddle">';
6962 print
'<select id="limit'.(is_numeric($selectlimitsuffix) ?
'' : $selectlimitsuffix).
'" name="limit" class="flat selectlimit nopadding maxwidth75 center'.(is_numeric($selectlimitsuffix) ?
'' :
' '.$selectlimitsuffix).
'" title="'.
dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
6964 $tmpchoice = explode(
',', $pagesizechoices);
6965 $tmpkey = $limit.
':'.$limit;
6966 if (!in_array($tmpkey, $tmpchoice)) {
6967 $tmpchoice[$tmpkey] = $tmpkey;
6969 $tmpkey =
$conf->liste_limit.
':'.
$conf->liste_limit;
6970 if (!in_array($tmpkey, $tmpchoice)) {
6971 $tmpchoice[$tmpkey] = $tmpkey;
6973 asort($tmpchoice, SORT_NUMERIC);
6974 foreach ($tmpchoice as $val) {
6976 $tmp = explode(
':', $val);
6979 if ($key !=
'' && $val !=
'') {
6980 if ((
int) $key == (
int) $limit) {
6981 $selected =
' selected="selected"';
6983 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
6987 print
'</datalist>';
6990 print
ajax_combobox(
"limit".(is_numeric($selectlimitsuffix) ?
'' : $selectlimitsuffix), array(), 0, 0,
'resolve',
'-1',
'limit');
6994 if (
$conf->use_javascript_ajax) {
6995 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
6997 jQuery(document).ready(function () {
6998 jQuery(".selectlimit").change(function() {
6999 console.log("We change limit so we submit the form");
7000 $(this).parents(\'form:first\').submit();
7009 print
'<li class="pagination paginationpage paginationpageleft"><a class="paginationprevious reposition" href="'.$file.
'?page='.($page - 1).$options.
'"><i class="fa fa-chevron-left" title="'.
dol_escape_htmltag($langs->trans(
"Previous")).
'"></i></a></li>';
7011 if ($betweenarrows) {
7012 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
7013 print $betweenarrows;
7014 print
'<!--</div>-->';
7016 if ($nextpage > 0) {
7017 print
'<li class="pagination paginationpage paginationpageright"><a class="paginationnext reposition" href="'.$file.
'?page='.($page + 1).$options.
'"><i class="fa fa-chevron-right" title="'.
dol_escape_htmltag($langs->trans(
"Next")).
'"></i></a></li>';
7020 print
'<li class="paginationafterarrows">';
7025 print
'</ul></div>'.
"\n";
7040function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
7044 if (preg_match(
'/%/', $rate)) {
7045 $rate = str_replace(
'%',
'', $rate);
7049 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
7050 $morelabel =
' ('.$reg[1].
')';
7051 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
7052 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
7054 if (preg_match(
'/\*/', $rate)) {
7055 $rate = str_replace(
'*',
'', $rate);
7060 if (!preg_match(
'/\//', $rate)) {
7061 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
7064 $ret = $rate.($addpercent ?
'%' :
'');
7066 if (($info_bits & 1) && $usestarfornpr >= 0) {
7089function price($amount, $form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
7091 global $langs,
$conf;
7094 if (empty($amount)) {
7097 $amount = (is_numeric($amount) ? $amount : 0);
7098 if ($rounding == -1) {
7101 $nbdecimal = $rounding;
7103 if ($outlangs ===
'none') {
7113 if (!($outlangs instanceof
Translate)) {
7117 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
7118 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
7120 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
7121 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
7123 if ($thousand ==
'None') {
7125 } elseif ($thousand ==
'Space') {
7132 $amount = str_replace(
',',
'.', $amount);
7134 $data = explode(
'.', $amount);
7135 $decpart = isset($data[1]) ? $data[1] :
'';
7136 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
7146 $nbdecimalmaxshown = (int) str_replace(
'...',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN'));
7147 if ($trunc && $nbdecimal > $nbdecimalmaxshown) {
7148 $nbdecimal = $nbdecimalmaxshown;
7156 if ((
string) $forcerounding !=
'-1' && (string) $forcerounding !=
'') {
7157 if ($forcerounding ===
'MU') {
7159 } elseif ($forcerounding ===
'MT') {
7161 } elseif ($forcerounding >= 0) {
7162 $nbdecimal = (int) $forcerounding;
7167 $output = number_format((
float) $amount, $nbdecimal, $dec, $thousand);
7169 $cursymbolbefore = $cursymbolafter =
'';
7170 if ($currency_code && is_object($outlangs)) {
7171 if ($currency_code ==
'auto') {
7172 $currency_code =
$conf->currency;
7175 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD',
'CRC',
'ZAR');
7176 $listoflanguagesbefore = array(
'nl_NL');
7177 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
7178 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
7180 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
7181 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
7184 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
7186 $output = preg_replace(
'/\s/',
' ', $output);
7187 $output = preg_replace(
'/\'/',
''', $output);
7217function price2num($amount, $rounding =
'', $option = 0)
7219 global $langs,
$conf;
7222 if (is_null($amount)) {
7231 if (is_null($langs)) {
7235 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
7236 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
7238 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
7239 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
7242 if ($thousand ==
'None') {
7244 } elseif ($thousand ==
'Space') {
7252 if (!is_numeric($amount)) {
7253 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
7256 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
7257 $amount = str_replace($thousand,
'', $amount);
7263 if (is_numeric($amount)) {
7265 $temps = sprintf(
"%10.10F", $amount - intval($amount));
7266 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
7268 $amount = number_format($amount, $nbofdec, $dec, $thousand);
7274 if ($thousand !=
',' && $thousand !=
'.') {
7287 if (preg_match(
'/^(?<int>[^,]*,|[^.]*\.)(?<dec>[^.,]*)$/u', $amount, $matches)) {
7288 $intPart = $matches[
'int'];
7289 $decPart = $matches[
'dec'];
7292 $intPart = str_replace([
'.',
','],
'', $intPart);
7295 $amount = $intPart . $dec . $decPart;
7299 $amount = str_replace(
' ',
'', $amount);
7300 $amount = str_replace($thousand,
'', $amount);
7301 $amount = str_replace($dec,
'.', $amount);
7303 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
7309 $nbofdectoround =
'';
7310 if ($rounding ==
'MU') {
7312 } elseif ($rounding ==
'MT') {
7314 } elseif ($rounding ==
'MS') {
7315 $nbofdectoround = isset(
$conf->global->MAIN_MAX_DECIMALS_STOCK) ?
getDolGlobalInt(
'MAIN_MAX_DECIMALS_STOCK') : 5;
7316 } elseif ($rounding ==
'CU') {
7318 } elseif ($rounding ==
'CT') {
7320 } elseif (is_numeric($rounding)) {
7321 $nbofdectoround = (int) $rounding;
7326 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
7328 return 'ErrorBadParameterProvidedToFunction';
7334 if (is_numeric($amount)) {
7336 $temps = sprintf(
"%10.10F", $amount - intval($amount));
7337 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
7339 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
7345 if ($thousand !=
',' && $thousand !=
'.') {
7346 $amount = str_replace(
',',
'.', $amount);
7349 $amount = str_replace(
' ',
'', $amount);
7350 $amount = str_replace($thousand,
'', $amount);
7351 $amount = str_replace($dec,
'.', $amount);
7353 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
7371function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
7373 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
7375 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
7376 $dimension *= 1000000;
7378 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
7381 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
7382 $dimension /= 1000000;
7384 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
7401 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
7403 $ret .=
' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
7421function get_localtax($vatrate, $local, $thirdparty_buyer =
null, $thirdparty_seller =
null, $vatnpr = 0)
7423 global $db,
$conf, $mysoc;
7425 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
7426 $thirdparty_seller = $mysoc;
7429 dol_syslog(
"get_localtax tva=".$vatrate.
" local=".$local.
" thirdparty_buyer id=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->id :
'').
"/country_code=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code :
'').
" thirdparty_seller id=".$thirdparty_seller->id.
"/country_code=".$thirdparty_seller->country_code.
" thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj.
" thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj);
7431 $vatratecleaned = $vatrate;
7433 if (preg_match(
'/^(.*)\s*\((.*)\)$/', (
string) $vatrate, $reg)) {
7434 $vatratecleaned = trim($reg[1]);
7435 $vatratecode = $reg[2];
7444 if ($mysoc->country_code ==
'ES') {
7446 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
7449 if ($thirdparty_seller->id == $mysoc->id) {
7450 if (!$thirdparty_buyer->localtax1_assuj) {
7454 if (!$thirdparty_seller->localtax1_assuj) {
7462 if (!$mysoc->localtax2_assuj) {
7465 if ($thirdparty_seller->id == $mysoc->id) {
7466 if (!$thirdparty_buyer->localtax2_assuj) {
7470 if (!$thirdparty_seller->localtax2_assuj) {
7476 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
7479 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
7485 if (in_array($mysoc->country_code, array(
'ES'))) {
7486 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
7492 if ($thirdparty_seller != $mysoc) {
7494 return $thirdparty_seller->localtax1_value;
7503 if ($thirdparty_seller != $mysoc) {
7506 return $thirdparty_seller->localtax2_value;
7509 if (in_array($mysoc->country_code, array(
'ES'))) {
7510 return $thirdparty_buyer->localtax2_value;
7519 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
7520 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7521 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
7522 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7523 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7524 if (!empty($vatratecode)) {
7525 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
7527 $sql .=
" AND t.recuperableonly = '".$db->escape((
string) $vatnpr).
"'";
7530 $resql = $db->query($sql);
7533 $obj = $db->fetch_object($resql);
7536 return $obj->localtax1;
7537 } elseif ($local == 2) {
7538 return $obj->localtax2;
7559 $valors = explode(
":", $tax);
7561 if (count($valors) > 1) {
7578 $sql =
" SELECT t.localtax".$local.
" as localtax";
7579 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_pays";
7580 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.entity IN (".
getEntity(
'c_tva').
") AND t.taux = (";
7581 $sql .=
"SELECT MAX(tt.taux) FROM ".MAIN_DB_PREFIX.
"c_tva as tt INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = tt.fk_pays";
7582 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.entity IN (".
getEntity(
'c_tva').
") AND tt.active = 1)";
7583 $sql .=
" AND t.localtax".$local.
"_type <> '0'";
7584 $sql .=
" ORDER BY t.rowid DESC";
7586 $resql = $db->query($sql);
7588 $obj = $db->fetch_object($resql);
7590 return $obj->localtax;
7611function getTaxesFromId($vatrate, $buyer =
null, $seller =
null, $firstparamisid = 1)
7615 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
7618 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
7619 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
7620 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7621 if ($firstparamisid) {
7622 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7624 $vatratecleaned = $vatrate;
7627 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7628 $vatratecleaned = $reg[1];
7629 $vatratecode = $reg[2];
7632 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7635 $sql .=
" WHERE t.fk_pays = c.rowid";
7637 $sql .=
" AND c.code = '".$db->escape($buyer->country_code).
"'";
7639 $sql .=
" AND c.code = '".$db->escape($seller->country_code).
"'";
7641 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7642 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7644 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7648 $resql = $db->query($sql);
7650 $obj = $db->fetch_object($resql);
7653 'rowid' => $obj->rowid,
7654 'code' => $obj->code,
7655 'rate' => $obj->rate,
7656 'localtax1' => $obj->localtax1,
7657 'localtax1_type' => $obj->localtax1_type,
7658 'localtax2' => $obj->localtax2,
7659 'localtax2_type' => $obj->localtax2_type,
7661 'accountancy_code_sell' => $obj->accountancy_code_sell,
7662 'accountancy_code_buy' => $obj->accountancy_code_buy
7694 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
7697 $sql =
"SELECT t.taux as rate, t.code, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
7698 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7699 if ($firstparamisid) {
7700 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7702 $vatratecleaned = $vatrate;
7705 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7706 $vatratecleaned = $reg[1];
7707 $vatratecode = $reg[2];
7710 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7711 if (!empty($mysoc) && $mysoc->country_code ==
'ES') {
7712 $countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
7713 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7715 $countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
7716 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7718 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7720 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7724 $resql = $db->query($sql);
7726 $obj = $db->fetch_object($resql);
7729 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
7732 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7733 } elseif ($local == 2) {
7734 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7736 return array($obj->localtax1_type,
get_localtax($vateratestring, 1, $buyer, $seller), $obj->localtax2_type,
get_localtax($vateratestring, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7758 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7766 $product->fetch($idprod);
7768 if (($mysoc->country_code == $thirdpartytouse->country_code)
7769 || (in_array($mysoc->country_code, array(
'FR',
'MC')) && in_array($thirdpartytouse->country_code, array(
'FR',
'MC')))
7770 || (in_array($mysoc->country_code, array(
'MQ',
'GP')) && in_array($thirdpartytouse->country_code, array(
'MQ',
'GP')))
7773 if ($idprodfournprice > 0) {
7774 $result = $product->get_buyprice($idprodfournprice, 0, 0,
'');
7776 $ret = $product->vatrate_supplier;
7777 if ($product->default_vat_code_supplier) {
7778 $ret .=
' ('.$product->default_vat_code_supplier.
')';
7784 $ret = $product->tva_tx;
7785 if ($product->default_vat_code) {
7786 $ret .=
' ('.$product->default_vat_code.
')';
7799 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
7800 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7801 $sql .=
" WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code).
"'";
7802 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7803 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
7804 $sql .= $db->plimit(1);
7806 $resql = $db->query($sql);
7808 $obj = $db->fetch_object($resql);
7810 $ret = $obj->vat_rate;
7811 if ($obj->default_vat_code) {
7812 $ret .=
' ('.$obj->default_vat_code.
')';
7836 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
7853 if (!class_exists(
'Product')) {
7854 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7863 $result = $product->fetch($idprod);
7865 if ($mysoc->country_code == $thirdpartytouse->country_code) {
7879 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
7880 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7881 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
7882 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7883 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
7884 $sql .= $db->plimit(1);
7886 $resql = $db->query($sql);
7888 $obj = $db->fetch_object($resql);
7891 $ret = $obj->localtax1;
7892 } elseif ($local == 2) {
7893 $ret = $obj->localtax2;
7901 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
7926 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
7929 $seller_use_vat = ((is_numeric($thirdparty_seller->tva_assuj) && !$thirdparty_seller->tva_assuj) || (!is_numeric($thirdparty_seller->tva_assuj) && $thirdparty_seller->tva_assuj ==
'franchise')) ? 0 : 1;
7931 if (empty($thirdparty_seller->country_code)) {
7932 $thirdparty_seller->country_code = $mysoc->country_code;
7934 $seller_country_code = $thirdparty_seller->country_code;
7935 $seller_in_cee =
isInEEC($thirdparty_seller);
7937 if (empty($thirdparty_buyer->country_code)) {
7938 $thirdparty_buyer->country_code = $mysoc->country_code;
7940 $buyer_country_code = $thirdparty_buyer->country_code;
7941 $buyer_in_cee =
isInEEC($thirdparty_buyer);
7943 dol_syslog(
"get_default_tva: seller use vat=".$seller_use_vat.
", seller country=".$seller_country_code.
", seller in cee=".((
string) (
int) $seller_in_cee).
", buyer vat number=".$thirdparty_buyer->tva_intra.
" buyer country=".$buyer_country_code.
", buyer state=".$thirdparty_buyer->state_id.
" buyer in cee=".((
string) (
int) $buyer_in_cee).
", idprod=".$idprod.
", idprodfournprice=".$idprodfournprice.
", SERVICE_ARE_ECOMMERCE_200238EC=".
getDolGlobalString(
'SERVICE_ARE_ECOMMERCE_200238EC'));
7948 if ($seller_in_cee && $buyer_in_cee) {
7949 $isacompany = $thirdparty_buyer->isACompany();
7950 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
7951 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
7965 if (!$seller_use_vat) {
7971 if (!empty($thirdparty_buyer->state_id)) {
7972 $sql =
"SELECT d.rowid, t.taux as vat_default_rate, t.code as vat_default_code ";
7973 $sql .=
" FROM ".$db->prefix().
"c_tva as t";
7974 $sql .=
" INNER JOIN ".$db->prefix().
"c_departements as d ON t.fk_department_buyer = d.rowid";
7975 $sql .=
" WHERE d.rowid = ".((int) $thirdparty_buyer->state_id);
7976 $sql .=
" AND t.active > 0";
7977 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7978 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
7980 $res = $db->query($sql);
7982 if ($db->num_rows($res)) {
7983 $obj = $db->fetch_object($res);
7984 return $obj->vat_default_rate.
' ('.$obj->vat_default_code.
')';
7991 if (($seller_country_code == $buyer_country_code)
7992 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))
7993 || (in_array($seller_country_code, array(
'MQ',
'GP')) && in_array($buyer_country_code, array(
'MQ',
'GP')))
7998 if ($seller_country_code ==
'IN' &&
getDolGlobalString(
'MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA')) {
8002 if (preg_match(
'/C+S-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id != $thirdparty_buyer->state_id) {
8004 $tmpvat = str_replace(
"C+S",
"I", $tmpvat);
8005 } elseif (preg_match(
'/I-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id == $thirdparty_buyer->state_id) {
8007 $tmpvat = str_replace(
"I",
"C+S", $tmpvat);
8019 if (($seller_in_cee && $buyer_in_cee)) {
8020 $isacompany = $thirdparty_buyer->isACompany();
8021 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
8022 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
8039 if (
getDolGlobalString(
'MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC') && empty($buyer_in_cee)) {
8040 $isacompany = $thirdparty_buyer->isACompany();
8068 if ($idprodfournprice > 0) {
8069 if (!class_exists(
'ProductFournisseur')) {
8070 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
8073 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
8074 return $prodprice->fourn_tva_npr;
8075 } elseif ($idprod > 0) {
8076 if (!class_exists(
'Product')) {
8077 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
8080 $prod->fetch($idprod);
8081 return $prod->tva_npr;
8104 if (!is_object($thirdparty_seller)) {
8107 if (!is_object($thirdparty_buyer)) {
8111 if (empty($thirdparty_seller->country_code)) {
8112 $thirdparty_seller->country_code = $mysoc->country_code;
8114 $seller_country_code = $thirdparty_seller->country_code;
8117 if (empty($thirdparty_buyer->country_code)) {
8118 $thirdparty_buyer->country_code = $mysoc->country_code;
8120 $buyer_country_code = $thirdparty_buyer->country_code;
8124 if ($mysoc->country_code ==
'ES') {
8125 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
8130 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
8133 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
8137 } elseif ($local == 2) {
8139 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
8142 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
8147 if ($seller_country_code == $buyer_country_code) {
8162function yn($yesno, $format = 1, $color = 0)
8166 $result =
'unknown';
8168 if ($yesno == 1 || (isset($yesno) && (strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true'))) {
8169 $result = $langs->trans(
'yes');
8170 if ($format == 1 || $format == 3) {
8171 $result = $langs->trans(
"Yes");
8174 $result =
'<input type="checkbox" value="1" checked disabled>';
8177 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
8179 if ($format == 4 || !is_numeric($format)) {
8180 $result =
img_picto(is_numeric($format) ?
'' : $format,
'check');
8184 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
8185 $result = $langs->trans(
"no");
8186 if ($format == 1 || $format == 3) {
8187 $result = $langs->trans(
"No");
8190 $result =
'<input type="checkbox" value="0" disabled>';
8193 $result =
'<input type="checkbox" value="0" disabled> '.$result;
8195 if ($format == 4 || !is_numeric($format)) {
8196 $result =
img_picto(is_numeric($format) ?
'' : $format,
'uncheck');
8202 $classname =
'error';
8206 return '<span class="'.$classname.
'">'.$result.
'</span>';
8229function get_exdir($num, $level, $alpha, $withoutslash,
$object, $modulepart =
'')
8231 if (empty($modulepart) && is_object(
$object)) {
8232 if (!empty(
$object->module)) {
8233 $modulepart =
$object->module;
8234 } elseif (!empty(
$object->element)) {
8235 $modulepart =
$object->element;
8242 $arrayforoldpath = array(
'cheque' => 2,
'category' => 2,
'holiday' => 2,
'supplier_invoice' => 2,
'invoice_supplier' => 2,
'mailing' => 2,
'supplier_payment' => 2);
8244 $arrayforoldpath[
'product'] = 2;
8247 if (empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
8248 $level = $arrayforoldpath[$modulepart];
8250 if (!empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
8252 if (empty($num) && is_object(
$object)) {
8255 if (empty($alpha)) {
8256 $num = preg_replace(
'/([^0-9])/i',
'', $num);
8258 $num = preg_replace(
'/^.*\-/i',
'', $num);
8260 $num = substr(
"000".$num, -$level);
8262 $path = substr($num, 0, 1);
8265 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
8268 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
8274 if (in_array($modulepart, array(
'societe',
'thirdparty')) &&
$object instanceOf
Societe) {
8282 if (empty($withoutslash) && !empty($path)) {
8297function dol_mkdir($dir, $dataroot =
'', $newmask =
'')
8299 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
8304 if (@is_dir($dir_osencoded)) {
8312 if (!empty($dataroot)) {
8314 $dir = str_replace($dataroot.
'/',
'', $dir);
8315 $ccdir = $dataroot.
'/';
8318 $cdir = explode(
"/", $dir);
8319 $num = count($cdir);
8320 for ($i = 0; $i < $num; $i++) {
8322 $ccdir .=
'/'.$cdir[$i];
8324 $ccdir .= $cdir[$i];
8327 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
8335 if (!@is_dir($ccdir_osencoded)) {
8336 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' is not found (does not exists or is outside open_basedir PHP setting).", LOG_DEBUG);
8339 $dirmaskdec = octdec((
string) $newmask);
8340 if (empty($newmask)) {
8343 $dirmaskdec |= octdec(
'0111');
8344 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
8346 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' (no permission to write into parent or directory already exists).", LOG_WARNING);
8349 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
8358 return ($nberr ? -$nberr : $nbcreated);
8369function dolChmod($filepath, $newmask =
'')
8371 if (!empty($newmask)) {
8372 @chmod($filepath, octdec($newmask));
8386 return '<span class="fieldrequired">*</span>';
8406function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
8408 if (is_null($stringtoclean)) {
8412 if ($removelinefeed == 2) {
8413 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
8415 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
8420 $temp = str_replace(
'< ',
'__ltspace__', $temp);
8421 $temp = str_replace(
'<:',
'__lttwopoints__', $temp);
8424 $temp = strip_tags($temp);
8427 $pattern =
"/<[^<>]+>/";
8434 $tempbis = str_replace(
'<>',
'', $temp);
8435 $tempbis = preg_replace($pattern,
'', $tempbis);
8437 }
while ($tempbis != $temp);
8442 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
8448 if ($removelinefeed == 1) {
8449 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
8453 if ($removedoublespaces) {
8454 while (strpos($temp,
" ") !==
false) {
8455 $temp = str_replace(
" ",
" ", $temp);
8459 $temp = str_replace(
'__ltspace__',
'< ', $temp);
8460 $temp = str_replace(
'__lttwopoints__',
'<:', $temp);
8484function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array(), $allowlink = 0, $allowscript = 0, $allowstyle = 0, $allowphp = 0)
8486 if (empty($allowed_tags)) {
8487 $allowed_tags = array(
8488 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
8489 "ol",
"p",
"q",
"s",
"span",
"strike",
"strong",
"title",
"table",
"tr",
"th",
"td",
"u",
"ul",
"sup",
"sub",
"blockquote",
"pre",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
8490 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
8493 $allowed_tags[] =
"comment";
8495 if (!in_array(
'iframe', $allowed_tags)) {
8496 $allowed_tags[] =
"iframe";
8500 if (!in_array(
'link', $allowed_tags)) {
8501 $allowed_tags[] =
"link";
8505 if (!in_array(
'script', $allowed_tags)) {
8506 $allowed_tags[] =
"script";
8510 if (!in_array(
'style', $allowed_tags)) {
8511 $allowed_tags[] =
"style";
8515 $allowed_tags_string = implode(
"><", $allowed_tags);
8516 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
8518 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
8523 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
8526 $allowed_tags[] =
"commentphp";
8527 $stringtoclean = preg_replace(
'/^<\?php([^"]+)\?>$/i',
'<commentphp>\1__</commentphp>', $stringtoclean);
8528 $stringtoclean = preg_replace(
'/"<\?php([^"]+)\?>"/i',
'"<commentphp>\1</commentphp>"', $stringtoclean);
8531 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
8532 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
8535 $temp = strip_tags($stringtoclean, $allowed_tags_string);
8537 if ($cleanalsosomestyles) {
8538 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
8540 if ($removeclassattribute) {
8541 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
8546 if ($cleanalsojavascript) {
8547 $temp = preg_replace(
'/j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t\s*:/i',
'', $temp);
8550 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
8553 $temp = preg_replace(
'/<commentphp>(.*)<\/commentphp>/',
'<?php\1?>', $temp);
8556 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
8577 if (is_null($allowed_attributes)) {
8578 $allowed_attributes = array(
8579 "allow",
"allowfullscreen",
"alt",
"async",
"class",
"contenteditable",
"crossorigin",
"data-html",
"frameborder",
"height",
"href",
"id",
"name",
"property",
"rel",
"src",
"style",
"target",
"title",
"type",
"width",
8581 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
8585 if (!in_array(
"content", $allowed_attributes)) {
8586 $allowed_attributes[] =
"content";
8588 if (!in_array(
"http-equiv", $allowed_attributes)) {
8589 $allowed_attributes[] =
"http-equiv";
8592 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
8594 $stringtoclean =
'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>'.$stringtoclean.
'</body></html>';
8597 $dom =
new DOMDocument(
'',
'UTF-8');
8599 $savwarning = error_reporting();
8600 error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
8601 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL);
8602 error_reporting($savwarning);
8604 if ($dom instanceof DOMDocument) {
8605 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
8606 $el = $els->item($i);
8607 if (!$el instanceof DOMElement) {
8610 $attrs = $el->attributes;
8611 for ($ii = $attrs->length - 1; $ii >= 0; $ii--) {
8613 if (!empty($attrs->item($ii)->name)) {
8614 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
8616 $els->item($i)->removeAttribute($attrs->item($ii)->name);
8617 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
8619 $valuetoclean = $attrs->item($ii)->value;
8621 if (isset($valuetoclean)) {
8623 $oldvaluetoclean = $valuetoclean;
8624 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
8625 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
8626 if ($els->item($i)->tagName ==
'a') {
8627 $valuetoclean = preg_replace(
'/display\s*:/mi',
'', $valuetoclean);
8628 $valuetoclean = preg_replace(
'/z-index\s*:/mi',
'', $valuetoclean);
8629 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*:/mi',
'', $valuetoclean);
8633 $valuetoclean = preg_replace(
'/(logout|passwordforgotten)\.php/mi',
'', $valuetoclean);
8634 $valuetoclean = preg_replace(
'/action=/mi',
'', $valuetoclean);
8635 }
while ($oldvaluetoclean != $valuetoclean);
8638 $attrs->item($ii)->value = $valuetoclean;
8645 $dom->encoding =
'UTF-8';
8647 $return = $dom->saveHTML();
8651 $return = preg_replace(
'/^'.preg_quote(
'<html><head><',
'/').
'[^<>]*'.preg_quote(
'></head><body>',
'/').
'/',
'', $return);
8652 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', trim($return));
8654 return trim($return);
8656 return $stringtoclean;
8673 $temp = $stringtoclean;
8674 foreach ($disallowed_tags as $tagtoremove) {
8675 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
8676 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
8679 if ($cleanalsosomestyles) {
8680 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
8698 if ($nboflines == 1) {
8700 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
8701 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
8704 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
8709 return $firstline.(isset($firstline) && isset($text) && (strlen($firstline) != strlen($text)) ?
'...' :
'');
8713 $text = preg_replace(
'/\n/',
'', $text);
8715 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8717 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8720 $text = strtr($text, $repTable);
8721 if ($charset ==
'UTF-8') {
8722 $pattern =
'/(<br[^>]*>)/Uu';
8725 $pattern =
'/(<br[^>]*>)/U';
8727 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
8732 $lastaddediscontent = 1;
8733 while ($countline < $nboflines && isset($a[$i])) {
8734 if (preg_match(
'/<br[^>]*>/', $a[$i])) {
8735 if (array_key_exists($i + 1, $a) && !empty($a[$i + 1])) {
8736 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
8738 if (!$lastaddediscontent) {
8741 $lastaddediscontent = 0;
8744 $firstline .= $a[$i];
8745 $lastaddediscontent = 1;
8751 $adddots = (isset($a[$i]) && (!preg_match(
'/<br[^>]*>/', $a[$i]) || (array_key_exists($i + 1, $a) && !empty($a[$i + 1]))));
8753 $ret = $firstline.($adddots ?
'...' :
'');
8771function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
8773 if (is_null($stringtoencode)) {
8778 return nl2br($stringtoencode, $forxml);
8780 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
8794function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check =
'restricthtml')
8796 if (empty($nouseofiframesandbox) &&
getDolGlobalString(
'MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS')) {
8801 return $stringtoencode;
8803 $out = $stringtoencode;
8807 $oldstringtoclean = $out;
8815 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML') && $check !=
'restricthtmlallowunvalid') {
8817 libxml_use_internal_errors(
false);
8818 if (LIBXML_VERSION < 20900) {
8822 libxml_disable_entity_loader(
true);
8825 $dom =
new DOMDocument();
8833 $out =
'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body><div class="tricktoremove">'.$out.
'</div></body></html>';
8837 $out =
'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body><div class="tricktoremove">'.dol_nl2br($out).
'</div></body></html>';
8841 $dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOXMLDECL);
8843 $dom->encoding =
'UTF-8';
8845 $out = trim($dom->saveHTML());
8849 $out = preg_replace(
'/^'.preg_quote(
'<html><head><',
'/').
'[^<>]+'.preg_quote(
'></head><body><div class="tricktoremove">',
'/').
'/',
'', $out);
8850 $out = preg_replace(
'/'.preg_quote(
'</div></body></html>',
'/').
'$/',
'', trim($out));
8856 $out = str_replace(
'<br>',
'', $out);
8861 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8868 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') && !in_array($check, array(
'restricthtmlallowunvalid',
'restricthtmlallowlinkscript')) && $outishtml) {
8874 if (extension_loaded(
'tidy') && class_exists(
"tidy")) {
8881 'quote-marks' =>
false,
8882 'doctype' =>
'strict',
8883 'show-body-only' =>
true,
8884 "indent-attributes" =>
false,
8885 "vertical-space" =>
false,
8888 'preserve-entities' =>
true
8898 $out = $tidy->repairString($out, $config,
'utf8');
8907 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8912 $out = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $out);
8915 $out = preg_replace(
'/&(tab|newline);/i',
' ', $out);
8919 $out = preg_replace(
'/'/i',
''', $out);
8924 if (function_exists(
'realCharForNumericEntities')) {
8925 $out = preg_replace_callback(
8926 '/&#(x?[0-9][0-9a-f]+;?)/i',
8931 static function ($m) {
8939 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
8942 if ($check ==
'restricthtmlallowlinkscript') {
8944 } elseif ($check ==
'restricthtmlallowclass' || $check ==
'restricthtmlallowunvalid') {
8946 } elseif ($check ==
'restricthtmlallowiframe') {
8959 $out = preg_replace(
'/'/i',
"'", $out);
8963 $out = preg_replace(
'/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i',
'', $out);
8964 $out = preg_replace(
'/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i',
'', $out);
8965 $out = preg_replace(
'/on(dblclick|drop|durationchange|emptied|end|ended|error|focus(in|out)?|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i',
'', $out);
8966 $out = preg_replace(
'/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i',
'', $out);
8967 $out = preg_replace(
'/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i',
'', $out);
8968 $out = preg_replace(
'/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i',
'', $out);
8970 $out = preg_replace(
'/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i',
'', $out);
8971 }
while ($oldstringtoclean != $out);
8978 $tmpout = preg_replace(
'/<img src="data:/mi',
'<__IMG_SRC_DATA__ src="data:', $out);
8979 preg_match_all(
'/(<img|url\(|<link)/i', $tmpout, $reg);
8980 $nblinks = count($reg[0]);
8981 if ($nblinks >
getDolGlobalInt(
"MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
8982 $out =
'ErrorTooManyLinksIntoHTMLString';
8985 if (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 2 || $check ==
'restricthtmlnolink') {
8987 $out =
'ErrorHTMLLinksNotAllowed';
8989 } elseif (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 1) {
8992 $pattern =
'/src=["\']?(http[^"\']+)|url\(["\']?(http[^\)]+)/';
8995 if (preg_match_all($pattern, $out, $matches)) {
8997 $urls = $matches[1];
9000 foreach ($urls as $url) {
9002 echo
"Found url = ".$url .
"\n";
9005 $out =
'ErrorHTMLExternalLinksNotAllowed';
9034function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
9036 if (is_null($stringtoencode)) {
9040 $newstring = $stringtoencode;
9042 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
9043 if ($removelasteolbr) {
9044 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
9046 $newstring = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $newstring);
9047 $newstring = strtr($newstring, array(
'&' =>
'__PROTECTand__',
'<' =>
'__PROTECTlt__',
'>' =>
'__PROTECTgt__',
'"' =>
'__PROTECTdquot__'));
9049 $newstring = strtr($newstring, array(
'__PROTECTand__' =>
'&',
'__PROTECTlt__' =>
'<',
'__PROTECTgt__' =>
'>',
'__PROTECTdquot__' =>
'"'));
9051 if ($removelasteolbr) {
9052 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
9071 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
9072 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
9073 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
9074 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
9086 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
9087 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
9103 if ($keepsomeentities) {
9104 $newstring = strtr($newstring, array(
'&' =>
'__andamp__',
'<' =>
'__andlt__',
'>' =>
'__andgt__',
'"' =>
'__dquot__'));
9106 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string)
$c);
9107 if ($keepsomeentities) {
9108 $newstring = strtr($newstring, array(
'__andamp__' =>
'&',
'__andlt__' =>
'<',
'__andgt__' =>
'>',
'__dquot__' =>
'"'));
9124function dol_htmlentities($string, $flags = ENT_QUOTES | ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
9126 return htmlentities($string, $flags, $encoding, $double_encode);
9145 for ($scursor = 0; $scursor < $len; $scursor++) {
9146 $ordchar = ord($s[$scursor]);
9148 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
9151 } elseif ($ordchar > 126 && $ordchar < 160) {
9155 $out .= $s[$scursor];
9177 $arraystring = explode(
"\n", $s);
9178 $nb = count($arraystring);
9195 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
9197 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
9200 $text = strtr($text, $repTable);
9201 if ($charset ==
'UTF-8') {
9202 $pattern =
'/(<br[^>]*>)/Uu';
9205 $pattern =
'/(<br[^>]*>)/U';
9207 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
9209 $nblines = (int) floor((count($a) + 1) / 2);
9212 foreach ($a as $line) {
9215 $line_dec = html_entity_decode($line);
9217 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
9218 $nblines += substr_count($line_dec,
'\n');
9238 if (is_null($msg)) {
9243 if (preg_match(
'/<(html|link|script)/i', $msg)) {
9245 } elseif (preg_match(
'/<body/i', $msg)) {
9247 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
9249 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
9251 } elseif (preg_match(
'/<br/i', $msg)) {
9257 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
9258 if (preg_match(
'/<(html|link|script|body)/i', $msg)) {
9260 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
9262 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
9264 } elseif (preg_match(
'/<(br|hr)\/>/i', $msg)) {
9266 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)>/i', $msg)) {
9268 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
9270 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
9272 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
9274 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
9276 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
9279 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
9281 } elseif (preg_match(
'/&#x[a-f0-9][a-f0-9];/i', $msg)) {
9303function dol_concatdesc($text1, $text2, $forxml =
false, $invert =
false)
9305 if (!empty($invert)) {
9313 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
9333function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude =
null,
$object =
null, $include =
null)
9335 global $db,
$conf, $mysoc, $user, $extrafields;
9337 $substitutionarray = array();
9339 if ((empty($exclude) || !in_array(
'user', $exclude)) && (empty($include) || in_array(
'user', $include)) && $user instanceof
User) {
9343 $emailsendersignature = $user->signature;
9344 $usersignature = $user->signature;
9345 $substitutionarray = array_merge($substitutionarray, array(
9346 '__SENDEREMAIL_SIGNATURE__' => (
string) ((!
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ?
dol_trunc(
'SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) :
''),
9350 if (is_object($user) && ($user instanceof
User)) {
9351 $substitutionarray = array_merge($substitutionarray, array(
9352 '__USER_ID__' => (
string) $user->id,
9353 '__USER_LOGIN__' => (
string) $user->login,
9354 '__USER_EMAIL__' => (
string) $user->email,
9355 '__USER_PHONE__' => (
string)
dol_print_phone($user->office_phone,
'', 0, 0,
'',
" ",
'',
'', -1),
9356 '__USER_PHONEPRO__' => (
string)
dol_print_phone($user->user_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
9357 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
9358 '__USER_FAX__' => (
string) $user->office_fax,
9359 '__USER_LASTNAME__' => (
string) $user->lastname,
9360 '__USER_FIRSTNAME__' => (
string) $user->firstname,
9361 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
9362 '__USER_SUPERVISOR_ID__' => (
string) ($user->fk_user ? $user->fk_user :
'0'),
9363 '__USER_JOB__' => (string) $user->job,
9365 '__USER_VCARD_URL__' => (string) $user->getOnlineVirtualCardUrl(
'',
'external')
9369 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc) && (empty($include) || in_array(
'mycompany', $include))) {
9370 $substitutionarray = array_merge($substitutionarray, array(
9371 '__MYCOMPANY_NAME__' => $mysoc->name,
9372 '__MYCOMPANY_EMAIL__' => $mysoc->email,
9373 '__MYCOMPANY_URL__' => $mysoc->url,
9374 '__MYCOMPANY_PHONE__' =>
dol_print_phone($mysoc->phone,
'', 0, 0,
'',
" ",
'',
'', -1),
9375 '__MYCOMPANY_PHONEMOBILE__' =>
dol_print_phone($mysoc->phone_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
9376 '__MYCOMPANY_FAX__' =>
dol_print_phone($mysoc->fax,
'', 0, 0,
'',
" ",
'',
'', -1),
9377 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
9378 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
9379 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
9380 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
9381 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
9382 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
9383 '__MYCOMPANY_PROFID7__' => $mysoc->idprof7,
9384 '__MYCOMPANY_PROFID8__' => $mysoc->idprof8,
9385 '__MYCOMPANY_PROFID9__' => $mysoc->idprof9,
9386 '__MYCOMPANY_PROFID10__' => $mysoc->idprof10,
9387 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
9388 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
9389 '__MYCOMPANY_ADDRESS__' => $mysoc->
address,
9390 '__MYCOMPANY_ZIP__' => $mysoc->zip,
9391 '__MYCOMPANY_TOWN__' => $mysoc->town,
9392 '__MYCOMPANY_STATE__' => $mysoc->state,
9393 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
9394 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
9395 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
9396 '__MYCOMPANY_CURRENCY_CODE__' =>
$conf->currency
9400 if (($onlykey || is_object(
$object)) && (empty($exclude) || !in_array(
'object', $exclude)) && (empty($include) || in_array(
'object', $include))) {
9402 $substitutionarray[
'__ID__'] =
'__ID__';
9403 $substitutionarray[
'__REF__'] =
'__REF__';
9404 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
9405 $substitutionarray[
'__LABEL__'] =
'__LABEL__';
9406 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
9407 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
9408 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
9409 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
9410 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
9412 if (isModEnabled(
"societe")) {
9413 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
9414 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
9415 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
9416 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
9417 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
9418 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
9420 $substitutionarray[
'__THIRDPARTY_URL__'] =
'__THIRDPARTY_URL__';
9422 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
9423 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
9424 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
9425 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
9426 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
9427 $substitutionarray[
'__THIRDPARTY_STATE__'] =
'__THIRDPARTY_STATE__';
9428 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
9429 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
9430 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
9431 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
9432 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
9433 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
9434 $substitutionarray[
'__THIRDPARTY_IDPROF7__'] =
'__THIRDPARTY_IDPROF7__';
9435 $substitutionarray[
'__THIRDPARTY_IDPROF8__'] =
'__THIRDPARTY_IDPROF8__';
9436 $substitutionarray[
'__THIRDPARTY_IDPROF9__'] =
'__THIRDPARTY_IDPROF9__';
9437 $substitutionarray[
'__THIRDPARTY_IDPROF10__'] =
'__THIRDPARTY_IDPROF10__';
9438 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
9439 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
9440 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
9442 if (isModEnabled(
'member') && (!is_object(
$object) ||
$object->element ==
'adherent') && (empty($exclude) || !in_array(
'member', $exclude)) && (empty($include) || in_array(
'member', $include))) {
9443 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
9444 $substitutionarray[
'__MEMBER_TITLE__'] =
'__MEMBER_TITLE__';
9445 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
9446 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
9447 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
9452 if (isModEnabled(
'ticket') && (!is_object(
$object) ||
$object->element ==
'ticket') && (empty($exclude) || !in_array(
'ticket', $exclude)) && (empty($include) || in_array(
'ticket', $include))) {
9453 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
9454 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
9455 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
9456 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
9457 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
9458 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
9459 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
9460 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
9461 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
9464 if (isModEnabled(
'recruitment') && (!is_object(
$object) ||
$object->element ==
'recruitmentcandidature') && (empty($exclude) || !in_array(
'recruitment', $exclude)) && (empty($include) || in_array(
'recruitment', $include))) {
9465 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
9466 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
9467 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
9469 if (isModEnabled(
'project') && (empty($exclude) || !in_array(
'project', $exclude)) && (empty($include) || in_array(
'project', $include))) {
9470 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
9471 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
9472 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
9476 if (isModEnabled(
'contract') && (!is_object(
$object) ||
$object->element ==
'contract') && (empty($exclude) || !in_array(
'contract', $exclude)) && (empty($include) || in_array(
'contract', $include))) {
9477 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
9478 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
9479 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
9480 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
9482 if (isModEnabled(
"propal") && (!is_object(
$object) ||
$object->element ==
'propal') && (empty($exclude) || !in_array(
'propal', $exclude)) && (empty($include) || in_array(
'propal', $include))) {
9483 $substitutionarray[
'__ONLINE_SIGN_URL__'] =
'ToOfferALinkForOnlineSignature';
9485 if (isModEnabled(
"intervention") && (!is_object(
$object) ||
$object->element ==
'fichinter') && (empty($exclude) || !in_array(
'intervention', $exclude)) && (empty($include) || in_array(
'intervention', $include))) {
9486 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] =
'ToOfferALinkForOnlineSignature';
9488 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
9489 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
9490 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
9491 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
9492 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
9493 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
9494 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
9496 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
9497 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
9498 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
9499 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
9500 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
9502 if (isModEnabled(
"shipping") && (!is_object(
$object) ||
$object->element ==
'shipping')) {
9503 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
9504 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
9505 $substitutionarray[
'__SHIPPINGMETHOD__'] =
'Shipping method';
9507 if (isModEnabled(
"reception") && (!is_object(
$object) ||
$object->element ==
'reception')) {
9508 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shipping tracking number of shipment';
9509 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
9512 '@phan-var-force Adherent|Delivery $object';
9514 $substitutionarray[
'__ID__'] =
$object->id;
9515 $substitutionarray[
'__REF__'] =
$object->ref;
9516 $substitutionarray[
'__NEWREF__'] =
$object->newref;
9518 $substitutionarray[
'__REF_CLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
9519 $substitutionarray[
'__REF_SUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
9520 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset(
$object->note_public) ?
$object->note_public :
null);
9521 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset(
$object->note_private) ?
$object->note_private :
null);
9523 $substitutionarray[
'__DATE_CREATION__'] = (isset(
$object->date_creation) ?
dol_print_date(
$object->date_creation,
'day',
false, $outputlangs) :
'');
9524 $substitutionarray[
'__DATE_MODIFICATION__'] = (isset(
$object->date_modification) ?
dol_print_date(
$object->date_modification,
'day',
false, $outputlangs) :
'');
9525 $substitutionarray[
'__DATE_VALIDATION__'] = (isset(
$object->date_validation) ?
dol_print_date(
$object->date_validation,
'day',
false, $outputlangs) :
'');
9528 $date_delivery =
null;
9529 if (property_exists(
$object,
'date_delivery')) {
9530 $date_delivery =
$object->date_delivery;
9531 } elseif (property_exists(
$object,
'delivery_date')) {
9532 $date_delivery =
$object->delivery_date;
9534 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day',
false, $outputlangs) :
'');
9535 $substitutionarray[
'__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%d") :
'');
9536 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%A") :
'');
9537 $substitutionarray[
'__DATE_DELIVERY_MON__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%m") :
'');
9538 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%b") :
'');
9539 $substitutionarray[
'__DATE_DELIVERY_YEAR__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%Y") :
'');
9540 $substitutionarray[
'__DATE_DELIVERY_HH__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%H") :
'');
9541 $substitutionarray[
'__DATE_DELIVERY_MM__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%M") :
'');
9542 $substitutionarray[
'__DATE_DELIVERY_SS__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%S") :
'');
9545 $substitutionarray[
'__REFCLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
9546 $substitutionarray[
'__REFSUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
9548 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day',
false, $outputlangs) :
'');
9549 $substitutionarray[
'__SUPPLIER_ORDER_DELAY_DELIVERY__'] = (isset(
$object->availability_code) ? ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) : $outputlangs->convToOutputCharset(isset(
$object->availability) ?
$object->availability :
'')) :
'');
9553 '@phan-var-force Adherent $object';
9557 $substitutionarray[
'__MEMBER_ID__'] = (isset(
$object->id) ?
$object->id :
'');
9558 if (method_exists(
$object,
'getCivilityLabel')) {
9559 $substitutionarray[
'__MEMBER_TITLE__'] =
$object->getCivilityLabel();
9561 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset(
$object->firstname) ?
$object->firstname :
'');
9562 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset(
$object->lastname) ?
$object->lastname :
'');
9563 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
9564 if (method_exists(
$object,
'getFullName')) {
9565 $substitutionarray[
'__MEMBER_FULLNAME__'] =
$object->getFullName($outputlangs);
9567 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset(
$object->societe) ?
$object->societe :
'');
9568 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset(
$object->address) ?
$object->address :
'');
9569 $substitutionarray[
'__MEMBER_ZIP__'] = (isset(
$object->zip) ?
$object->zip :
'');
9570 $substitutionarray[
'__MEMBER_TOWN__'] = (isset(
$object->town) ?
$object->town :
'');
9571 $substitutionarray[
'__MEMBER_STATE__'] = (isset(
$object->state) ?
$object->state :
'');
9572 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset(
$object->country) ?
$object->country :
'');
9573 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset(
$object->email) ?
$object->email :
'');
9574 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
9575 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset(
$object->photo) ?
$object->photo :
'');
9576 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset(
$object->login) ?
$object->login :
'');
9577 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset(
$object->pass) ?
$object->pass :
'');
9581 $substitutionarray[
'__MEMBER_TYPE__'] = (isset(
$object->type) ?
$object->type :
'');
9582 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->first_subscription_date,
'day');
9584 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->first_subscription_date,
'dayrfc');
9585 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'day') :
'');
9586 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START_RFC__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'dayrfc') :
'');
9587 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'day') :
'');
9588 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END_RFC__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'dayrfc') :
'');
9589 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->last_subscription_date,
'day');
9590 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->last_subscription_date,
'dayrfc');
9591 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date(
$object->last_subscription_date_start,
'day');
9592 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START_RFC__'] =
dol_print_date(
$object->last_subscription_date_start,
'dayrfc');
9593 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date(
$object->last_subscription_date_end,
'day');
9594 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END_RFC__'] =
dol_print_date(
$object->last_subscription_date_end,
'dayrfc');
9599 '@phan-var-force Societe $object';
9600 $substitutionarray[
'__THIRDPARTY_ID__'] =
$object->id ??
'';
9601 $substitutionarray[
'__THIRDPARTY_NAME__'] =
$object->name ??
'';
9602 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
$object->name_alias ??
'';
9603 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
$object->code_client ??
'';
9604 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
$object->code_fournisseur ??
'';
9605 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
$object->email ??
'';
9606 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(
$object->email ??
'');
9607 $substitutionarray[
'__THIRDPARTY_URL__'] =
$object->url ??
'';
9608 $substitutionarray[
'__THIRDPARTY_URL_URLENCODED__'] = urlencode(
$object->url ??
'');
9611 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
$object->address ??
'';
9612 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
$object->zip ??
'';
9613 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
$object->town ??
'';
9614 $substitutionarray[
'__THIRDPARTY_STATE__'] =
$object->state ??
'';
9615 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (
$object->country_id > 0 ?:
'');
9616 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] =
$object->country_code ??
'';
9617 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
$object->idprof1 ??
'';
9618 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
$object->idprof2 ??
'';
9619 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
$object->idprof3 ??
'';
9620 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
$object->idprof4 ??
'';
9621 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
$object->idprof5 ??
'';
9622 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
$object->idprof6 ??
'';
9623 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
$object->tva_intra ??
'';
9626 } elseif (is_object(
$object) && is_object(
$object->thirdparty)) {
9627 $substitutionarray[
'__THIRDPARTY_ID__'] =
$object->thirdparty->id ??
'';
9628 $substitutionarray[
'__THIRDPARTY_NAME__'] =
$object->thirdparty->name ??
'';
9629 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
$object->thirdparty->name_alias ??
'';
9630 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
$object->thirdparty->code_client ??
'';
9631 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
$object->thirdparty->code_fournisseur ??
'';
9632 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
$object->thirdparty->email ??
'';
9633 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(
$object->thirdparty->email ??
'');
9636 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
$object->thirdparty->address ??
'';
9637 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
$object->thirdparty->zip ??
'';
9638 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
$object->thirdparty->town ??
'';
9639 $substitutionarray[
'__THIRDPARTY_STATE__'] =
$object->thirdparty->state ??
'';
9640 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (
$object->thirdparty->country_id > 0 ?:
'');
9641 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] =
$object->thirdparty->country_code ??
'';
9642 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
$object->thirdparty->idprof1 ??
'';
9643 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
$object->thirdparty->idprof2 ??
'';
9644 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
$object->thirdparty->idprof3 ??
'';
9645 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
$object->thirdparty->idprof4 ??
'';
9646 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
$object->thirdparty->idprof5 ??
'';
9647 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
$object->thirdparty->idprof6 ??
'';
9648 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
$object->thirdparty->tva_intra ??
'';
9653 if (is_object(
$object) &&
$object->element ==
'recruitmentcandidature') {
9654 '@phan-var-force RecruitmentCandidature $object';
9656 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
$object->getFullName($outputlangs);
9657 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9658 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9660 if (is_object(
$object) &&
$object->element ==
'conferenceorboothattendee') {
9661 '@phan-var-force ConferenceOrBoothAttendee $object';
9663 $substitutionarray[
'__ATTENDEE_FULLNAME__'] =
$object->getFullName($outputlangs);
9664 $substitutionarray[
'__ATTENDEE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9665 $substitutionarray[
'__ATTENDEE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9669 '@phan-var-force Project $object';
9671 $substitutionarray[
'__PROJECT_ID__'] =
$object->id;
9672 $substitutionarray[
'__PROJECT_REF__'] =
$object->ref;
9673 $substitutionarray[
'__PROJECT_NAME__'] =
$object->title;
9674 } elseif (is_object(
$object)) {
9676 if (!empty(
$object->project)) {
9678 } elseif (!empty(
$object->projet)) {
9681 if (!is_null($project) && is_object($project)) {
9682 $substitutionarray[
'__PROJECT_ID__'] = $project->id;
9683 $substitutionarray[
'__PROJECT_REF__'] = $project->ref;
9684 $substitutionarray[
'__PROJECT_NAME__'] = $project->title;
9689 $project_id =
$object->fk_project;
9690 } elseif (!empty(
$object->fk_projet) &&
$object->fk_projet > 0) {
9691 $project_id =
$object->fk_project;
9693 if ($project_id > 0) {
9695 $substitutionarray[
'__PROJECT_ID__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9696 $substitutionarray[
'__PROJECT_REF__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9697 $substitutionarray[
'__PROJECT_NAME__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9703 '@phan-var-force Facture $object';
9705 $substitutionarray[
'__INVOICE_SITUATION_NUMBER__'] = isset(
$object->situation_counter) ?
$object->situation_counter :
'';
9708 '@phan-var-force Expedition $object';
9710 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
$object->tracking_number;
9711 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
$object->tracking_url;
9712 $substitutionarray[
'__SHIPPINGMETHOD__'] =
$object->shipping_method;
9715 '@phan-var-force Reception $object';
9717 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
$object->tracking_number;
9718 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
$object->tracking_url;
9722 '@phan-var-force Contrat $object';
9724 $dateplannedstart =
'';
9725 $datenextexpiration =
'';
9726 foreach (
$object->lines as $line) {
9727 if ($line->date_start > $dateplannedstart) {
9728 $dateplannedstart = $line->date_start;
9730 if ($line->statut == 4 && $line->date_end && (!$datenextexpiration || $line->date_end < $datenextexpiration)) {
9731 $datenextexpiration = $line->date_end;
9734 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'day');
9735 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE_RFC__'] =
dol_print_date($dateplannedstart,
'dayrfc');
9736 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
9738 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'day');
9739 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE_RFC__'] =
dol_print_date($datenextexpiration,
'dayrfc');
9740 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
9744 '@phan-var-force Ticket $object';
9746 $substitutionarray[
'__TICKET_TRACKID__'] =
$object->track_id;
9747 $substitutionarray[
'__TICKET_SUBJECT__'] =
$object->subject;
9748 $substitutionarray[
'__TICKET_TYPE__'] =
$object->type_code;
9749 $substitutionarray[
'__TICKET_SEVERITY__'] =
$object->severity_code;
9750 $substitutionarray[
'__TICKET_CATEGORY__'] =
$object->category_code;
9751 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
$object->category_code;
9752 $substitutionarray[
'__TICKET_MESSAGE__'] =
$object->message;
9753 $substitutionarray[
'__TICKET_PROGRESSION__'] =
$object->progress;
9754 $userstat =
new User($db);
9755 if (
$object->fk_user_assign > 0) {
9756 $userstat->fetch(
$object->fk_user_assign);
9757 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9760 if (
$object->fk_user_create > 0) {
9761 $userstat->fetch(
$object->fk_user_create);
9762 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9768 if (!is_object($extrafields)) {
9771 $extrafields->fetch_name_optionals_label(
$object->table_element,
true);
9773 if (
$object->fetch_optionals() > 0) {
9774 if (is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label']) > 0) {
9775 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
9776 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'date') {
9777 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day');
9778 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
9779 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'dayrfc');
9780 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'datetime') {
9781 $datetime =
$object->array_options[
'options_'.$key];
9782 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
9783 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
9784 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
9785 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
9786 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'phone') {
9787 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone(
$object->array_options[
'options_'.$key]);
9788 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'price') {
9789 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
$object->array_options[
'options_'.$key];
9790 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price(
$object->array_options[
'options_'.$key]);
9791 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATTED__'] =
price(
$object->array_options[
'options_'.$key]);
9792 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separator') {
9793 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = !empty(
$object->array_options[
'options_'.$key]) ?
$object->array_options[
'options_'.$key] :
'';
9801 if (empty($substitutionarray[
'__REF__'])) {
9805 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
9806 $outputlangs->loadLangs(array(
'paypal',
'other'));
9809 $typeforonlinepayment =
'free';
9811 $typeforonlinepayment =
'order';
9814 $typeforonlinepayment =
'invoice';
9817 $typeforonlinepayment =
'member';
9818 if (!empty(
$object->last_subscription_amount)) {
9819 $amounttouse =
$object->last_subscription_amount;
9823 $typeforonlinepayment =
'contract';
9826 $typeforonlinepayment =
'ficheinter';
9829 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__'], $amounttouse);
9834 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ? str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
9835 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
9839 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
9844 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9846 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
9849 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
$object->getLastMainDocLink(
$object->element);
9851 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
9854 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
$object->getLastMainDocLink(
$object->element);
9856 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
9859 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
$object->getLastMainDocLink(
$object->element);
9861 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
9864 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
$object->getLastMainDocLink(
$object->element);
9866 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
'';
9869 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9871 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
9875 '@phan-var-force Propal $object';
9877 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".
$object->id;
9878 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9879 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal',
$object->ref, 1,
$object);
9882 '@phan-var-force Commande $object';
9884 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".
$object->id;
9887 '@phan-var-force Facture $object';
9889 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".
$object->id;
9892 '@phan-var-force Contrat $object';
9894 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".
$object->id;
9895 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9896 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'contract',
$object->ref, 1,
$object);
9899 '@phan-var-force Fichinter $object';
9901 $substitutionarray[
'__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT.
"/fichinter/card.php?id=".
$object->id;
9902 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9903 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0,
'fichinter',
$object->ref, 1,
$object);
9905 if (is_object(
$object) &&
$object->element ==
'supplier_proposal') {
9906 '@phan-var-force SupplierProposal $object';
9908 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".
$object->id;
9910 if (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
9911 '@phan-var-force FactureFournisseur $object';
9913 $substitutionarray[
'__URL_SUPPLIER_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/fourn/facture/card.php?id=".
$object->id;
9916 '@phan-var-force Expedition $object';
9918 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".
$object->id;
9923 '@phan-var-force ActionComm $object';
9925 $substitutionarray[
'__EVENT_LABEL__'] =
$object->label;
9926 $substitutionarray[
'__EVENT_TYPE__'] = $outputlangs->trans(
"Action".
$object->type_code);
9928 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date(
$object->datep,
'hour',
'auto', $outputlangs);
9932 if ((empty($exclude) || !in_array(
'objectamount', $exclude)) && (empty($include) || in_array(
'objectamount', $include))) {
9933 '@phan-var-force Facture|FactureRec $object';
9935 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
9938 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'day',
false, $outputlangs) : null) :
'';
9940 $substitutionarray[
'__DATE_DUE_YMD_TEXT__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'daytext',
false, $outputlangs) : null) :
'';
9942 $already_payed_all = 0;
9947 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object(
$object) ?
$object->total_ht :
'';
9951 $substitutionarray[
'__AMOUNT__'] = is_object(
$object) ?
$object->total_ttc :
'';
9955 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object(
$object) ?
price2num(
$object->total_ttc - $already_payed_all,
'MT') :
'';
9957 $substitutionarray[
'__AMOUNT_VAT__'] = is_object(
$object) ? (isset(
$object->total_vat) ?
$object->total_vat :
$object->total_tva) :
'';
9961 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9962 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object(
$object) ?
$object->total_localtax1 :
'';
9964 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9965 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object(
$object) ?
$object->total_localtax2 :
'';
9969 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'] = is_object(
$object) ? (
$object->total_ht ?
price(
$object->total_ht, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9970 $substitutionarray[
'__AMOUNT_FORMATTED__'] = is_object(
$object) ? (
$object->total_ttc ?
price(
$object->total_ttc, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9971 $substitutionarray[
'__AMOUNT_REMAIN_FORMATTED__'] = is_object(
$object) ? (
$object->total_ttc ?
price(
$object->total_ttc - $already_payed_all, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9972 $substitutionarray[
'__AMOUNT_VAT_FORMATTED__'] = is_object(
$object) ? (isset(
$object->total_vat) ?
price(
$object->total_vat, 0, $outputlangs, 0, -1, -1,
$conf->currency) : (
$object->total_tva ?
price(
$object->total_tva, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null)) :
'';
9973 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9974 $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax1 ?
price(
$object->total_localtax1, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9976 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9977 $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax2 ?
price(
$object->total_localtax2, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9980 if ($onlykey != 2) {
9981 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'];
9982 $substitutionarray[
'__AMOUNT_FORMATED__'] = $substitutionarray[
'__AMOUNT_FORMATTED__'];
9983 $substitutionarray[
'__AMOUNT_REMAIN_FORMATED__'] = $substitutionarray[
'__AMOUNT_REMAIN_FORMATTED__'];
9984 $substitutionarray[
'__AMOUNT_VAT_FORMATED__'] = $substitutionarray[
'__AMOUNT_VAT_FORMATTED__'];
9985 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(1)) {
9986 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'];
9988 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(2)) {
9989 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'];
9993 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
$object->multicurrency_total_ttc :
'';
9994 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
9995 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
$object->multicurrency_code,
true) :
'';
9996 $substitutionarray[
'__MULTICURRENCY_CODE__'] = (is_object(
$object) && isset(
$object->multicurrency_code)) ?
$object->multicurrency_code :
'';
10000 if ($onlykey != 2) {
10001 $substitutionarray[
'__TOTAL_TTC__'] = is_object(
$object) ?
$object->total_ttc :
'';
10002 $substitutionarray[
'__TOTAL_HT__'] = is_object(
$object) ?
$object->total_ht :
'';
10003 $substitutionarray[
'__TOTAL_VAT__'] = is_object(
$object) ? (isset(
$object->total_vat) ?
$object->total_vat :
$object->total_tva) :
'';
10008 if ((empty($exclude) || !in_array(
'date', $exclude)) && (empty($include) || in_array(
'date', $include))) {
10009 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
10019 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
10021 $substitutionarray = array_merge($substitutionarray, array(
10022 '__NOW_TMS__' => (
string) $now,
10023 '__NOW_TMS_YMD__' =>
dol_print_date($now,
'day',
'auto', $outputlangs),
10024 '__DAY__' => (
string) $tmp[
'mday'],
10025 '__DAY_TEXT__' => $daytext,
10026 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
10027 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
10028 '__MONTH__' => (
string) $tmp[
'mon'],
10029 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
10030 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
10031 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
10032 '__YEAR__' => (
string) $tmp[
'year'],
10033 '__YEAR_PREVIOUS_MONTH__' => (
string) $tmp3[
'year'],
10034 '__YEAR_NEXT_MONTH__' => (
string) $tmp5[
'year'],
10035 '__PREVIOUS_DAY__' => (
string) $tmp2[
'day'],
10036 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
10037 '__PREVIOUS_MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp3[
'month'])),
10038 '__PREVIOUS_MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp3[
'month'])),
10039 '__PREVIOUS_MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp3[
'month'])),
10040 '__PREVIOUS_YEAR__' => (
string) ($tmp[
'year'] - 1),
10041 '__NEXT_DAY__' => (
string) $tmp4[
'day'],
10042 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
10043 '__NEXT_MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp5[
'month'])),
10044 '__NEXT_MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp5[
'month'])),
10045 '__NEXT_MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp5[
'month'])),
10046 '__NEXT_YEAR__' => (
string) ($tmp[
'year'] + 1),
10050 if (isModEnabled(
'multicompany')) {
10051 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' =>
$conf->entity));
10053 if ((empty($exclude) || !in_array(
'system', $exclude)) && (empty($include) || in_array(
'user', $include))) {
10054 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
10055 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
10056 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
10057 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
10062 return $substitutionarray;
10081function make_substitutions($text, $substitutionarray, $outputlangs =
null, $converttextinhtmlifnecessary = 0)
10083 global
$conf, $db, $langs;
10085 if (!is_array($substitutionarray)) {
10086 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
10089 if (empty($outputlangs)) {
10090 $outputlangs = $langs;
10100 if (is_object($outputlangs)) {
10102 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
10104 $tmp = explode(
'|', $reg[1]);
10105 if (!empty($tmp[1])) {
10106 $outputlangs->load($tmp[1]);
10109 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
10111 if (empty($converttextinhtmlifnecessary)) {
10113 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
10115 if (! $msgishtml) {
10119 if ($valueishtml) {
10127 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
10135 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
10136 $keyfound = $reg[1];
10138 $value =
'*****forbidden*****';
10140 $value = empty(
$conf->global->$keyfound) ?
'' :
$conf->global->$keyfound;
10143 if (empty($converttextinhtmlifnecessary)) {
10145 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
10147 if (! $msgishtml) {
10150 if ($valueishtml) {
10158 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
10163 foreach ($substitutionarray as $key => $value) {
10164 if (!isset($value)) {
10168 if (($key ==
'__USER_SIGNATURE__' || $key ==
'__SENDEREMAIL_SIGNATURE__') && (
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN'))) {
10172 if (empty($converttextinhtmlifnecessary)) {
10173 $text = str_replace((
string) $key, (
string) $value, $text);
10175 if (! $msgishtml) {
10178 if ($valueishtml) {
10185 $text = str_replace((
string) $key, (
string) $value, $text);
10201 $memory_object_list = array();
10202 foreach ($substitutionarray as $key => $value) {
10203 $lazy_load_arr = array();
10204 if (preg_match(
'/(__[A-Z\_]+__)@lazyload$/', $key, $lazy_load_arr)) {
10205 if (isset($lazy_load_arr[1]) && !empty($lazy_load_arr[1])) {
10206 $key_to_substitute = $lazy_load_arr[1];
10207 if (preg_match(
'/' . preg_quote($key_to_substitute,
'/') .
'/', $text)) {
10208 $param_arr = explode(
':', (
string) $value);
10210 if (count($param_arr) == 4) {
10211 $path = $param_arr[0];
10212 $class = $param_arr[1];
10213 $method = $param_arr[2];
10214 $id = (int) $param_arr[3];
10217 if (!isset($memory_object_list[$class])) {
10219 require_once DOL_DOCUMENT_ROOT . $path;
10220 if (class_exists($class)) {
10221 $memory_object_list[$class] = array(
10229 if (isset($memory_object_list[$class]) && isset($memory_object_list[$class][
'list'])) {
10230 if (method_exists($class, $method)) {
10231 if (!isset($memory_object_list[$class][
'list'][
$id])) {
10232 $tmpobj =
new $class($db);
10234 $valuetouseforsubstitution = $tmpobj->$method(
$id, $key_to_substitute);
10235 $memory_object_list[$class][
'list'][
$id] = $tmpobj;
10238 $tmpobj = $memory_object_list[$class][
'list'][
$id];
10240 $valuetouseforsubstitution = $tmpobj->$method(
$id, $key_to_substitute,
true);
10243 $text = str_replace((
string) $key_to_substitute, (
string) $valuetouseforsubstitution, $text);
10269 global
$conf, $user;
10271 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
10276 $dirsubstitutions = array_merge(array(), (array)
$conf->modules_parts[
'substitutions']);
10278 foreach ($dirsubstitutions as $reldir) {
10286 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
10287 foreach ($substitfiles as $substitfile) {
10289 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
10292 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
10294 require_once $dir.$substitfile[
'name'];
10296 $function_name = $module.
"_".$callfunc;
10297 if (function_exists($function_name)) {
10298 $function_name($substitutionarray, $outputlangs,
$object, $parameters);
10306 foreach ($substitutionarray as $key => $value) {
10307 $tags .=
'{'.$key.
'} => '.$value.
"\n";
10309 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
10322function print_date_range($date_start, $date_end, $format =
'', $outputlangs =
null)
10324 print
get_date_range($date_start, $date_end, $format, $outputlangs);
10337function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
null, $withparenthesis = 1)
10343 if (!is_object($outputlangs)) {
10344 $outputlangs = $langs;
10347 if ($date_start && $date_end) {
10348 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
10350 if ($date_start && !$date_end) {
10351 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
10353 if (!$date_start && $date_end) {
10354 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
10374 if ($nameorder < 0) {
10377 if ($nameorder == 1) {
10378 $ret .= $firstname;
10379 if ($firstname && $lastname) {
10383 } elseif ($nameorder == 2 || $nameorder == 3) {
10384 $ret .= $firstname;
10385 if (empty($ret) && $nameorder == 3) {
10390 if (empty($ret) && $nameorder == 5) {
10391 $ret .= $firstname;
10393 if ($nameorder == 0) {
10394 if ($firstname && $lastname) {
10397 $ret .= $firstname;
10416function setEventMessage($mesgs, $style =
'mesgs', $noduplicate = 0, $attop = 0)
10419 if (!is_array($mesgs)) {
10420 $mesgs = trim((
string) $mesgs);
10423 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesgs, $_SESSION[
'dol_events'][$style])) {
10427 array_unshift($_SESSION[
'dol_events'][$style], $mesgs);
10429 $_SESSION[
'dol_events'][$style][] = $mesgs;
10434 foreach ($mesgs as $mesg) {
10435 $mesg = trim((
string) $mesg);
10437 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesg, $_SESSION[
'dol_events'][$style])) {
10441 array_unshift($_SESSION[
'dol_events'][$style], $mesgs);
10443 $_SESSION[
'dol_events'][$style][] = $mesg;
10463function setEventMessages($mesg, $mesgs, $style =
'mesgs', $messagekey =
'', $noduplicate = 0, $attop = 0)
10465 if (empty($mesg) && empty($mesgs)) {
10473 if (empty($messagekey) || empty($_COOKIE[
"DOLUSER_HIDEMESSAGE".$messagekey])) {
10474 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
10475 dol_print_error(
null,
'Bad parameter style='.$style.
' for setEventMessages');
10477 if (empty($mesgs)) {
10480 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
10501 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
10502 if (empty($disabledoutputofmessages)) {
10505 unset($_SESSION[
'dol_events'][
'mesgs']);
10508 if (isset($_SESSION[
'dol_events'][
'errors'])) {
10509 if (empty($disabledoutputofmessages)) {
10512 unset($_SESSION[
'dol_events'][
'errors']);
10516 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
10517 if (empty($disabledoutputofmessages)) {
10520 unset($_SESSION[
'dol_events'][
'warnings']);
10538function get_htmloutput_mesg($mesgstring =
'', $mesgarray = [], $style =
'ok', $keepembedded = 0)
10540 global
$conf, $langs;
10545 $divstart = $divend =
'';
10548 if ((empty(
$conf->use_javascript_ajax) ||
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
10549 $divstart =
'<div class="'.$style.
' clearboth">';
10550 $divend =
'</div>';
10553 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
10554 $langs->load(
"errors");
10556 if (is_array($mesgarray) && count($mesgarray)) {
10557 foreach ($mesgarray as $message) {
10559 $out .= $langs->trans($message);
10560 if ($ret < count($mesgarray)) {
10567 $out .= $langs->trans($mesgstring);
10573 if (!empty(
$conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && empty($keepembedded)) {
10574 $return =
'<script nonce="'.getNonce().
'">
10575 $(document).ready(function() {
10576 /* jnotify(message, preset of message type, keepmessage) */
10577 $.jnotify("'.
dol_escape_js($out).
'", "'.($style ==
"ok" ? 3000 : $style).
'", '.($style ==
"ok" ?
"false" :
"true").
',{ remove: function (){} } );
10617function dol_htmloutput_mesg($mesgstring =
'', $mesgarray = array(), $style =
'ok', $keepembedded = 0)
10619 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
10625 if (is_array($mesgarray)) {
10626 foreach ($mesgarray as $val) {
10627 if ($val && preg_match(
'/class="error"/i', $val)) {
10631 if ($val && preg_match(
'/class="warning"/i', $val)) {
10636 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
10638 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
10641 if ($style ==
'error') {
10644 if ($style ==
'warning') {
10648 if ($iserror || $iswarning) {
10650 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
10651 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
10652 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
10654 if (is_array($mesgarray)) {
10655 $newmesgarray = array();
10656 foreach ($mesgarray as $val) {
10657 if (is_string($val)) {
10658 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
10659 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
10660 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
10661 $newmesgarray[] = $tmpmesgstring;
10663 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
10666 $mesgarray = $newmesgarray;
10668 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
10710function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
10713 $order = strtolower($order);
10715 if (is_array($array)) {
10716 $sizearray = count($array);
10717 if ($sizearray > 0) {
10719 foreach (array_keys($array) as $key) {
10720 if (is_object($array[$key])) {
10721 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
10724 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
10726 if ($natsort == -1) {
10727 $temp[$key] =
'___'.$temp[$key];
10731 if (empty($natsort) || $natsort == -1) {
10732 if ($order ==
'asc') {
10738 if ($case_sensitive) {
10741 natcasesort($temp);
10743 if ($order !=
'asc') {
10744 $temp = array_reverse($temp,
true);
10750 foreach (array_keys($temp) as $key) {
10751 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
10770 $str = (string) $str;
10773 $strLength = strlen($str);
10774 for ($i = 0; $i < $strLength; $i++) {
10775 if (ord($str[$i]) < 0x80) {
10777 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
10779 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
10781 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
10783 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
10785 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
10790 for ($j = 0; $j < $n; $j++) {
10791 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
10812 return preg_match(
'//u', $str) ? true :
false;
10824 if (function_exists(
'mb_check_encoding')) {
10826 if (!mb_check_encoding($str,
'ASCII')) {
10830 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
10848 $tmp = ini_get(
"unicode.filesystem_encoding");
10849 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
10850 $tmp =
'iso-8859-1';
10859 if ($tmp ==
'iso-8859-1') {
10860 return mb_convert_encoding($str,
'ISO-8859-1',
'UTF-8');
10881function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'', $useCache =
true)
10891 if ($useCache && isset(
$conf->cache[
'codeid'][$tablename][$key][$fieldid])) {
10892 return $conf->cache[
'codeid'][$tablename][$key][$fieldid];
10895 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
10897 $sql =
"SELECT ".$fieldid.
" as valuetoget";
10898 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
10899 if ($fieldkey ==
'id' || $fieldkey ==
'rowid') {
10900 $sql .=
" WHERE ".$fieldkey.
" = ".((int) $key);
10902 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
10904 if (!empty($entityfilter)) {
10905 $sql .=
" AND entity IN (".getEntity($tablename).
")";
10911 $resql = $db->query($sql);
10913 $obj = $db->fetch_object($resql);
10916 $valuetoget = $obj->valuetoget;
10917 $conf->cache[
'codeid'][$tablename][$key][$fieldid] = $valuetoget;
10919 $conf->cache[
'codeid'][$tablename][$key][$fieldid] =
'';
10923 return $valuetoget;
10940 if ($matchrule == 1) {
10941 if ($var ==
'mainmenu') {
10943 return (preg_match(
'/^'.$regextext.
'/', $mainmenu));
10944 } elseif ($var ==
'leftmenu') {
10946 return (preg_match(
'/^'.$regextext.
'/', $leftmenu));
10948 return 'This variable is not accessible with dol_eval';
10951 return 'This value for matchrule is not implemented';
10965function verifCond($strToEvaluate, $onlysimplestring =
'1')
10969 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
10972 $rep =
dol_eval($strToEvaluate, 1, 1, $onlysimplestring);
10973 $rights = (bool) $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
10993function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring =
'1')
10995 if ($returnvalue != 1) {
10996 dol_syslog(
"Use of dol_eval with parameter returnvalue = 0 is now forbidden. Please fix this", LOG_ERR);
11019 $db, $langs, $user, $website, $websitepage,
11020 $action, $mainmenu, $leftmenu,
11029 defined(
'T_COALESCE_EQUAL') || define(
'T_COALESCE_EQUAL', PHP_INT_MAX);
11030 defined(
'T_FN') || define(
'T_FN', PHP_INT_MAX);
11033 defined(
'T_ATTRIBUTE') || define(
'T_ATTRIBUTE', PHP_INT_MAX);
11034 defined(
'T_MATCH') || define(
'T_MATCH', PHP_INT_MAX);
11035 defined(
'T_NAME_FULLY_QUALIFIED') || define(
'T_NAME_FULLY_QUALIFIED', PHP_INT_MAX);
11036 defined(
'T_NAME_QUALIFIED') || define(
'T_NAME_QUALIFIED', PHP_INT_MAX);
11037 defined(
'T_NAME_RELATIVE') || define(
'T_NAME_RELATIVE', PHP_INT_MAX);
11040 defined(
'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG') || define(
'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG', PHP_INT_MAX);
11041 defined(
'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG') || define(
'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG', PHP_INT_MAX);
11042 defined(
'T_ENUM') || define(
'T_ENUM', PHP_INT_MAX);
11043 defined(
'T_READONLY') || define(
'T_READONLY', PHP_INT_MAX);
11046 defined(
'T_PRIVATE_SET') || define(
'T_PRIVATE_SET', PHP_INT_MAX);
11047 defined(
'T_PROTECTED_SET') || define(
'T_PROTECTED_SET', PHP_INT_MAX);
11048 defined(
'T_PUBLIC_SET') || define(
'T_PUBLIC_SET', PHP_INT_MAX);
11050 $prohibited_token_ids = [
11056 'T_ABSTRACT',
'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG',
'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG',
'T_ATTRIBUTE',
11061 'T_CALLABLE',
'T_CATCH',
'T_CLASS',
'T_CLOSE_TAG',
'T_CONST',
11064 'T_DECLARE',
'T_DIR',
11067 'T_ECHO',
'T_ENDDECLARE',
'T_ENUM',
'T_EVAL',
'T_EXIT',
'T_EXTENDS',
11069 'T_FILE',
'T_FINAL',
'T_FINALLY',
'T_FN',
'T_FUNCTION',
'T_FUNC_C',
11070 'T_GLOBAL',
'T_GOTO',
11074 'T_IMPLEMENTS',
'T_INCLUDE',
'T_INCLUDE_ONCE',
'T_INSTEADOF',
'T_INTERFACE',
11084 'T_OPEN_TAG',
'T_OPEN_TAG_WITH_ECHO',
11086 'T_PRINT',
'T_PRIVATE',
'T_PROTECTED',
'T_PUBLIC',
11088 'T_READONLY',
'T_REQUIRE',
'T_REQUIRE_ONCE',
'T_RETURN',
11092 'T_THROW',
'T_TRAIT',
'T_TRAIT_C',
'T_TRY',
11093 'T_UNSET',
'T_UNSET_CAST',
'T_USE',
11106 $prohibited_variables = [
11107 '$_COOKIE',
'$_ENV',
'$_FILES',
'$GLOBALS',
'$_GET',
'$_POST',
'$_REQUEST',
'$_SERVER',
'$_SESSION',
11110 $prohibited_functions = [
11113 'override_function',
'session_id',
'session_create_id',
'session_regenerate_id',
11114 'call_user_func',
'call_user_func_array',
11115 'exec',
'passthru',
'shell_exec',
'system',
'proc_open',
'popen',
11116 'dol_eval',
'dol_eval_new',
'dol_eval_standard',
'dol_contctdesc',
'executeCLI',
'verifCond',
'GETPOST',
11117 'create_function',
'assert',
'mb_ereg_replace',
'mb_eregi_replace',
11118 'dol_compress_dir',
'dol_decode',
'dol_delete_file',
'dol_delete_dir',
'dol_delete_dir_recursive',
'dol_copy',
'archiveOrBackupFile',
11119 'fopen',
'file_put_contents',
'fputs',
'fputscsv',
'fwrite',
'fpassthru',
'mkdir',
'rmdir',
'symlink',
'touch',
'unlink',
'umask',
11120 'invoke',
'invokeArgs',
11121 'filter_input',
'filter_input_array',
'GETPOST',
11124 $prohibited_token_arrangements = [
11126 ' T_VARIABLE ( ',
' " ( ',
' \' ( ',
' T_CONSTANT_ENCAPSED_STRING ( ',
' ) ( ',
11129 $tokens = token_get_all(
"<?php return {$s};", TOKEN_PARSE);
11131 $tokens_arrangement =
' ';
11133 for ($i = 2,
$c = count($tokens) - 1; $i <
$c; ++$i) {
11134 if (is_array($tokens[$i])) {
11135 $token_id = $tokens[$i][0];
11136 $token_value = $tokens[$i][1];
11137 $token_name = token_name($tokens[$i][0]);
11139 $token_id = $tokens[$i];
11140 $token_value = $tokens[$i];
11141 $token_name = $tokens[$i];
11145 if (T_WHITESPACE === $token_id) {
11150 $tokens_arrangement .=
"{$token_name} ";
11153 if (T_VARIABLE === $token_id
11154 && in_array($token_value, $prohibited_variables,
true)
11156 return "« {$token_value} » is prohibited in « {$s} »";
11160 if (T_STRING === $token_id
11161 && in_array($token_value, $prohibited_functions,
true)
11163 return "« {$token_value} » is prohibited in « {$s} »";
11168 $maxi = count($prohibited_token_ids);
11169 for ($i = 0; $i < $maxi; ++$i) {
11170 if (
false !== strpos($tokens_arrangement,
" {$prohibited_token_ids[$i]} ")) {
11171 return "« {$prohibited_token_ids[$i]} » is prohibited in « {$s} »";
11176 $maxi = count($prohibited_token_arrangements);
11177 for ($i = 0; $i < $maxi; ++$i) {
11178 if (
false !== strpos($tokens_arrangement, $prohibited_token_arrangements[$i])) {
11179 return "« {$prohibited_token_arrangements[$i]} » is prohibited in « {$s} »";
11185 return @eval(
"return {$s};") ??
'';
11186 }
catch (Throwable $ex) {
11187 return "Exception during evaluation: ".$s.
" - ".$ex->getMessage();
11205function dol_eval_standard($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring =
'1')
11209 global $db, $langs, $user, $website, $websitepage;
11210 global $action, $mainmenu, $leftmenu;
11212 global $objectoffield;
11218 $isObBufferActive =
false;
11219 if (!in_array($onlysimplestring, array(
'0',
'1',
'2'))) {
11220 return "Bad call of dol_eval. Parameter onlysimplestring must be '0' (deprecated), '1' or '2'";
11222 if (!is_scalar($s)) {
11223 return "Bad call of dol_eval. First parameter must be a string, found ".var_export($s,
true);
11228 if ($onlysimplestring ==
'1' || $onlysimplestring ==
'2') {
11234 $specialcharsallowed =
'^$_+-.*>&|=!?():"\',/@';
11235 if ($onlysimplestring ==
'2') {
11236 $specialcharsallowed .=
'<[]';
11239 $specialcharsallowed .=
getDolGlobalString(
'MAIN_ALLOW_UNSECURED_SPECIAL_CHARS_IN_DOL_EVAL');
11241 if (preg_match(
'/[^a-z0-9\s'.preg_quote($specialcharsallowed,
'/').
']/i', $s)) {
11242 if ($returnvalue) {
11243 return 'Bad string syntax to evaluate (found chars that are not chars for a simple one line clean eval string): '.$s;
11245 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for a simple one line clean eval string): '.$s, LOG_WARNING);
11251 $tmps = str_replace(
' ? ',
'__XXX__', $s);
11252 if (strpos($tmps,
'?') !==
false) {
11253 if ($returnvalue) {
11254 return 'Bad string syntax to evaluate (The char ? can be used only with a space before and after): '.$s;
11256 dol_syslog(
'Bad string syntax to evaluate (The char ? can be used only with a space before and after): '.$s, LOG_WARNING);
11262 if (preg_match(
'/<=?[^\s]/', $s)) {
11263 if ($returnvalue) {
11264 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a < or <= without space before and after): '.$s;
11266 dol_syslog(
'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a < or <= without space before and after): '.$s, LOG_WARNING);
11272 if (preg_match(
'/\$[\w]*\s*\(/', $s)) {
11273 if ($returnvalue) {
11274 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a call using "$abc(" or "$abc (" instead of using the direct name of the function): '.$s;
11276 dol_syslog(
'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a call using "$abc(" or "$abc (" instead of using the direct name of the function): '.$s, LOG_WARNING);
11285 while ($scheck && $savescheck != $scheck) {
11286 $savescheck = $scheck;
11287 $scheck = preg_replace(
'/->[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
11288 $scheck = preg_replace(
'/::[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
11289 $scheck = preg_replace(
'/^\(+/',
'__PARENTHESIS__ ', $scheck);
11290 $scheck = preg_replace(
'/\&\&\s+\(/',
'__ANDPARENTHESIS__ ', $scheck);
11291 $scheck = preg_replace(
'/\|\|\s+\(/',
'__ORPARENTHESIS__ ', $scheck);
11292 $scheck = preg_replace(
'/^!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
11293 $scheck = preg_replace(
'/\s!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
11294 $scheck = preg_replace(
'/^!\(/',
'__NOTANDPARENTHESIS__', $scheck);
11295 $scheck = preg_replace(
'/\s!\(/',
' __NOTANDPARENTHESIS__', $scheck);
11296 $scheck = preg_replace(
'/(\^|\')\(/',
'__REGEXSTART__', $scheck);
11301 if (strpos($scheck,
'(') !==
false) {
11302 if ($returnvalue) {
11303 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found call of a function or method without using the direct name of the function): '.$s;
11305 dol_syslog(
'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found call of a function or method without using the direct name of the function): '.$s, LOG_WARNING);
11314 if ($s ===
'Array') {
11315 if ($returnvalue) {
11316 return 'Bad string syntax to evaluate (value is Array): '.var_export($s,
true);
11318 dol_syslog(
'Bad string syntax to evaluate (value is Array): '.var_export($s,
true), LOG_WARNING);
11323 if (!
getDolGlobalString(
'MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL') && strpos($s,
'::') !==
false) {
11324 if ($returnvalue) {
11325 return 'Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s;
11327 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s, LOG_WARNING);
11332 if (strpos($s,
'`') !==
false) {
11333 if ($returnvalue) {
11334 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
11336 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s, LOG_WARNING);
11343 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
11344 if ($returnvalue) {
11345 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
11347 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s, LOG_WARNING);
11354 $forbiddenphpstrings = array(
'$$',
'$_',
'}[',
')(');
11355 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_GLOBAL',
'_POST',
'_REQUEST',
'ReflectionFunction'));
11360 $forbiddenphpfunctions = array();
11361 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"override_function",
"session_id",
"session_create_id",
"session_regenerate_id"));
11362 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
11363 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func",
"call_user_func_array"));
11365 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"array_all",
"array_any",
"array_diff_ukey",
"array_filter",
"array_find",
"array_find_key",
"array_map",
"array_reduce",
"array_intersect_uassoc",
"array_intersect_ukey",
"array_walk",
"array_walk_recursive"));
11366 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"usort",
"uasort",
"uksort",
"preg_replace_callback",
"preg_replace_callback_array",
"header_register_callback"));
11367 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"error_log",
"set_error_handler",
"set_exception_handler",
"libxml_set_external_entity_loader",
"register_shutdown_function",
"register_tick_function",
"unregister_tick_function"));
11368 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"spl_autoload_register",
"spl_autoload_unregister",
"iterator_apply",
"session_set_save_handler"));
11369 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"forward_static_call",
"forward_static_call_array",
"register_postsend_function"));
11371 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"ob_start"));
11373 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"require",
"include",
"require_once",
"include_once"));
11374 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen"));
11375 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"dol_eval_new",
"dol_eval_standard",
"dol_concatdesc",
"executeCLI",
"verifCond",
"GETPOST",
"dolEncrypt",
"dolDecrypt"));
11376 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace"));
11377 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"readline_completion_function",
"readline_callback_handler_install"));
11378 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_compress_dir",
"dol_decode",
"dol_dir_list",
"dol_dir_list_in_database",
"dol_delete_file",
"dol_delete_dir",
"dol_delete_dir_recursive",
"dol_copy",
"archiveOrBackupFile"));
11379 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"chdir",
"dir",
"fopen",
"file",
"file_exists",
"file_get_contents",
"file_put_contents",
"fget",
"fgetc",
"fgetcsv",
"fputs",
"fputscsv",
"fpassthru",
"fscanf",
"fseek",
"fwrite",
"is_file",
"is_dir",
"is_link",
"mkdir",
"opendir",
"rmdir",
"scandir",
"symlink",
"touch",
"unlink",
"umask"));
11380 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"require",
"include"));
11383 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"base64".
"_".
"decode",
"rawurl".
"decode",
"url".
"decode",
"str".
"_rot13",
"hex".
"2bin"));
11384 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_concatdesc"));
11387 $forbiddenphpmethods = array(
'invoke',
'invokeArgs');
11389 $forbiddenphpregex =
'global\s*\$';
11390 $forbiddenphpregex .=
'|';
11391 $forbiddenphpregex .=
'\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
11393 $forbiddenphpmethodsregex =
'->('.implode(
'|', $forbiddenphpmethods).
')';
11396 $oldstringtoclean = $s;
11397 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
11398 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
11399 $s = preg_replace(
'/'.$forbiddenphpmethodsregex.
'/i',
'__forbiddenstring__', $s);
11401 }
while ($oldstringtoclean != $s);
11404 if (strpos($s,
'__forbiddenstring__') !==
false) {
11405 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
11406 if ($returnvalue) {
11407 return 'Bad string syntax to evaluate: '.$s;
11409 dol_syslog(
'Bad string syntax to evaluate: '.$s);
11415 if ($returnvalue) {
11417 $isObBufferActive =
true;
11418 $tmps = $hideerrors ? @eval(
'return ' . $s .
';') : eval(
'return ' . $s .
';');
11419 $tmpo = ob_get_clean();
11420 $isObBufferActive =
false;
11422 print
'Bad string syntax to evaluate. Some data were output when it should not when evaluating: ' . $s;
11426 dol_syslog(
'Do not use anymore dol_eval with param returnvalue=0', LOG_WARNING);
11434 }
catch (Error $e) {
11435 if ($isObBufferActive) {
11437 $tmpo = ob_get_clean();
11438 $isObBufferActive =
false;
11440 $error =
'dol_eval try/catch error : ';
11441 $error .= $e->getMessage();
11443 if ($returnvalue) {
11444 return 'Exception during evaluation: '.$s;
11460 return (trim($element) !=
'');
11473 if (empty($codelang)) {
11477 if ($codelang ==
'auto') {
11478 return '<span class="fa fa-language"></span>';
11481 $langtocountryflag = array(
11483 'ca_ES' =>
'catalonia',
11487 'sw_SW' =>
'unknown',
11497 if (isset($langtocountryflag[$codelang])) {
11498 $flagImage = $langtocountryflag[$codelang];
11500 $tmparray = explode(
'_', $codelang);
11501 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
11506 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
11507 $morecss = $reg[1];
11512 return '<span class="flag-sprite '.strtolower($flagImage).($morecss ?
' '.$morecss :
'').
'"'.($moreatt ?
' '.$moreatt :
'').(!$notitlealt ?
' title="'.$codelang.
'"' :
'').
'></span>';
11526 if (empty($countrycode)) {
11530 if (strtoupper($countrycode) ==
'MQ') {
11533 if (strtoupper($countrycode) ==
'SE') {
11536 if (strtoupper($countrycode) ==
'CH') {
11537 if ($mysoc->country_code ==
'FR') {
11540 if ($mysoc->country_code ==
'DE') {
11543 if ($mysoc->country_code ==
'IT') {
11725 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
11726 if (in_array($buildprimarykeytotest, $locales)) {
11727 return strtolower($countrycode).
'_'.strtoupper($countrycode);
11730 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
11731 foreach ($locales as $locale) {
11732 $locale_language = locale_get_primary_language($locale);
11733 $locale_region = locale_get_region($locale);
11734 if (strtoupper($countrycode) == $locale_region) {
11736 return strtolower($locale_language).
'_'.strtoupper($locale_region);
11740 dol_syslog(
"Warning Extension php-intl is not available", LOG_WARNING);
11778 global $hookmanager, $db;
11780 if (isset(
$conf->modules_parts[
'tabs'][$type]) && is_array(
$conf->modules_parts[
'tabs'][$type])) {
11781 foreach (
$conf->modules_parts[
'tabs'][$type] as $value) {
11782 $values = explode(
':', $value);
11785 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
11790 $posstart = strpos($str,
'(');
11791 if ($posstart > 0) {
11792 $posend = strpos($str,
')');
11793 if ($posstart > 0) {
11794 $res1 = substr($str, $posstart + 1, $posend - $posstart - 1);
11795 if (is_numeric($res1)) {
11796 $postab = (int) $res1;
11797 $values[1] =
'+' . substr($str, $posend + 1);
11801 if (count($values) == 6) {
11805 if ($values[0] != $type) {
11811 if ($filterorigmodule) {
11812 if (strpos($values[3],
'@')) {
11813 if ($filterorigmodule !=
'external') {
11817 if ($filterorigmodule !=
'core') {
11822 $langs->load($values[3]);
11824 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
11826 $substitutionarray = array();
11831 $labeltemp = explode(
',', $values[2]);
11832 $label = $langs->trans($labeltemp[0]);
11834 if (!empty($labeltemp[1]) && is_object(
$object) && !empty(
$object->id)) {
11836 $classtoload = $labeltemp[1];
11837 if (class_exists($classtoload)) {
11838 $obj =
new $classtoload($db);
11839 $function = $labeltemp[3];
11840 if ($obj && $function && method_exists($obj, $function)) {
11842 $nbrec = $obj->$function(
$object->id, $obj);
11843 if (!empty($nbrec)) {
11844 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
11852 $newtab[1] = $label;
11853 $newtab[2] = str_replace(
'+',
'', $values[1]);
11858 } elseif (count($values) == 5) {
11859 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
11861 if ($values[0] != $type) {
11865 if ($filterorigmodule) {
11866 if (strpos($values[3],
'@')) {
11867 if ($filterorigmodule !=
'external') {
11871 if ($filterorigmodule !=
'core') {
11876 $langs->load($values[3]);
11878 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
11879 $substitutionarray = array();
11883 $label = $langs->trans($values[2]);
11887 $newtab[1] = $label;
11888 $newtab[2] = str_replace(
'+',
'', $values[1]);
11892 $head = array_merge(array_slice($head, 0, $postab), array($newtab), array_slice($head, $postab));
11893 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
11894 if ($values[0] != $type) {
11897 $tabname = str_replace(
'-',
'', $values[1]);
11898 foreach ($head as $key => $val) {
11899 $condition = (!empty($values[3]) ?
verifCond($values[3],
'2') : 1);
11901 if ($head[$key][2] == $tabname && $condition) {
11902 unset($head[$key]);
11911 if (!empty($hookmanager)) {
11912 $parameters = array(
'object' =>
$object,
'mode' => $mode,
'head' => &$head,
'filterorigmodule' => $filterorigmodule);
11914 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters,
$object);
11915 if ($reshook > 0) {
11916 $head = $hookmanager->resArray;
11918 $head = array_merge($head, $hookmanager->resArray);
11937 global
$conf, $hookmanager, $user, $langs;
11940 global $micro_start_time;
11942 if ($zone ==
'private') {
11943 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
11945 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
11949 print
"\n<!-- A div to store page_y POST parameter -->\n";
11950 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
11952 $parameters = array();
11953 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
11954 if (empty($reshook)) {
11960 if (!empty(
$conf->use_javascript_ajax)) {
11961 print
"\n<!-- A script section to add menuhider handler on backoffice, manage focus and mandatory fields, tuning info, ... -->\n";
11962 print
'<script>'.
"\n";
11963 print
'jQuery(document).ready(function() {'.
"\n";
11965 if ($zone ==
'private' && empty(
$conf->dol_use_jmobile)) {
11967 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
11968 print
'jQuery("li.menuhider").click(function(event) {';
11969 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
11970 print
' console.log("We click on .menuhider");'.
"\n";
11971 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
11976 if ($action ==
'create' || $action ==
'add' || $action ==
'edit' || (empty($action) && (preg_match(
'/new\.php/', $_SERVER[
"PHP_SELF"]))) || ((empty($action) || $action ==
'addline') && (preg_match(
'/card\.php/', $_SERVER[
"PHP_SELF"])))) {
11977 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
11978 $relativepathstring = $_SERVER[
"PHP_SELF"];
11980 if (constant(
'DOL_URL_ROOT')) {
11981 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
11983 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
11984 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
11987 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
11988 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
11990 if ($defkey !=
'_noquery_') {
11991 $tmpqueryarraytohave = explode(
'&', $defkey);
11993 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
11994 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
11996 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
12000 if (!$foundintru) {
12009 print
'console.log("set the focus by executing jQuery(...).focus();")'.
"\n";
12010 foreach ($defval as $paramkey => $paramval) {
12012 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
12013 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // TODO KO with ckeditor
12014 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really useful, but we keep it in case of.
12019 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
12020 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
12022 if ($defkey != '_noquery_') {
12023 $tmpqueryarraytohave = explode('&', $defkey);
12025 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
12026 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
12027 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
12028 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
12032 if (!$foundintru) {
12035 //var_dump($defkey.'-'.$qualified);
12041 print 'console.log("set the js code to manage fields that are
set as mandatory
");'."\n
";
12043 foreach ($defval as $paramkey => $paramval) {
12044 // Solution 1: Add handler on submit to check if mandatory fields are empty
12045 print 'var form = $(\'[name="'.dol_escape_js($paramkey).'"]\').closest("form
");'."\n
";
12046 print "form.on(
'submit',
function(event) {
12047 var submitter = \$(
this).find(
':submit:focus').get(0);
12048 var buttonName = submitter ? \$(submitter).attr(
'name') :
'save';
12050 if (buttonName ==
'cancel') {
12051 console.log(
'We click on cancel button so we accept submit with no need to check mandatory fields');
12055 console.log(
'We did not click on cancel button but on something else, we check that field [name=".dol_escape_js($paramkey)."] is not empty');
12057 var tmpvalue = jQuery(
'[name=\"".dol_escape_js($paramkey)."\"]').val();
12058 let tmptypefield = jQuery(
'[name=\"".dol_escape_js($paramkey)."\"]').prop(
'nodeName').toLowerCase();
12060 if (tmptypefield ==
'textarea') {
12062 var tmpeditor = (typeof CKEDITOR !==
'undefined') ? CKEDITOR.instances[
'".dol_escape_js($paramkey)."'] : null;
12064 tmpvalue = tmpeditor.getData();
12065 console.log(
'For textarea tmpvalue is '+tmpvalue);
12069 let tmpvalueisempty =
false;
12070 if (tmpvalue ===
null || tmpvalue === undefined || tmpvalue ===
'' || tmpvalue === -1 || tmpvalue ===
'-1') {
12071 tmpvalueisempty =
true;
12073 if (tmpvalue ===
'0' && (tmptypefield ==
'select' || tmptypefield ==
'input')) {
12074 tmpvalueisempty =
true;
12076 if (tmpvalueisempty && buttonName !==
'cancel') {
12077 console.log(
'field has type '+tmptypefield+
' and is empty, we cancel the submit');
12078 event.preventDefault();
12079 event.stopPropagation();
12081 alert(
'".dol_escape_js($langs->transnoentitiesnoconv("ErrorFieldRequired", $paramkey).' (
'.$langs->transnoentitiesnoconv("CustomMandatoryFieldRule").')
')."');
12085 console.log(
'field has type '+tmptypefield+
' and is defined to '+tmpvalue);
12090 // Solution 2: Add property 'required' on input
12091 // so browser will check value and try to focus on it when submitting the form.
12092 //print 'setTimeout(function() {'; // If we want to wait that ckeditor beuatifier has finished its job.
12093 //print 'jQuery("input[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
12094 //print 'jQuery("textarea[
id=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
12095 //print 'jQuery("select[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";*/
12096 //print '// required on a select works only if key is "", so we add the required attributes but also we reset the key -1 or 0 to an empty string'."\n
";
12097 //print 'jQuery("select[
name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
12103 print
'jQuery(\':input[name="' .
dol_escape_js($paramkey) .
'"]\').closest("tr").find("td:first").addClass("fieldrequired");'.
"\n";
12107 print
'jQuery("input[name=\'cancel\']").click(function() {
12108 console.log("We click on cancel button so removed all required attribute");
12109 jQuery("input, textarea, select").each(function(){this.removeAttribute(\'required\');});
12119 if (!empty($_SERVER[
'MAIN_SHOW_TUNING_INFO']) ||
getDolGlobalString(
'MAIN_SHOW_TUNING_INFO')) {
12121 print
"/* JS CODE TO ENABLE to add memory info */\n";
12122 print
'window.console && console.log("';
12127 if (!empty($micro_start_time)) {
12128 $micro_end_time = microtime(
true);
12129 print
' - Build time: '.ceil(1000 * ($micro_end_time - $micro_start_time)).
' ms';
12132 if (function_exists(
"memory_get_usage")) {
12133 print
' - Mem: '.memory_get_usage();
12135 if (function_exists(
"memory_get_peak_usage")) {
12136 print
' - Real mem peak: '.memory_get_peak_usage(
true);
12138 if (function_exists(
"zend_loader_file_encoded")) {
12139 print
' - Zend encoded file: '.(zend_loader_file_encoded() ?
'yes' :
'no');
12144 print
"\n".
'</script>'.
"\n";
12150 foreach ($tmptagarray as $tmptag) {
12152 print
"<!-- JS CODE TO ENABLE for google analtics tag -->\n";
12154 <!-- Global site tag (gtag.js) - Google Analytics -->
12155 <script nonce="'.getNonce().
'" async src="https://www.googletagmanager.com/gtag/js?id='.trim($tmptag).
'"></script>
12157 window.dataLayer = window.dataLayer || [];
12158 function gtag(){dataLayer.push(arguments);}
12159 gtag(\'js\', new Date());
12161 gtag(\'config\', \''.trim($tmptag).
'\');
12168 // Add Xdebug coverage of code
12169 if (defined('XDEBUGCOVERAGE
')) {
12170 print_r(xdebug_get_code_coverage());
12173 // Add DebugBar data
12174 if ($user->hasRight('debugbar
', 'read
') && $debugbar instanceof DebugBar\DebugBar) {
12175 if (isset($debugbar['time
'])) {
12176 // @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
12177 $debugbar['time
']->stopMeasure('pageaftermaster
');
12179 print '<!-- Output debugbar data -->
'."\n";
12180 $renderer = $debugbar->getJavascriptRenderer();
12181 print $renderer->render();
12182 } elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
12184 print "<!-- Start of log output\n";
12185 //print '<div
class=
"hidden">
'."\n";
12186 foreach ($conf->logbuffer as $logline) {
12187 print $logline."<br>\n";
12189 //print '</div>
'."\n";
12190 print "End of log output -->\n";
12204function dolExplodeIntoArray($string, $delimiter = ';
', $kv = '=
')
12206 if (is_null($string)) {
12210 if (preg_match('/^\[.*\]$/sm
', $delimiter) || preg_match('/^\(.*\)$/sm
', $delimiter)) {
12211 // This is a regex string
12212 $newdelimiter = $delimiter;
12214 // This is a simple string
12215 // @phan-suppress-next-line PhanPluginSuspiciousParamPositionInternal
12216 $newdelimiter = preg_quote($delimiter, '/
');
12219 if ($a = preg_split('/
'.$newdelimiter.'/
', $string)) {
12221 foreach ($a as $s) { // each part
12223 if ($pos = strpos($s, $kv)) { // key/value delimiter
12224 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
12225 } else { // key delimiter not found
12243function dolExplodeKeepIfQuotes($input)
12245 // Use regexp to capture words and section in quotes
12246 $matches = array();
12247 preg_match_all('/
"([^"]*)
"|\'([^\']*)\'|(\S+)/', $input, $matches);
12249 // Merge result and delete empty values
12251 $result = array_map(
12258 static function ($a, $b, $c) {
12274 return array_values(array_filter(
12282 static function ($val) {
12283 return $val !== '';
12295function dol_set_focus($selector)
12297 print "\n
".'<!-- Set focus onto a specific field -->'."\n
";
12298 print '<script nonce="'.getNonce().'">jQuery(document).ready(function() { console.log("Force focus by
dol_set_focus"); jQuery("'.dol_escape_js($selector).'").focus(); });</script>'."\n
";
12309function dol_getmypid()
12311 if (!function_exists('getmypid')) {
12312 return mt_rand(99900000, 99965535);
12314 return getmypid(); // May be a number on 64 bits (depending on OS)
12339function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
12341 global $db, $langs;
12343 $value = trim($value);
12346 $value = preg_replace('/\*/', '%', $value); // Replace * with %
12349 $value = preg_replace('/([!<>=]+)\s+([0-9'.preg_quote($langs->trans("SeparatorDecimal
"), '/').'\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can then explode on space to get all tests to do
12352 $value = preg_replace('/\s*\|\s*/', '|', $value);
12354 // Split criteria on ' ' but not if we are inside quotes.
12355 // For mode 3, the split is done later on the , only and not on the ' '.
12356 if ($mode != -3 && $mode != 3) {
12357 $crits = dolExplodeKeepIfQuotes($value);
12359 $crits = array($value);
12363 if (!is_array($fields)) {
12364 $fields = array($fields);
12366 $i1 = 0; // count the nb of "and
" criteria added (all fields / criteria)
12367 foreach ($crits as $crit) { // Loop on each AND criteria
12368 $crit = trim($crit);
12369 $i2 = 0; // count the nb of valid criteria added for this this first criteria
12372 foreach ($fields as $field) {
12374 $tmpcrits = explode('|', $crit);
12375 $i3 = 0; // count the nb of valid criteria added for this current field
12376 foreach ($tmpcrits as $tmpcrit) {
12377 if ($tmpcrit !== '0' && empty($tmpcrit)) {
12380 $tmpcrit = trim($tmpcrit);
12382 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
12385 $newcrit = preg_replace('/([!<>=]+)/', '', $tmpcrit);
12388 preg_match('/([!<>=]+)/', $tmpcrit, $reg);
12389 if (!empty($reg[1])) {
12390 $operator = $reg[1];
12392 if ($newcrit != '') {
12393 $numnewcrit = price2num($newcrit);
12394 if (is_numeric($numnewcrit)) {
12395 $newres .= $db->sanitize($field).' '.$operator.' '.((float) $numnewcrit); // should be a numeric
12397 $newres .= '1 = 2'; // force false, we received a corrupted data
12399 $i3++; // a criteria was added to string
12402 $i2++; // a criteria for 1 more field was added to string
12403 } elseif ($mode == 2 || $mode == -2) {
12404 $crit = preg_replace('/[^\-0-9,]/', '', $crit); // ID are always integer
12405 $newres .= ($i2 > 0 ? ' OR ' : '').$db->sanitize($field)." ".($mode == -2 ? 'NOT ' : '');
12406 $newres .= $crit ? "IN (
".$db->sanitize($db->escape($crit)).")
" : "IN (0)
";
12408 $newres .= ' OR '.$db->sanitize($field).' IS NULL';
12410 $i2++; // a criteria for 1 more field was added to string
12411 } elseif ($mode == 3 || $mode == -3) {
12412 $tmparray = explode(',', $crit);
12413 if (count($tmparray)) {
12415 foreach ($tmparray as $val) {
12418 $listofcodes .= ($listofcodes ? ',' : '');
12419 $listofcodes .= "'".$db->escape($val)."'";
12422 $newres .= ($i2 > 0 ? ' OR ' : '').$db->sanitize($field)." ".($mode == -3 ? 'NOT ' : '')."IN (
".$db->sanitize($listofcodes, 1, 0, 1).")
";
12423 $i2++; // a criteria for 1 more field was added to string
12426 $newres .= ' OR '.$db->sanitize($field).' IS NULL';
12428 } elseif ($mode == 4) {
12429 $tmparray = explode(',', $crit);
12430 if (count($tmparray)) {
12432 foreach ($tmparray as $val) {
12435 $newres .= ($i2 > 0 ? " OR (
" : "(
").$db->sanitize($field)." LIKE
'".$db->escape($val).",%'";
12436 $newres .= ' OR '.$db->sanitize($field)." =
'".$db->escape($val)."'";
12437 $newres .= ' OR '.$db->sanitize($field)." LIKE
'%,".$db->escape($val)."'";
12438 $newres .= ' OR '.$db->sanitize($field)." LIKE
'%,".$db->escape($val).",%'";
12440 $i2++; // a criteria for 1 more field was added to string (we can add several criteria for the same field as it is a multiselect search criteria)
12444 } else { // $mode=0
12445 $tmpcrits = explode('|', $crit);
12446 $i3 = 0; // count the nb of valid criteria added for the current couple criteria/field
12447 foreach ($tmpcrits as $tmpcrit) { // loop on each OR criteria
12448 if ($tmpcrit !== '0' && empty($tmpcrit)) {
12451 $tmpcrit = trim($tmpcrit);
12453 if ($tmpcrit == '^$' || strpos($crit, '!') === 0) { // If we search empty, we must combined different OR fields with AND
12454 $newres .= (($i2 > 0 || $i3 > 0) ? ' AND ' : '');
12456 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
12459 if (preg_match('/\.(id|rowid)$/', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
12460 $newres .= $db->sanitize($field)." =
".(is_numeric($tmpcrit) ? ((float) $tmpcrit) : '0');
12462 $tmpcrit2 = $tmpcrit;
12467 if (preg_match('/^!/', $tmpcrit)) {
12468 $tmps .= $db->sanitize($field)." NOT LIKE
"; // ! as exclude character
12469 $tmpcrit2 = preg_replace('/^!/', '', $tmpcrit2);
12471 $tmps .= $db->sanitize($field)." LIKE
";
12475 if (preg_match('/^[\^\$]/
', $tmpcrit)) {
12477 $tmpcrit2 = preg_replace('/^[\^\$]/
', '', $tmpcrit2);
12479 if (preg_match('/[\^\$]$/
', $tmpcrit)) {
12481 $tmpcrit2 = preg_replace('/[\^\$]$/
', '', $tmpcrit2);
12484 if ($tmpcrit2 == '' || preg_match('/^!/
', $tmpcrit)) {
12488 $newres .= $tmpbefore;
12489 $newres .= $db->escape($tmpcrit2);
12490 $newres .= $tmpafter;
12492 if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) {
12493 $newres .= " OR
".$field." IS NULL)
";
12500 $i2++; // a criteria for 1 more field was added to string
12504 $res = $res.($res ? ' AND ' : '').($i2 > 1 ? '(' : '').$newres.($i2 > 1 ? ')' : '');
12508 $res = ($nofirstand ? "" : " AND
")."(
".$res.")
";
12519function showDirectDownloadLink($object)
12524 $url = $object->getLastMainDocLink($object->element);
12526 $out .= img_picto($langs->trans("PublicDownloadLinkDesc
"), 'globe').' <span class="opacitymedium
">'.$langs->trans("DirectDownloadLink
").'</span><br>';
12528 $out .= '<div class="urllink
"><input type="text
" id="directdownloadlink
" class="quatrevingtpercent
" value="'.$url.'"></div>';
12529 $out .= ajax_autoselect("directdownloadlink
", '');
12531 $out .= '<div class="urllink
">'.$langs->trans("FileNotShared
").'</div>';
12545function getImageFileNameForSize($file, $extName, $extImgTarget = '')
12547 $dirName = dirname($file);
12548 if ($dirName == '.') {
12552 if (!in_array($extName, array('', '_small', '_mini'))) {
12553 return 'Bad parameter extName';
12556 $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i', '', $file); // We remove image extension, whatever is its case
12557 $fileName = basename($fileName);
12559 if (empty($extImgTarget)) {
12560 $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
12562 if (empty($extImgTarget)) {
12563 $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
12565 if (empty($extImgTarget)) {
12566 $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
12568 if (empty($extImgTarget)) {
12569 $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
12571 if (empty($extImgTarget)) {
12572 $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
12574 if (empty($extImgTarget)) {
12575 $extImgTarget = (preg_match('/\.webp$/i', $file) ? '.webp' : '');
12578 if (!$extImgTarget) {
12584 $subdir = 'thumbs/';
12587 return ($dirName ? $dirName.'/' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
12600function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '')
12602 global $conf, $langs;
12604 if (empty($conf->use_javascript_ajax)) {
12608 $isAllowedForPreview = dolIsAllowedForPreview($relativepath);
12610 if ($alldata == 1) {
12611 if ($isAllowedForPreview) {
12612 return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart).'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''), 'mime' => dol_mimetype($relativepath));
12618 // old behavior, return a string
12619 if ($isAllowedForPreview) {
12620 $tmpurl = DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart).'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : '');
12621 $title = $langs->transnoentities("Preview
");
12622 //$title = '%27-alert(document.domain)-%27'; // An example of js injection into a corrupted title string, that should be blocked by the dol_escape_uri().
12623 //$tmpurl = 'file='.urlencode("'-alert(document.domain)-'_small.jpg
"); // An example of tmpurl that should be blocked by the dol_escape_uri()
12625 // We need to do a dol_escape_uri() on the full string after the javascript: because such parts are the URI and when we click on such links, a RFC3986 decode is done,
12626 // by the browser, converting the %27 (like when having param file=abc%27def), or when having a corrupted title), into a ', BEFORE interpreting the content that can be a js code.
12627 // Using the dol_escape_uri guarantee that we encode for URI so decode retrieve original expected value.
12628 return 'javascript:'.dol_escape_uri('document_preview(\''.dol_escape_js($tmpurl).'\', \''.dol_escape_js(dol_mimetype($relativepath)).'\', \''.dol_escape_js($title).'\')');
12640function getLabelSpecialCode($idcode)
12644 $arrayspecialines = array(1 => 'Transport', 2 => 'EcoTax', 3 => 'Option');
12645 if ($idcode > 10) {
12646 return 'Module ID '.$idcode;
12648 if (!empty($arrayspecialines[$idcode])) {
12649 return $langs->trans($arrayspecialines[$idcode]);
12662function ajax_autoselect($htmlname, $addlink = '', $textonlink = 'Link')
12665 $out = '<script nonce="
'.getNonce().'">
12666 jQuery(document).ready(function () {
12667 jQuery("'.((strpos($htmlname, '.
') === 0 ? '' : '#
').$htmlname).'").click(function() { jQuery(this).select(); } );
12671 if ($textonlink === 'image') {
12672 $out .= ' <a href="'.$addlink.'" target="_blank
" rel="noopener noreferrer
">'.img_picto('', 'globe').'</a>';
12674 $out .= ' <a href="'.$addlink.'" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("Link").'</a>';
12687function dolIsAllowedForPreview($file)
12689 // Check .noexe extension in filename
12690 if (preg_match('/\.noexe$/i', $file)) {
12694 // Check mime types
12695 $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'webp');
12696 if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES')) {
12697 $mime_preview[] = 'svg+xml';
12699 //$mime_preview[]='vnd.oasis.opendocument.presentation';
12700 //$mime_preview[]='archive';
12701 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
12702 if ($num_mime !== false) {
12706 // By default, not allowed for preview
12720function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
12723 $imgmime = 'other.png';
12724 $famime = 'file-o';
12727 $tmpfile = preg_replace('/\.noexe$/', '', $file);
12729 // Plain text files
12730 if (preg_match('/\.txt$/i', $tmpfile)) {
12731 $mime = 'text/plain';
12732 $imgmime = 'text.png';
12733 $famime = 'file-alt';
12734 } elseif (preg_match('/\.rtx$/i', $tmpfile)) {
12735 $mime = 'text/richtext';
12736 $imgmime = 'text.png';
12737 $famime = 'file-alt';
12738 } elseif (preg_match('/\.csv$/i', $tmpfile)) {
12739 $mime = 'text/csv';
12740 $imgmime = 'text.png';
12741 $famime = 'file-csv';
12742 } elseif (preg_match('/\.tsv$/i', $tmpfile)) {
12743 $mime = 'text/tab-separated-values';
12744 $imgmime = 'text.png';
12745 $famime = 'file-alt';
12746 } elseif (preg_match('/\.(cf|conf|log)$/i', $tmpfile)) {
12747 $mime = 'text/plain';
12748 $imgmime = 'text.png';
12749 $famime = 'file-alt';
12750 } elseif (preg_match('/\.ini$/i', $tmpfile)) {
12751 $mime = 'text/plain';
12752 $imgmime = 'text.png';
12754 $famime = 'file-alt';
12755 } elseif (preg_match('/\.md$/i', $tmpfile)) {
12756 $mime = 'text/plain';
12757 $imgmime = 'text.png';
12759 $famime = 'file-alt';
12760 } elseif (preg_match('/\.css$/i', $tmpfile)) {
12761 $mime = 'text/css';
12762 $imgmime = 'css.png';
12764 $famime = 'file-alt';
12765 } elseif (preg_match('/\.lang$/i', $tmpfile)) {
12766 $mime = 'text/plain';
12767 $imgmime = 'text.png';
12769 $famime = 'file-alt';
12770 } elseif (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { // Certificate files
12771 $mime = 'text/plain';
12772 $imgmime = 'text.png';
12773 $famime = 'file-alt';
12774 } elseif (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { // XML based (HTML/XML/XAML)
12775 $mime = 'text/html';
12776 $imgmime = 'html.png';
12778 $famime = 'file-alt';
12779 } elseif (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) {
12780 $mime = 'text/xml';
12781 $imgmime = 'other.png';
12783 $famime = 'file-alt';
12784 } elseif (preg_match('/\.xaml$/i', $tmpfile)) {
12785 $mime = 'text/xml';
12786 $imgmime = 'other.png';
12788 $famime = 'file-alt';
12789 } elseif (preg_match('/\.bas$/i', $tmpfile)) { // Languages
12790 $mime = 'text/plain';
12791 $imgmime = 'text.png';
12793 $famime = 'file-code';
12794 } elseif (preg_match('/\.(c)$/i', $tmpfile)) {
12795 $mime = 'text/plain';
12796 $imgmime = 'text.png';
12798 $famime = 'file-code';
12799 } elseif (preg_match('/\.(cpp)$/i', $tmpfile)) {
12800 $mime = 'text/plain';
12801 $imgmime = 'text.png';
12803 $famime = 'file-code';
12804 } elseif (preg_match('/\.cs$/i', $tmpfile)) {
12805 $mime = 'text/plain';
12806 $imgmime = 'text.png';
12808 $famime = 'file-code';
12809 } elseif (preg_match('/\.(h)$/i', $tmpfile)) {
12810 $mime = 'text/plain';
12811 $imgmime = 'text.png';
12813 $famime = 'file-code';
12814 } elseif (preg_match('/\.(java|jsp)$/i', $tmpfile)) {
12815 $mime = 'text/plain';
12816 $imgmime = 'text.png';
12818 $famime = 'file-code';
12819 } elseif (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) {
12820 $mime = 'text/plain';
12821 $imgmime = 'php.png';
12823 $famime = 'file-code';
12824 } elseif (preg_match('/\.phtml$/i', $tmpfile)) {
12825 $mime = 'text/plain';
12826 $imgmime = 'php.png';
12828 $famime = 'file-code';
12829 } elseif (preg_match('/\.(pl|pm)$/i', $tmpfile)) {
12830 $mime = 'text/plain';
12831 $imgmime = 'pl.png';
12833 $famime = 'file-code';
12834 } elseif (preg_match('/\.sql$/i', $tmpfile)) {
12835 $mime = 'text/plain';
12836 $imgmime = 'text.png';
12838 $famime = 'file-code';
12839 } elseif (preg_match('/\.js$/i', $tmpfile)) {
12840 $mime = 'text/x-javascript';
12841 $imgmime = 'jscript.png';
12843 $famime = 'file-code';
12844 } elseif (preg_match('/\.odp$/i', $tmpfile)) { // Open office
12845 $mime = 'application/vnd.oasis.opendocument.presentation';
12846 $imgmime = 'ooffice.png';
12847 $famime = 'file-powerpoint';
12848 } elseif (preg_match('/\.ods$/i', $tmpfile)) {
12849 $mime = 'application/vnd.oasis.opendocument.spreadsheet';
12850 $imgmime = 'ooffice.png';
12851 $famime = 'file-excel';
12852 } elseif (preg_match('/\.odt$/i', $tmpfile)) {
12853 $mime = 'application/vnd.oasis.opendocument.text';
12854 $imgmime = 'ooffice.png';
12855 $famime = 'file-word';
12856 } elseif (preg_match('/\.mdb$/i', $tmpfile)) { // MS Office
12857 $mime = 'application/msaccess';
12858 $imgmime = 'mdb.png';
12860 } elseif (preg_match('/\.doc[xm]?$/i', $tmpfile)) {
12861 $mime = 'application/msword';
12862 $imgmime = 'doc.png';
12863 $famime = 'file-word';
12864 } elseif (preg_match('/\.dot[xm]?$/i', $tmpfile)) {
12865 $mime = 'application/msword';
12866 $imgmime = 'doc.png';
12867 $famime = 'file-word';
12868 } elseif (preg_match('/\.xlt(x)?$/i', $tmpfile)) {
12869 $mime = 'application/vnd.ms-excel';
12870 $imgmime = 'xls.png';
12871 $famime = 'file-excel';
12872 } elseif (preg_match('/\.xla(m)?$/i', $tmpfile)) {
12873 $mime = 'application/vnd.ms-excel';
12874 $imgmime = 'xls.png';
12875 $famime = 'file-excel';
12876 } elseif (preg_match('/\.xls$/i', $tmpfile)) {
12877 $mime = 'application/vnd.ms-excel';
12878 $imgmime = 'xls.png';
12879 $famime = 'file-excel';
12880 } elseif (preg_match('/\.xls[bmx]$/i', $tmpfile)) {
12881 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
12882 $imgmime = 'xls.png';
12883 $famime = 'file-excel';
12884 } elseif (preg_match('/\.pps[mx]?$/i', $tmpfile)) {
12885 $mime = 'application/vnd.ms-powerpoint';
12886 $imgmime = 'ppt.png';
12887 $famime = 'file-powerpoint';
12888 } elseif (preg_match('/\.ppt[mx]?$/i', $tmpfile)) {
12889 $mime = 'application/x-mspowerpoint';
12890 $imgmime = 'ppt.png';
12891 $famime = 'file-powerpoint';
12892 } elseif (preg_match('/\.pdf$/i', $tmpfile)) { // Other
12893 $mime = 'application/pdf';
12894 $imgmime = 'pdf.png';
12895 $famime = 'file-pdf';
12896 } elseif (preg_match('/\.bat$/i', $tmpfile)) { // Scripts
12897 $mime = 'text/x-bat';
12898 $imgmime = 'script.png';
12900 $famime = 'file-code';
12901 } elseif (preg_match('/\.sh$/i', $tmpfile)) {
12902 $mime = 'text/x-sh';
12903 $imgmime = 'script.png';
12905 $famime = 'file-code';
12906 } elseif (preg_match('/\.ksh$/i', $tmpfile)) {
12907 $mime = 'text/x-ksh';
12908 $imgmime = 'script.png';
12910 $famime = 'file-code';
12911 } elseif (preg_match('/\.bash$/i', $tmpfile)) {
12912 $mime = 'text/x-bash';
12913 $imgmime = 'script.png';
12915 $famime = 'file-code';
12916 } elseif (preg_match('/\.ico$/i', $tmpfile)) { // Images
12917 $mime = 'image/x-icon';
12918 $imgmime = 'image.png';
12919 $famime = 'file-image';
12920 } elseif (preg_match('/\.(jpg|jpeg)$/i', $tmpfile)) {
12921 $mime = 'image/jpeg';
12922 $imgmime = 'image.png';
12923 $famime = 'file-image';
12924 } elseif (preg_match('/\.png$/i', $tmpfile)) {
12925 $mime = 'image/png';
12926 $imgmime = 'image.png';
12927 $famime = 'file-image';
12928 } elseif (preg_match('/\.gif$/i', $tmpfile)) {
12929 $mime = 'image/gif';
12930 $imgmime = 'image.png';
12931 $famime = 'file-image';
12932 } elseif (preg_match('/\.bmp$/i', $tmpfile)) {
12933 $mime = 'image/bmp';
12934 $imgmime = 'image.png';
12935 $famime = 'file-image';
12936 } elseif (preg_match('/\.(tif|tiff)$/i', $tmpfile)) {
12937 $mime = 'image/tiff';
12938 $imgmime = 'image.png';
12939 $famime = 'file-image';
12940 } elseif (preg_match('/\.svg$/i', $tmpfile)) {
12941 $mime = 'image/svg+xml';
12942 $imgmime = 'image.png';
12943 $famime = 'file-image';
12944 } elseif (preg_match('/\.webp$/i', $tmpfile)) {
12945 $mime = 'image/webp';
12946 $imgmime = 'image.png';
12947 $famime = 'file-image';
12948 } elseif (preg_match('/\.vcs$/i', $tmpfile)) { // Calendar
12949 $mime = 'text/calendar';
12950 $imgmime = 'other.png';
12951 $famime = 'file-alt';
12952 } elseif (preg_match('/\.ics$/i', $tmpfile)) {
12953 $mime = 'text/calendar';
12954 $imgmime = 'other.png';
12955 $famime = 'file-alt';
12956 } elseif (preg_match('/\.torrent$/i', $tmpfile)) { // Other
12957 $mime = 'application/x-bittorrent';
12958 $imgmime = 'other.png';
12959 $famime = 'file-o';
12960 } elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i', $tmpfile)) { // Audio
12962 $imgmime = 'audio.png';
12963 $famime = 'file-audio';
12964 } elseif (preg_match('/\.mp4$/i', $tmpfile)) { // Video
12965 $mime = 'video/mp4';
12966 $imgmime = 'video.png';
12967 $famime = 'file-video';
12968 } elseif (preg_match('/\.ogv$/i', $tmpfile)) {
12969 $mime = 'video/ogg';
12970 $imgmime = 'video.png';
12971 $famime = 'file-video';
12972 } elseif (preg_match('/\.webm$/i', $tmpfile)) {
12973 $mime = 'video/webm';
12974 $imgmime = 'video.png';
12975 $famime = 'file-video';
12976 } elseif (preg_match('/\.avi$/i', $tmpfile)) {
12977 $mime = 'video/x-msvideo';
12978 $imgmime = 'video.png';
12979 $famime = 'file-video';
12980 } elseif (preg_match('/\.divx$/i', $tmpfile)) {
12981 $mime = 'video/divx';
12982 $imgmime = 'video.png';
12983 $famime = 'file-video';
12984 } elseif (preg_match('/\.xvid$/i', $tmpfile)) {
12985 $mime = 'video/xvid';
12986 $imgmime = 'video.png';
12987 $famime = 'file-video';
12988 } elseif (preg_match('/\.(wmv|mpg|mpeg)$/i', $tmpfile)) {
12990 $imgmime = 'video.png';
12991 $famime = 'file-video';
12992 } elseif (preg_match('/\.(zip|rar|gz|tgz|xz|z|cab|bz2|7z|tar|lzh|zst)$/i', $tmpfile)) { // Archive
12993 // application/xxx where zzz is zip, ...
12995 $imgmime = 'archive.png';
12996 $famime = 'file-archive';
12997 } elseif (preg_match('/\.(exe|com)$/i', $tmpfile)) { // Exe
12998 $mime = 'application/octet-stream';
12999 $imgmime = 'other.png';
13000 $famime = 'file-o';
13001 } elseif (preg_match('/\.(dll|lib|o|so|a)$/i', $tmpfile)) { // Lib
13003 $imgmime = 'library.png';
13004 $famime = 'file-o';
13005 } elseif (preg_match('/\.err$/i', $tmpfile)) { // phpcs:ignore
13007 $imgmime = 'error.png';
13008 $famime = 'file-alt';
13011 if ($famime == 'file-o') {
13012 // file-o seems to not work in fontawesome 5
13016 // Return mimetype string
13017 switch ((int) $mode) {
13019 $tmp = explode('/', $mime);
13020 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
13042function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid')
13046 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename); // Clean name of table for backward compatibility.
13048 $dictvalues = (isset($conf->cache['dictvalues_'.$tablename]) ? $conf->cache['dictvalues_'.$tablename] : null);
13050 if (is_null($dictvalues)) {
13051 $dictvalues = array();
13053 $sql = "SELECT * FROM
".MAIN_DB_PREFIX.$tablename." WHERE 1 = 1
"; // Here select * is allowed as it is generic code and we don't have list of fields
13054 if ($checkentity) {
13055 $sql .= ' AND entity IN (0,'.getEntity($tablename).')';
13058 $resql = $db->query($sql);
13060 while ($obj = $db->fetch_object($resql)) {
13061 $dictvalues[$obj->$rowidfield] = $obj; // $obj is stdClass
13064 dol_print_error($db);
13067 $conf->cache['dictvalues_'.$tablename] = $dictvalues;
13070 if (!empty($dictvalues[$id])) {
13072 $tmp = $dictvalues[$id];
13073 return (property_exists($tmp, $field) ? $tmp->$field : '');
13086function colorIsLight($stringcolor)
13088 $stringcolor = str_replace('#', '', $stringcolor);
13090 if (!empty($stringcolor)) {
13092 $tmp = explode(',', $stringcolor);
13093 if (count($tmp) > 1) { // This is a comma RGB ('255','255','255')
13098 $hexr = $stringcolor[0].$stringcolor[1];
13099 $hexg = $stringcolor[2].$stringcolor[3];
13100 $hexb = $stringcolor[4].$stringcolor[5];
13101 $r = hexdec($hexr);
13102 $g = hexdec($hexg);
13103 $b = hexdec($hexb);
13105 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
13106 if ($bright > 0.6) {
13121function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
13125 //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
13126 //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
13127 if (empty($menuentry['enabled'])) {
13128 return 0; // Entry disabled by condition
13130 if ($type_user && array_key_exists('module', $menuentry) && $menuentry['module']) {
13131 $tmploops = explode('|', $menuentry['module']);
13133 foreach ($tmploops as $tmploop) {
13134 if (in_array($tmploop, $listofmodulesforexternal)) {
13140 return 0; // Entry is for menus all excluded to external users
13143 if (!$menuentry['perms'] && $type_user) {
13144 return 0; // No permissions and user is external
13146 if (!$menuentry['perms'] && getDolGlobalString('MAIN_MENU_HIDE_UNAUTHORIZED')) {
13147 return 0; // No permissions and option to hide when not allowed, even for internal user, is on
13149 if (!$menuentry['perms']) {
13150 return 2; // No permissions and user is external
13162function roundUpToNextMultiple($n, $x = 5)
13164 $result = (ceil($n) % $x === 0) ? ceil($n) : (round(($n + $x / 2) / $x) * $x);
13165 return (int) $result;
13179function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array())
13181 $csstouse = 'badge';
13182 $csstouse .= (!empty($mode) ? ' badge-'.$mode : '');
13183 $csstouse .= (!empty($type) ? ' badge-'.$type : '');
13184 $csstouse .= (empty($params['css']) ? '' : ' '.$params['css']);
13187 'class' => $csstouse
13190 if (empty($html)) {
13194 if (!empty($url)) {
13195 $attr['href'] = $url;
13198 if ($mode === 'dot') {
13199 $attr['class'] .= ' classfortooltip';
13200 $attr['title'] = $html;
13201 $attr['aria-label'] = $label;
13206 if (!empty($params['attr']) && is_array($params['attr'])) {
13207 foreach ($params['attr'] as $key => $value) {
13208 if ($key == 'class') {
13209 $attr['class'] .= ' '.$value;
13210 } elseif ($key == 'classOverride') {
13211 $attr['class'] = $value;
13213 $attr[$key] = $value;
13220 // escape all attribute
13221 $attr = array_map('dolPrintHTMLForAttribute', $attr);
13223 $TCompiledAttr = array();
13224 foreach ($attr as $key => $value) {
13225 $TCompiledAttr[] = $key.'="
'.$value.'"';
13228 $compiledAttributes = !empty($TCompiledAttr) ? implode(' ', $TCompiledAttr) : '';
13230 $tag = !empty($url) ? 'a' : 'span';
13232 return '<'.$tag.' '.$compiledAttributes.'>'.$html.'</'.$tag.'>';
13248function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array())
13253 $dolGetBadgeParams = array();
13255 if (!empty($params['badgeParams'])) {
13256 $dolGetBadgeParams = $params['badgeParams'];
13259 // TODO : add a hook
13260 if ($displayMode == 0) {
13261 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
13262 } elseif ($displayMode == 1) {
13263 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
13264 } elseif (getDolGlobalString('MAIN_STATUS_USES_IMAGES')) {
13265 // Use status with images (for backward compatibility)
13267 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ? '<span class="hideonsmartphone
">' : '').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ? '</span>' : '');
13268 $htmlLabelShort = (in_array($displayMode, array(1, 2, 5)) ? '<span class="hideonsmartphone
">' : '').(!empty($html) ? $html : (!empty($statusLabelShort) ? $statusLabelShort : $statusLabel)).(in_array($displayMode, array(1, 2, 5)) ? '</span>' : '');
13270 // For small screen, we always use the short label instead of long label.
13271 if (!empty($conf->dol_optimize_smallscreen)) {
13272 if ($displayMode == 0) {
13274 } elseif ($displayMode == 4) {
13276 } elseif ($displayMode == 6) {
13281 // For backward compatibility. Image's filename are still in French, so we use this array to convert
13282 $statusImg = array(
13283 'status0' => 'statut0',
13284 'status1' => 'statut1',
13285 'status2' => 'statut2',
13286 'status3' => 'statut3',
13287 'status4' => 'statut4',
13288 'status5' => 'statut5',
13289 'status6' => 'statut6',
13290 'status7' => 'statut7',
13291 'status8' => 'statut8',
13292 'status9' => 'statut9'
13295 if (!empty($statusImg[$statusType])) {
13296 $htmlImg = img_picto($statusLabel, $statusImg[$statusType]);
13298 $htmlImg = img_picto($statusLabel, $statusType);
13301 if ($displayMode === 2) {
13302 $return = $htmlImg.' '.$htmlLabelShort;
13303 } elseif ($displayMode === 3) {
13304 $return = $htmlImg;
13305 } elseif ($displayMode === 4) {
13306 $return = $htmlImg.' '.$htmlLabel;
13307 } elseif ($displayMode === 5) {
13308 $return = $htmlLabelShort.' '.$htmlImg;
13309 } else { // $displayMode >= 6
13310 $return = $htmlLabel.' '.$htmlImg;
13312 } elseif (!getDolGlobalString('MAIN_STATUS_USES_IMAGES') && !empty($displayMode)) {
13314 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
13316 $dolGetBadgeParams['attr']['class'] = 'badge-status';
13317 if (empty($dolGetBadgeParams['attr']['title'])) {
13318 $dolGetBadgeParams['attr']['title'] = empty($params['tooltip']) ? $statusLabel : ($params['tooltip'] != 'no' ? $params['tooltip'] : '');
13319 } else { // If a title was forced from $params['badgeParams']['attr']['title'], we set the class to get it as a tooltip.
13320 $dolGetBadgeParams['attr']['class'] .= ' classfortooltip';
13321 // And if we use tooltip, we can output title in HTML @phan-suppress-next-line PhanTypeInvalidDimOffset
13322 $dolGetBadgeParams['attr']['title'] = dol_htmlentitiesbr((string) $dolGetBadgeParams['attr']['title'], 1);
13325 if ($displayMode == 3) {
13326 $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), '', $statusType, 'dot', $url, $dolGetBadgeParams);
13327 } elseif ($displayMode === 5) {
13328 $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url, $dolGetBadgeParams);
13330 $return = dolGetBadge(((empty($conf->dol_optimize_smallscreen) && $displayMode != 2) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType, '', $url, $dolGetBadgeParams);
13373function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = '', $id = '', $userRight = 1, $params = array())
13375 global $hookmanager, $action, $object, $langs;
13377 // If $url is an array, we must build a dropdown button or recursively iterate over each value
13378 if (is_array($url)) {
13379 // Loop on $url array to remove entries of disabled modules
13380 foreach ($url as $key => $subbutton) {
13381 if (isset($subbutton['enabled']) && empty($subbutton['enabled'])) {
13388 if (array_key_exists('areDropdownButtons', $params) && $params["areDropdownButtons
"] === false) { // @phan-suppress-current-line PhanTypeInvalidDimOffset
13389 foreach ($url as $button) {
13390 if (!empty($button['lang'])) {
13391 $langs->load($button['lang']);
13393 $label = $langs->trans($button['label']);
13394 $text = $button['text'] ?? '';
13395 $actionType = $button['actionType'] ?? '';
13396 $tmpUrl = DOL_URL_ROOT.$button['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage']));
13397 $id = $button['id'] ?? '';
13398 $userRight = $button['perm'] ?? 1;
13399 $button['params'] = $button['params'] ?? []; // @phan-suppress-current-line PhanPluginDuplicateExpressionAssignmentOperation
13401 $out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $button['params']);
13406 if (count($url) > 1) {
13407 $out .= '<div class="dropdown
inline-block dropdown-holder
">';
13408 $out .= '<a style="margin-right: auto;
" class="dropdown-toggle classfortooltip butAction
'.($userRight ? '' : 'Refused
').'" title="'.dol_escape_htmltag($label).'" data-toggle="dropdown
">'.($text ? $text : $label).'</a>';
13409 $out .= '<div class="dropdown-content
">';
13410 foreach ($url as $subbutton) {
13411 if (!empty($subbutton['lang'])) {
13412 $langs->load($subbutton['lang']);
13415 if (!empty($subbutton['urlraw'])) {
13416 $tmpurl = $subbutton['urlraw']; // Use raw url, no url completion, use only what developer send
13418 $tmpurl = !empty($subbutton['urlroot']) ? $subbutton['urlroot'] : $subbutton['url'];
13419 $tmpurl = dolCompletUrlForDropdownButton($tmpurl, $params, empty($subbutton['urlroot']));
13422 $subbuttonparam = array();
13423 if (!empty($subbutton['attr'])) {
13424 $subbuttonparam['attr'] = $subbutton['attr'];
13426 $subbuttonparam['isDropDown'] = (empty($params['isDropDown']) ? ($subbutton['isDropDown'] ?? false) : $params['isDropDown']);
13428 $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, $subbutton['id'] ?? '', $subbutton['perm'], $subbuttonparam);
13433 foreach ($url as $subbutton) { // Should loop on 1 record only
13434 if (!empty($subbutton['lang'])) {
13435 $langs->load($subbutton['lang']);
13438 if (!empty($subbutton['urlraw'])) {
13439 $tmpurl = $subbutton['urlraw']; // Use raw url, no url completion, use only what developer send
13441 $tmpurl = !empty($subbutton['urlroot']) ? $subbutton['urlroot'] : $subbutton['url'];
13442 $tmpurl = dolCompletUrlForDropdownButton($tmpurl, $params, empty($subbutton['urlroot']));
13445 $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], $params);
13452 // Here, $url is a simple link
13454 if (!empty($params['isDropdown']) || !empty($params['isDropDown'])) { // Use the dropdown-item style (not for action button)
13455 $class = "dropdown-item
";
13457 $class = 'butAction';
13458 if ($actionType == 'danger' || $actionType == 'delete') {
13459 $class = 'butActionDelete';
13460 if (!empty($url) && strpos($url, 'token=') === false) {
13461 $url .= '&token='.newToken();
13467 'href' => empty($url) ? '' : $url,
13471 if (empty($text)) {
13473 $attr['title'] = ''; // if html not set, leave label on title is redundant
13475 $attr['title'] = $label;
13476 $attr['aria-label'] = $label;
13479 if (empty($userRight) || $userRight < 0) {
13480 $attr['class'] = 'butActionRefused';
13481 $attr['href'] = '';
13482 $attr['title'] = (($label && $text && $label != $text) ? $label : '');
13483 $attr['title'] = ($attr['title'] ? $attr['title'] . (empty($userRight) ? '<br>' : '') : '').(empty($userRight) ? $langs->trans('NotEnoughPermissions') : '');
13491 if (!empty($params['attr']) && is_array($params['attr'])) {
13492 foreach ($params['attr'] as $key => $value) {
13493 if ($key == 'class') {
13494 $attr['class'] .= ' '.$value;
13495 } elseif ($key == 'classOverride') {
13496 $attr['class'] = $value;
13498 $attr[$key] = $value;
13503 // automatic add tooltip when title is detected
13504 if (!empty($attr['title']) && !empty($attr['class']) && strpos($attr['class'], 'classfortooltip') === false) {
13505 $attr['class'] .= ' classfortooltip';
13508 // Js Confirm button
13509 if ($userRight && !empty($params['confirm'])) {
13510 if (!is_array($params['confirm'])) {
13511 $params['confirm'] = array();
13514 if (empty($params['confirm']['url'])) {
13515 $params['confirm']['url'] = $url . (strpos($url, '?') > 0 ? '&' : '?') . 'confirm=yes';
13518 // for js disabled compatibility set $url as call to confirm action and $params['confirm']['url'] to confirmed action
13519 $attr['data-confirm-url'] = $params['confirm']['url'];
13520 $attr['data-confirm-title'] = !empty($params['confirm']['title']) ? $params['confirm']['title'] : $langs->trans('ConfirmBtnCommonTitle', $label);
13521 $attr['data-confirm-content'] = !empty($params['confirm']['content']) ? $params['confirm']['content'] : $langs->trans('ConfirmBtnCommonContent', $label);
13522 $attr['data-confirm-content'] = preg_replace("/\r|\n/
", "", $attr['data-confirm-content']);
13523 $attr['data-confirm-action-btn-label'] = !empty($params['confirm']['action-btn-label']) ? $params['confirm']['action-btn-label'] : $langs->trans('Confirm');
13524 $attr['data-confirm-cancel-btn-label'] = !empty($params['confirm']['cancel-btn-label']) ? $params['confirm']['cancel-btn-label'] : $langs->trans('CloseDialog');
13525 $attr['data-confirm-modal'] = !empty($params['confirm']['modal']) ? $params['confirm']['modal'] : true;
13527 $attr['class'] .= ' butActionConfirm';
13530 if (isset($attr['href']) && empty($attr['href'])) {
13531 unset($attr['href']);
13534 $TCompiledAttr = array();
13535 foreach ($attr as $key => $value) {
13536 if (!empty($params['use_unsecured_unescapedattr']) && is_array($params['use_unsecured_unescapedattr']) && in_array($key, $params['use_unsecured_unescapedattr'])) {
13538 $value = dol_htmlentities($value, ENT_QUOTES | ENT_SUBSTITUTE);
13539 } elseif ($key == 'href') {
13540 $value = dolPrintHTMLForAttributeUrl($value);
13542 $value = dolPrintHTMLForAttribute($value);
13545 $TCompiledAttr[] = $key.'="'.$value.'"'; // $value has been escaped by the dolPrintHTMLForAttribute... just before
13548 $compiledAttributes = empty($TCompiledAttr) ? '' : implode(' ', $TCompiledAttr);
13550 $tag = !empty($attr['href']) ? 'a' : 'span';
13553 $parameters = array(
13554 'TCompiledAttr' => $TCompiledAttr, // array
13555 'compiledAttributes' => $compiledAttributes, // string
13560 'actionType' => $actionType,
13563 'userRight' => $userRight,
13564 'params' => $params
13567 $reshook = $hookmanager->executeHooks('dolGetButtonAction', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
13568 if ($reshook < 0) {
13569 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
13572 if (empty($reshook)) {
13573 if (dol_textishtml($text)) { // If content already HTML encoded
13574 return '<' . $tag . ' ' . $compiledAttributes . '><span class="textbutton
">' . $text . '</span></' . $tag . '>';
13576 return '<' . $tag . ' ' . $compiledAttributes . '><span class="textbutton
">' . dol_escape_htmltag($text) . '</span></' . $tag . '>';
13579 return $hookmanager->resPrint;
13592function dolCompletUrlForDropdownButton(string $url, array $params, bool $addDolUrlRoot = true)
13598 $parsedUrl = parse_url($url);
13599 if ((isset($parsedUrl['scheme']) && in_array($parsedUrl['scheme'], ['javascript', 'mailto', 'tel'])) || strpos($url, '#') === 0) {
13603 if (!empty($parsedUrl['query'])) {
13604 // Use parse_str() function to parse the string passed via URL
13605 parse_str($parsedUrl['query'], $urlQuery);
13606 if (!isset($urlQuery['backtopage']) && isset($params['backtopage'])) {
13607 $url .= '&backtopage='.urlencode($params['backtopage']);
13611 if (!isset($parsedUrl['scheme']) && $addDolUrlRoot) {
13612 $url = DOL_URL_ROOT.$url;
13625function dolGetButtonTitleSeparator($moreClass = "
")
13627 return '<span class="button-title-separator
'.$moreClass.'" ></span>';
13636function getFieldErrorIcon($fieldValidationErrorMsg)
13639 if (!empty($fieldValidationErrorMsg)) {
13640 $out .= '<span class="field-error-icon classfortooltip
" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).'" role="alert
" >'; // role alert is used for accessibility
13641 $out .= '<span class="fa fa-exclamation-circle
" aria-hidden="true" ></span>'; // For accessibility icon is separated and aria-hidden
13660function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $url = '', $id = '', $status = 1, $params = array())
13662 global $langs, $user;
13664 // Actually this conf is used in css too for external module compatibility and smooth transition to this function
13665 if (getDolGlobalString('MAIN_BUTTON_HIDE_UNAUTHORIZED') && (!$user->admin) && $status <= 0) {
13668 // Fix old picto fa-th-list to use fa-grid-vertical instead
13669 if ($iconClass == 'fa fa-th-list imgforviewmode') {
13670 $iconClass = ' fa fa-grip-horizontal imgforviewmode';
13673 $class = 'btnTitle';
13674 if (in_array($iconClass, array('fa fa-plus-circle', 'fa fa-plus-circle size15x', 'fa fa-comment-dots', 'fa fa-paper-plane'))) {
13675 $class .= ' btnTitlePlus';
13677 $useclassfortooltip = 1;
13679 if (!empty($params['morecss'])) {
13680 $class .= ' '.$params['morecss'];
13685 'href' => empty($url) ? '' : $url
13688 if (!empty($helpText)) {
13689 $attr['title'] = $helpText;
13690 } elseif ($label) { // empty($attr['title']) &&
13691 $attr['title'] = $label;
13692 $useclassfortooltip = 0;
13695 if ($status == 2) {
13696 $attr['class'] .= ' btnTitleSelected';
13697 } elseif ($status <= 0) {
13698 $attr['class'] .= ' refused';
13700 $attr['href'] = '';
13702 if ($status == -1) { // disable
13703 $attr['title'] = $langs->transnoentitiesnoconv("FeatureDisabled
");
13704 } elseif ($status == 0) { // Not enough permissions
13705 $attr['title'] = $langs->transnoentitiesnoconv("NotEnoughPermissions
");
13709 if (!empty($attr['title']) && $useclassfortooltip) {
13710 $attr['class'] .= ' classfortooltip';
13718 if (!empty($params['attr']) && is_array($params['attr'])) {
13719 foreach ($params['attr'] as $key => $value) {
13720 if ($key == 'class') {
13721 $attr['class'] .= ' '.$value;
13722 } elseif ($key == 'classOverride') {
13723 $attr['class'] = $value;
13725 $attr[$key] = $value;
13730 if (isset($attr['href']) && empty($attr['href'])) {
13731 unset($attr['href']);
13734 // TODO : add a hook
13736 // Generate attributes with escapement
13737 $TCompiledAttr = array();
13738 foreach ($attr as $key => $value) {
13739 $TCompiledAttr[] = $key.'="'.dol_escape_htmltag($value).'"'; // Do not use dolPrintHTMLForAttribute() here, we must accept "javascript:
string"
13742 $compiledAttributes = (empty($TCompiledAttr) ? '' : implode(' ', $TCompiledAttr));
13744 $tag = (empty($attr['href']) ? 'span' : 'a');
13746 $button = '<'.$tag.' '.$compiledAttributes.'>';
13747 $button .= '<span class="'.$iconClass.' valignmiddle btnTitle-icon
"></span>';
13748 if (!empty($params['forcenohideoftext'])) {
13749 $button .= '<span class="valignmiddle text-plus-circle btnTitle-label
'.(empty($params['forcenohideoftext
']) ? ' hideonsmartphone
' : '').'">'.$label.'</span>';
13751 $button .= '</'.$tag.'>';
13765function getElementProperties($elementType)
13767 global $conf, $db, $hookmanager;
13771 //$element_type='facture';
13773 $classfile = $classname = $classpath = $subdir = $dir_output = $dir_temp = $parent_element = '';
13775 // Parse element/subelement
13776 $module = $elementType;
13777 $element = $elementType;
13778 $subelement = $elementType;
13779 $table_element = $elementType;
13781 // If we ask a resource form external module (instead of default path)
13782 if (preg_match('/^([^@]+)@([^@]+)$/i', $elementType, $regs)) { // 'myobject@mymodule'
13783 $element = $subelement = $regs[1];
13784 $module = $regs[2];
13787 // If we ask a resource for a string with an element and a subelement
13788 // Example 'project_task'
13789 if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) { // 'myobject_mysubobject' with myobject=mymodule
13790 $module = $element = $regs[1];
13791 $subelement = $regs[2];
13794 // Object lines will use parent classpath and module ref
13795 if (substr($elementType, -3) == 'det') {
13796 $module = preg_replace('/det$/', '', $element);
13797 $subelement = preg_replace('/det$/', '', $subelement);
13798 $classpath = $module.'/class';
13799 $classfile = $module;
13800 $classname = preg_replace('/det$/', 'Line', $element);
13801 if (in_array($module, array('expedition', 'propale', 'facture', 'contrat', 'fichinter', 'commandefournisseur'))) {
13802 $classname = preg_replace('/det$/', 'Ligne', $element);
13805 // For compatibility and to work with non standard path
13806 if ($elementType == "action
" || $elementType == "actioncomm
") {
13807 $classpath = 'comm/action/class';
13808 $subelement = 'Actioncomm';
13809 $module = 'agenda';
13810 $table_element = 'actioncomm';
13811 } elseif ($elementType == 'cronjob') {
13812 $classpath = 'cron/class';
13814 $table_element = 'cron';
13815 } elseif ($elementType == 'adherent_type') {
13816 $classpath = 'adherents/class';
13817 $classfile = 'adherent_type';
13818 $module = 'adherent';
13819 $subelement = 'adherent_type';
13820 $classname = 'AdherentType';
13821 $table_element = 'adherent_type';
13822 } elseif ($elementType == 'bank_account') {
13823 $classpath = 'compta/bank/class';
13824 $module = 'bank'; // We need $conf->bank->dir_output and not $conf->banque->dir_output
13825 $classfile = 'account';
13826 $classname = 'Account';
13827 } elseif ($elementType == 'bank_line') {
13828 $classpath = 'compta/bank/class';
13829 $module = 'bank'; // We need $conf->bank->dir_output and not $conf->banque->dir_output
13830 $classfile = 'account';
13831 $classname = 'AccountLine';
13832 } elseif ($elementType == 'category') {
13833 $classpath = 'categories/class';
13834 $module = 'categorie';
13835 $subelement = 'categorie';
13836 $table_element = 'categorie';
13837 } elseif ($elementType == 'contact') {
13838 $classpath = 'contact/class';
13839 $classfile = 'contact';
13840 $module = 'societe';
13841 $subelement = 'contact';
13842 $table_element = 'socpeople';
13843 } elseif ($elementType == 'inventory') {
13844 $module = 'product';
13845 $classpath = 'product/inventory/class';
13846 } elseif ($elementType == 'inventoryline') {
13847 $module = 'product';
13848 $classpath = 'product/inventory/class';
13849 $table_element = 'inventorydet';
13850 $parent_element = 'inventory';
13851 } elseif ($elementType == 'stock' || $elementType == 'entrepot' || $elementType == 'warehouse') {
13853 $classpath = 'product/stock/class';
13854 $classfile = 'entrepot';
13855 $classname = 'Entrepot';
13856 $table_element = 'entrepot';
13857 } elseif ($elementType == 'project') {
13858 $classpath = 'projet/class';
13859 $module = 'projet';
13860 $table_element = 'projet';
13861 } elseif ($elementType == 'project_task') {
13862 $classpath = 'projet/class';
13863 $module = 'projet';
13864 $subelement = 'task';
13865 $table_element = 'projet_task';
13866 } elseif ($elementType == 'facture' || $elementType == 'invoice') {
13867 $classpath = 'compta/facture/class';
13868 $module = 'facture';
13869 $subelement = 'facture';
13870 $table_element = 'facture';
13871 } elseif ($elementType == 'facturedet') {
13872 $classpath = 'compta/facture/class';
13873 $classfile = 'facture';
13874 $classname = 'FactureLigne';
13875 $module = 'facture';
13876 $table_element = 'facturedet';
13877 $parent_element = 'facture';
13878 } elseif ($elementType == 'facturerec') {
13879 $classpath = 'compta/facture/class';
13880 $classfile = 'facture-rec';
13881 $module = 'facture';
13882 $classname = 'FactureRec';
13883 } elseif ($elementType == 'commande' || $elementType == 'order') {
13884 $classpath = 'commande/class';
13885 $module = 'commande';
13886 $subelement = 'commande';
13887 $table_element = 'commande';
13888 } elseif ($elementType == 'commandedet') {
13889 $classpath = 'commande/class';
13890 $classfile = 'commande';
13891 $classname = 'OrderLine';
13892 $module = 'commande';
13893 $table_element = 'commandedet';
13894 $parent_element = 'commande';
13895 } elseif ($elementType == 'propal') {
13896 $classpath = 'comm/propal/class';
13897 $table_element = 'propal';
13898 } elseif ($elementType == 'propaldet') {
13899 $classpath = 'comm/propal/class';
13900 $classfile = 'propal';
13901 $subelement = 'propaleligne';
13902 $module = 'propal';
13903 $table_element = 'propaldet';
13904 $parent_element = 'propal';
13905 } elseif ($elementType == 'shipping') {
13906 $classpath = 'expedition/class';
13907 $classfile = 'expedition';
13908 $classname = 'Expedition';
13909 $module = 'expedition';
13910 $table_element = 'expedition';
13911 } elseif ($elementType == 'expeditiondet' || $elementType == 'shippingdet') {
13912 $classpath = 'expedition/class';
13913 $classfile = 'expedition';
13914 $classname = 'ExpeditionLigne';
13915 $module = 'expedition';
13916 $table_element = 'expeditiondet';
13917 $parent_element = 'expedition';
13918 } elseif ($elementType == 'delivery_note') {
13919 $classpath = 'delivery/class';
13920 $subelement = 'delivery';
13921 $module = 'expedition';
13922 } elseif ($elementType == 'delivery') {
13923 $classpath = 'delivery/class';
13924 $subelement = 'delivery';
13925 $module = 'expedition';
13926 } elseif ($elementType == 'deliverydet') {
13928 } elseif ($elementType == 'supplier_proposal') {
13929 $classpath = 'supplier_proposal/class';
13930 $module = 'supplier_proposal';
13931 $element = 'supplierproposal';
13932 $classfile = 'supplier_proposal';
13933 $subelement = 'supplierproposal';
13934 } elseif ($elementType == 'supplier_proposaldet') {
13935 $classpath = 'supplier_proposal/class';
13936 $module = 'supplier_proposal';
13937 $classfile = 'supplier_proposal';
13938 $classname = 'SupplierProposalLine';
13939 $table_element = 'supplier_proposaldet';
13940 $parent_element = 'supplier_proposal';
13941 } elseif ($elementType == 'contract') {
13942 $classpath = 'contrat/class';
13943 $module = 'contrat';
13944 $subelement = 'contrat';
13945 $table_element = 'contract';
13946 } elseif ($elementType == 'contratdet') {
13947 $classpath = 'contrat/class';
13948 $module = 'contrat';
13949 $table_element = 'contratdet';
13950 $parent_element = 'contrat';
13951 } elseif ($elementType == 'mailing') {
13952 $classpath = 'comm/mailing/class';
13953 $module = 'mailing';
13954 $classfile = 'mailing';
13955 $classname = 'Mailing';
13957 } elseif ($elementType == 'member' || $elementType == 'adherent') {
13958 $classpath = 'adherents/class';
13959 $module = 'adherent';
13960 $subelement = 'adherent';
13961 $table_element = 'adherent';
13962 } elseif ($elementType == 'subscription') {
13963 $classpath = 'adherents/class';
13964 $classfile = 'subscription';
13965 $module = 'adherent';
13966 $subelement = 'subscription';
13967 $classname = 'Subscription';
13968 $table_element = 'subscription';
13969 } elseif ($elementType == 'usergroup') {
13970 $classpath = 'user/class';
13972 } elseif ($elementType == 'mo') {
13973 $classpath = 'mrp/class';
13978 $table_element = 'mrp_mo';
13979 } elseif ($elementType == 'mrp_production') {
13980 $classpath = 'mrp/class';
13982 $classname = 'MoLine';
13985 $table_element = 'mrp_production';
13986 $parent_element = 'mo';
13987 } elseif ($elementType == 'cabinetmed_cons') {
13988 $classpath = 'cabinetmed/class';
13989 $module = 'cabinetmed';
13990 $subelement = 'cabinetmedcons';
13991 $table_element = 'cabinetmedcons';
13992 } elseif ($elementType == 'fichinter') {
13993 $classpath = 'fichinter/class';
13994 $module = 'ficheinter';
13995 $subelement = 'fichinter';
13996 $table_element = 'fichinter';
13997 } elseif ($elementType == 'dolresource' || $elementType == 'resource') {
13998 $classpath = 'resource/class';
13999 $module = 'resource';
14000 $subelement = 'dolresource';
14001 $table_element = 'resource';
14002 } elseif ($elementType == 'opensurvey_sondage') {
14003 $classpath = 'opensurvey/class';
14004 $module = 'opensurvey';
14005 $subelement = 'opensurveysondage';
14006 } elseif ($elementType == 'order_supplier' || $elementType == 'supplier_order' ||$elementType == 'commande_fournisseur' || $elementType == 'commandefournisseur') {
14007 $classpath = 'fourn/class';
14008 $module = 'fournisseur';
14009 $classfile = 'fournisseur.commande';
14010 $element = 'order_supplier';
14012 $classname = 'CommandeFournisseur';
14013 $table_element = 'commande_fournisseur';
14014 } elseif ($elementType == 'commande_fournisseurdet') {
14015 $classpath = 'fourn/class';
14016 $module = 'fournisseur';
14017 $classfile = 'fournisseur.commande';
14018 $element = 'commande_fournisseurdet';
14020 $classname = 'CommandeFournisseurLigne';
14021 $table_element = 'commande_fournisseurdet';
14022 $parent_element = 'commande_fournisseur';
14023 } elseif ($elementType == 'invoice_supplier' || $elementType == 'supplier_invoice' || $elementType == 'facture_fourn') {
14024 $classpath = 'fourn/class';
14025 $module = 'fournisseur';
14026 $classfile = 'fournisseur.facture';
14027 $element = 'invoice_supplier';
14029 $classname = 'FactureFournisseur';
14030 $table_element = 'facture_fourn';
14031 } elseif ($elementType == 'facture_fourn_det') {
14032 $classpath = 'fourn/class';
14033 $module = 'fournisseur';
14034 $classfile = 'fournisseur.facture';
14035 $element = 'facture_fourn_det';
14037 $classname = 'SupplierInvoiceLine';
14038 $table_element = 'facture_fourn_det';
14039 $parent_element = 'invoice_supplier';
14040 } elseif ($elementType == "service
") {
14041 $classpath = 'product/class';
14042 $subelement = 'product';
14043 $table_element = 'product';
14044 } elseif ($elementType == 'salary') {
14045 $classpath = 'salaries/class';
14046 $module = 'salaries';
14047 } elseif ($elementType == 'payment_salary') {
14048 $classpath = 'salaries/class';
14049 $classfile = 'paymentsalary';
14050 $classname = 'PaymentSalary';
14051 $module = 'salaries';
14052 } elseif ($elementType == 'productlot') {
14053 $module = 'productbatch';
14054 $classpath = 'product/stock/class';
14055 $classfile = 'productlot';
14056 $classname = 'Productlot';
14057 $element = 'productlot';
14059 $table_element = 'product_lot';
14060 } elseif ($elementType == 'societeaccount') {
14061 $classpath = 'societe/class';
14062 $classfile = 'societeaccount';
14063 $classname = 'SocieteAccount';
14064 $module = 'societe';
14065 } elseif ($elementType == 'websitepage' || $elementType == 'website_page') {
14066 $classpath = 'website/class';
14067 $classfile = 'websitepage';
14068 $classname = 'Websitepage';
14069 $module = 'website';
14070 $subelement = 'websitepage';
14071 $table_element = 'website_page';
14072 } elseif ($elementType == 'fiscalyear') {
14073 $classpath = 'core/class';
14074 $module = 'accounting';
14075 $subelement = 'fiscalyear';
14076 } elseif ($elementType == 'chargesociales') {
14077 $classpath = 'compta/sociales/class';
14079 $table_element = 'chargesociales';
14080 } elseif ($elementType == 'tva') {
14081 $classpath = 'compta/tva/class';
14084 $table_element = 'tva';
14085 } elseif ($elementType == 'emailsenderprofile') {
14087 $classpath = 'core/class';
14088 $classfile = 'emailsenderprofile';
14089 $classname = 'EmailSenderProfile';
14090 $table_element = 'c_email_senderprofile';
14092 } elseif ($elementType == 'conferenceorboothattendee') {
14093 $classpath = 'eventorganization/class';
14094 $classfile = 'conferenceorboothattendee';
14095 $classname = 'ConferenceOrBoothAttendee';
14096 $module = 'eventorganization';
14097 } elseif ($elementType == 'conferenceorbooth') {
14098 $classpath = 'eventorganization/class';
14099 $classfile = 'conferenceorbooth';
14100 $classname = 'ConferenceOrBooth';
14101 $module = 'eventorganization';
14102 } elseif ($elementType == 'ccountry') {
14104 $classpath = 'core/class';
14105 $classfile = 'ccountry';
14106 $classname = 'Ccountry';
14107 $table_element = 'c_country';
14109 } elseif ($elementType == 'ecmfiles') {
14111 $classpath = 'ecm/class';
14112 $classfile = 'ecmfiles';
14113 $classname = 'Ecmfiles';
14114 $table_element = 'ecmfiles';
14116 } elseif ($elementType == 'knowledgerecord' || $elementType == 'knowledgemanagement') {
14117 $module = 'knowledgemanagement';
14118 $classpath = 'knowledgemanagement/class';
14119 $classfile = 'knowledgerecord';
14120 $classname = 'KnowledgeRecord';
14121 $table_element = 'knowledgemanagement_knowledgerecord';
14123 } elseif ($elementType == 'customer') {
14124 $module = 'societe';
14125 $classpath = 'societe/class';
14126 $classfile = 'client';
14127 $classname = 'Client';
14128 $table_element = 'societe';
14130 } elseif ($elementType == 'fournisseur' || $elementType == 'supplier') {
14131 $module = 'societe';
14132 $classpath = 'fourn/class';
14133 $classfile = 'fournisseur';
14134 $classname = 'Fournisseur';
14135 $table_element = 'societe';
14140 if (empty($classfile)) {
14141 $classfile = strtolower($subelement);
14143 if (empty($classname)) {
14144 $classname = ucfirst($subelement);
14146 if (empty($classpath)) {
14147 $classpath = $module.'/class';
14150 //print 'getElementProperties subdir='.$subdir;
14153 if ($module && isset($conf->$module)) { // The generic case
14154 if (!empty($conf->$module->multidir_output[$conf->entity])) {
14155 $dir_output = $conf->$module->multidir_output[$conf->entity];
14156 } elseif (!empty($conf->$module->output[$conf->entity])) {
14157 $dir_output = $conf->$module->output[$conf->entity];
14158 } elseif (!empty($conf->$module->dir_output)) {
14159 $dir_output = $conf->$module->dir_output;
14161 if (!empty($conf->$module->multidir_temp[$conf->entity])) {
14162 $dir_temp = $conf->$module->multidir_temp[$conf->entity];
14163 } elseif (!empty($conf->$module->temp[$conf->entity])) {
14164 $dir_temp = $conf->$module->temp[$conf->entity];
14165 } elseif (!empty($conf->$module->dir_temp)) {
14166 $dir_temp = $conf->$module->dir_temp;
14170 // Overwrite value for special cases
14171 if ($element == 'order_supplier' && isModEnabled('fournisseur')) {
14172 $dir_output = $conf->fournisseur->commande->dir_output;
14173 $dir_temp = $conf->fournisseur->commande->dir_temp;
14174 } elseif ($element == 'invoice_supplier' && isModEnabled('fournisseur')) {
14175 $dir_output = $conf->fournisseur->facture->dir_output;
14176 $dir_temp = $conf->fournisseur->facture->dir_temp;
14178 $dir_output .= $subdir;
14179 $dir_temp .= $subdir;
14181 $elementProperties = array(
14182 'module' => $module,
14183 'element' => $element,
14184 'table_element' => $table_element,
14185 'subelement' => $subelement,
14186 'classpath' => $classpath,
14187 'classfile' => $classfile,
14188 'classname' => $classname,
14189 'dir_output' => $dir_output,
14190 'dir_temp' => $dir_temp,
14191 'parent_element' => $parent_element,
14196 if (!is_object($hookmanager)) {
14197 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
14198 $hookmanager = new HookManager($db);
14200 $hookmanager->initHooks(array('elementproperties'));
14204 $parameters = array(
14205 'elementType' => $elementType,
14206 'elementProperties' => $elementProperties
14209 $reshook = $hookmanager->executeHooks('getElementProperties', $parameters);
14212 $elementProperties = $hookmanager->resArray;
14213 } elseif (!empty($hookmanager->resArray) && is_array($hookmanager->resArray)) { // resArray is always an array but for sécurity against misconfigured external modules
14214 $elementProperties = array_replace($elementProperties, $hookmanager->resArray);
14217 // context of elementproperties doesn't need to exist out of this function so delete it to avoid elementproperties context is equal to all
14218 if (($key = array_search('elementproperties', $hookmanager->contextarray)) !== false) {
14219 unset($hookmanager->contextarray[$key]);
14222 return $elementProperties;
14237function fetchObjectByElement($element_id, $element_type, $element_ref = '', $useCache = 0, $maxCacheByType = 10)
14243 $element_prop = getElementProperties($element_type);
14245 if ($element_prop['module'] == 'product' || $element_prop['module'] == 'service') {
14246 // For example, for an extrafield 'product' (shared for both product and service) that is a link to an object,
14247 // this is called with $element_type = 'product' when we need element properties of a service, we must return a product. If we create the
14248 // extrafield for a service, it is not supported and not found when editing the product/service card. So we must keep 'product' for extrafields
14249 // of service and we will return properties of a product.
14250 $ismodenabled = (isModEnabled('product') || isModEnabled('service'));
14251 } elseif ($element_prop['module'] == 'societeaccount') {
14252 $ismodenabled = isModEnabled('website') || isModEnabled('webportal');
14254 $ismodenabled = isModEnabled($element_prop['module']);
14256 //var_dump('element_type='.$element_type);
14257 //var_dump($element_prop);
14258 //var_dump($element_prop['module'].' '.$ismodenabled);
14259 if (is_array($element_prop) && (empty($element_prop['module']) || $ismodenabled)) {
14260 if ($useCache === 1 && $element_id > 0
14261 && !empty($conf->cache['fetchObjectByElement'][$element_type])
14262 && !empty($conf->cache['fetchObjectByElement'][$element_type][$element_id])
14263 && is_object($conf->cache['fetchObjectByElement'][$element_type][$element_id])
14265 return $conf->cache['fetchObjectByElement'][$element_type][$element_id];
14268 dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php');
14270 if (class_exists($element_prop['classname'])) {
14271 $className = $element_prop['classname'];
14272 $objecttmp = new $className($db);
14273 '@phan-var-force CommonObject $objecttmp';
14275 if ($element_id > 0 || !empty($element_ref)) {
14276 $ret = $objecttmp->fetch($element_id, $element_ref);
14278 if (empty($objecttmp->module)) {
14279 $objecttmp->module = $element_prop['module'];
14282 if ($useCache > 0) {
14283 if (!isset($conf->cache['fetchObjectByElement'][$element_type])) {
14284 $conf->cache['fetchObjectByElement'][$element_type] = [];
14287 // Manage cache limit
14288 if (! empty($conf->cache['fetchObjectByElement'][$element_type]) && is_array($conf->cache['fetchObjectByElement'][$element_type]) && count($conf->cache['fetchObjectByElement'][$element_type]) >= $maxCacheByType) {
14289 array_shift($conf->cache['fetchObjectByElement'][$element_type]);
14292 $conf->cache['fetchObjectByElement'][$element_type][$element_id] = $objecttmp;
14298 return $objecttmp; // returned an object without fetch
14301 dol_syslog($element_prop['classname'].' doesn\'t exists in /'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php');
14314function getExecutableContent()
14316 $arrayofregexextension = array(
14317 'htm', 'html', 'shtml', 'js', 'phar', 'php', 'php3', 'php4', 'php5', 'phtml', 'pht', 'pl', 'py', 'cgi', 'ksh', 'sh', 'shtml',
14318 'bash', 'bat', 'cmd', 'wpk', 'exe', 'dmg', 'appimage'
14321 return $arrayofregexextension;
14330function isAFileWithExecutableContent($filename)
14332 $arrayofregexextension = getExecutableContent();
14334 foreach ($arrayofregexextension as $fileextension) {
14335 if (preg_match('/\.'.preg_quote($fileextension, '/').'$/i', $filename)) {
14352 return empty($_SESSION['newtoken']) ? '' : $_SESSION['newtoken'];
14362function currentToken()
14364 return isset($_SESSION['token']) ? $_SESSION['token'] : '';
14376 if (empty($conf->cache['nonce'])) {
14377 $conf->cache['nonce'] = dolGetRandomBytes(8);
14380 return $conf->cache['nonce'];
14397function startSimpleTable($header, $link = "
", $arguments = "", $emptyColumns = 0, $number = -1, $pictofulllist = '')
14401 print '<div class="div-
table-responsive-no-min
">';
14402 print '<table class="noborder centpercent
">';
14403 print '<tr class="liste_titre
">';
14405 print ($emptyColumns < 1) ? '<th>' : '<th colspan="'.($emptyColumns + 1).'">';
14407 print '<span class="valignmiddle
">'.$langs->trans($header).'</span>';
14409 if (!empty($link)) {
14410 if (!empty($arguments)) {
14411 print '<a href="'.DOL_URL_ROOT.'/
'.$link.'?
'.$arguments.'">';
14413 print '<a href="'.DOL_URL_ROOT.'/
'.$link.'">';
14417 if ($number > -1) {
14418 print '<span class="badge marginleftonlyshort
">'.$number.'</span>';
14419 } elseif (!empty($link)) {
14420 print '<span class="badge marginleftonlyshort
">...</span>';
14423 if (!empty($link)) {
14429 if ($number < 0 && !empty($link)) {
14430 print '<th class="right
">';
14445function finishSimpleTable($addLineBreak = false)
14450 if ($addLineBreak) {
14466function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None
", $extraRightColumn = false)
14471 print '<tr class="oddeven
">';
14472 print '<td colspan="'.$tableColumnCount.'"><span class="opacitymedium
">'.$langs->trans($noneWord).'</span></td>';
14477 if ($nbofloop === 0) {
14478 // don't show a summary line
14482 /* Case already handled above, commented to satisfy phpstan.
14484 $colspan = $tableColumnCount;
14487 if ($num > $nbofloop) {
14488 $colspan = $tableColumnCount;
14490 $colspan = $tableColumnCount - 1;
14493 if ($extraRightColumn) {
14497 print '<tr class="liste_total
">';
14499 if ($nbofloop > 0 && $num > $nbofloop) {
14500 print '<td colspan="'.$colspan.'" class="right
">'.$langs->trans("XMoreLines
", ($num - $nbofloop)).'</td>';
14502 print '<td colspan="'.$colspan.'" class="right
"> '.$langs->trans("Total
").'</td>';
14503 print '<td class="right centpercent
">'.price($total).'</td>';
14506 if ($extraRightColumn) {
14521function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
14523 if ($method == -1) {
14525 if (getDolGlobalString('MAIN_FORCE_READFILE_WITH_FREAD')) {
14528 if (getDolGlobalString('MAIN_FORCE_READFILE_WITH_STREAM_COPY')) {
14533 // Be sure we don't have output buffering enabled to have readfile working correctly
14534 while (ob_get_level()) {
14539 if ($method == 0) {
14540 readfile($fullpath_original_file_osencoded);
14541 } elseif ($method == 1) {
14543 $handle = fopen($fullpath_original_file_osencoded, "rb
");
14544 while (!feof($handle)) {
14545 print fread($handle, 8192);
14548 } elseif ($method == 2) {
14550 $handle1 = fopen($fullpath_original_file_osencoded, "rb
");
14551 $handle2 = fopen("php:
14552 stream_copy_to_stream($handle1, $handle2);
14573 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'">';
14574 if ($texttoshow ===
'none') {
14575 $result .=
'<'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'>';
14576 $result .=
'<span class="clipboardCPValueToPrint"></span>';
14577 } elseif ($texttoshow) {
14578 $result .=
'<'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'>';
14579 $result .=
'<span class="clipboardCPValueToPrint">'.dol_escape_htmltag($texttoshow, 1, 1).
'</span>';
14581 $result .=
'<'.$tag.
' class="clipboardCPValue">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'>';
14583 $result .=
'<span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft pictomodule" title="'.dolPrintHTML($langs->trans(
"ClickToCopyToClipboard")).
'"></span>';
14584 $result .=
img_picto(
'',
'tick',
'class="clipboardCPTick hidden paddingleft pictomodule"');
14585 $result .=
'<span class="clipboardCPText"></span>';
14586 $result .=
'</span>';
14600 $result = json_decode($stringtodecode);
14601 if ($result ===
null) {
14602 $result = unserialize($stringtodecode);
14629 if (is_null($filter) || !is_string($filter) || $filter ===
'') {
14632 if (!preg_match(
'/^\(.*\)$/', $filter)) {
14633 $filter =
'(' . $filter .
')';
14636 $regexstring =
'\(([a-zA-Z0-9_\.]+:[<>!=insotlke]+:[^\(\)]+)\)';
14637 $firstandlastparenthesis = 0;
14639 if (!
dolCheckFilters($filter, $errorstr, $firstandlastparenthesis)) {
14643 return 'Filter syntax error - '.$errorstr;
14648 $t = preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeDummyCriteriaCallback', $filter);
14649 $t = str_ireplace(array(
'and',
'or',
' '),
'', $t);
14652 if (preg_match(
'/[^\(\)]/', $t)) {
14653 $tmperrorstr =
'Bad syntax of the search string';
14654 $errorstr =
'Bad syntax of the search string: '.$filter;
14658 dol_syslog(
"forgeSQLFromUniversalSearchCriteria Filter error - ".$errorstr, LOG_WARNING);
14659 return 'Filter error - '.$tmperrorstr;
14663 $ret = ($noand ?
"" :
" AND ").($nopar ?
"" :
'(').preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeSQLCriteriaCallback', $filter).($nopar ?
"" :
')');
14665 if (is_object($db)) {
14666 $ret = str_replace(
'__NOW__',
"'".$db->idate(
dol_now()).
"'", $ret);
14668 if (is_object($user)) {
14669 $ret = str_replace(
'__USER_ID__', (
string) $user->id, $ret);
14684 $arrayofandtags = array();
14688 $parenthesislevel = 0;
14693 if ($parenthesislevel >= 1) {
14694 $sqlfilters = preg_replace(
'/^\(/',
'', preg_replace(
'/\)$/',
'', $sqlfilters));
14699 $countparenthesis = 0;
14700 while ($i < $nbofchars) {
14703 if ($char ==
'(') {
14704 $countparenthesis++;
14705 } elseif ($char ==
')') {
14706 $countparenthesis--;
14709 if ($countparenthesis == 0) {
14710 $char2 =
dol_substr($sqlfilters, $i + 1, 1);
14711 $char3 =
dol_substr($sqlfilters, $i + 2, 1);
14712 if ($char ==
'A' && $char2 ==
'N' && $char3 ==
'D') {
14715 if (!preg_match(
'/^\(.*\)$/', $s)) {
14718 $arrayofandtags[] = $s;
14731 if (!preg_match(
'/^\(.*\)$/', $s)) {
14734 $arrayofandtags[] = $s;
14737 return $arrayofandtags;
14749function dolCheckFilters($sqlfilters, &$error =
'', &$parenthesislevel = 0)
14753 $tmp = $sqlfilters;
14757 $parenthesislevel = 0;
14765 if ($char ==
'(') {
14766 if ($i == $parenthesislevel && $parenthesislevel == $counter) {
14768 $parenthesislevel++;
14771 } elseif ($char ==
')') {
14772 $nbcharremaining = ($nb - $i - 1);
14773 if ($nbcharremaining >= $counter) {
14774 $parenthesislevel = min($parenthesislevel, $counter - 1);
14776 if ($parenthesislevel > $counter && $nbcharremaining >= $counter) {
14777 $parenthesislevel = $counter;
14782 if ($counter < 0) {
14783 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
14784 $parenthesislevel = 0;
14792 if ($counter > 0) {
14793 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
14794 $parenthesislevel = 0;
14812 if (empty($matches[1])) {
14815 $tmp = explode(
':', $matches[1]);
14816 if (count($tmp) < 3) {
14836 if (empty($matches[1])) {
14839 $tmp = explode(
':', $matches[1], 3);
14840 if (count($tmp) < 3) {
14844 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
14846 $operator = strtoupper(preg_replace(
'/[^a-z<>!=]/i',
'', trim($tmp[1])));
14849 'NOTLIKE' =>
'NOT LIKE',
14850 'ISNOT' =>
'IS NOT',
14851 'NOTIN' =>
'NOT IN',
14855 if (array_key_exists($operator, $realOperator)) {
14856 $operator = $realOperator[$operator];
14859 $tmpescaped = $tmp[2];
14865 if ($operator ==
'IN' || $operator ==
'NOT IN') {
14867 $tmpescaped2 =
'(';
14869 $tmpelemarray = explode(
',', $tmpescaped);
14870 foreach ($tmpelemarray as $tmpkey => $tmpelem) {
14872 $tmpelem = trim($tmpelem);
14873 if (preg_match(
'/^\'(.*)\'$/', $tmpelem, $reg)) {
14874 $tmpelemarray[$tmpkey] =
"'".$db->escape($db->sanitize($reg[1], 2, 1, 1, 1)).
"'";
14875 } elseif (preg_match(
'/^[0-9]+$/', (
string) $tmpelem)) {
14876 $tmpelemarray[$tmpkey] = (int) $tmpelem;
14877 } elseif (is_numeric((
string) $tmpelem)) {
14878 $tmpelemarray[$tmpkey] = (float) $tmpelem;
14879 } elseif (!
getDolGlobalString(
"MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER")) {
14880 $tmpelemarray[$tmpkey] = preg_replace(
'/[^a-z0-9_<>=!\s]/i',
'', $tmpelem);
14882 $tmpelemarray[$tmpkey] = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpelem);
14885 $tmpescaped2 .= implode(
',', $tmpelemarray);
14886 $tmpescaped2 .=
')';
14888 $tmpescaped = $tmpescaped2;
14889 } elseif ($operator ==
'LIKE' || $operator ==
'NOT LIKE') {
14890 if (preg_match(
'/^\'([^\']*)\'$/', $tmpescaped, $regbis)) {
14891 $tmpescaped = $regbis[1];
14894 $tmpescaped =
"'".$db->escape($tmpescaped).
"'";
14895 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
14898 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
14900 if (strtoupper($tmpescaped) ==
'NULL') {
14901 $tmpescaped =
'NULL';
14902 } elseif (preg_match(
'/^[0-9]+$/', (
string) $tmpescaped)) {
14903 $tmpescaped = (int) $tmpescaped;
14904 } elseif (is_numeric((
string) $tmpescaped)) {
14905 $tmpescaped = (float) $tmpescaped;
14907 $tmpescaped = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpescaped);
14911 return '('.$db->escape($operand).
' '.strtoupper($operator).
' '.$tmpescaped.
')';
14928 $out =
'<!-- timeline icon -->'.
"\n";
14929 $iconClass =
'fa fa-comments';
14934 if ($histo[$key][
'percent'] == -1) {
14935 $colorClass =
'timeline-icon-not-applicble';
14936 $pictoTitle = $langs->trans(
'StatusNotApplicable');
14937 } elseif ($histo[$key][
'percent'] == 0) {
14938 $colorClass =
'timeline-icon-todo';
14939 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
14940 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
14941 $colorClass =
'timeline-icon-in-progress';
14942 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
14943 } elseif ($histo[$key][
'percent'] >= 100) {
14944 $colorClass =
'timeline-icon-done';
14945 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
14948 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
14949 $iconClass =
'fa fa-ticket';
14950 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
14951 $iconClass =
'fa fa-pencilxxx';
14952 } elseif (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
14953 $iconClass =
'fa fa-comments';
14954 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
14955 $iconClass =
'fa fa-mask';
14957 if ($actionstatic->type_picto) {
14958 $img_picto =
img_picto(
'', $actionstatic->type_picto);
14960 if ($actionstatic->type_code ==
'AC_RDV') {
14961 $iconClass =
'fa fa-handshake';
14962 } elseif ($actionstatic->type_code ==
'AC_TEL') {
14963 $iconClass =
'fa fa-phone';
14964 } elseif ($actionstatic->type_code ==
'AC_FAX') {
14965 $iconClass =
'fa fa-fax';
14966 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
14967 $iconClass =
'fa fa-envelope';
14968 } elseif ($actionstatic->type_code ==
'AC_INT') {
14969 $iconClass =
'fa fa-shipping-fast';
14970 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
14971 $iconClass =
'fa fa-robot';
14972 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
14973 $iconClass =
'fa fa-robot';
14978 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
14992 $documents = array();
14994 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename, ecm.agenda_id';
14995 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
14996 $sql .=
" WHERE ecm.filepath = 'agenda/".((int)
$object->id).
"'";
14998 $sql.=
' OR ecm.agenda_id = '.(int)
$object->id;
14999 $sql .=
' ORDER BY ecm.position ASC';
15001 $resql = $db->query($sql);
15003 if ($db->num_rows($resql)) {
15004 while ($obj = $db->fetch_object($resql)) {
15005 $documents[$obj->id] = $obj;
15031function show_actions_messaging(
$conf, $langs, $db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
15033 global $user,
$conf;
15036 global $param, $massactionbutton;
15038 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
15041 if (!is_object($filterobj) && !is_object($objcon)) {
15046 '@phan-var-force array<int,array{type:string,tododone:string,id:string,datestart:int|string,dateend:int|string,note:string,message:string,percent:string,userid:string,login:string,userfirstname:string,userlastname:string,userphoto:string,msg_from?:string,contact_id?:string,socpeopleassigned?:int[],lastname?:string,firstname?:string,fk_element?:int,elementtype?:string,acode:string,alabel?:string,libelle?:string,apicto?:string}> $histo';
15051 $sortfield_list = explode(
',', $sortfield);
15052 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
15053 $sortfield_new_list = array();
15054 foreach ($sortfield_list as $sortfield_value) {
15055 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
15057 $sortfield_new = implode(
',', $sortfield_new_list);
15062 if (isModEnabled(
'agenda')) {
15064 if (is_object($objcon) && $objcon->id > 0) {
15065 $sql =
"SELECT DISTINCT a.id, a.label as label,";
15067 $sql =
"SELECT a.id, a.label as label,";
15069 $sql .=
" a.datep as dp,";
15070 $sql .=
" a.note as message,";
15071 $sql .=
" a.datep2 as dp2,";
15072 $sql .=
" a.percent as percent, 'action' as type,";
15073 $sql .=
" a.fk_element, a.elementtype,";
15074 $sql .=
" a.fk_contact,";
15075 $sql .=
" a.email_from as msg_from,";
15076 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
15077 $sql .=
" u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
15078 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
15079 $sql .=
", sp.lastname, sp.firstname";
15080 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
15081 $sql .=
", m.lastname, m.firstname";
15082 } elseif (is_object($filterobj) && in_array(get_class($filterobj), array(
'Commande',
'CommandeFournisseur',
'Product',
'Ticket',
'BOM',
'Contrat',
'Facture',
'FactureFournisseur'))) {
15085 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
15086 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
15087 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
15089 $force_filter_contact = $filterobj instanceof
User;
15091 if (is_object($objcon) && $objcon->id > 0) {
15092 $force_filter_contact =
true;
15093 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
15094 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
15097 if ((is_object($filterobj) && get_class($filterobj) ==
'Societe') || (is_object($filterobj) && get_class($filterobj) ==
'Contact')) {
15098 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
15099 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
15100 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
15101 $sql .=
" ON er.resource_type = 'dolresource'";
15102 $sql .=
" AND er.element_id = a.id";
15103 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
15104 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
15105 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
15106 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
15107 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
15108 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
15109 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
15110 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
15111 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
15112 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
15113 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
15114 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
15115 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
15116 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
15117 $sql .=
", ".MAIN_DB_PREFIX.
"facture as o";
15118 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
15119 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as o";
15122 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
15123 if (!$force_filter_contact) {
15124 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
15125 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
15126 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
15127 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
15128 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
15129 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
15130 if ($filterobj->id) {
15131 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15133 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
15134 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
15135 if ($filterobj->id) {
15136 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15138 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
15139 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
15140 if ($filterobj->id) {
15141 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15143 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
15144 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
15145 if ($filterobj->id) {
15146 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15148 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
15149 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
15150 if ($filterobj->id) {
15151 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15153 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
15154 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
15155 if ($filterobj->id) {
15156 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15158 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
15159 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
15160 if ($filterobj->id) {
15161 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15163 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contact' && $filterobj->id) {
15164 $sql .=
" AND a.fk_contact = sp.rowid";
15165 if ($filterobj->id) {
15166 $sql .=
" AND a.fk_contact = ".((int) $filterobj->id);
15168 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
15169 $sql .=
" AND a.fk_element = o.rowid";
15170 if ($filterobj->id) {
15171 $sql .=
" AND a.fk_element = ".((int) $filterobj->id).
" AND a.elementtype = 'invoice'";
15173 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
15174 $sql .=
" AND a.fk_element = o.rowid";
15175 if ($filterobj->id) {
15176 $sql .=
" AND a.fk_element = ".((int) $filterobj->id).
" AND a.elementtype = 'invoice_supplier'";
15180 $sql .=
" AND u.rowid = ". ((int) $filterobj->id);
15184 if (!empty($actioncode) && $actioncode !=
'-1') {
15186 if ($actioncode ==
'AC_NON_AUTO') {
15187 $sql .=
" AND c.type != 'systemauto'";
15188 } elseif ($actioncode ==
'AC_ALL_AUTO') {
15189 $sql .=
" AND c.type = 'systemauto'";
15191 if ($actioncode ==
'AC_OTH') {
15192 $sql .=
" AND c.type != 'systemauto'";
15193 } elseif ($actioncode ==
'AC_OTH_AUTO') {
15194 $sql .=
" AND c.type = 'systemauto'";
15198 if ($actioncode ==
'AC_NON_AUTO') {
15199 $sql .=
" AND c.type != 'systemauto'";
15200 } elseif ($actioncode ==
'AC_ALL_AUTO') {
15201 $sql .=
" AND c.type = 'systemauto'";
15203 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
15207 if ($donetodo ==
'todo') {
15208 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
15209 } elseif ($donetodo ==
'done') {
15210 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
15212 if (is_array($filters) && $filters[
'search_agenda_label']) {
15213 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
15218 if (isModEnabled(
'mailing') && !empty($objcon->email)
15219 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
15220 $langs->load(
"mails");
15222 $sql2 =
"SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
15223 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
15224 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
15225 $sql2 .=
", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
15226 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
15227 $sql2 .=
", '' as lastname, '' as firstname";
15228 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
15229 $sql2 .=
", '' as lastname, '' as firstname";
15230 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
15231 $sql2 .=
", '' as ref";
15232 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
15233 $sql2 .=
", '' as ref";
15234 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
15235 $sql2 .=
", '' as ref";
15237 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
15238 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
15239 $sql2 .=
" AND mc.statut = 1";
15240 $sql2 .=
" AND u.rowid = m.fk_user_valid";
15241 $sql2 .=
" AND mc.fk_mailing=m.rowid";
15244 if ($sql || $sql2) {
15245 if (!empty($sql) && !empty($sql2)) {
15246 $sql = $sql.
" UNION ".$sql2;
15247 } elseif (empty($sql) && !empty($sql2)) {
15256 $sql .= $db->order($sortfield_new, $sortorder);
15258 $sql .= $db->plimit($limit + 1, $offset);
15261 dol_syslog(
"function.lib::show_actions_messaging", LOG_DEBUG);
15262 $resql = $db->query($sql);
15265 $num = $db->num_rows($resql);
15267 $imaxinloop = ($limit ? min($num, $limit) : $num);
15268 while ($i < $imaxinloop) {
15269 $obj = $db->fetch_object($resql);
15271 if ($obj->type ==
'action') {
15273 $contactaction->id = $obj->id;
15274 $result = $contactaction->fetchResources();
15277 setEventMessage(
"actions.lib::show_actions_messaging Error fetch resource",
'errors');
15283 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) {
15284 $tododone =
'todo';
15287 $histo[$numaction] = array(
15288 'type' => $obj->type,
15289 'tododone' => $tododone,
15291 'datestart' => $db->jdate($obj->dp),
15292 'dateend' => $db->jdate($obj->dp2),
15293 'note' => $obj->label,
15295 'percent' => $obj->percent,
15297 'userid' => $obj->user_id,
15298 'login' => $obj->user_login,
15299 'userfirstname' => $obj->user_firstname,
15300 'userlastname' => $obj->user_lastname,
15301 'userphoto' => $obj->user_photo,
15302 'msg_from' => $obj->msg_from,
15304 'contact_id' => $obj->fk_contact,
15305 'socpeopleassigned' => $contactaction->socpeopleassigned,
15306 'lastname' => (empty($obj->lastname) ?
'' : $obj->lastname),
15307 'firstname' => (empty($obj->firstname) ?
'' : $obj->firstname),
15308 'fk_element' => $obj->fk_element,
15309 'elementtype' => $obj->elementtype,
15311 'acode' => $obj->acode,
15312 'alabel' => $obj->alabel,
15313 'libelle' => $obj->alabel,
15314 'apicto' => $obj->apicto
15317 $histo[$numaction] = array(
15318 'type' => $obj->type,
15319 'tododone' =>
'done',
15321 'datestart' => $db->jdate($obj->dp),
15322 'dateend' => $db->jdate($obj->dp2),
15323 'note' => $obj->label,
15325 'percent' => $obj->percent,
15326 'acode' => $obj->acode,
15328 'userid' => $obj->user_id,
15329 'login' => $obj->user_login,
15330 'userfirstname' => $obj->user_firstname,
15331 'userlastname' => $obj->user_lastname,
15332 'userphoto' => $obj->user_photo
15347 if (!isModEnabled(
'agenda')) {
15348 $langs->loadLangs(array(
"admin",
"errors"));
15349 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
15352 if (isModEnabled(
'agenda') || (isModEnabled(
'mailing') && !empty($objcon->email))) {
15353 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
15355 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
15356 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
15357 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
15358 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
15363 $userstatic =
new User($db);
15364 $contactstatic =
new Contact($db);
15365 $userGetNomUrlCache = array();
15366 $contactGetNomUrlCache = array();
15368 $out .=
'<div class="filters-container" >';
15369 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
15370 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
15372 if ($objcon && get_class($objcon) ==
'Contact' &&
15373 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
15374 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
15376 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
15378 if (($filterobj && get_class($filterobj) ==
'Societe')) {
15379 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
15381 $out .=
'<input type="hidden" name="userid" value="'.$filterobj->id.
'" />';
15386 $out .=
'<div class="div-table-responsive-no-min">';
15387 $out .=
'<table class="noborder borderbottom centpercent">';
15389 $out .=
'<tr class="liste_titre">';
15393 $out .=
'<th class="liste_titre width50 middle">';
15394 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
15395 $out .= $searchpicto;
15400 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'nowraponall nopaddingleftimp ').
"\n";
15402 $out .=
'<th class="liste_titre hideonsmartphone"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
15404 $out .=
'<th class="liste_titre"></th>';
15407 $out .=
'<th class="liste_titre">';
15408 $out .=
'<span class="fas fa-square inline-block fawidth30 hideonsmartphone" style="color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
15409 $out .= $formactions->select_type_actions($actioncode,
"actioncode",
'',
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? -1 : 1, 0, 0, 1,
'selecttype minwidth100', $langs->trans(
"Type"));
15412 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
15413 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
15418 $out .=
'<th class="liste_titre width50 middle">';
15419 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
15420 $out .= $searchpicto;
15426 $out .=
'</table>';
15433 $out .=
'<ul class="timeline">';
15437 if ($filterobj instanceof
Societe) {
15438 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
15440 if ($filterobj instanceof
User) {
15441 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
15443 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
15444 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
15445 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
15447 if ($filterobj instanceof
Societe) {
15450 if ($filterobj instanceof
User) {
15456 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
15458 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
15460 $actualCycleDate =
false;
15463 foreach ($histo as $key => $value) {
15464 $actionstatic->fetch($histo[$key][
'id']);
15466 $actionstatic->type_picto = $histo[$key][
'apicto'];
15467 $actionstatic->type_code = $histo[$key][
'acode'];
15469 $labeltype = $actionstatic->type_code;
15470 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
15471 $labeltype =
'AC_OTH';
15473 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
15474 $labeltype = $langs->trans(
"Message");
15476 if (!empty($arraylist[$labeltype])) {
15477 $labeltype = $arraylist[$labeltype];
15479 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
15480 $labeltype .=
' - '.$arraylist[$actionstatic->code];
15484 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
15486 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
15488 if (isset($tmpa[
'year']) && isset($tmpa[
'yday']) && $actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
15489 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
15490 $out .=
'<!-- timeline time label -->';
15491 $out .=
'<li class="time-label">';
15492 $out .=
'<span class="timeline-badge-date">';
15493 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
15496 $out .=
'<!-- /.timeline-label -->';
15500 $out .=
'<!-- timeline item -->'.
"\n";
15501 $out .=
'<li class="timeline-code-'.(!empty($actionstatic->code) ? strtolower($actionstatic->code) :
"none").
'">';
15504 $typeicon = $actionstatic->getTypePicto(
'pictofixedwidth timeline-icon-not-applicble', $labeltype);
15509 $out .=
'<div class="timeline-item">'.
"\n";
15511 $out .=
'<span class="time timeline-header-action2">';
15513 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
15514 $out .=
'<a class="paddingleft paddingright timeline-btn2 editfielda" href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
15515 $out .= $histo[$key][
'id'];
15518 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
15521 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
15522 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
15523 $out .=
'<a class="paddingleft paddingright timeline-btn2 editfielda" href="'.DOL_MAIN_URL_ROOT.
'/comm/action/card.php?action=edit&token='.
newToken().
'&id='.$actionstatic->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'">';
15525 $out .=
img_picto($langs->trans(
"Modify"),
'edit',
'class="edita"');
15532 $out .=
'<span class="time"><i class="fa fa-clock-o valignmiddle"></i> <span class="valignmiddle">';
15533 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
15534 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
15535 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
15536 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
15537 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
15538 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
15540 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
15544 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
15547 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
15550 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
15553 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
15559 $out .=
"</span></span>\n";
15561 $out .=
'<span class="time">';
15562 $out .= $actionstatic->getLibStatut(2);
15566 $out .=
'<h3 class="timeline-header">';
15569 $out .=
'<div class="messaging-author inline-block tdoverflowmax150 valignmiddle marginrightonly">';
15570 if ($histo[$key][
'userid'] > 0) {
15571 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
15572 $userstatic->fetch($histo[$key][
'userid']);
15573 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
15575 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
15576 } elseif (!empty($histo[$key][
'msg_from']) && $actionstatic->code ==
'TICKET_MSG') {
15577 if (!isset($contactGetNomUrlCache[$histo[$key][
'msg_from']])) {
15578 if ($contactstatic->fetch(0,
null,
'', $histo[$key][
'msg_from']) > 0) {
15579 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $contactstatic->getNomUrl(-1,
'', 16);
15581 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $histo[$key][
'msg_from'];
15584 $out .= $contactGetNomUrlCache[$histo[$key][
'msg_from']];
15589 $out .=
' <div class="messaging-title inline-block">';
15591 if (empty(
$conf->dol_optimize_smallscreen) && $actionstatic->type_code !=
'AC_OTH_AUTO') {
15592 $out .= $labeltype.
' - ';
15597 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
15598 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
15599 } elseif (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
15600 $out .= $langs->trans(
'TicketNewMessage');
15601 } elseif (isset($histo[$key][
'type'])) {
15602 if ($histo[$key][
'type'] ==
'action') {
15603 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
15604 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
15605 $libelle = $histo[$key][
'note'];
15606 $actionstatic->id = $histo[$key][
'id'];
15607 if ($libelle != $labeltype) {
15610 } elseif ($histo[$key][
'type'] ==
'mailing') {
15611 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
15612 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
15613 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
15616 $libelle .= $histo[$key][
'note'];
15620 $out = preg_replace(
'/ - $/',
'', $out);
15622 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
15623 if (isset(
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']]) && isset(
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
15624 $link =
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
15626 if (!isset(
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']])) {
15627 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']] = array();
15629 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
15630 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
15633 $out .=
' - '.$link;
15642 if (!empty($histo[$key][
'message'] && $histo[$key][
'message'] != $libelle)
15643 && $actionstatic->code !=
'AC_TICKET_CREATE'
15644 && $actionstatic->code !=
'AC_TICKET_MODIFY'
15646 $out .=
'<div class="timeline-body wordbreak small">';
15647 $truncateLines =
getDolGlobalInt(
'MAIN_TRUNCATE_TIMELINE_MESSAGE', 3);
15649 if ($truncateLines > 0 && strlen($histo[$key][
'message']) > strlen($truncatedText)) {
15650 $out .=
'<div class="readmore-block --closed" >';
15651 $out .=
' <div class="readmore-block__excerpt">';
15653 $out .=
' <br><a class="read-more-link" data-read-more-action="open" href="'.DOL_MAIN_URL_ROOT.
'/comm/action/card.php?id='.$actionstatic->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'" >'.$langs->trans(
"ReadMore").
' <span class="fa fa-chevron-right" aria-hidden="true"></span></a>';
15655 $out .=
' <div class="readmore-block__full-text" >';
15657 $out .=
' <a class="read-less-link" data-read-more-action="close" href="#" ><span class="fa fa-chevron-up" aria-hidden="true"></span> '.$langs->trans(
"ReadLess").
'</a>';
15671 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
15673 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
15674 if (empty(
$conf->cache[
'contact'][$cid])) {
15676 $contact->fetch($cid);
15677 $conf->cache[
'contact'][$cid] = $contact;
15679 $contact =
$conf->cache[
'contact'][$cid];
15683 $contactList .= !empty($contactList) ?
', ' :
'';
15684 $contactList .= $contact->getNomUrl(1);
15685 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
15686 if (!empty($contact->phone_pro)) {
15687 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
15693 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
15694 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
15695 if (empty(
$conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
15697 $result = $contact->fetch($histo[$key][
'contact_id']);
15698 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
15700 $contact =
$conf->cache[
'contact'][$histo[$key][
'contact_id']];
15701 $result = ($contact instanceof
Contact) ? $contact->id : 0;
15705 $footer .= $contact->getNomUrl(1);
15706 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
15707 if (!empty($contact->phone_pro)) {
15708 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
15715 if (!empty($documents)) {
15716 $footer .=
'<div class="timeline-documents-container">';
15717 foreach ($documents as $doc) {
15718 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
15719 $footer .=
' data-id="'.$doc->id.
'" ';
15720 $footer .=
' data-path="'.$doc->filepath.
'"';
15721 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
15724 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
15726 if (empty($doc->agenda_id)) {
15727 $dir_ref = $actionstatic->id;
15728 $modulepart =
'actions';
15730 $split_dir = explode(
'/', $doc->filepath);
15731 $modulepart = array_shift($split_dir);
15732 $dir_ref = implode(
'/', $split_dir);
15735 $file = $dir_ref.
'/'.$doc->filename;
15736 $thumb = $dir_ref.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
15737 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart='.$modulepart.
'&attachment=0&file='.urlencode($file).
'&entity='.
$conf->entity;
15738 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart='.$modulepart.
'&file='.urlencode($thumb).
'&entity='.
$conf->entity;
15742 $mimeAttr =
' mime="'.$mime.
'" ';
15744 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
15745 $class .=
' documentpreview';
15748 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
15749 $footer .=
img_mime($filePath).
' '.$doc->filename;
15752 $footer .=
'</span>';
15754 $footer .=
'</div>';
15757 if (!empty($footer)) {
15758 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
15761 $out .=
'</div>'.
"\n";
15764 $out .=
'<!-- END timeline item -->';
15771 jQuery(document).ready(function () {
15772 $(document).on("click", "[data-read-more-action]", function(e){
15773 console.log("We click on data-read-more-action");
15774 let readMoreBloc = $(this).closest(".readmore-block");
15775 if(readMoreBloc.length > 0){
15776 e.preventDefault();
15777 if($(this).attr("data-read-more-action") == "close"){
15778 readMoreBloc.addClass("--closed").removeClass("--open");
15779 $("html, body").animate({
15780 scrollTop: readMoreBloc.offset().top - 200
15783 readMoreBloc.addClass("--open").removeClass("--closed");
15791 if (empty($histo)) {
15792 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
15815function buildParamDate($prefix, $timestamp =
null, $hourTime =
'', $gm =
'auto')
15817 if ($timestamp ===
null) {
15818 $timestamp =
GETPOSTDATE($prefix, $hourTime, $gm);
15825 if ($hourTime ===
'getpost' || ($timestamp !==
null &&
dol_print_date($timestamp,
'%H:%M:%S') !==
'00:00:00')) {
15826 $TParam = array_merge($TParam, array(
15833 return '&' . http_build_query($TParam);
15854function recordNotFound($message =
'', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params =
null)
15856 global
$conf, $db, $langs, $hookmanager;
15859 if (!is_object($langs)) {
15860 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
15862 $langs->setDefaultLang();
15865 $langs->load(
"errors");
15867 if ($printheader) {
15868 if (function_exists(
"llxHeader")) {
15870 } elseif (function_exists(
"llxHeaderVierge")) {
15875 print
'<div class="error">';
15876 if (empty($message)) {
15877 print $langs->trans(
"ErrorRecordNotFound");
15879 print $langs->trans($message);
15884 if (empty($showonlymessage)) {
15885 if (empty($hookmanager)) {
15886 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
15889 $hookmanager->initHooks(array(
'main'));
15892 $parameters = array(
'message' => $message,
'params' => $params);
15893 $reshook = $hookmanager->executeHooks(
'getErrorRecordNotFound', $parameters,
$object, $action);
15894 print $hookmanager->resPrint;
15897 if ($printfooter && function_exists(
"llxFooter")) {
15899 if (is_object($db)) {
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined( 'NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined( 'NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined( 'NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined( 'NOIPCHECK')) llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[])
Header function.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0, $moreparam='')
On/off button to change a property status of an object This uses the ajax service objectonoff....
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage agenda events (actions)
Class to manage different types of events.
Class to manage GeoIP conversion Usage: $geoip=new GeoIP('country',$datfile); $geoip->getCountryCodeF...
Class to manage invoices.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dol_get_prev_month($month, $year)
Return previous month.
dol_get_next_day($day, $month, $year)
Return next day.
getServerTimeZoneInt($refgmtdate='now')
Return server timezone int.
dol_get_prev_day($day, $month, $year)
Return previous day.
dol_get_next_month($month, $year)
Return next month.
dol_convert_file($fileinput, $ext='png', $fileoutput='', $page='')
Convert an image file or a PDF into another image format.
dragAndDropFileUpload($htmlname)
Function to manage the drag and drop of a file.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_is_dir($folder)
Test if filename is a directory.
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option='')
Return link url to an object.
isValidVATID($company)
Check if VAT numero is valid (check done on syntax only, no database or remote access)
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
dol_fiche_end($notab=0)
Show tab footer of a card.
verifCond($strToEvaluate, $onlysimplestring='1')
Verify if condition in string is ok or not.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
getDolGlobalFloat($key, $default=0)
Return a Dolibarr global constant float value.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) If ...
img_weather($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $morecss='')
Show weather picto.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
dolCheckFilters($sqlfilters, &$error='', &$parenthesislevel=0)
Return if a $sqlfilters parameter has a valid balance of parenthesis.
show_actions_messaging($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC')
Show html area with actions in messaging format.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
setEntity($currentobject)
Set entity id to use when to create an object.
dolForgeExplodeAnd($sqlfilters)
Explode an universal search string with AND parts.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dol_print_ip($ip, $mode=0, $showname=0)
Return an IP formatted to be shown on screen.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_ucfirst($string, $encoding="UTF-8")
Convert first character of the first word of a string to upper.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_right($titlealt='default', $selected=0, $moreatt='')
Show right arrow logo.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto='UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_left($titlealt='default', $selected=0, $moreatt='')
Show left arrow logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs=null, $mode=0, $extralangcode='')
Return a formatted address (part address/zip/town/state) according to country rules.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='paddingright')
Format phone numbers according to country.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
isASecretKey($keyname)
Return if string has a name dedicated to store a secret.
dolPrintHTMLForTextArea($s, $allowiframe=0)
Return a string ready to be output on input textarea.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_eval_new($s)
Replace eval function to add more security.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
get_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Get formatted error messages to output (Used to show messages on html output).
dol_user_country()
Return country code for current user.
dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes=null)
Clean a string from some undesirable HTML tags.
getMultidirTemp($object, $module='', $forobject=0)
Return the full path of the directory where a module (or an object of a module) stores its temporary ...
isHTTPS()
Return if we are using a HTTPS connection Check HTTPS (no way to be modified by user but may be empty...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
picto_required()
Return picto saying a field is required.
isDolTms($timestamp)
isDolTms check if a timestamp is valid.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='')
Show Url link.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
checkVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolPrintText($s)
Return a string label (possible on several lines and that should not contains any HTML) ready to be o...
utf8_valid($str)
Check if a string is in UTF8.
getPictoForType($key, $morecss='')
Return the picto for a data type.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
img_allow($allow, $titlealt='default')
Show tick logo if allowed.
isValidMXRecord($domain)
Return if the domain name has a valid MX record.
dolButtonToOpenExportDialog($name, $label, $buttonstring, $exportSiteName, $overwriteGitUrl, $website)
Create a dialog with two buttons for export and overwrite of a website.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
dol_print_socialnetworks($value, $contactid, $socid, $type, $dictsocialnetworks=array())
Show social network link.
getImgPictoNameList()
Get all usage icon key usable for img_picto(..., key)
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tab header of a card.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
get_localtax_by_third($local)
Get values of localtaxes (1 or 2) for company country for the common vat with the highest value.
dol_escape_php($stringtoescape, $stringforquotes=2)
Returns text escaped for inclusion into a php string, build with double quotes " or '.
dolSetCookie(string $cookiename, string $cookievalue, int $expire=-1)
Set a cookie.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_get_object_properties($obj, $properties=[])
Get properties for an object - including magic properties when requested.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_strftime($fmt, $ts=false, $is_gmt=false)
Format a string.
img_picto_common($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $notitle=0)
Show picto (generic function)
img_search($titlealt='default', $other='')
Show search logo.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
isValidPhone($phone)
Return true if phone number syntax is ok TODO Decide what to do with this.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
fieldLabel($langkey, $fieldkey, $fieldrequired=0)
Show a string with the label tag dedicated to the HTML edit field.
getBrowserInfo($user_agent)
Return information about user browser.
dolGetFirstLetters($s, $nbofchar=1)
Return first letters of a strings.
dol_eval_standard($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dolPrintLabel($s, $escapeonlyhtmltags=0)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
getMultidirVersion($object, $module='', $forobject=0)
Return the full path of the directory where a module (or an object of a module) stores its versioned ...
dol_sanitizeUrl($stringtoclean, $type=1)
Clean a string to use it as an URL (into a href or src attribute)
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
img_printer($titlealt="default", $other='')
Show printer logo.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
ascii_check($str)
Check if a string is in ASCII.
get_date_range($date_start, $date_end, $format='', $outputlangs=null, $withparenthesis=1)
Format output for start and end date.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getImgPictoConv($mode='fa')
Get array to convert the Dolibarr picto keys into font awesome keys.
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
getArrayOfSocialNetworks()
Get array of social network dictionary.
num2Alpha($n)
Return a numeric value into an Excel like column number.
dol_size($size, $type='')
Optimize a size for some browsers (phone, smarphone...)
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
img_pdf($titlealt='default', $size=3)
Show pdf logo.
dolGetCountryCodeFromIp($ip)
Return a country code from IP.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolPrintPassword($s)
Return a string ready to be output on an HTML attribute (alt, title, ...)
dol_escape_all($stringtoescape)
Returns text escaped for all protocols (so only alpha chars and numbers)
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dolForgeSQLCriteriaCallback($matches)
Function to forge a SQL criteria from a USF (Universal Filter Syntax) string.
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
dol_shutdown()
Function called at end of web php process.
dol_print_address($address, $htmlid, $element, $id, $noprint=0, $charfornl='')
Format address string.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
dol_escape_uri($stringtoescape)
Returns text escaped by RFC 3986 for inclusion into a clickable link.
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1)
Format professional IDs according to their country.
print_titre($title)
Show a title.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_string_nounprintableascii($str, $removetabcrlf=1)
Clean a string from all non printable ASCII chars (0x00-0x1F and 0x7F).
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
img_error($titlealt='default')
Show error logo.
getTimelineIcon($actionstatic, &$histo, $key)
Get timeline icon.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getUserRemoteIP($trusted=0)
Return the real IP of remote user.
buildParamDate($prefix, $timestamp=null, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_next($titlealt='default', $moreatt='')
Show next logo.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_string_is_good_iso($s, $clean=0)
Check if a string is a correct iso string If not, it will not be considered as HTML encoded even if i...
getNonce()
Return a random string to be used as a nonce value for js.
isStringVarMatching($var, $regextext, $matchrule=1)
Check if a variable with name $var startx with $text.
dolSlugify($stringtoslugify)
Returns text slugified (lowercase and no special char, separator is "-").
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
get_htmloutput_mesg($mesgstring='', $mesgarray=[], $style='ok', $keepembedded=0)
Get formatted messages to output (Used to show messages on html output).
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
get_product_localtax_for_country($idprod, $local, $thirdpartytouse)
Return localtax vat rate of a product in a particular country or default country vat if product is un...
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $selectlimitsuffix='', $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
dol_nboflines($s, $maxchar=0)
Return nb of lines of a clear text.
dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox=0, $check='restricthtml')
Sanitize a HTML to remove js, dangerous content and external links.
jsonOrUnserialize($stringtodecode)
Decode an encode string.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
dol_escape_xml($stringtoescape)
Returns text escaped for inclusion into a XML string.
getActionCommEcmList($object)
getActionCommEcmList
dol_ucwords($string, $encoding="UTF-8")
Convert first character of all the words of a string to upper.
img_edit_add($titlealt='default', $other='')
Show logo +.
print_fiche_titre($title, $mesg='', $picto='generic', $pictoisfullpath=0, $id='')
Show a title with picto.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournprice=0)
Return vat rate of a product in a particular country, or default country vat if product is unknown.
dolForgeDummyCriteriaCallback($matches)
Function to forge a SQL criteria from a Dolibarr filter syntax string.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0, $allowscript=0, $allowstyle=0, $allowphp=0)
Clean a string to keep only desirable HTML tags.
dol_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_validElement($element)
Return if var element is ok.
dol_sanitizeKeyCode($str)
Clean a string to use it as a key or code.
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_searchclear($titlealt='default', $other='')
Show search logo.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
utf8_check($str)
Check if a string is in UTF8.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dolPrintHTMLForAttributeUrl($s)
Return a string ready to be output on a href attribute (this one need a special because we need conte...
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
img_edit_remove($titlealt='default', $other='')
Show logo -.
img_info($titlealt='default')
Show info logo.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
dol_sanitizeEmail($stringtoclean)
Clean a string to use it as an Email.
dol_nboflines_bis($text, $maxlinesize=0, $charset='UTF-8')
Return nb of lines of a formatted text with and (WARNING: string must not have mixed and br sep...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
const MODULE_MAPPING
This mapping defines the conversion to the current internal names from the alternative allowed names ...
dolBECalculateStructuredCommunication($invoice_number, $invoice_type)
Calculate Structured Communication / BE Bank payment reference number.
dol_convertToWord($num, $langs, $currency='', $centimes=false)
Function to return a number into a text.
treeview li table
No Email.
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
div refaddress div address
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
dol_setcache($memoryid, $data, $expire=0, $filecache=0, $replace=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
realCharForNumericEntities($matches)
Return the real char for a numeric entities.